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

Add validation test about creating pipeline layout with null bind group layout #4076

Merged
merged 7 commits into from
Dec 18, 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
29 changes: 8 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/w3c-image-capture": "^1.0.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"@webgpu/types": "^0.1.51",
"@webgpu/types": "^0.1.52",
"ansi-colors": "4.1.3",
"babel-plugin-add-header-comment": "^1.0.3",
"babel-plugin-const-enum": "^1.2.0",
Expand Down
94 changes: 94 additions & 0 deletions src/webgpu/api/validation/createPipelineLayout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TODO: review existing tests, write descriptions, and make sure tests are complet

import { makeTestGroup } from '../../../common/framework/test_group.js';
import { bufferBindingTypeInfo, kBufferBindingTypes } from '../../capability_info.js';
import { GPUConst } from '../../constants.js';

import { ValidationTest } from './validation_test.js';

Expand Down Expand Up @@ -162,3 +163,96 @@ g.test('bind_group_layouts,device_mismatch')
t.device.createPipelineLayout({ bindGroupLayouts: [layout0, layout1] });
}, mismatched);
});

const MaybeNullBindGroupLayoutTypes = ['Null', 'Undefined', 'Empty', 'NonEmpty'] as const;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combinatorially adding undefined increases the subcase count from 90 to 310, but I think that's a bit too many. This test is not that slow, but our combinatorial explosions in the CTS overall are quite out of hand so I'd like to be more cautious when we're adding new tests.

The null vs undefined thing is a trivial WebIDL check and we really just need one tiny test that makes sure null and undefined behave the same way.

That's a bit of extra work though. Would we get complete coverage by testing only the cases that have exactly one Null/Undefined/Empty? This reduces the whole thing to just 30 subcases without having to write another test.

See #4107


g.test('bind_group_layouts,null_bind_group_layouts')
.desc(
`
Tests that it is valid to create a pipeline layout with null bind group layouts.
`
)
.paramsSubcasesOnly(u =>
u //
.combine('bindGroupLayoutCount', [1, 2, 3, 4] as const)
.combine('bindGroupLayout0', MaybeNullBindGroupLayoutTypes)
.expand('bindGroupLayout1', p =>
p.bindGroupLayoutCount > 1 ? MaybeNullBindGroupLayoutTypes : (['Null'] as const)
)
.expand('bindGroupLayout2', p =>
p.bindGroupLayoutCount > 2 ? MaybeNullBindGroupLayoutTypes : (['Null'] as const)
)
.expand('bindGroupLayout3', p =>
p.bindGroupLayoutCount > 3 ? MaybeNullBindGroupLayoutTypes : (['Null'] as const)
)
.filter(p => {
// Only test cases where at least one of the bind group layouts is null.
const allBGLs = [
p.bindGroupLayout0,
p.bindGroupLayout1,
p.bindGroupLayout2,
p.bindGroupLayout3,
];
const bgls = allBGLs.slice(0, p.bindGroupLayoutCount);
return bgls.includes('Null') || bgls.includes('Undefined');
})
)
.fn(t => {
const {
bindGroupLayoutCount,
bindGroupLayout0,
bindGroupLayout1,
bindGroupLayout2,
bindGroupLayout3,
} = t.params;

const emptyBindGroupLayout = t.device.createBindGroupLayout({
entries: [],
});
const nonEmptyBindGroupLayout = t.device.createBindGroupLayout({
entries: [
{
binding: 0,
visibility: GPUConst.ShaderStage.COMPUTE,
texture: {},
},
],
});

const bindGroupLayouts: (GPUBindGroupLayout | null | undefined)[] = [];

const AddBindGroupLayout = function (
bindGroupLayoutType: (typeof MaybeNullBindGroupLayoutTypes)[number]
) {
switch (bindGroupLayoutType) {
case 'Null':
bindGroupLayouts.push(null);
break;
case 'Undefined':
bindGroupLayouts.push(undefined);
break;
case 'Empty':
bindGroupLayouts.push(emptyBindGroupLayout);
break;
case 'NonEmpty':
bindGroupLayouts.push(nonEmptyBindGroupLayout);
break;
}
};

AddBindGroupLayout(bindGroupLayout0);
if (bindGroupLayoutCount > 1) {
AddBindGroupLayout(bindGroupLayout1);
}
if (bindGroupLayoutCount > 2) {
AddBindGroupLayout(bindGroupLayout2);
}
if (bindGroupLayoutCount > 3) {
AddBindGroupLayout(bindGroupLayout3);
}

const kShouldError = false;
t.expectValidationError(() => {
t.device.createPipelineLayout({ bindGroupLayouts });
}, kShouldError);
});
Loading