[vulkan] Set VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT This guarantees that: - SPIR-V SubgroupSize is the number of invocations in the subgroup, even if some invocations start out inactive. - All subgroups in the dispatch have the same SubgroupSize. Fixed: crbug.com/410595996 Change-Id: Ib6bd941e721ecd2c4f64a12123534e9f6853b261 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/247214 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: David Neto <dneto@google.com>
diff --git a/src/dawn/native/vulkan/ComputePipelineVk.cpp b/src/dawn/native/vulkan/ComputePipelineVk.cpp index c237679..b633ed2 100644 --- a/src/dawn/native/vulkan/ComputePipelineVk.cpp +++ b/src/dawn/native/vulkan/ComputePipelineVk.cpp
@@ -94,10 +94,14 @@ createInfo.stage.pName = device->GetIsolatedEntryPointName().data(); createInfo.stage.pSpecializationInfo = nullptr; + // This is required to ensure SubgroupSize is reported as the actual size of the subgroups + // (even if some invocations may be disabled), and that the subgroup size will be uniform + // across the entire dispatch. This becomes unnecessary with SPIR-V 1.6. + createInfo.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT; + // If the shader stage uses subgroup matrix types, we need to enable full subgroups to guarantee // that all shader invocations are active. This becomes unnecessary with SPIR-V 1.6. if (computeStage.metadata->usesSubgroupMatrix) { - createInfo.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT; createInfo.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT; }
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp index a3bb0b0..48f3c46 100644 --- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp +++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -447,8 +447,9 @@ // 2. subgroupSupportedStages includes compute and fragment stage bit, and // 3. subgroupSupportedOperations includes vote, ballot, shuffle, shuffle relative, arithmetic, // and quad bits, and - // 4. VK_EXT_subgroup_size_control extension is valid, and both subgroupSizeControl - // and computeFullSubgroups is TRUE in VkPhysicalDeviceSubgroupSizeControlFeaturesEXT. + // 4. VK_EXT_subgroup_size_control extension is valid, and subgroupSizeControl + // is TRUE in VkPhysicalDeviceSubgroupSizeControlFeaturesEXT. This is required + // to support VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT. const bool hasBaseSubgroupSupport = (mDeviceInfo.properties.apiVersion >= VK_API_VERSION_1_1) && (mDeviceInfo.subgroupProperties.supportedStages & VK_SHADER_STAGE_COMPUTE_BIT) && @@ -461,8 +462,7 @@ (mDeviceInfo.subgroupProperties.supportedOperations & VK_SUBGROUP_FEATURE_ARITHMETIC_BIT) && (mDeviceInfo.subgroupProperties.supportedOperations & VK_SUBGROUP_FEATURE_QUAD_BIT) && (mDeviceInfo.HasExt(DeviceExt::SubgroupSizeControl)) && - (mDeviceInfo.subgroupSizeControlFeatures.subgroupSizeControl == VK_TRUE) && - (mDeviceInfo.subgroupSizeControlFeatures.computeFullSubgroups == VK_TRUE); + (mDeviceInfo.subgroupSizeControlFeatures.subgroupSizeControl == VK_TRUE); // If shader f16 is enabled we only enable subgroups if we extended subgroup support. // This means there is a vary narrow number of devices (~4%) will not get subgroup