[WebGPU backend] Set explicit compute subgroup size configs in `APIGetInfo` In WebGPU backend we did not populate the `AdapterPropertiesExplicitComputeSubgroupSizeConfigs` struct in `PhysicalDevice::PopulateBackendProperties()`, leaving its fields at their default value of 0. When `APIGetInfo` checked the post-condition `DAWN_ASSERT(IsPowerOfTwo(...))`, it failed because `IsPowerOfTwo(0)` is false. This patch fixes this assertion failure by supporting the query of `AdapterPropertiesExplicitComputeSubgroupSizeConfigs` in `APIGetInfo`. Bug: 413053623 Change-Id: Ibadf26ba117859a17b1a3655e5b5ca9070fcd259 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/297456 Commit-Queue: Shao, Jiawei <jiawei.shao@intel.com> Reviewed-by: Shrek Shao <shrekshao@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/webgpu/PhysicalDeviceWGPU.cpp b/src/dawn/native/webgpu/PhysicalDeviceWGPU.cpp index 476ffce..43bdacc 100644 --- a/src/dawn/native/webgpu/PhysicalDeviceWGPU.cpp +++ b/src/dawn/native/webgpu/PhysicalDeviceWGPU.cpp
@@ -51,6 +51,17 @@ mBackend(backend), mInnerAdapter(innerAdapter) { WGPUAdapterInfo info = {}; + + const bool supportsSubgroupSizeControl = GetFunctions().adapterHasFeature( + mInnerAdapter, WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl); + + WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs explicitComputeSubgroupSizeConfigs = {}; + explicitComputeSubgroupSizeConfigs.chain.sType = + WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs; + if (supportsSubgroupSizeControl) { + info.nextInChain = &explicitComputeSubgroupSizeConfigs.chain; + } + WGPUStatus status = GetFunctions().adapterGetInfo(mInnerAdapter, &info); DAWN_ASSERT(status == WGPUStatus_Success); DAWN_ASSERT(info.backendType != WGPUBackendType_WebGPU); @@ -67,6 +78,15 @@ mSubgroupMaxSize = info.subgroupMaxSize; mInnerBackendType = info.backendType; + if (supportsSubgroupSizeControl) { + mMinExplicitComputeSubgroupSize = + explicitComputeSubgroupSizeConfigs.minExplicitComputeSubgroupSize; + mMaxExplicitComputeSubgroupSize = + explicitComputeSubgroupSizeConfigs.maxExplicitComputeSubgroupSize; + mMaxComputeWorkgroupSubgroups = + explicitComputeSubgroupSizeConfigs.maxComputeWorkgroupSubgroups; + } + GetFunctions().adapterInfoFreeMembers(info); } @@ -150,6 +170,14 @@ if (auto* wgpuProperties = info.Get<AdapterPropertiesWGPU>()) { wgpuProperties->backendType = FromAPI(mInnerBackendType); } + if (auto* explicitSubgroupSizeConfigs = + info.Get<AdapterPropertiesExplicitComputeSubgroupSizeConfigs>()) { + explicitSubgroupSizeConfigs->minExplicitComputeSubgroupSize = + mMinExplicitComputeSubgroupSize; + explicitSubgroupSizeConfigs->maxExplicitComputeSubgroupSize = + mMaxExplicitComputeSubgroupSize; + explicitSubgroupSizeConfigs->maxComputeWorkgroupSubgroups = mMaxComputeWorkgroupSubgroups; + } } FeatureValidationResult PhysicalDevice::ValidateFeatureSupportedWithTogglesImpl(