Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test maxBindGroupsPlusVertexBuffers limits #3368

Merged
merged 6 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading