-
Notifications
You must be signed in to change notification settings - Fork 86
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 tests for Multi-Draw Indirect #3962
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the stylistic nitpick, LGTM.
u.expandWithParams(() => { | ||
return [ | ||
// In bounds | ||
{ bufferSize: 4, indirectOffset: 0, _valid: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could we combine these test cases with the ones below as a variable? If I didn't miss anything these cases seem similar with small differences, and combining them would be cleaner/more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, if possible store this array as a variable and use it twice. A pattern we use elsewhere to make this work is instead of having bufferSize
as a parameter, have something like bufferExtraSize
which has negative, zero, and positive cases (4 + (-1) = 3
for indirect, 5 + (-1) = 4
for indexed indirect)
And if there are any cases that are specific to one or the other then you can do:
const kIndirectOffsetOOBCommonCases = [
/* ... */
] as const;
/* ... */
.combineWithParams([
...kIndirectOffsetOOBCommonCases,
/* any additional cases which are not common between the two */
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've hopefully addressed your feedback in latest patch. Please have a look!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sirtsu55 @kainino0x Does latest patch look good to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late response, but the patch looks good to me!
FYI @beaufortfrancois , I'm working on #3970 to add more rendering tests. Should we incrementally add rendering tests to this branch or should submit all of the rendering tests at once? |
I'll let @kainino0x weigh in as I don't have strong preferences. |
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
u.expandWithParams(() => { | ||
return [ | ||
// In bounds | ||
{ bufferSize: 4, indirectOffset: 0, _valid: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, if possible store this array as a variable and use it twice. A pattern we use elsewhere to make this work is instead of having bufferSize
as a parameter, have something like bufferExtraSize
which has negative, zero, and positive cases (4 + (-1) = 3
for indirect, 5 + (-1) = 4
for indexed indirect)
And if there are any cases that are specific to one or the other then you can do:
const kIndirectOffsetOOBCommonCases = [
/* ... */
] as const;
/* ... */
.combineWithParams([
...kIndirectOffsetOOBCommonCases,
/* any additional cases which are not common between the two */
])
IMO land tests as soon as they're landable. It's easy enough to modify tests after they land. |
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Show resolved
Hide resolved
_valid: boolean; | ||
} | ||
|
||
g.test('indirect_offset_oob') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test name implies it only tests OOB on the indirectBuffer, but is also doing a bunch of stuff with drawCountBuffer that is hard to separate in my head. Can there be two tests:
indirectBuffer_OOB
(just a single boolean param for whether it uses a drawCountBuffer or not)drawCountBuffer_OOB
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed this test as the implementation of two tests would be identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if the two were totally separate, as the validation for OOB on each of the two buffers is totally orthogonal. For offsets_alignment it's fine because the list of cases is small, but this list of cases is large and needs to test all the corner cases of two separate checks. Reviewing the list to make sure it covers all of those cases is difficult.
If I'm misunderstanding and they're not orthogonal then this is fine, I just still will need to review the list of cases more closely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also the other tests use kIndirectMultiDrawTestParams so if they were split I think they would have a lot of duplicated control cases; that's not the case here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the thorough review @kainino0x!
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
_valid: boolean; | ||
} | ||
|
||
g.test('indirect_offset_oob') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed this test as the implementation of two tests would be identical.
@@ -112,7 +128,7 @@ g.test('buffers,device_mismatch') | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
(encoder as any).multiDrawIndirect(indirectBuffer, 0, 1, drawCountBuffer); | |||
} | |||
validateFinish(!mismatched); | |||
validateFinish(!indirectMismatched && (!useDrawCountBuffer || !drawCountMismatched)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I forgot also that drawCountMismatched wouldn't matter if !useDrawCountBuffer. That useless case should ideally be filtered out as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
_valid: boolean; | ||
} | ||
|
||
g.test('indirect_offset_oob') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if the two were totally separate, as the validation for OOB on each of the two buffers is totally orthogonal. For offsets_alignment it's fine because the list of cases is small, but this list of cases is large and needs to test all the corner cases of two separate checks. Reviewing the list to make sure it covers all of those cases is difficult.
If I'm misunderstanding and they're not orthogonal then this is fine, I just still will need to review the list of cases more closely.
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
src/webgpu/api/validation/encoding/cmds/render/indirect_multi_draw.spec.ts
Outdated
Show resolved
Hide resolved
.paramsSubcasesOnly(u => | ||
u.combine('indexed', [true, false] as const).expandWithParams(p => { | ||
const indirectParamsSize = p.indexed ? 20 : 16; | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to tell reading this list which boundary conditions are checked correctly. Generally we want pairs of control case and error case where the error case is minimally-wrong: just slightly too small, or just slightly too unaligned.
I've pushed commits that refactor this a bit (and address my other comments), PTAL.
PTAL. If my changes look good (they pass in Chrome), you can go ahead and land the PR. |
I've checked locally and all tests pass in Chrome! Thank you @kainino0x |
Sorry, I wrote that unclearly :) |
This PR adds validation tests for the experimental Multi-Draw Indirect feature that can be tested in Chrome Canary behind the "Unsafe WebGPU support" flag at
chrome://flag#enable-unsafe-webgpu
Issue: #3961
Requirements for PR author:
.unimplemented()
./** documented */
and new helper files are found inhelper_index.txt
.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.