Skip to content

Commit 70247ad

Browse files
committed
Merge pull request godotengine#89734 from BastiaanOlij/openxr_reorder_wait_frame
OpenXR: Change timing of xrWaitFrame and fix XR multithreading issues
2 parents 273a643 + cbab7dc commit 70247ad

19 files changed

+615
-244
lines changed

doc/classes/RenderingServer.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,12 @@
19791979
[b]Warning:[/b] This function is primarily intended for editor usage. For in-game use cases, prefer physics collision.
19801980
</description>
19811981
</method>
1982+
<method name="is_on_render_thread">
1983+
<return type="bool" />
1984+
<description>
1985+
Returns [code]true[/code] if our code is currently executing on the rendering thread.
1986+
</description>
1987+
</method>
19821988
<method name="light_directional_set_blend_splits">
19831989
<return type="void" />
19841990
<param index="0" name="light" type="RID" />

doc/classes/XRServer.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
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.
3838
</description>
3939
</method>
40-
<method name="clear_reference_frame" qualifiers="const">
41-
<return type="Transform3D" />
40+
<method name="clear_reference_frame">
41+
<return type="void" />
4242
<description>
4343
Clears the reference frame that was set by previous calls to [method center_on_hmd].
4444
</description>

modules/openxr/doc_classes/OpenXRAPIExtension.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<method name="get_next_frame_time">
5555
<return type="int" />
5656
<description>
57-
Returns the timing for the next frame.
57+
Returns the predicted display timing for the next frame.
5858
</description>
5959
</method>
6060
<method name="get_play_space">
@@ -63,6 +63,12 @@
6363
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.
6464
</description>
6565
</method>
66+
<method name="get_predicted_display_time">
67+
<return type="int" />
68+
<description>
69+
Returns the predicted display timing for the current frame.
70+
</description>
71+
</method>
6672
<method name="get_session">
6773
<return type="int" />
6874
<description>

modules/openxr/doc_classes/OpenXRInterface.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@
147147
</member>
148148
</members>
149149
<signals>
150+
<signal name="instance_exiting">
151+
<description>
152+
Informs our OpenXR instance is exiting.
153+
</description>
154+
</signal>
150155
<signal name="pose_recentered">
151156
<description>
152157
Informs the user queued a recenter of the player position.
@@ -169,6 +174,11 @@
169174
Informs our OpenXR session now has focus.
170175
</description>
171176
</signal>
177+
<signal name="session_loss_pending">
178+
<description>
179+
Informs our OpenXR session is in the process of being lost.
180+
</description>
181+
</signal>
172182
<signal name="session_stopping">
173183
<description>
174184
Informs our OpenXR session is stopping.

modules/openxr/extensions/openxr_composition_layer_extension.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
274274
if (swapchain_size == viewport_size && !p_static_image && !static_image) {
275275
// We're all good! Just acquire it.
276276
// We can ignore should_render here, return will be false.
277-
XrBool32 should_render = true;
277+
bool should_render = true;
278278
return swapchain_info.acquire(should_render);
279279
}
280280

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

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

302302
swapchain_size = viewport_size;

modules/openxr/extensions/openxr_hand_tracking_extension.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void OpenXRHandTrackingExtension::on_process() {
128128
}
129129

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

0 commit comments

Comments
 (0)