diff --git a/src/xrt/compositor/client/comp_egl_client.c b/src/xrt/compositor/client/comp_egl_client.c index dd72d0c7f..45b7d4e85 100644 --- a/src/xrt/compositor/client/comp_egl_client.c +++ b/src/xrt/compositor/client/comp_egl_client.c @@ -582,6 +582,7 @@ xrt_gfx_provider_create_gl_egl(struct xrt_compositor_native *xcn, struct client_egl_compositor *ceglc = U_TYPED_CALLOC(struct client_egl_compositor); ceglc->current.dpy = display; ceglc->current.ctx = context; + ceglc->base.renderdoc_enabled = renderdoc_enabled; bool bret = client_gl_compositor_init( // &ceglc->base, // c diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index aa5e563cb..9d62b16d7 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -387,6 +387,11 @@ client_gl_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_h struct client_gl_compositor *c = client_gl_compositor(xc); + if (c->renderdoc_enabled) { + glDebugMessageInsert(GL_DEBUG_SOURCE_THIRD_PARTY, GL_DEBUG_TYPE_MARKER, 1, + GL_DEBUG_SEVERITY_NOTIFICATION, -1, "vr-marker,frame_end,type,application"); + } + // We make the sync object, not st/oxr which is our user. assert(!xrt_graphics_sync_handle_is_valid(sync_handle)); diff --git a/src/xrt/compositor/client/comp_gl_client.h b/src/xrt/compositor/client/comp_gl_client.h index 205f59a73..d2e234440 100644 --- a/src/xrt/compositor/client/comp_gl_client.h +++ b/src/xrt/compositor/client/comp_gl_client.h @@ -170,6 +170,8 @@ struct client_gl_compositor * know it is bound to a thread. */ struct os_mutex context_mutex; + + bool renderdoc_enabled; }; diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index ff26b3ff2..0e425eb5a 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -594,6 +594,15 @@ client_vk_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_h struct client_vk_compositor *c = client_vk_compositor(xc); + if (c->renderdoc_enabled) { + struct vk_bundle *vk = &c->vk; + VkResult ret = vk_cmd_pool_submit_cmd_buffer(vk, &c->pool, c->dcb); + if (ret != VK_SUCCESS) { + VK_ERROR(vk, "vk_cmd_pool_submit_cmd_buffer: %s %u", vk_result_string(ret), ret); + return XRT_ERROR_FAILED_TO_SUBMIT_VULKAN_COMMANDS; + } + } + xrt_result_t xret = XRT_SUCCESS; if (submit_handle(c, sync_handle, &xret)) { return xret; @@ -782,6 +791,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn, bool external_semaphore_fd_enabled, bool timeline_semaphore_enabled, bool debug_utils_enabled, + bool renderdoc_enabled, uint32_t queueFamilyIndex, uint32_t queueIndex) { @@ -817,6 +827,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn, } c->base.base.info.format_count = xcn->base.info.format_count; + c->renderdoc_enabled = renderdoc_enabled; // Default to info. enum u_logging_level log_level = debug_get_log_option_vulkan_log(); @@ -867,6 +878,25 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn, c->base.base.info.max_tetxure_size = pdp.limits.maxImageDimension2D; } + if (!c->renderdoc_enabled) { + return c; + } + + struct vk_bundle *vk = &c->vk; + if (!vk->has_EXT_debug_utils) { + c->renderdoc_enabled = false; + return c; + } + + // Create a dummy VkCommandBuffer and submit it to the VkQueue, just for inserting a debug label into + // RenderDoc for triggering the capture. + ret = vk_cmd_pool_create_begin_insert_label_and_end_cmd_buffer_locked( + vk, &c->pool, "vr-marker,frame_end,type,application", &c->dcb); + if (ret != VK_SUCCESS) { + VK_ERROR(vk, "vk_cmd_pool_create_insert_debug_label_and_end_cmd_buffer: %s", vk_result_string(ret)); + goto err_pool; + } + return c; err_pool: diff --git a/src/xrt/compositor/client/comp_vk_client.h b/src/xrt/compositor/client/comp_vk_client.h index 49302d855..4acc0c4c7 100644 --- a/src/xrt/compositor/client/comp_vk_client.h +++ b/src/xrt/compositor/client/comp_vk_client.h @@ -78,6 +78,9 @@ struct client_vk_compositor struct vk_bundle vk; struct vk_cmd_pool pool; + + bool renderdoc_enabled; + VkCommandBuffer dcb; }; @@ -106,6 +109,7 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn, bool external_semaphore_fd_enabled, bool timeline_semaphore_enabled, bool debug_utils_enabled, + bool renderdoc_enabled, uint32_t queueFamilyIndex, uint32_t queueIndex); diff --git a/src/xrt/compositor/client/comp_vk_glue.c b/src/xrt/compositor/client/comp_vk_glue.c index 88da93477..f9a473b5b 100644 --- a/src/xrt/compositor/client/comp_vk_glue.c +++ b/src/xrt/compositor/client/comp_vk_glue.c @@ -87,6 +87,7 @@ xrt_gfx_vk_provider_create(struct xrt_compositor_native *xcn, external_semaphore_fd_enabled, // timeline_semaphore_enabled, // debug_utils_enabled, // + renderdoc_enabled, // queue_family_index, // queue_index); //