From 7dc41008503134ff149fa235e463dcc7fba9d992 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sun, 8 Dec 2024 02:17:21 +0900 Subject: [PATCH] do not use ALPHA_BLEND if passthrough is off --- src/backend/openxr/mod.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/backend/openxr/mod.rs b/src/backend/openxr/mod.rs index 96637ae..b53195d 100644 --- a/src/backend/openxr/mod.rs +++ b/src/backend/openxr/mod.rs @@ -66,9 +66,16 @@ pub fn openxr_run(running: Arc, show_by_default: bool) -> Result<(), } }; + let mut app_state = { + let graphics = WlxGraphics::new_openxr(xr_instance.clone(), system)?; + AppState::from_graphics(graphics)? + }; + let environment_blend_mode = { let modes = xr_instance.enumerate_environment_blend_modes(system, VIEW_TYPE)?; - if modes.contains(&xr::EnvironmentBlendMode::ALPHA_BLEND) { + if modes.contains(&xr::EnvironmentBlendMode::ALPHA_BLEND) + && app_state.session.config.use_passthrough + { xr::EnvironmentBlendMode::ALPHA_BLEND } else { modes[0] @@ -76,11 +83,6 @@ pub fn openxr_run(running: Arc, show_by_default: bool) -> Result<(), }; log::info!("Using environment blend mode: {:?}", environment_blend_mode); - let mut app_state = { - let graphics = WlxGraphics::new_openxr(xr_instance.clone(), system)?; - AppState::from_graphics(graphics)? - }; - if show_by_default { app_state.tasks.enqueue_at( TaskType::System(SystemTask::ShowHide), @@ -147,9 +149,7 @@ pub fn openxr_run(running: Arc, show_by_default: bool) -> Result<(), stage_offset: Affine3A::IDENTITY, }; - let mut skybox = if environment_blend_mode == xr::EnvironmentBlendMode::OPAQUE - || !app_state.session.config.use_passthrough - { + let mut skybox = if environment_blend_mode == xr::EnvironmentBlendMode::OPAQUE { create_skybox(&xr_state, &app_state) } else { None @@ -224,9 +224,7 @@ pub fn openxr_run(running: Arc, show_by_default: bool) -> Result<(), if main_session_visible { log::debug!("Destroying skybox."); skybox = None; - } else if environment_blend_mode == xr::EnvironmentBlendMode::OPAQUE - || !app_state.session.config.use_passthrough - { + } else if environment_blend_mode == xr::EnvironmentBlendMode::OPAQUE { log::debug!("Allocating skybox."); skybox = create_skybox(&xr_state, &app_state); }