Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Richard-Yunchao
Copy link

@Richard-Yunchao Richard-Yunchao commented Aug 4, 2020

The revisions include:

  • add aspect (in addition to array layer and mip level) for
    subresource
  • add definition of atom resource, and use atom resource to
    replace subresource
  • race condition of writable storage buffer/texture in render
    pass is allowed
  • resource usages validation is done within "usage scope"
  • invisible usages and overwritten usages should be tracked

Preview | Diff

The revisions include:
  - add aspect (in addition to array layer and mip level) for
    subresource
  - add definition of atom resource, and use atom resource to
    replace subresource
  - race condition of writable storage buffer/texture in render
    pass is allowed
  - resource usages validation is done within "usage scope"
  - invisible usages and overwritten usages should be tracked
@Richard-Yunchao
Copy link
Author

We discussed this before at #769 and #657. PTAL. Thanks!

spec/index.bs Outdated
of storage-buffer usages upon the same [#atom resource#] in render pass is allowed.

Note that all invisible usages and overwritten usages should be counted, for example:
- a resource binding attached to a shader stage with visiblity none
Copy link
Contributor

Choose a reason for hiding this comment

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

we should talk about whether this makes any sense to allow at all, it's just a useless footgun

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. We can discuss about this if needed.

spec/index.bs Outdated
- a resource binding attached to a shader stage with visiblity none
- a resource binding attached to compute shader stage in render pass, or vice versa
- a collection of bindings are set by a bind group but being overwritten within current [=usage scope=]
- index or vertex buffer being overwritten within current [=usage scope=]
Copy link
Contributor

Choose a reason for hiding this comment

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

similarly here. "overwriting a vertex buffer" is confusing, since users may read this as the contents are overwritten, while you mean the bindings

Copy link
Author

Choose a reason for hiding this comment

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

Done

@Richard-Yunchao
Copy link
Author

We have different opinions, but I really appreciate your review, @kvark . 👍

@Richard-Yunchao
Copy link
Author

Richard-Yunchao commented Aug 5, 2020

OK. To summarize the discussions above, it looks like there are 3 issues to address for resource usage tracking and validation . The latter two issues should be not that controversial though, and I'd like to propose a solution:

  1. We claimed that multiple instances of a single [=mutating usage=] is valid. However, looks like that race condition upon storage buffer/texture in render pass is valid. What about in compute pass? What about race condition upon the same render target (multiple color attachments with the same texture view)?
  2. Do we need to track those resource usages with invisible bindings and/or being replaced by another setBindGroup/setVertexBuffer/setIndexBuffer before issuing any draw/dispatch. I tend to do so because filtering those unused bindings and not track them is expensive from the perspective of implementation. And the validation failure can remind WebGPU devs to remove those useless code.
  3. In addition to mip level and array layer, can we add aspect (dpeht/stencil) as another factor to define different texture subresource when we do resource usages tracking and validation? This means we can track depth and stencil aspect separately. I tend to do so because this is aligned with native graphics like D3D12 and Vulkan from 2 perspectives: 1) texture subresource definition, 2) resource usage tracking via barriers. But I am not sure about the situation in Metal.

Alternatively, we can leave any one of these 3 issues being open before MVP/v1 and discuss them after MVP/v1 if you think it is a corner case.

@kainino0x
Copy link
Contributor

What about in compute pass?

A whole render pass is a usage scope, but not a whole compute pass. In compute, just a single dispatch is a usage scope; we insert necessary synchronization between dispatches.

@Kangz
Copy link
Contributor

Kangz commented Aug 11, 2020

Do we need to track those resource usages with invisible bindings and/or being replaced by another setBindGroup/setVertexBuffer/setIndexBuffer before issuing any draw/dispatch.

IMHO yes, it adds implementation complexity to skip unused bindings, and doesn't provide value except for badly behaved applications.

In addition to mip level and array layer, can we add aspect (dpeht/stencil) as another factor to define different texture subresource when we do resource usages tracking and validation?

Probably, even though right now WebGPU doesn't support any usecase where depth and stencil would have different usages. (read only depth or stencil has to match because of Vulkan 1.0/1.1 limitations)

@Richard-Yunchao
Copy link
Author

What about in compute pass?

A whole render pass is a usage scope, but not a whole compute pass. In compute, just a single dispatch is a usage scope; we insert necessary synchronization between dispatches.

Yeah. I meant to say compute scope (per each dispatch call).

@kainino0x
Copy link
Contributor

That means a resource is used twice in the same dispatch, and that's not any worse than using the resource once in the dispatch (since it can already be written from multiple threads of the dispatch).

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

@Richard-Yunchao sorry about the lack of clarity on what is expected here.

Would you mind removing the "atom" related naming changes from this PR, only leaving the following points in it:

  • add aspect (in addition to array layer and mip level) for subresource
  • race condition of writable storage buffer/texture in render pass is allowed
  • invisible usages and overwritten usages should be tracked

The synchronization scopes are being clarified in #994 in the meantime. Please free to review it and/or follow-up with better description of what's going on.

@Richard-Yunchao Richard-Yunchao force-pushed the resource-usages-validation branch from 430ecfb to 62df6fe Compare August 21, 2020 18:54
@Richard-Yunchao
Copy link
Author

@Richard-Yunchao sorry about the lack of clarity on what is expected here.

Would you mind removing the "atom" related naming changes from this PR, only leaving the following points in it:

  • add aspect (in addition to array layer and mip level) for subresource
  • race condition of writable storage buffer/texture in render pass is allowed
  • invisible usages and overwritten usages should be tracked

The synchronization scopes are being clarified in #994 in the meantime. Please free to review it and/or follow-up with better description of what's going on.

Done, with one minor change that combine two readonly usages you added at #994 into one. Sorry for the late response, @kvark.

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@kvark kvark requested a review from kainino0x August 21, 2020 19:20
@grorg
Copy link
Contributor

grorg commented Aug 24, 2020

Discussed at the 2020-08-24 meeting.

@Richard-Yunchao
Copy link
Author

Addressed feedback from CG meeting and spec editors' meeting on Monday. PTAL. Thank you!

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Thank you!

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.

5 participants