Skip to content

Commit

Permalink
Merge pull request #89734 from BastiaanOlij/openxr_reorder_wait_frame
Browse files Browse the repository at this point in the history
OpenXR: Change timing of xrWaitFrame and fix XR multithreading issues
  • Loading branch information
akien-mga committed May 1, 2024
2 parents 273a643 + cbab7dc commit 70247ad
Show file tree
Hide file tree
Showing 19 changed files with 615 additions and 244 deletions.
6 changes: 6 additions & 0 deletions doc/classes/RenderingServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,12 @@
[b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
</description>
</method>
<method name="is_on_render_thread">
<return type="bool" />
<description>
Returns [code]true[/code] if our code is currently executing on the rendering thread.
</description>
</method>
<method name="light_directional_set_blend_splits">
<return type="void" />
<param index="0" name="light" type="RID" />
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/XRServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
You should call this method after a few seconds have passed. For example, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
</description>
</method>
<method name="clear_reference_frame" qualifiers="const">
<return type="Transform3D" />
<method name="clear_reference_frame">
<return type="void" />
<description>
Clears the reference frame that was set by previous calls to [method center_on_hmd].
</description>
Expand Down
8 changes: 7 additions & 1 deletion modules/openxr/doc_classes/OpenXRAPIExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<method name="get_next_frame_time">
<return type="int" />
<description>
Returns the timing for the next frame.
Returns the predicted display timing for the next frame.
</description>
</method>
<method name="get_play_space">
Expand All @@ -63,6 +63,12 @@
Returns the play space, which is an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSpace.html]XrSpace[/url] cast to an integer.
</description>
</method>
<method name="get_predicted_display_time">
<return type="int" />
<description>
Returns the predicted display timing for the current frame.
</description>
</method>
<method name="get_session">
<return type="int" />
<description>
Expand Down
10 changes: 10 additions & 0 deletions modules/openxr/doc_classes/OpenXRInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
</member>
</members>
<signals>
<signal name="instance_exiting">
<description>
Informs our OpenXR instance is exiting.
</description>
</signal>
<signal name="pose_recentered">
<description>
Informs the user queued a recenter of the player position.
Expand All @@ -169,6 +174,11 @@
Informs our OpenXR session now has focus.
</description>
</signal>
<signal name="session_loss_pending">
<description>
Informs our OpenXR session is in the process of being lost.
</description>
</signal>
<signal name="session_stopping">
<description>
Informs our OpenXR session is stopping.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
if (swapchain_size == viewport_size && !p_static_image && !static_image) {
// We're all good! Just acquire it.
// We can ignore should_render here, return will be false.
XrBool32 should_render = true;
bool should_render = true;
return swapchain_info.acquire(should_render);
}

Expand All @@ -296,7 +296,7 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p

// Acquire our image so we can start rendering into it,
// we can ignore should_render here, ret will be false.
XrBool32 should_render = true;
bool should_render = true;
bool ret = swapchain_info.acquire(should_render);

swapchain_size = viewport_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void OpenXRHandTrackingExtension::on_process() {
}

// process our hands
const XrTime time = OpenXRAPI::get_singleton()->get_next_frame_time(); // This data will be used for the next frame we render
const XrTime time = OpenXRAPI::get_singleton()->get_predicted_display_time();
if (time == 0) {
// we don't have timing info yet, or we're skipping a frame...
return;
Expand Down

0 comments on commit 70247ad

Please sign in to comment.