radv: Defaulting to a subgroup size of 32 for ray tracing shaders that use SPIR-V versions below 1.6?
From the Vulkan 1.3 specification:
If the pipeline stage SPIR-V module is less than version 1.6 and was not created with the
VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT
flag set and no VkPipelineShaderStageRequiredSubgroupSizeCreateInfo structure was chained, the variable decorated withSubgroupSize
will matchsubgroupSize
.
A later informative note reiterates this point in the context of ray tracing shaders:
While the
SubgroupSize
built-in is required to be declaredVolatile
, its value will never change unlessVK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT
is set on pipeline creation, as without that bit set, its value is required to match that of VkPhysicalDeviceSubgroupProperties::subgroupSize
.
I was poking around the spec and the radv code related to subgroup sizes and noticed that these statements might not line up with what radv's doing right now. I don't have Wave32-capable or RT-capable hardware, so it's a little hard for me to suss out whether I've caught a real problem or not. (There are also the RADV_PERFTEST options that switch other shader stages to Wave32. I don't know if those are supposed to be 100% conformant.)
This may be less of an edge case than it looks like. radv only advertises VK_SHADER_STAGE_COMPUTE_BIT
in requiredSubgroupSizeStages
, so as far as I can tell, using a SPIR-V version below 1.6 is the only way to get a guaranteed subgroup size in ray tracing and other non-compute shaders. (If I'm wrong on this point, a correction would be more than welcome.)