gfx-rs / wgpu-native

Native WebGPU implementation based on wgpu-core
Apache License 2.0
865 stars 103 forks source link

Update to wgpu-core 0.20.0 #387

Closed almarklein closed 1 month ago

almarklein commented 4 months ago

Updating to https://github.com/gfx-rs/wgpu/releases/tag/v0.20.0

almarklein commented 4 months ago

I'm attempting to update, but my I'm somewhat overwhelmed by the Rust type errors:

E.g. I get a ton of these; is the suggestion from the Rust compiler the way to go?

error[E0599]: no method named `as_mut` found for struct `Id` in the current scope
    --> src/lib.rs:4293:32
     |
4293 |     let encoder = pass.encoder.as_mut().unwrap();
     |                                ^^^^^^ method not found in `Id<RenderPassEncoder>`
     |
    ::: /Users/almar/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/convert/mod.rs:372:8
     |
372  |     fn as_mut(&mut self) -> &mut T;
     |        ------
     |        |
     |        the method is available for `Box<Id<RenderPassEncoder>>` here
     |        the method is available for `Box<&mut Id<RenderPassEncoder>>` here
     |        the method is available for `Box<&Id<RenderPassEncoder>>` here
     |
help: consider wrapping the receiver expression with the appropriate type
     |
4293 |     let encoder = Box::new(pass.encoder).as_mut().unwrap();
     |                   +++++++++            +
help: consider wrapping the receiver expression with the appropriate type
     |
4293 |     let encoder = Box::new(&mut pass.encoder).as_mut().unwrap();
     |                   +++++++++++++             +
help: consider wrapping the receiver expression with the appropriate type
     |
4293 |     let encoder = Box::new(&pass.encoder).as_mut().unwrap();
     |                   ++++++++++            +
rajveermalviya commented 4 months ago

Yeah there are quite a lot of changes needed, here's my branch that I was working a while ago, it compiles and runs but has a ref counting race condition somewhere for the surface, so it segfaults at exit. I didn't get much time to work on finding it though.

rajveermalviya commented 4 months ago

(Feel free to pull those changes in this PR :))

almarklein commented 4 months ago

Ah, great to see you've already made the changes. That segfault sounds bad. I might also have a look.

almarklein commented 4 months ago

I reviewed your changes, and it looks fine to me (albeit my Rust knowledge is limited). I especially checked the code related to surfaces, but cannot find anything suspicious of why the race condition was introduced. I also don't get a segfault on MacOS.

rajveermalviya commented 4 months ago

This https://github.com/gfx-rs/wgpu/issues/5637 may be related, it's fix is added as a backport, so maybe will need to wait till next point release. (I still need to verify by moving to wgpu trunk)

Update: It doesn't fix it unfortunately, but it's related to our Arc usage for Surface + Device.

ygdrasil-io commented 3 months ago

Is it possible to publish a version even if we have some memory issue on it ? The issue could be track and fix on a futur minor version, so, peoples waiting for bugfixes/new features are not block.

rajveermalviya commented 2 months ago

The segfault turned out to be fixed via https://github.com/gfx-rs/wgpu/pull/6052, #402 updates wgpu to v22.1.0 which includes that fix and no longer segfaults.