Skip to content

Adding validation for GPURenderPassEncoderBase methods - #980

Merged
kainino0x merged 6 commits into
gpuweb:mainfrom
toji:renderpassencoderbase-validation
Aug 11, 2020
Merged

kainino0x merged 6 commits into
gpuweb:mainfrom
toji:renderpassencoderbase-validation

Conversation

@toji

@toji toji commented Aug 5, 2020 •

Copy link
Copy Markdown
Member

Draft for the moment because I'm not done yet, but wanted to ask some questions while I finished up:

  • My intuition is that these steps should take place on the queue timeline, but I'm still kind of fuzzy on which things execute where so I could be wrong.
  • I'm leaning heavily on the Dawn source to determine what validation is needed, but there's odd omissions. For example, draw() and drawIndexed() have no validation that I can see, and indexFormat for setIndexBuffer() isn't actually being passed in to the dawn version of the command encoder? I'm assuming I'm just missing something?
  • Very much not sure about the "add |buffer| to [=usage scope=] as..." bits, would appreciate feedback on if that's formulated correctly.

Preview | Diff

@toji
toji requested a review from kainino0x August 5, 2020 23:12
@kainino0x

Copy link
Copy Markdown
Contributor

Haven't reviewed yet, but notes:

We just added indexFormat to setIndexBuffer and we don't implement it in Dawn yet.

We recently decided not to have validation for things like a draw going out of bounds on a vertex buffer (because a drawIndexed could do this on the GPU side anyway) or a drawIndexed going out of bounds on an index buffer (because a drawIndexedIndirect could do this on the GPU), instead relying on robust buffer access behavior and warnings. So it's expected not to have validation there. I don't remember whether we wanted validation for the range of the indirectBuffer used by an indirect call.

@toji

toji commented Aug 6, 2020

Copy link
Copy Markdown
Member Author

Thanks, that helps. Still question whether or not the draw commands should be validating things like "Do I have a valid pipline bound." But I don't really know what the overall plan is for that kind of encoder-wide state validation.

Finished up the rest of this block of method definitions, so I'll take this out of draft now. Reasonably happy with it, but happy to take feedback on verbiage, additional validation needed, whatever. Also not sure how the group feels about the C-ism of explaining the indirect buffer layout as a struct. (It's what felt most comfortable to me, but perhaps you all had different plans?)

@toji
toji marked this pull request as ready for review August 6, 2020 03:08

@kvark kvark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved

@kvark kvark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome, thank you for great stuff!

@toji
toji force-pushed the renderpassencoderbase-validation branch 2 times, most recently from e67fc7b to 89baed0 Compare August 7, 2020 21:53

@kainino0x kainino0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with a few comments

Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
@toji
toji force-pushed the renderpassencoderbase-validation branch from 89baed0 to 062f4d7 Compare August 11, 2020 05:12
@toji

toji commented Aug 11, 2020

Copy link
Copy Markdown
Member Author

Thanks @kainino0x! Applied the suggested changes, think it helps it read better across the board.

Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
@Kangz

Kangz commented Aug 11, 2020

Copy link
Copy Markdown
Contributor

For example, draw() and drawIndexed() have no validation that I can see, and indexFormat for setIndexBuffer() isn't actually being passed in to the dawn version of the command encoder? I'm assuming I'm just missing something?

Yeah that validation is in a different places at the moment, it's in the CommandBufferStateTracker and adds the following checks for draws:

  • A pipeline has been set.
  • For each BGL in the pipeline layout, a BG with the same BGL is set at the correct slot.
  • For each vertex buffer the pipeline uses, a vertex buffer is set in the correct slot.
  • For indexed draws, an index buffer is set.

Comment thread spec/index.bs Resolved

@kvark kvark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did another pass, noticed a few great things spotted by other reviewers (thanks!).
Note that the fact that we are checking for a usage, and adding the usage to the scope, seems redundant. But once #745 is implemented, these are going to be different usages, so it's going to be much less redundant.

Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
@toji

toji commented Aug 11, 2020

Copy link
Copy Markdown
Member Author

Thanks for the continued feedback! Addressed what I can, but I'd like to defer a bit of the pipeline/bind group/draw validation to a follow up for the sake of keeping the patch size reasonable and reviewable.

@kainino0x
kainino0x merged commit 16aeeef into gpuweb:main Aug 11, 2020
@toji
toji deleted the renderpassencoderbase-validation branch August 11, 2020 16:53
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
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.

4 participants