Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.74k stars 468 forks source link

Upgrade to raw-window-handle 0.6 #1385

Closed Noahnoah55 closed 3 months ago

Noahnoah55 commented 5 months ago

I implemented HasWindowHandle and HasDisplayHandle for Window, though its not send/sync due to it containing the underlying pointer to SDL_Window, preventing it from being used with wgpu without unsafe. Still, I updated the raw-window-handle/wgpu example to work with the most current version of both libraries.

Should fix https://github.com/Rust-SDL2/rust-sdl2/issues/1376

I ran cargo check on the code for other platforms, but I don't have access to anything but my linux machine right now. I feel especially iffy about iOS code, as the required field changed from UI_Window to UI_View.

I'm hoping to find a better solution to implement send/sync for Window than just wrapping it in Arc<Mutex<>>, partially because it smells bad, and partially because it looks like it'll take a long time.

Noahnoah55 commented 5 months ago

Oh, also for some reason with the example, when I resize the screen I get one frame of SurfaceError::Outdated, but if you ignore it the problem goes away the next frame.

Cobrand commented 5 months ago

I am really not familiar with all the raw-window-handle parts, so if someone else is knowledgeable and can tell me if this looks good, I'd appreciate it.

thefiredman commented 5 months ago

I am really not familiar with all the raw-window-handle parts, so if someone else is knowledgeable and can tell me if this looks good, I'd appreciate it.

I have tested it on MacOS and NixOS, it appears to work great. I'm not knowledgeable enough to know though.

Hope this will be resolved soon.

nickbp commented 5 months ago

I was able to use this branch to upgrade wgpu to 0.19 which requires raw-window-handle 0.6.x. Not seeing any problems on Linux with X11.

Using it with this Cargo.toml for reference:

sdl2 = { git = "https://github.com/Noahnoah55/rust-sdl2/", branch = "master", features = ["raw-window-handle"] }
[...]
wgpu = "0.19"

Can see usage here: https://git.sr.ht/~nickbp/soundview/commit/d71d9f337ccfcb67ef2988b9f2d64c7106394c24#Cargo.toml

Cobrand commented 5 months ago

Alright then, it looks good, I just need to fix the CI beforehand (unrelated to your PR)