-
Notifications
You must be signed in to change notification settings - Fork 978
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
Separate out ComputeCommand id->arc resolve (a step towards no lifetimes on wgpu::ComputePass
)
#5432
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 tasks
cwfitzgerald
requested changes
Apr 18, 2024
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.
Looking good, have some comments
6 tasks
6 tasks
cwfitzgerald
approved these changes
Apr 22, 2024
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.
Nice!
6 tasks
6 tasks
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connections
RenderPass
make it difficult to use. #1453Part of a series towards lifetime removal:
wgpu::ComputePass
) #5432wgpu::ComputePass
methods #5570Description
Background
This is working towards removing the dreaded lifetimes on
wgpu::ComputePass
&wgpu::RenderPass
. I'm starting with compute passes since they have a much smaller API surface area.Today, the lifetime on the wgpu objects protect us from dropping resources that may be used during pass execution. For example if one passes a pipeline to a render/compute pass, it musn't be dropped until the pass is executed/ended since the pass currently only remembers the pipeline's id.
To allow dropping it (and thus removing the lifetime constraint), we have to bump the reference count of all resources going into a pass upon recording and not (as done today) upon finishing the pass. Ever since Arcanization landed this is technically possible with manageable overhead.
This PR
This PR introduces
ArcComputeCommand
which is toComputeCommand
like the existingArcRenderCommand
toRenderCommand
(ArcRenderCommand
is only used in RenderBundle today, but this likely going to change soon as well!).The goal in a follow-up PR is for
ComputePass
to recordArcComputeCommand
directly, reservingComputeCommand
solely for tracing.Instead, in this iteration recording operations on
ComputePass
still pushComputeCommand
into an internal vector which then is converted just before finish toArcComputeCommand
, thus separating out id->Arc resolve of the actual execution. -> Only recording replay will need to do this bulk conversion in the future, but it's not going away until ids are gone. The pass execution itself now relies already onArcComputeCommand
.Alternatives considered
The original idea was to extend
ComputeCommand
to hold both ids as well as optional Arc in order to avoid duplication of the command enum. However what made me decide differently:ComputeCommand
generic over aHalApi
making the trace infrastructure infected with this. It looked to me like some type erasure would have been neededArcRenderCommand
ArcComputeCommand
can become justComputeCommand
and what'sComputeCommand
today becomesTraceComputeCommand
!)Testing
Regular unit tests run compute, this should cover this well enough.
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.[ ] Add change toCHANGELOG.md
. See simple instructions inside file.