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

Reduce draw validation test parameterization #3122

Merged
merged 9 commits into from
Nov 2, 2023

Conversation

kainino0x
Copy link
Collaborator

Draw validation tests were taking a huge chunk (maybe 25%) of the time of the whole api,validation suite. This should reduce their time by roughly 80-90%.

It may be useful to look at each commit separately to have a good sense of how much they're reducing the test coverage by. My estimate is that we still probably have all of the coverage we need.

cc @jzm-intel in case you have opinions about these tests.

Issue: None


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.)

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.

@kainino0x kainino0x requested review from lokokung and jiangzhaoming and removed request for jiangzhaoming October 31, 2023 21:27
// the factor for offset of attributes in vertex layout
.combine('offset', [0, 1, 2, 7]) // the offset of attribute will be factor * MIN(4, sizeof(vertexFormat))
.beginSubcases()
.combine('setBufferOffset', [0, 200]) // must be a multiple of 4
.combine('setBufferOffset', [200]) // must be a multiple of 4
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. If we are just using 1 value, maybe we can just make it a constant in the test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a bit silly but I left it here since the test is already parameterized around it. Having it here makes it clear we could add more values in the future if needed.

@@ -459,7 +478,7 @@ success/error as expected. Such set of buffer parameters should include cases li
}

const calcSetBufferSize = (
boundBufferSizeState: 'zero' | 'exile' | 'enough',
boundBufferSizeState: 'zero' | 'oneTooSmall' | 'exact',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. maybe just 'tooSmall' is good enough? Not sure whether the one part is relevant.

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 think it's kinda helpful to a test reader to know that we're testing the boundary condition. Also both 'zero' and 'oneTooSmall' are too small.

.combineWithParams([
{ vertexOffsetFactor: 0.0, instanceOffsetFactor: 0.0, indexOffsetFactor: 0.0 },
{ vertexOffsetFactor: 1.0, instanceOffsetFactor: 1.0, indexOffsetFactor: 1.0 },
//
Copy link
Contributor

Choose a reason for hiding this comment

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

nit. Since you already included comment sections to separate the cases, maybe a brief one-liner explaining what the cases are testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Honestly I don't have much of an explanation here. I just picked some reasonable looking subset of the original combinatorial explosion that would maybe have the right amounts of overlaps. But I don't fully understand how they're used so I can't really write intelligently here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Initially these factors are designed to emulate all overlay possibility of three buffer binding within a single GPUBuffer. Consider each binding size is 1, and the offset factor indicate the begin point of each binding form 0 to 2 in 0.5 steps.
So some of the cases are:

  1. No overlay: [0, 1, 2]
  2. The first two binding no overlay, third binding overlay: [0, 1, (1, 1.5)]
  3. The first two partially overlay, and the third one may or may not overlay with them: [0, 0.5, (0.5, 1, 1.5)]
  4. The first two complete overlay, and the third one may or may not overlay with them: [0, 0, (0, 0.5, 1)]

And three different kind of binding (vertex, instance, index) map to these three binding in several ways.
Yes there are too many combination and many of them is duplicated...

And oops I realize that the expected binding size of three kind is not necessary the same, so combining the factor doesn't ensure all overlay cases are tested.
Maybe I should review this tests later and replace these factor things with explicit overlay expectation...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the explanation, that's about what I thought but I wasn't sure.
Let me see if we can do something like:

  • No overlay: [0, 2, 4]
  • The first two binding no overlay, third binding overlay: [0, 2, (2, 2.5)]
  • The first two partially overlay, and the third one may or may not overlay with them: [0, 0.5, (0.5, 1, 4)]
  • The first two complete overlay, and the third one may or may not overlay with them: [0, 0, (0, 0.5, 4)]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually - this test is only a tiny fraction of the slowness here, so I'm just going to revert this, add a TODO for what you suggested, and land this PR.

@kainino0x kainino0x enabled auto-merge (squash) November 2, 2023 00:28
@kainino0x kainino0x merged commit a71c816 into gpuweb:main Nov 2, 2023
2 checks passed
@kainino0x kainino0x deleted the misc-test-optimizations branch November 2, 2023 00:51
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