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

Optimized the creation of CommandEncoders on WebGPU #7037

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Oct 15, 2024

The rendering on WebGPU used to create a new command encoder for each render pass, and also for other operations between the passes, like buffer upload / download, query resolves and similar.

Now this has been minimized to 2-3 a frame, depending on how the scheduling of dynamic buffer uploads needs to execute.

The hope is that this will minimize the gaps on the gpu between render passes, which this likely contributes to, at least on Apple HW. Follows this advice from Apple engineer:

Each command encoder creates a MTLCommandBuffer and MTLCommandBuffer requires synchronization
back to the unified memory on Apple Silicon and iOS. So this is much much slower in general than using
a single MTLCommandBuffer (1 GPUCommandEncoder) and creating several render or compute passes.

This is the before capture, where the gaps can be observed. It seems the hea dof mini-browser is broken at the moment, and so I cannot capture after screenshot currently :(

Note especially the gaps between those tiny bloom blur passes, where the gaps are significantly larger than the passes themselves.
image

@mvaligursky mvaligursky self-assigned this Oct 15, 2024
@mvaligursky mvaligursky added performance Relating to load times or frame rate area: graphics Graphics related issue labels Oct 15, 2024
@mvaligursky mvaligursky requested a review from a team October 15, 2024 10:36
@mvaligursky mvaligursky merged commit 2f0b136 into main Oct 15, 2024
8 checks passed
@mvaligursky mvaligursky deleted the mv-webgpu-command-encoders branch October 15, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue performance Relating to load times or frame rate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants