Skip to content

Commit c3f6eb5

Browse files
Elabajabamockersf
andauthored
Update to wgpu 0.19 and raw-window-handle 0.6 (#11280)
# Objective Keep core dependencies up to date. ## Solution Update the dependencies. wgpu 0.19 only supports raw-window-handle (rwh) 0.6, so bumping that was included in this. The rwh 0.6 version bump is just the simplest way of doing it. There might be a way we can take advantage of wgpu's new safe surface creation api, but I'm not familiar enough with bevy's window management to untangle it and my attempt ended up being a mess of lifetimes and rustc complaining about missing trait impls (that were implemented). Thanks to @MiniaczQ for the (much simpler) rwh 0.6 version bump code. Unblocks bevyengine/bevy#9172 and bevyengine/bevy#10812 ~~This might be blocked on cpal and oboe updating their ndk versions to 0.8, as they both currently target ndk 0.7 which uses rwh 0.5.2~~ Tested on android, and everything seems to work correctly (audio properly stops when minimized, and plays when re-focusing the app). --- ## Changelog - `wgpu` has been updated to 0.19! The long awaited arcanization has been merged (for more info, see https://gfx-rs.github.io/2023/11/24/arcanization.html), and Vulkan should now be working again on Intel GPUs. - Targeting WebGPU now requires that you add the new `webgpu` feature (setting the `RUSTFLAGS` environment variable to `--cfg=web_sys_unstable_apis` is still required). This feature currently overrides the `webgl2` feature if you have both enabled (the `webgl2` feature is enabled by default), so it is not recommended to add it as a default feature to libraries without putting it behind a flag that allows library users to opt out of it! In the future we plan on supporting wasm binaries that can target both webgl2 and webgpu now that wgpu added support for doing so (see bevyengine/bevy#11505). - `raw-window-handle` has been updated to version 0.6. ## Migration Guide - `bevy_render::instance_index::get_instance_index()` has been removed as the webgl2 workaround is no longer required as it was fixed upstream in wgpu. The `BASE_INSTANCE_WORKAROUND` shaderdef has also been removed. - WebGPU now requires the new `webgpu` feature to be enabled. The `webgpu` feature currently overrides the `webgl2` feature so you no longer need to disable all default features and re-add them all when targeting `webgpu`, but binaries built with both the `webgpu` and `webgl2` features will only target the webgpu backend, and will only work on browsers that support WebGPU. - Places where you conditionally compiled things for webgl2 need to be updated because of this change, eg: - `#[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))]` becomes `#[cfg(any(not(feature = "webgl") ,not(target_arch = "wasm32"), feature = "webgpu"))]` - `#[cfg(all(feature = "webgl", target_arch = "wasm32"))]` becomes `#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]` - `if cfg!(all(feature = "webgl", target_arch = "wasm32"))` becomes `if cfg!(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))` - `create_texture_with_data` now also takes a `TextureDataOrder`. You can probably just set this to `TextureDataOrder::default()` - `TextureFormat`'s `block_size` has been renamed to `block_copy_size` - See the `wgpu` changelog for anything I might've missed: https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md --------- Co-authored-by: François <mockersf@gmail.com>
1 parent 38cab0f commit c3f6eb5

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ bevy_utils = { path = "../bevy_utils", version = "0.12.0" }
2828
bevy_tasks = { path = "../bevy_tasks", version = "0.12.0" }
2929

3030
# other
31-
# feature rwh_05 refers to window_raw_handle@v0.5,
32-
# updating to rwh_06 is blocked until wgpu 0.19 release lands.
33-
winit = { version = "0.29", default-features = false, features = ["rwh_05"] }
31+
# feature rwh_06 refers to window_raw_handle@v0.6
32+
winit = { version = "0.29", default-features = false, features = ["rwh_06"] }
3433
accesskit_winit = { version = "0.17", default-features = false, features = [
35-
"rwh_05",
34+
"rwh_06",
3635
] }
3736
approx = { version = "0.5", default-features = false }
38-
raw-window-handle = "0.5"
37+
raw-window-handle = "0.6"
3938

4039
[target.'cfg(target_os = "android")'.dependencies]
4140
winit = { version = "0.29", default-features = false, features = [
4241
"android-native-activity",
43-
"rwh_05",
42+
"rwh_06",
4443
] }
4544

4645
[target.'cfg(target_arch = "wasm32")'.dependencies]

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ pub fn winit_runner(mut app: App) {
797797
.world
798798
.query_filtered::<(Entity, &Window), (With<CachedWindow>, Without<bevy_window::RawHandleWrapper>)>();
799799
if let Ok((entity, window)) = query.get_single(&app.world) {
800-
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
800+
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
801801
let window = window.clone();
802802

803803
let (
@@ -820,8 +820,8 @@ pub fn winit_runner(mut app: App) {
820820
);
821821

822822
let wrapper = RawHandleWrapper {
823-
window_handle: winit_window.raw_window_handle(),
824-
display_handle: winit_window.raw_display_handle(),
823+
window_handle: winit_window.window_handle().unwrap().as_raw(),
824+
display_handle: winit_window.display_handle().unwrap().as_raw(),
825825
};
826826

827827
app.world.entity_mut(entity).insert(wrapper);

src/system.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use bevy_utils::{
1212
EntityHashMap,
1313
};
1414
use bevy_window::{RawHandleWrapper, Window, WindowClosed, WindowCreated};
15-
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
1615

16+
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
1717
use winit::{
1818
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize},
1919
event_loop::EventLoopWindowTarget,
@@ -74,8 +74,8 @@ pub(crate) fn create_windows<'a>(
7474
commands
7575
.entity(entity)
7676
.insert(RawHandleWrapper {
77-
window_handle: winit_window.raw_window_handle(),
78-
display_handle: winit_window.raw_display_handle(),
77+
window_handle: winit_window.window_handle().unwrap().as_raw(),
78+
display_handle: winit_window.display_handle().unwrap().as_raw(),
7979
})
8080
.insert(CachedWindow {
8181
window: window.clone(),

0 commit comments

Comments
 (0)