From dded2f54029f0145027c2251b4395bd819ef695a Mon Sep 17 00:00:00 2001 From: Kevin King <4kevinking@gmail.com> Date: Wed, 5 Jan 2022 23:22:39 -0800 Subject: [PATCH] add back XrGraphicsContext impl now running into thread '' panicked at 'Cannot get the native window, it's null and will always be null before Event::Resumed and after Event::Suspended. Make sure you only call this function between those events.', C:\Users\kevin\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.26.1\src\platform_impl\android\mod.rs:598:13 perhaps this is related to https://github.com/bevyengine/bevy/issues/2432 --- Cargo.toml | 6 ++++-- crates/bevy_openxr/src/presentation.rs | 25 ++++++++++++------------- examples/xr/vr_cubes.rs | 10 +++++----- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 18a8e68f46f3c..803540222b193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ default = [ "vorbis", "x11", "filesystem_watcher", - "bevy_openxr", # todo: remove + "bevy_openxr", # todo: remove ] @@ -100,7 +100,9 @@ bevy_dylib = { path = "crates/bevy_dylib", version = "0.5.0", default-features = bevy_internal = { path = "crates/bevy_internal", version = "0.5.0", default-features = false } [target.'cfg(target_arch = "wasm32")'.dependencies] -bevy_internal = { path = "crates/bevy_internal", version = "0.5.0", default-features = false, features = ["webgl"] } +bevy_internal = { path = "crates/bevy_internal", version = "0.5.0", default-features = false, features = [ + "webgl", +] } [dev-dependencies] anyhow = "1.0.4" diff --git a/crates/bevy_openxr/src/presentation.rs b/crates/bevy_openxr/src/presentation.rs index 239806dae5edc..64112f3fdd112 100644 --- a/crates/bevy_openxr/src/presentation.rs +++ b/crates/bevy_openxr/src/presentation.rs @@ -177,13 +177,13 @@ pub fn create_graphics_context( .map_err(Box::new)? }; - // let wgpu_instance = unsafe { wgpu::Instance::from_hal::(hal_instance) }; - // let wgpu_adapter = unsafe { wgpu_instance.adapter_from_hal(hal_exposed_adapter) }; - // let (wgpu_device, wgpu_queue) = unsafe { - // wgpu_adapter - // .device_from_hal(hal_device, &device_descriptor, None) - // .map_err(Box::new)? - // }; + let wgpu_instance = unsafe { wgpu::Instance::from_hal::(hal_instance) }; + let wgpu_adapter = unsafe { wgpu_instance.create_adapter_from_hal(hal_exposed_adapter) }; + let (wgpu_device, wgpu_queue) = unsafe { + wgpu_adapter + .create_device_from_hal(hal_device, &device_descriptor, None) + .map_err(Box::new)? + }; Ok(( GraphicsContextHandles::Vulkan { @@ -193,12 +193,11 @@ pub fn create_graphics_context( queue_family_index, queue_index, }, - todo!(), - // XrGraphicsContext { - // instance: wgpu_instance, - // device: Arc::new(wgpu_device), - // queue: wgpu_queue, - // }, + XrGraphicsContext { + instance: wgpu_instance, + device: Arc::new(wgpu_device), + queue: wgpu_queue, + }, )) } else { #[cfg(windows)] diff --git a/examples/xr/vr_cubes.rs b/examples/xr/vr_cubes.rs index 8b3d7a2cb232b..c1d83274376d4 100644 --- a/examples/xr/vr_cubes.rs +++ b/examples/xr/vr_cubes.rs @@ -8,7 +8,7 @@ use bevy::{ XrReferenceSpaceType, XrSessionMode, XrSystem, XrTrackingSource, XrVibrationEvent, XrVibrationEventType, }, - DefaultPlugins, PipelinedDefaultPlugins, + DefaultPlugins, }; #[bevy_main] @@ -16,7 +16,7 @@ fn main() { App::new() .add_plugin(XrPlugin) .add_plugin(OpenXrPlugin) - .add_plugins(PipelinedDefaultPlugins) + .add_plugins(DefaultPlugins) .add_startup_system(startup) .add_system(interaction) .run(); @@ -42,7 +42,7 @@ fn startup(mut xr_system: ResMut, mut app_exit_events: EventWriter 0.0 { // Low frequency rumble vibration_events.send(XrVibrationEvent {