Browse Source

OpenXR: Add profiling macro for process, `xrWaitFrame()` and acquiring swapchain

David Snopek 4 weeks ago
parent
commit
01a5ba4b9d
2 changed files with 12 additions and 0 deletions
  1. 2 0
      main/main.cpp
  2. 10 0
      modules/openxr/openxr_api.cpp

+ 2 - 0
main/main.cpp

@@ -4759,9 +4759,11 @@ bool Main::iteration() {
 
 
 	// process all our active interfaces
 	// process all our active interfaces
 #ifndef XR_DISABLED
 #ifndef XR_DISABLED
+	GodotProfileZoneGrouped(_profile_zone, "xr_server->_process");
 	XRServer::get_singleton()->_process();
 	XRServer::get_singleton()->_process();
 #endif // XR_DISABLED
 #endif // XR_DISABLED
 
 
+	GodotProfileZoneGrouped(_profile_zone, "physics");
 	for (int iters = 0; iters < advance.physics_steps; ++iters) {
 	for (int iters = 0; iters < advance.physics_steps; ++iters) {
 		GodotProfileZone("Physics Step");
 		GodotProfileZone("Physics Step");
 		GodotProfileZoneGroupedFirst(_physics_zone, "setup");
 		GodotProfileZoneGroupedFirst(_physics_zone, "setup");

+ 10 - 0
modules/openxr/openxr_api.cpp

@@ -36,6 +36,7 @@
 #include "core/config/engine.h"
 #include "core/config/engine.h"
 #include "core/config/project_settings.h"
 #include "core/config/project_settings.h"
 #include "core/os/memory.h"
 #include "core/os/memory.h"
+#include "core/profiling/profiling.h"
 #include "core/version.h"
 #include "core/version.h"
 
 
 #include "openxr_platform_inc.h"
 #include "openxr_platform_inc.h"
@@ -170,6 +171,7 @@ void OpenXRAPI::OpenXRSwapChainInfo::free() {
 }
 }
 
 
 bool OpenXRAPI::OpenXRSwapChainInfo::acquire(bool &p_should_render) {
 bool OpenXRAPI::OpenXRSwapChainInfo::acquire(bool &p_should_render) {
+	GodotProfileZone("OpenXR: acquire swapchain");
 	ERR_FAIL_COND_V(image_acquired, true); // This was not released when it should be, error out and reuse...
 	ERR_FAIL_COND_V(image_acquired, true); // This was not released when it should be, error out and reuse...
 
 
 	OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
 	OpenXRAPI *openxr_api = OpenXRAPI::get_singleton();
@@ -2239,11 +2241,15 @@ bool OpenXRAPI::process() {
 		return false;
 		return false;
 	}
 	}
 
 
+	GodotProfileZone("OpenXRAPI::process");
+	GodotProfileZoneGroupedFirst(_profile_zone, "xrWaitFrame");
+
 	// We call xrWaitFrame as early as possible, this will allow OpenXR to get
 	// We call xrWaitFrame as early as possible, this will allow OpenXR to get
 	// proper timing info between this point, and when we're ready to start rendering.
 	// proper timing info between this point, and when we're ready to start rendering.
 	// As the name suggests, OpenXR can pause the thread to minimize the time between
 	// As the name suggests, OpenXR can pause the thread to minimize the time between
 	// retrieving tracking data and using that tracking data to render.
 	// retrieving tracking data and using that tracking data to render.
 	// OpenXR thus works best if rendering is performed on a separate thread.
 	// OpenXR thus works best if rendering is performed on a separate thread.
+
 	void *frame_wait_info_next_pointer = nullptr;
 	void *frame_wait_info_next_pointer = nullptr;
 	for (OpenXRExtensionWrapper *extension : frame_info_extensions) {
 	for (OpenXRExtensionWrapper *extension : frame_info_extensions) {
 		void *np = extension->set_frame_wait_info_and_get_next_pointer(frame_wait_info_next_pointer);
 		void *np = extension->set_frame_wait_info_and_get_next_pointer(frame_wait_info_next_pointer);
@@ -2277,20 +2283,24 @@ bool OpenXRAPI::process() {
 		frame_state.predictedDisplayPeriod = 0;
 		frame_state.predictedDisplayPeriod = 0;
 	}
 	}
 
 
+	GodotProfileZoneGrouped(_profile_zone, "set_render_display_info");
 	set_render_display_info(frame_state.predictedDisplayTime, frame_state.shouldRender);
 	set_render_display_info(frame_state.predictedDisplayTime, frame_state.shouldRender);
 
 
 	// This is before setup_play_space() to ensure that it happens on the frame after
 	// This is before setup_play_space() to ensure that it happens on the frame after
 	// the play space has been created.
 	// the play space has been created.
 	if (unlikely(local_floor_emulation.should_reset_floor_height && !play_space_is_dirty)) {
 	if (unlikely(local_floor_emulation.should_reset_floor_height && !play_space_is_dirty)) {
+		GodotProfileZoneGrouped(_profile_zone, "reset_emulated_floor_height");
 		reset_emulated_floor_height();
 		reset_emulated_floor_height();
 		local_floor_emulation.should_reset_floor_height = false;
 		local_floor_emulation.should_reset_floor_height = false;
 	}
 	}
 
 
 	if (unlikely(play_space_is_dirty)) {
 	if (unlikely(play_space_is_dirty)) {
+		GodotProfileZoneGrouped(_profile_zone, "setup_play_space");
 		setup_play_space();
 		setup_play_space();
 		play_space_is_dirty = false;
 		play_space_is_dirty = false;
 	}
 	}
 
 
+	GodotProfileZoneGrouped(_profile_zone, "extension wrappers on_process");
 	for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) {
 	for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) {
 		wrapper->on_process();
 		wrapper->on_process();
 	}
 	}