-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Encode commands on finish #8220
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
Conversation
|
Would be nice to run Bevy and see what the performance difference is. |
teoxoy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
I ran the |
Interesting, we've been in that state before transiently :) |
|
For what it's worth: this PR is important to Firefox. |
cwfitzgerald
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good progres and we should land it.
Just so that I understand correctly, this doesn't yet resolve the issue of us needing multiple underlying command buffers in renderpasses - that would be a future pass?
Correct. This PR does change the behavior for non-pass operations directly on a command encoder -- previously each was given its own command buffer, now they will reuse a single command buffer. But each pass will still still have two command buffers, one for the "pre-pass" and one for the actual pass. |
|
I'm not too concerned about performance here as we can always optimize later, plus this is far from its final form. |
|
Merging. |
Co-authored-by: Andreas Reich <[email protected]>
Resolves #7679. Fixes #7854.
This moves command encoding from happening within the calls to the various methods for each command, to instead happen within
CommandEncoder.finish. The motivation to do this is to allow generating better barriers in the command stream (in the future -- this PR does not change the barriers), and it also fixes a validation error that could occur in certain cases.The change is divided into commits, but I'm not sure that makes reviewing easier other than by providing a way to bookmark review progress. (Which I think could equally well be done by noting which files you have reviewed.)
A lot of code has changed, but many of the changes are rote -- e.g. referencing things via
state: EncodingStaterather than viacmd_buf_data. Some particular things to focus on might be the comment onstruct EncodingState, everything incommand/mod.rs, and handling of compute / render passes.With this PR, two copies of every command are saved when tracing -- one with
Ids for the trace, and one withArcs for encoding. I am still working on resolving that.Testing
Mostly via existing tests, but this enables the tests from #7854 that are sensitive to when command encoding happens, which provides some directed coverage.
I did do some performance testing which had somewhat inconclusive results. When I ran the entire wgpu benchmark (which takes hours), it looked like things might be significantly (10-40%) slower. But since it took hours, I was doing other things on my system. When I isolated a specific test case and adjusted to a more reasonable runtime, things were within a few percent before and after the changes.
Squash or Rebase? Probably squash. Things mostly work at the intermediate stages, but there are also weird failures when commands get encoded out of order, that will not necessarily be obvious if encountered without context.
Checklist