Skip to content

Commit

Permalink
Compat: Make compute pass tests handle different limits
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Sep 26, 2023
1 parent 206d3fb commit cd6bc78
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/webgpu/api/validation/encoding/cmds/compute_pass.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Does **not** test usage scopes (resource_usages/) or programmable pass stuff (pr
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { kBufferUsages, kLimitInfo } from '../../../../capability_info.js';
import { makeValueTestVariant } from '../../../../../common/util/util.js';
import { kBufferUsages } from '../../../../capability_info.js';
import { GPUConst } from '../../../../constants.js';
import { kResourceStates, ResourceState } from '../../../../gpu_test.js';
import { ValidationTest } from '../../validation_test.js';
Expand Down Expand Up @@ -88,7 +89,6 @@ g.test('pipeline,device_mismatch')
validateFinish(!mismatched);
});

const kMaxDispatch = kLimitInfo.maxComputeWorkgroupsPerDimension.default;
g.test('dispatch_sizes')
.desc(
`Test 'direct' and 'indirect' dispatch with various sizes.
Expand All @@ -104,13 +104,22 @@ g.test('dispatch_sizes')
.params(u =>
u
.combine('dispatchType', ['direct', 'indirect'] as const)
.combine('largeDimValue', [0, 1, kMaxDispatch, kMaxDispatch + 1, 0x7fff_ffff, 0xffff_ffff])
.combine('largeDimValueVariant', [
{ mult: 0, add: 0 },
{ mult: 0, add: 1 },
{ mult: 1, add: 0 },
{ mult: 1, add: 1 },
{ mult: 0, add: 0x7fff_ffff },
{ mult: 0, add: 0xffff_ffff },
])
.beginSubcases()
.combine('largeDimIndex', [0, 1, 2] as const)
.combine('smallDimValue', [0, 1])
)
.fn(t => {
const { dispatchType, largeDimIndex, smallDimValue, largeDimValue } = t.params;
const { dispatchType, largeDimIndex, smallDimValue, largeDimValueVariant } = t.params;
const maxDispatch = t.device.limits.maxComputeWorkgroupsPerDimension;
const largeDimValue = makeValueTestVariant(maxDispatch, largeDimValueVariant);

const pipeline = t.createNoOpComputePipeline();

Expand All @@ -131,7 +140,7 @@ g.test('dispatch_sizes')

const shouldError =
dispatchType === 'direct' &&
(workSizes[0] > kMaxDispatch || workSizes[1] > kMaxDispatch || workSizes[2] > kMaxDispatch);
(workSizes[0] > maxDispatch || workSizes[1] > maxDispatch || workSizes[2] > maxDispatch);

validateFinishAndSubmit(!shouldError, true);
});
Expand Down

0 comments on commit cd6bc78

Please sign in to comment.