Skip to content

Commit

Permalink
Test maxBindGroupsPlusVertexBuffers limits (#3368)
Browse files Browse the repository at this point in the history
* Test maxBindGroupsPlusVertexBuffers limits
  • Loading branch information
greggman authored Feb 7, 2024
1 parent 9ce9531 commit 75d8f8a
Show file tree
Hide file tree
Showing 5 changed files with 319 additions and 28 deletions.
52 changes: 29 additions & 23 deletions src/webgpu/api/validation/capability_checks/limits/limit_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ export class LimitTestsImpl extends GPUTestBase {
/**
* Creates an GPURenderCommandsMixin setup with some initial state.
*/
_getGPURenderCommandsMixin(encoderType: RenderEncoderType) {
#getGPURenderCommandsMixin(encoderType: RenderEncoderType) {
const { device } = this;

switch (encoderType) {
Expand Down Expand Up @@ -920,7 +920,7 @@ export class LimitTestsImpl extends GPUTestBase {
});

const encoder = device.createCommandEncoder();
const mixin = encoder.beginRenderPass({
const passEncoder = encoder.beginRenderPass({
colorAttachments: [
{
view: texture.createView(),
Expand All @@ -931,10 +931,10 @@ export class LimitTestsImpl extends GPUTestBase {
});

return {
mixin,
passEncoder,
bindGroup,
prep() {
mixin.end();
passEncoder.end();
},
test() {
encoder.finish();
Expand Down Expand Up @@ -971,16 +971,16 @@ export class LimitTestsImpl extends GPUTestBase {
],
});

const mixin = device.createRenderBundleEncoder({
const passEncoder = device.createRenderBundleEncoder({
colorFormats: ['rgba8unorm'],
});

return {
mixin,
passEncoder,
bindGroup,
prep() {},
test() {
mixin.finish();
passEncoder.finish();
},
};
break;
Expand All @@ -989,17 +989,23 @@ export class LimitTestsImpl extends GPUTestBase {
}

/**
* Tests a method on GPURenderCommandsMixin
* The function will be called with the mixin.
* Test a method on GPURenderCommandsMixin or GPUBindingCommandsMixin
* The function will be called with the passEncoder.
*/
async testGPURenderCommandsMixin(
async testGPURenderAndBindingCommandsMixin(
encoderType: RenderEncoderType,
fn: ({ mixin }: { mixin: GPURenderCommandsMixin }) => void,
fn: ({
passEncoder,
bindGroup,
}: {
passEncoder: GPURenderCommandsMixin & GPUBindingCommandsMixin;
bindGroup: GPUBindGroup;
}) => void,
shouldError: boolean,
msg = ''
) {
const { mixin, prep, test } = this._getGPURenderCommandsMixin(encoderType);
fn({ mixin });
const { passEncoder, prep, test, bindGroup } = this.#getGPURenderCommandsMixin(encoderType);
fn({ passEncoder, bindGroup });
prep();

await this.expectValidationError(test, shouldError, msg);
Expand All @@ -1008,7 +1014,7 @@ export class LimitTestsImpl extends GPUTestBase {
/**
* Creates GPUBindingCommandsMixin setup with some initial state.
*/
_getGPUBindingCommandsMixin(encoderType: EncoderType) {
#getGPUBindingCommandsMixin(encoderType: EncoderType) {
const { device } = this;

switch (encoderType) {
Expand Down Expand Up @@ -1041,12 +1047,12 @@ export class LimitTestsImpl extends GPUTestBase {
});

const encoder = device.createCommandEncoder();
const mixin = encoder.beginComputePass();
const passEncoder = encoder.beginComputePass();
return {
mixin,
passEncoder,
bindGroup,
prep() {
mixin.end();
passEncoder.end();
},
test() {
encoder.finish();
Expand All @@ -1055,24 +1061,24 @@ export class LimitTestsImpl extends GPUTestBase {
break;
}
case 'render':
return this._getGPURenderCommandsMixin('render');
return this.#getGPURenderCommandsMixin('render');
case 'renderBundle':
return this._getGPURenderCommandsMixin('renderBundle');
return this.#getGPURenderCommandsMixin('renderBundle');
}
}

/**
* Tests a method on GPUBindingCommandsMixin
* The function pass will be called with the mixin and a bindGroup
* The function pass will be called with the passEncoder and a bindGroup
*/
async testGPUBindingCommandsMixin(
encoderType: EncoderType,
fn: ({ bindGroup }: { mixin: GPUBindingCommandsMixin; bindGroup: GPUBindGroup }) => void,
fn: ({ bindGroup }: { passEncoder: GPUBindingCommandsMixin; bindGroup: GPUBindGroup }) => void,
shouldError: boolean,
msg = ''
) {
const { mixin, bindGroup, prep, test } = this._getGPUBindingCommandsMixin(encoderType);
fn({ mixin, bindGroup });
const { passEncoder, bindGroup, prep, test } = this.#getGPUBindingCommandsMixin(encoderType);
fn({ passEncoder, bindGroup });
prep();

await this.expectValidationError(test, shouldError, msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ g.test('setBindGroup,at_over')
const lastIndex = testValue - 1;
await t.testGPUBindingCommandsMixin(
encoderType,
({ mixin, bindGroup }) => {
mixin.setBindGroup(lastIndex, bindGroup);
({ passEncoder, bindGroup }) => {
passEncoder.setBindGroup(lastIndex, bindGroup);
},
shouldError,
`shouldError: ${shouldError}, actualLimit: ${actualLimit}, testValue: ${lastIndex}`
Expand Down
Loading

0 comments on commit 75d8f8a

Please sign in to comment.