Skip to content

Commit 3f5b871

Browse files
committed
Merge pull request #112893 from dsnopek/openxr-profiling
OpenXR: Add profiling macro for process, `xrWaitFrame()` and acquiring swapchain
2 parents 412601a + 01a5ba4 commit 3f5b871

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

main/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4759,9 +4759,11 @@ bool Main::iteration() {
47594759

47604760
// process all our active interfaces
47614761
#ifndef XR_DISABLED
4762+
GodotProfileZoneGrouped(_profile_zone, "xr_server->_process");
47624763
XRServer::get_singleton()->_process();
47634764
#endif // XR_DISABLED
47644765

4766+
GodotProfileZoneGrouped(_profile_zone, "physics");
47654767
for (int iters = 0; iters < advance.physics_steps; ++iters) {
47664768
GodotProfileZone("Physics Step");
47674769
GodotProfileZoneGroupedFirst(_physics_zone, "setup");

modules/openxr/openxr_api.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "core/config/engine.h"
3737
#include "core/config/project_settings.h"
3838
#include "core/os/memory.h"
39+
#include "core/profiling/profiling.h"
3940
#include "core/version.h"
4041

4142
#include "openxr_platform_inc.h"
@@ -170,6 +171,7 @@ void OpenXRAPI::OpenXRSwapChainInfo::free() {
170171
}
171172

172173
bool OpenXRAPI::OpenXRSwapChainInfo::acquire(bool &p_should_render) {
174+
GodotProfileZone("OpenXR: acquire swapchain");
173175
ERR_FAIL_COND_V(image_acquired, true); // This was not released when it should be, error out and reuse...
174176

175177
OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
@@ -2260,11 +2262,15 @@ bool OpenXRAPI::process() {
22602262
return false;
22612263
}
22622264

2265+
GodotProfileZone("OpenXRAPI::process");
2266+
GodotProfileZoneGroupedFirst(_profile_zone, "xrWaitFrame");
2267+
22632268
// We call xrWaitFrame as early as possible, this will allow OpenXR to get
22642269
// proper timing info between this point, and when we're ready to start rendering.
22652270
// As the name suggests, OpenXR can pause the thread to minimize the time between
22662271
// retrieving tracking data and using that tracking data to render.
22672272
// OpenXR thus works best if rendering is performed on a separate thread.
2273+
22682274
void *frame_wait_info_next_pointer = nullptr;
22692275
for (OpenXRExtensionWrapper *extension : frame_info_extensions) {
22702276
void *np = extension->set_frame_wait_info_and_get_next_pointer(frame_wait_info_next_pointer);
@@ -2298,20 +2304,24 @@ bool OpenXRAPI::process() {
22982304
frame_state.predictedDisplayPeriod = 0;
22992305
}
23002306

2307+
GodotProfileZoneGrouped(_profile_zone, "set_render_display_info");
23012308
set_render_display_info(frame_state.predictedDisplayTime, frame_state.shouldRender);
23022309

23032310
// This is before setup_play_space() to ensure that it happens on the frame after
23042311
// the play space has been created.
23052312
if (unlikely(local_floor_emulation.should_reset_floor_height && !play_space_is_dirty)) {
2313+
GodotProfileZoneGrouped(_profile_zone, "reset_emulated_floor_height");
23062314
reset_emulated_floor_height();
23072315
local_floor_emulation.should_reset_floor_height = false;
23082316
}
23092317

23102318
if (unlikely(play_space_is_dirty)) {
2319+
GodotProfileZoneGrouped(_profile_zone, "setup_play_space");
23112320
setup_play_space();
23122321
play_space_is_dirty = false;
23132322
}
23142323

2324+
GodotProfileZoneGrouped(_profile_zone, "extension wrappers on_process");
23152325
for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) {
23162326
wrapper->on_process();
23172327
}

0 commit comments

Comments
 (0)