Skip to content

Commit

Permalink
Update 'buffer,usage' test in createBindGroup.spec.ts (#1824)
Browse files Browse the repository at this point in the history
This PR updates the buffer,usage test to handle the case that the buffer's
type is `storage` or `read-only-storage`. In such cases, the usage should
be STORAGE.

Issue: #884
  • Loading branch information
Gyuyoung authored Sep 7, 2022
1 parent 0007e62 commit a6451cc
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/webgpu/api/validation/createBindGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,17 @@ g.test('storage_texture,mip_level_count')
g.test('buffer,usage')
.desc(
`
Test that the buffer usage contains 'uniform' if the BindGroup entry defines
buffer and it's type is 'uniform'.
Test that the buffer usage contains 'UNIFORM' if the BindGroup entry defines buffer and it's
type is 'uniform', and the buffer usage contains 'STORAGE' if the BindGroup entry's buffer type
is 'storage'|read-only-storage'.
`
)
.params(u =>
u //
.combine('type', kBufferBindingTypes)
// If usage0 and usage1 are the same, the usage being test is a single usage. Otherwise, it's
// a combined usage.
.beginSubcases()
.combine('usage0', kBufferUsages)
.combine('usage1', kBufferUsages)
.unless(
Expand All @@ -767,7 +770,7 @@ g.test('buffer,usage')
)
)
.fn(async t => {
const { usage0, usage1 } = t.params;
const { type, usage0, usage1 } = t.params;

const usage = usage0 | usage1;

Expand All @@ -776,7 +779,7 @@ g.test('buffer,usage')
{
binding: 0,
visibility: GPUShaderStage.COMPUTE,
buffer: { type: 'uniform' },
buffer: { type },
},
],
});
Expand All @@ -786,7 +789,12 @@ g.test('buffer,usage')
usage,
});

const isValid = GPUBufferUsage.UNIFORM & usage;
let isValid = false;
if (type === 'uniform') {
isValid = GPUBufferUsage.UNIFORM & usage ? true : false;
} else if (type === 'storage' || type === 'read-only-storage') {
isValid = GPUBufferUsage.STORAGE & usage ? true : false;
}

t.expectValidationError(() => {
t.device.createBindGroup({
Expand Down

0 comments on commit a6451cc

Please sign in to comment.