KhronosGroup / MoltenVK

MoltenVK is a Vulkan Portability implementation. It layers a subset of the high-performance, industry-standard Vulkan graphics and compute API over Apple's Metal graphics framework, enabling Vulkan applications to run on macOS, iOS and tvOS.
Apache License 2.0
4.63k stars 402 forks source link

Why requiredSubgroupSizeStages is 0? #2218

Closed stripe2933 closed 2 months ago

stripe2933 commented 2 months ago

MoltenVK advertises that supporting VK_EXT_subgroup_size_control and minSubgroupSize...maxSubgroupSIze=4...32, however requiredSubgroupSizeStages is 0. Does it means none of the shader stage supports the subgroup size control? I can't understand why this value is 0.

The validation layer complains me:

VUID-VkPipelineShaderStageCreateInfo-pNext-02755(ERROR / SPEC): msgNum: -2142406189 - Validation Error: [ VUID-VkPipelineShaderStageCreateInfo-pNext-02755 ] Object 0: handle = 0x2e2941000000001f, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x804d79d3 | vkCreateComputePipelines(): pCreateInfos[0].stage SPIR-V (VK_SHADER_STAGE_COMPUTE_BIT) is not in requiredSubgroupSizeStages (VkShaderStageFlags(0)). The Vulkan spec states: If a VkPipelineShaderStageRequiredSubgroupSizeCreateInfo structure is included in the pNext chain, the subgroupSizeControl feature must be enabled, and stage must be a valid bit specified in requiredSubgroupSizeStages (https://vulkan.lunarg.com/doc/view/1.3.275.0/mac/1.3-extensions/vkspec.html#VUID-VkPipelineShaderStageCreateInfo-pNext-02755)

cdavis5e commented 2 months ago

Does it means none of the shader stage supports the subgroup size control?

Yes, that's correct. AFAIK Metal provides no way to declare that a shader function must run with a particular SIMD-group[1] size. MoltenVK, being an implementation of Vulkan on top of Metal, mirrors the capabilities provided by Metal to the application.

[1]: The Metal term for what in Vulkan is called a subgroup.

stripe2933 commented 2 months ago

Thank you for explanation.