Reintroduce computepass->encoder lifetime constraint and make it opt-out via wgpu::ComputePass::forget_lifetime
#5768
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. #1453ComputePass
to its parent command encoder #5620Description
As suggested on Matrix chat by @kpreid.
In #5620,
wgpu::ComputePass
lost its explicit lifetime constraint towgpu::CommandEncoder
. This constraint prevented use of the command encoder while a pass is recorded. This is still an error, but now a runtime error. While removing this lifetime is very useful especially for library authors, it also prevented trivial incorrect api usage, i.e. that PR was great but also created a massive footgun ;-).Here, we remedy this issue by re-introducing the exact same lifetime constraint but making it opt-out with a zero-overhead
forget_lifetime
method.Testing
Existing tests have been adjusted - compilation failed as expected without these adjustments!
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.