MoltenVK-specific fixes for descriptorindexing and oit examples
This commit is contained in:
parent
79ec9b126b
commit
ef02a20d5d
3 changed files with 23 additions and 4 deletions
|
|
@ -65,6 +65,12 @@ public:
|
||||||
physicalDeviceDescriptorIndexingFeatures.descriptorBindingVariableDescriptorCount = VK_TRUE;
|
physicalDeviceDescriptorIndexingFeatures.descriptorBindingVariableDescriptorCount = VK_TRUE;
|
||||||
|
|
||||||
deviceCreatepNextChain = &physicalDeviceDescriptorIndexingFeatures;
|
deviceCreatepNextChain = &physicalDeviceDescriptorIndexingFeatures;
|
||||||
|
|
||||||
|
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||||
|
// SRS - on macOS set environment variable to configure MoltenVK for using Metal argument buffers (needed for descriptor indexing)
|
||||||
|
// - MoltenVK supports Metal argument buffers on macOS, iOS possible in future (see https://github.com/KhronosGroup/MoltenVK/issues/1651)
|
||||||
|
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "1", 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
@ -203,6 +209,10 @@ public:
|
||||||
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, static_cast<uint32_t>(textures.size()))
|
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, static_cast<uint32_t>(textures.size()))
|
||||||
};
|
};
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo = vks::initializers::descriptorPoolCreateInfo(poolSizes, 2);
|
VkDescriptorPoolCreateInfo descriptorPoolInfo = vks::initializers::descriptorPoolCreateInfo(poolSizes, 2);
|
||||||
|
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||||
|
// SRS - increase the per-stage descriptor samplers limit on macOS (maxPerStageDescriptorUpdateAfterBindSamplers > maxPerStageDescriptorSamplers)
|
||||||
|
descriptorPoolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT;
|
||||||
|
#endif
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
||||||
|
|
||||||
// Descriptor set layout
|
// Descriptor set layout
|
||||||
|
|
@ -228,6 +238,10 @@ public:
|
||||||
setLayoutBindingFlags.pBindingFlags = descriptorBindingFlags.data();
|
setLayoutBindingFlags.pBindingFlags = descriptorBindingFlags.data();
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCI = vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCI = vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
||||||
|
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||||
|
// SRS - increase the per-stage descriptor samplers limit on macOS (maxPerStageDescriptorUpdateAfterBindSamplers > maxPerStageDescriptorSamplers)
|
||||||
|
descriptorSetLayoutCI.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT;
|
||||||
|
#endif
|
||||||
descriptorSetLayoutCI.pNext = &setLayoutBindingFlags;
|
descriptorSetLayoutCI.pNext = &setLayoutBindingFlags;
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayout));
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayout));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,12 @@ private:
|
||||||
imageInfo.mipLevels = 1;
|
imageInfo.mipLevels = 1;
|
||||||
imageInfo.arrayLayers = 1;
|
imageInfo.arrayLayers = 1;
|
||||||
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
|
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||||
|
// SRS - On macOS/iOS use linear tiling for atomic image access, see https://github.com/KhronosGroup/MoltenVK/issues/1027
|
||||||
|
imageInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||||
|
#else
|
||||||
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||||
|
#endif
|
||||||
imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT;
|
imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT;
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateImage(device, &imageInfo, nullptr, &geometryPass.headIndex.image));
|
VK_CHECK_RESULT(vkCreateImage(device, &imageInfo, nullptr, &geometryPass.headIndex.image));
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@
|
||||||
# include "../examples/vertexattributes/vertexattributes.cpp"
|
# include "../examples/vertexattributes/vertexattributes.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does not run. MoltenVK/Metal does not support stores and atomic operations in the fragment stage.
|
// Runs, but some Apple GPUs may not support stores and atomic operations in the fragment stage.
|
||||||
#ifdef MVK_oit
|
#ifdef MVK_oit
|
||||||
# include "../examples/oit/oit.cpp"
|
# include "../examples/oit/oit.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -222,7 +222,7 @@
|
||||||
# include "../examples/pushdescriptors/pushdescriptors.cpp"
|
# include "../examples/pushdescriptors/pushdescriptors.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does not run. Shader compilation fails with MoltenVK.
|
// Runs on macOS 11.0 or later with Metal argument buffers enabled. Not yet supported on iOS.
|
||||||
#ifdef MVK_descriptorindexing
|
#ifdef MVK_descriptorindexing
|
||||||
# include "../examples/descriptorindexing/descriptorindexing.cpp"
|
# include "../examples/descriptorindexing/descriptorindexing.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -358,7 +358,7 @@
|
||||||
# include "../examples/graphicspipelinelibrary/graphicspipelinelibrary.cpp"
|
# include "../examples/graphicspipelinelibrary/graphicspipelinelibrary.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does not run yet. Requires VK_KHR_dynamic_rendering (under development in MoltenVK)
|
// Runs on MoltenVK 1.1.10 (SDK 1.3.216) or later. Requires VK_KHR_dynamic_rendering and dependencies.
|
||||||
#ifdef MVK_dynamicrendering
|
#ifdef MVK_dynamicrendering
|
||||||
# include "../examples/dynamicrendering/dynamicrendering.cpp"
|
# include "../examples/dynamicrendering/dynamicrendering.cpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue