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

Updated the way WebGPU dynamic UBs are used for rendering #6349

Merged
merged 2 commits into from
May 13, 2024

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented May 10, 2024

Fixes #6315 based on this comment: #6315 (comment)

  • mesh bind group is split into two, one for a uniform buffer, and one for the rest of resources (textures and storage buffers and similar)
  • this allows us to re-use the same bind ground from the dynamic uniform buffer for all meshes using the same dynamic buffer (per UB size). When a UB buffer jumps to a different per frame bump allocated buffer, it would simply use it's existing bind group instead of creating a new one
  • a good example to demonstrate this is the `hierarchy' engine example, where due to large amount of meshes rendered in different order over time, many of them would need to allocate a new bind group. This does not happen now at all.
  • note that this does not solve the case where a new bind group needs to be created due to assigning a different texture to it, as that is unavoidable

Separately, the order of bind groups in the layout is sorted the opposite way:

  • original order: mesh -> view
  • new order: view -> mesh -> mesh_ub
    This is a recommended way to sort, from the least frequently updated to more frequently updated, to allow the underlying platform to skip all follow up bind groups to be re-set on their device.

Few engine examples that use WGSL directly had to be change to work with this, as there is no automatic bind group allocation yet. This is a non-breaking change as those are not public APIs yet.

@mvaligursky mvaligursky self-assigned this May 10, 2024
@mvaligursky mvaligursky added performance Relating to load times or frame rate area: graphics Graphics related issue enhancement labels May 10, 2024
@mvaligursky mvaligursky requested a review from a team May 10, 2024 15:54
@mvaligursky mvaligursky merged commit e1d77b9 into main May 13, 2024
7 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-dynamic-ub branch May 13, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue enhancement performance Relating to load times or frame rate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebGPU: BindGroups aren't being reused
2 participants