X Tutup
Skip to content

OpenXR: Safely set environment blend mode when rendering on a separate thread#109532

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
dsnopek:openxr-api-environment-blend-mode-thread-safe
Sep 30, 2025
Merged

OpenXR: Safely set environment blend mode when rendering on a separate thread#109532
Repiteo merged 1 commit intogodotengine:masterfrom
dsnopek:openxr-api-environment-blend-mode-thread-safe

Conversation

@dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Aug 11, 2025

For OpenXR to work safely when Godot is rendering on a separate thread (by setting "Rendering" -> "Driver" -> "Thread Model" to "Safe" in Project Settings), any dynamic values we read from on the render thread need to be either protected by a mutex, or set via RenderingServer::call_on_render_thread()

Currently, in OpenXR::end_frame() (which runs on the render thread) we're reading from environment_blend_mode, which can be set directly on the main thread.

This PR adds a new variable to render_state that will be read their instead, and sets it via RenderingServer::call_on_render_thread()

I've tested that this works on Quest 3, even for applications that were configured to start in passthrough mode by setting "Environment Blend Mode" to "Alpha" in project settings. They can go from passthrough to passthrough, without having a random opaque frame in-between (at least as far as I could tell :-)).

@dsnopek dsnopek added this to the 4.6 milestone Aug 11, 2025
@dsnopek dsnopek requested a review from a team as a code owner August 11, 2025 19:56
@dsnopek dsnopek force-pushed the openxr-api-environment-blend-mode-thread-safe branch from 8494600 to da70105 Compare August 11, 2025 20:22
@dsnopek dsnopek force-pushed the openxr-api-environment-blend-mode-thread-safe branch from da70105 to 13a643d Compare August 22, 2025 13:11
@Repiteo Repiteo merged commit 4f66d53 into godotengine:master Sep 30, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Sep 30, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup