From b40f788a417c70330d3819f870301cb4bb7b22cd Mon Sep 17 00:00:00 2001
From: Pedro Diaz
Date: Tue, 14 Jan 2025 23:25:11 +0100
Subject: [PATCH] Ensure that Bevy works using Meta XR Simulator in macOS when
using a patched MoltenVK's SPIRV-Cross.
---
.../src/openxr/features/passthrough.rs | 17 ++++++++---------
.../bevy_openxr/src/openxr/graphics/vulkan.rs | 5 +++++
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/crates/bevy_openxr/src/openxr/features/passthrough.rs b/crates/bevy_openxr/src/openxr/features/passthrough.rs
index b5065d6..79df4a2 100644
--- a/crates/bevy_openxr/src/openxr/features/passthrough.rs
+++ b/crates/bevy_openxr/src/openxr/features/passthrough.rs
@@ -40,18 +40,17 @@ impl Plugin for OxrPassthroughPlugin {
pub fn insert_passthrough(world: &mut World) {
let session = world.resource::();
- let (passthrough, passthrough_layer) = create_passthrough(
+ if let Ok((passthrough, passthrough_layer)) = create_passthrough(
session,
openxr::PassthroughFlagsFB::IS_RUNNING_AT_CREATION,
openxr::PassthroughLayerPurposeFB::RECONSTRUCTION,
- )
- .unwrap();
-
- world
- .resource_mut::()
- .insert(0, Box::new(PassthroughLayer));
- world.insert_resource(passthrough);
- world.insert_resource(passthrough_layer);
+ ) {
+ world
+ .resource_mut::()
+ .insert(0, Box::new(PassthroughLayer));
+ world.insert_resource(passthrough);
+ world.insert_resource(passthrough_layer);
+ }
}
pub fn resume_passthrough(
diff --git a/crates/bevy_openxr/src/openxr/graphics/vulkan.rs b/crates/bevy_openxr/src/openxr/graphics/vulkan.rs
index a18f584..9d88177 100644
--- a/crates/bevy_openxr/src/openxr/graphics/vulkan.rs
+++ b/crates/bevy_openxr/src/openxr/graphics/vulkan.rs
@@ -115,10 +115,15 @@ unsafe impl GraphicsExt for openxr::Vulkan {
::Instance::desired_extensions(&vk_entry, VK_TARGET_VERSION_ASH, flags)?;
let device_extensions = [
ash::khr::swapchain::NAME,
+ #[cfg(target_os = "android")]
ash::khr::draw_indirect_count::NAME,
ash::khr::timeline_semaphore::NAME,
ash::khr::imageless_framebuffer::NAME,
ash::khr::image_format_list::NAME,
+ #[cfg(target_os = "macos")]
+ ash::khr::portability_subset::NAME,
+ #[cfg(target_os = "macos")]
+ ash::ext::metal_objects::NAME,
];
let vk_instance = unsafe {