Ensure WorkgroupSizeX never exceeds the maximum value in subgroup size control tests (#4655)

Issue: #4640
This commit is contained in:
Jiawei Shao 2026-06-03 00:40:55 +08:00 committed by GitHub
parent b507bd117e
commit 9964a05b4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -1193,6 +1193,9 @@ g.test('subgroup_size_attribute')
for (let subgroupSize = subgroupMinSize; subgroupSize <= subgroupMaxSize; subgroupSize *= 2) {
const wgx = subgroupSize * numSubgroups;
if (wgx > t.device.limits.maxComputeWorkgroupSizeX) {
continue;
}
const wgsl = `
enable subgroups;

View file

@ -214,9 +214,11 @@ async function getValidSubgroupSizes(device: GPUDevice): Promise<number[]> {
subgroupMaxSize: number;
}
const { subgroupMinSize, subgroupMaxSize } = device.adapterInfo as SubgroupProperties;
const maxWorkgroupSizeX = device.limits.maxComputeWorkgroupSizeX;
const sizes: number[] = [];
for (let subgroupSize = subgroupMinSize; subgroupSize <= subgroupMaxSize; subgroupSize *= 2) {
if (subgroupSize > maxWorkgroupSizeX) break;
const wgsl = `
enable subgroups;
enable subgroup_size_control;
@ -294,6 +296,7 @@ g.test('workgroup_size_x_must_be_multiple_of_subgroup_size_at_pipeline_creation'
for (const subgroupSize of validSubgroupSizes) {
const workgroupSizeX = subgroupSize * multiplier + offset;
if (workgroupSizeX <= 0) continue;
if (workgroupSizeX > t.device.limits.maxComputeWorkgroupSizeX) continue;
const isMultiple = workgroupSizeX % subgroupSize === 0;