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 tests for Multi-Draw Indirect #3962

Merged
merged 11 commits into from
Nov 25, 2024
Merged

Conversation

beaufortfrancois
Copy link
Collaborator

@beaufortfrancois beaufortfrancois commented Sep 24, 2024

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

image

Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)
  • Test have be tested with compatibility mode validation enabled and behave as expected. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

Copy link

@Sirtsu55 Sirtsu55 left a 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 },

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.

Copy link
Collaborator

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 */
  ])

Copy link
Collaborator Author

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!

Copy link
Collaborator Author

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?

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!

@Sirtsu55
Copy link

Sirtsu55 commented Oct 28, 2024

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?

@beaufortfrancois
Copy link
Collaborator Author

FYI @beaufortfrancois , I'm working on #3962 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.

u.expandWithParams(() => {
return [
// In bounds
{ bufferSize: 4, indirectOffset: 0, _valid: true },
Copy link
Collaborator

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 */
  ])

@kainino0x
Copy link
Collaborator

kainino0x commented Nov 4, 2024

FYI @beaufortfrancois , I'm working on #3962 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.

IMO land tests as soon as they're landable. It's easy enough to modify tests after they land.

_valid: boolean;
}

g.test('indirect_offset_oob')
Copy link
Collaborator

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
    ?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator Author

@beaufortfrancois beaufortfrancois left a 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!

_valid: boolean;
}

g.test('indirect_offset_oob')
Copy link
Collaborator Author

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));
Copy link
Collaborator

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.

Copy link
Collaborator Author

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')
Copy link
Collaborator

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.

.paramsSubcasesOnly(u =>
u.combine('indexed', [true, false] as const).expandWithParams(p => {
const indirectParamsSize = p.indexed ? 20 : 16;
return [
Copy link
Collaborator

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.

@kainino0x
Copy link
Collaborator

PTAL. If my changes look good (they pass in Chrome), you can go ahead and land the PR.

@beaufortfrancois
Copy link
Collaborator Author

I've checked locally and all tests pass in Chrome! Thank you @kainino0x

@beaufortfrancois beaufortfrancois merged commit b78115a into main Nov 25, 2024
1 check passed
@beaufortfrancois beaufortfrancois deleted the multi-draw-indirect branch November 25, 2024 10:33
@kainino0x
Copy link
Collaborator

Sorry, I wrote that unclearly :)
what I meant was, "They already pass in chrome, so if they look good to you, you can land it"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants