diff --git a/examples/descriptorindexing/descriptorindexing.cpp b/examples/descriptorindexing/descriptorindexing.cpp index d0a016ac..0a10d5e5 100644 --- a/examples/descriptorindexing/descriptorindexing.cpp +++ b/examples/descriptorindexing/descriptorindexing.cpp @@ -65,6 +65,12 @@ public: physicalDeviceDescriptorIndexingFeatures.descriptorBindingVariableDescriptorCount = VK_TRUE; 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() @@ -203,6 +209,10 @@ public: vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, static_cast(textures.size())) }; 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)); // Descriptor set layout @@ -228,6 +238,10 @@ public: setLayoutBindingFlags.pBindingFlags = descriptorBindingFlags.data(); 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; VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayout)); @@ -416,4 +430,4 @@ public: }; -VULKAN_EXAMPLE_MAIN() \ No newline at end of file +VULKAN_EXAMPLE_MAIN() diff --git a/examples/oit/oit.cpp b/examples/oit/oit.cpp index 77bdd68e..c6ffddf3 100644 --- a/examples/oit/oit.cpp +++ b/examples/oit/oit.cpp @@ -234,7 +234,12 @@ private: imageInfo.mipLevels = 1; imageInfo.arrayLayers = 1; 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; +#endif imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT; VK_CHECK_RESULT(vkCreateImage(device, &imageInfo, nullptr, &geometryPass.headIndex.image)); diff --git a/xcode/examples.h b/xcode/examples.h index c6107e4f..15787981 100644 --- a/xcode/examples.h +++ b/xcode/examples.h @@ -191,7 +191,7 @@ # include "../examples/vertexattributes/vertexattributes.cpp" #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 # include "../examples/oit/oit.cpp" #endif @@ -222,7 +222,7 @@ # include "../examples/pushdescriptors/pushdescriptors.cpp" #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 # include "../examples/descriptorindexing/descriptorindexing.cpp" #endif @@ -358,7 +358,7 @@ # include "../examples/graphicspipelinelibrary/graphicspipelinelibrary.cpp" #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 # include "../examples/dynamicrendering/dynamicrendering.cpp" #endif