From e328c4212174a297c37b71f8936bd60117e170d1 Mon Sep 17 00:00:00 2001 From: Zhongwang Zhang Date: Tue, 7 Nov 2023 16:16:20 +0800 Subject: [PATCH] st/oxr: RenderDoc support on Vulkan/GLES client sides and Android platform Makes it so RenderDoc can be captured by the button in UI. --- src/xrt/state_trackers/oxr/oxr_api_session.c | 4 ++++ src/xrt/state_trackers/oxr/oxr_session_gfx_egl.c | 3 ++- .../state_trackers/oxr/oxr_session_gfx_gles_android.c | 8 ++++++++ src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c | 9 ++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/xrt/state_trackers/oxr/oxr_api_session.c b/src/xrt/state_trackers/oxr/oxr_api_session.c index c6d8fe991..a3368fabc 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_session.c +++ b/src/xrt/state_trackers/oxr/oxr_api_session.c @@ -150,7 +150,9 @@ oxr_xrBeginFrame(XrSession session, const XrFrameBeginInfo *frameBeginInfo) #ifdef XRT_FEATURE_RENDERDOC if (sess->sys->inst->rdoc_api) { +#ifndef XR_USE_PLATFORM_ANDROID sess->sys->inst->rdoc_api->StartFrameCapture(NULL, NULL); +#endif } #endif @@ -171,7 +173,9 @@ oxr_xrEndFrame(XrSession session, const XrFrameEndInfo *frameEndInfo) #ifdef XRT_FEATURE_RENDERDOC if (sess->sys->inst->rdoc_api) { +#ifndef XR_USE_PLATFORM_ANDROID sess->sys->inst->rdoc_api->EndFrameCapture(NULL, NULL); +#endif } #endif diff --git a/src/xrt/state_trackers/oxr/oxr_session_gfx_egl.c b/src/xrt/state_trackers/oxr/oxr_session_gfx_egl.c index 1105184b1..dd80224b4 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_gfx_egl.c +++ b/src/xrt/state_trackers/oxr/oxr_session_gfx_egl.c @@ -43,6 +43,7 @@ oxr_session_populate_egl(struct oxr_logger *log, struct oxr_session *sess) { EGLint egl_client_type = -1; + bool renderdoc_enabled = false; PFNEGLQUERYCONTEXTPROC eglQueryContext = (PFNEGLQUERYCONTEXTPROC)next->getProcAddress("eglQueryContext"); if (!eglQueryContext) { @@ -67,7 +68,7 @@ oxr_session_populate_egl(struct oxr_logger *log, next->config, // next->context, // next->getProcAddress, // - false, // renderdoc_enabled + renderdoc_enabled, // renderdoc_enabled &xcgl); // if (xret == XRT_ERROR_EGL_CONFIG_MISSING) { diff --git a/src/xrt/state_trackers/oxr/oxr_session_gfx_gles_android.c b/src/xrt/state_trackers/oxr/oxr_session_gfx_gles_android.c index f9a5ceb9d..32e612313 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_gfx_gles_android.c +++ b/src/xrt/state_trackers/oxr/oxr_session_gfx_gles_android.c @@ -76,6 +76,13 @@ oxr_session_populate_gles_android(struct oxr_logger *log, return oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, "Unsupported EGL client type"); } + bool renderdoc_enabled = false; + +#if defined(XRT_FEATURE_RENDERDOC) + if (sess->sys->inst->rdoc_api) { + renderdoc_enabled = true; + } +#endif struct xrt_compositor_native *xcn = sess->xcn; struct xrt_compositor_gl *xcgl = NULL; @@ -85,6 +92,7 @@ oxr_session_populate_gles_android(struct oxr_logger *log, next->config, // next->context, // get_proc_addr, // + renderdoc_enabled, // &xcgl); // if (xret == XRT_ERROR_EGL_CONFIG_MISSING) { diff --git a/src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c b/src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c index e35ea1d11..07f11c8dd 100644 --- a/src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c +++ b/src/xrt/state_trackers/oxr/oxr_session_gfx_vk.c @@ -81,6 +81,7 @@ oxr_session_populate_vk(struct oxr_logger *log, bool timeline_semaphore_enabled = sess->sys->vk.timeline_semaphore_enabled; bool external_fence_fd_enabled = sess->sys->vk.external_fence_fd_enabled; bool external_semaphore_fd_enabled = sess->sys->vk.external_semaphore_fd_enabled; + bool renderdoc_enabled = false; #if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD) @@ -109,6 +110,12 @@ oxr_session_populate_vk(struct oxr_logger *log, timeline_semaphore_enabled = true; } +#if defined(XRT_FEATURE_RENDERDOC) && defined(XR_USE_PLATFORM_ANDROID) + if (sess->sys->inst->rdoc_api) { + renderdoc_enabled = true; + } +#endif + struct xrt_compositor_native *xcn = sess->xcn; struct xrt_compositor_vk *xcvk = xrt_gfx_vk_provider_create( // xcn, // @@ -120,7 +127,7 @@ oxr_session_populate_vk(struct oxr_logger *log, external_semaphore_fd_enabled, // timeline_semaphore_enabled, // sess->sys->vk.debug_utils_enabled, // - false, // + renderdoc_enabled, // next->queueFamilyIndex, // next->queueIndex); //