-
Notifications
You must be signed in to change notification settings - Fork 920
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
Free command encoders' platform resources on drop on _all_ platforms #5251
Free command encoders' platform resources on drop on _all_ platforms #5251
Conversation
c9a7cbb
to
4515fcb
Compare
4515fcb
to
349433b
Compare
CommandEncoder
is created but finish
isn't called349433b
to
ced2015
Compare
anxiously waiting for a release with this fix in, preferably in the |
@torokati44: Have you confirmed that this fix addresses an issue in Ruffle? It's unclear if the CI issue you're linking is caused by this fix, or fixed by this fix. 😅 |
Since Ruffle is on |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Agh - I honestly thought this PR was caught up in all the other internal work, I didn't realize it was so backportable. There will be a 0.19.3 decently soon, so I'll include this in that |
Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories
This is my attempt to investigate and resolve #3193.
I believe this code is ready to go, but have not yet confirmed internal details to my satisfaction. I'm leaving this as WIP for now because I will be unavailable to work on finalizing details until ~2024-02-21. If somebody wants to pick it up before then, great!Description
Describe what problem this is solving, and how it's solved.
I believe that #3193 is caused by not freeing command encoders early enough. This is apparent on the DX12 backend, where the DX12 API actually emits an error to inform us of our mistake. This is likely causing issues in other backends (i.e., Vulkan), where the symptoms aren't as obvious. Metal has already been cared for by @bradwerth with #2077, so only the other backends need attention here.
Interestingly, we don't currently do any clean-up of command encoders when they are dropped, but we do when they're
finish
ed. This seems wrong. So, this change adds aCommandEncoder::discard_encoding
call for command encoders withinwgpu_core::Global::command_encoder_drop
. This change also adds a similar call to theDrop
implementation of backends that appear to be idempotent in theirCommandEncoder::discard_encoder
calls (N.B., this does not include Vulkan). This appears to resolve DX12 API errors.To be completely clear about how each backend is changed here:
Testing
Explain how this change is tested.
A test (wgpu_test::buffer::command_encoder_without_finish_fine
) has been added, demonstrating both the expected failure before the fix and resolution to "just" passing.This change changes numerous expected error cases for tests for
DX12
, most notablywgpu_tests::encoder::drop_encoder_after_error
, to simply be passing.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.