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

Eagerly release GPU resources when we lose the device. #4834

Closed
wants to merge 21 commits into from

Conversation

bradwerth
Copy link
Contributor

@bradwerth bradwerth commented Dec 5, 2023

Connections
N/A

Description
This destroys buffer objects whenever we "lose the device", including at the end of the device.destroy process. Destruction of the buffers triggers reclamation of GPU memory, rather than waiting for the garbage collector to drop the buffer. It would be ideal to also destroy texture objects, but texture.destroy is not implemented, as noted in a TODO.

Testing
This is exercised by any bulk test execution, like the CTS, which relies on device.destroy (not waiting for the garbage collector) to free up GPU resources. Bulk test execution will have less failures due to full memory conditions.

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.

@bradwerth bradwerth requested a review from a team as a code owner December 5, 2023 20:58
@@ -3317,7 3321,8 @@ impl<A: HalApi> Device<A> {
self.valid.store(false, Ordering::Release);

// 1) Resolve the GPUDevice device.lost promise.
let closure = self.lock_life().device_lost_closure.take();
let mut life_lock = self.lock_life();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be holding the life lock across external closure invocations - this could potentially deadlock.

jimblandy and others added 19 commits December 8, 2023 14:06
This prepares for introducing a similar test for global variables.
Co-authored-by: dependabot[bot] <49699333 dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: JMS55 <47158642 [email protected]>
Co-authored-by: Ashley Ruglys <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
…calls (gfx-rs#4726)

* Add reusable buffer mappings for WASM

* Run cargo fmt

* Update CHANGELOG.md

* Update web.rs

* Add documentation for WebBuffer struct
* Remove expose-ids feature

* Changelog
cbindgen spins out of control if wgpu_hal reexports a wgpu_types type using pub type in stead of pub use while keeping the same name.
…nUniform`, not just buffer binding arrays.

Apply the `NonUniform` decoration to the results of all access chains rooted in binding arrays that use non-uniform values as indices, regardless of the binding array's element type and address space. Previously, Naga only decorated non-uniform access chains for binding arrays of buffers.
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.18.0 to 1.19.0.
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](matklad/once_cell@v1.18.0...v1.19.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333 dependabot[bot]@users.noreply.github.com>
@bradwerth bradwerth requested a review from a team as a code owner December 8, 2023 22:06
@bradwerth bradwerth requested a review from a team December 8, 2023 22:06
@bradwerth
Copy link
Contributor Author

Ugh, I botched the rebase/merge and I'm not sure how to recover. I'll resubmit as a new PR.

@bradwerth bradwerth closed this Dec 8, 2023
@bradwerth bradwerth deleted the eagerGPURelease branch December 8, 2023 22:12
@bradwerth
Copy link
Contributor Author

New, non-borked PR is #4851.

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.