Free command encoders' platform resources on drop on _all_ platforms#5251
Merged
ErichDonGubler merged 3 commits intogfx-rs:trunkfrom Feb 15, 2024
Merged
Conversation
ErichDonGubler
commented
Feb 14, 2024
c9a7cbb to
4515fcb
Compare
4515fcb to
349433b
Compare
CommandEncoder is created but finish isn't called
nical
approved these changes
Feb 15, 2024
349433b to
ced2015
Compare
Contributor
|
anxiously waiting for a release with this fix in, preferably in the |
Member
Author
|
@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. 😅 |
Contributor
|
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.
Member
|
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 |
Closed
1 task
Merged
This file contains hidden or 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
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
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
finished. This seems wrong. So, this change adds aCommandEncoder::discard_encodingcall for command encoders withinwgpu_core::Global::command_encoder_drop. This change also adds a similar call to theDropimplementation of backends that appear to be idempotent in theirCommandEncoder::discard_encodercalls (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-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.