The chromium_experimental_subgroup_size_control is an experimental extension that allows the use of the subgroup_size attribute in compute shaders in WGSL. When the attribute subgroup_size is declared, the compute shader will only be executed with the specified subgroup size, and the built-in value subgroup_size will be the the value of the attribute subgroup_size. Otherwise, the compute shader may be executed with a subgroup size chosen by the GPU driver, which is unknown before the execution of the compute shader.
This extension is experimental and the syntax is being discussed. No official WebGPU specification has been written yet.
The status can be tracked at 463721943.
The usage is restricted to compute shaders.
| Backend | Implementation | Requirements |
|---|---|---|
| D3D12 | [WaveSize(<numLanes>)] in HLSL | Shader Model 6.6 |
| Vulkan | requiredSubgroupSize in VkPipelineShaderStageRequiredSubgroupSizeCreateInfo on the API side | subgroupSizeControl and computeFullSubgroups in VK_EXT_subgroup_size_control or Vulkan 1.3 |
| Metal | Not Supported | Not Supported |
VK_EXT_subgroup_control is required to enable feature Subgroups so we can always enable chromium_experimental_subgroup_size_control when Subgroups can be enabled.computeFullSubgroups is required on Vulkan because we need to set VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT when creating Vulkan compute pipeline to ensure subgroup sizes will always be launched with all invocations active.subgroupSizeControl and computeFullSubgroups according to the report on GPUInfo.org.enable statement to be used. For this experimental extension it would be enable chromium_experimental_subgroup_size_control.This extension adds a new subgroup_size attribute for compute shaders.
Enabling this extension on the API side will implicitly enable the subgroups extension.
subgroup_size_attr :
'@' 'subgroup_size' '(' expression ',' ? ')'
i32 or u32.minExplicitComputeSubgroupSize (described later) on the current adapter.maxExplicitComputeSubgroupSize (described later) on the current adapter.subgroup_size.enable subgroups; enable chromium_experimental_subgroup_size_control; @subgroup_size(32) @compute @workgroup_size(64, 1, 1) fn main(@builtin(subgroup_invocation_id) sg_id : u32, @builtin(subgroup_size) sg_size : u32) { }
This extension also adds below limits in Dawn:
maxComputeWorkgroupSubgroupsRequired by Vulkan VK_EXT_subgroup_size_control and defined in VkPhysicalDeviceSubgroupSizeControlProperties.maxComputeWorkgroupSubgroups. Note that there is no such limitation on D3D12.
| Limit name | Type | Limit class | Default | Compatibility Mode Default |
|---|---|---|---|---|
maxComputeWorkgroupSubgroups | GPUSize32 | maximum | - | Not Supported |
workgroup_size attribute, subgroup_size attribute and maxComputeWorkgroupSubgroups limit must follow below requirement:workgroup_size.x * workgroup_size.y * workgroup_size.z <= subgroup_size * maxComputeWorkgroupSubgroups
minExplicitComputeSubgroupSize and maxExplicitComputeSubgroupSize (in structure wgpu::AdapterPropertiesExplicitComputeSubgroupSizeConfigs that can be chained in wgpu::AdapterInfo)Required by both Vulkan and D3D12:
D3D12_FEATURE_DATA_D3D12_OPTIONS1::waveLaneCountMin and D3D12_FEATURE_DATA_D3D12_OPTIONS1::waveLaneCountMax, which are not always used as wgpu::AdapterInfo::subgroupMinSize or wgpu::AdapterInfo::subgroupMaxSize in Dawn. For example:waveLaneCountMin is 16, meaning in compute shaders the wave lane count will always be at least 16 (A toggle “d3d12_relax_min_subgroup_size_to_8” has been added for this issue).128 as SubgroupMaxSize because in D3D12 document "the WaveLaneCountMax queried from D3D12 API is not reliable and the meaning is unclear, while waveLaneCountMax is actually the maximum value that can be used as HLSL attribute [WaveSize].VkPhysicalDeviceSubgroupSizeControlPropertiesEXT::minSubgroupSize and VkPhysicalDeviceSubgroupSizeControlPropertiesEXT::maxSubgroupSize.| Limit name | Type | Limit class | Default | Compatibility Mode Default |
|---|---|---|---|---|
minExplicitComputeSubgroupSize | GPUSize32 | maximum | - | Not Supported |
maxExplicitComputeSubgroupSize | GPUSize32 | maximum | - | Not Supported |