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

Remove lifetime dependency of ComputePass to its parent command encoder #5620

Draft
wants to merge 22 commits into
base: trunk
Choose a base branch
from

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Apr 28, 2024

Connections

Part of a series towards lifetime removal on compute passes:

Description

ComputePass had a static lifetime dependency to its parent encoder. This PR removes this (ComputePass<'a> -> ComputePass) by having ComputePass own an Arc to its parent encoder. A side-effect of this is that ComputePass creation can now fail in theory (if an invalid id is passed or commandbuffer allocation fails for some reason).

Another wide reaching side effect is that command encoders can now be in a Locked state. (via WebGPU spec) any operation on a locked command encoder fails and makes the encoder invalid.

The last remaining lifetime dependency to resolve on ComputePass after this PR is in ComputePassTimestampWrites<'a>: We currently don't bump the reference count on the referenced QuerySet. This is in fact more of a pre-existing bug since destroying a QuerySet after recording it in a ComputePass and before closing the pass already causes issues!

Testing

  • added a test that verifies that a command encoder can be dropped child compute pass is still live
  • added a that that while a compute pass is being recorded, trying to do any operation on the encoder fails and makes it invalid

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Wumpf added 21 commits April 23, 2024 09:06
…rectly on recording

TODO:
* bind groups don't work because the Binder gets an id only
* wgpu level error handling is missing
…hod of compute/render pass instead of encoder
@Wumpf Wumpf force-pushed the lifetime-free-computepass2 branch from ed88c1f to 70c925d Compare May 5, 2024 10:02
@Wumpf Wumpf mentioned this pull request May 5, 2024
6 tasks
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.

None yet

1 participant