Commit a7dc6178 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋
Browse files

renderdoc hacks

parent 6432f067
Pipeline #280045 waiting for manual action with stages
This diff is collapsed.
......@@ -295,6 +295,7 @@ zink_reset_batch(struct zink_context *ctx, struct zink_batch *batch)
void
zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
{
struct zink_screen *screen = zink_screen(ctx->base.screen);
zink_reset_batch(ctx, batch);
VkCommandBufferBeginInfo cbbi = {};
......@@ -304,7 +305,15 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
debug_printf("vkBeginCommandBuffer failed\n");
if (vkBeginCommandBuffer(batch->state->barrier_cmdbuf, &cbbi) != VK_SUCCESS)
debug_printf("vkBeginCommandBuffer failed\n");
VkDebugUtilsLabelEXT capture_label;
/* Magic fallback which lets us bridge the Wine barrier over to Linux RenderDoc. */
capture_label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
capture_label.pNext = NULL;
capture_label.pLabelName = "vr-marker,frame_end,type,application";
memset(capture_label.color, 0, sizeof(capture_label.color));
assert(screen->vk_CmdInsertDebugUtilsLabelEXT);
screen->vk_CmdInsertDebugUtilsLabelEXT(batch->state->barrier_cmdbuf, &capture_label);
screen->vk_CmdInsertDebugUtilsLabelEXT(batch->state->cmdbuf, &capture_label);
batch->state->fence.batch_id = ctx->curr_batch;
batch->state->fence.completed = false;
if (ctx->last_fence) {
......@@ -312,7 +321,7 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch)
batch->last_batch_id = last_state->fence.batch_id;
} else {
/* TODO: move to wsi */
if (zink_screen(ctx->base.screen)->threaded) {
if (screen->threaded) {
util_queue_init(&batch->flush_queue, "zfq", 8, 1, UTIL_QUEUE_INIT_RESIZE_IF_FULL);
}
}
......@@ -371,11 +380,23 @@ submit_queue(void *data, int thread_index)
si.pNext = &mem_signal;
}
struct zink_screen *screen = zink_screen(bs->ctx->base.screen);
static unsigned frame = 0;
frame++;
if (frame == 400) {
if (screen->renderdoc_api)
screen->renderdoc_api->StartFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL);
}
if (vkQueueSubmit(bs->queue, 1, &si, bs->fence.fence) != VK_SUCCESS) {
debug_printf("ZINK: vkQueueSubmit() failed\n");
bs->is_device_lost = true;
}
p_atomic_set(&bs->fence.submitted, true);
if (frame == 400 && screen->renderdoc_api)
screen->renderdoc_api->EndFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL);
}
void
......
......@@ -1353,6 +1353,23 @@ zink_internal_setup_moltenvk(struct zink_screen *screen)
return true;
}
static void
setup_renderdoc(struct zink_screen *screen)
{
#ifndef _WIN32
void *renderdoc = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD);
/* not loaded */
if (!renderdoc)
return;
pRENDERDOC_GetAPI get_api = dlsym(renderdoc, "RENDERDOC_GetAPI");
if (!get_api)
return;
get_api(eRENDERDOC_API_Version_1_0_0, (void**)&screen->renderdoc_api);
#endif
}
static void
check_device_needs_mesa_wsi(struct zink_screen *screen)
{
......@@ -1468,6 +1485,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
if (screen->instance_info.have_EXT_debug_utils && !create_debug(screen))
debug_printf("ZINK: failed to setup debug utils\n");
GET_PROC_ADDR_INSTANCE(CmdInsertDebugUtilsLabelEXT);
screen->pdev = choose_pdev(screen->instance);
if (screen->pdev == VK_NULL_HANDLE)
......@@ -1485,6 +1503,8 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
goto fail;
}
setup_renderdoc(screen);
/* Some Vulkan implementations have special requirements for WSI
* allocations.
*/
......
......@@ -41,6 +41,8 @@
#include "MoltenVK/vk_mvk_moltenvk.h"
#endif
#include "renderdoc_app.h"
extern uint32_t zink_debug;
struct hash_table;
......@@ -105,6 +107,8 @@ struct zink_screen {
uint32_t cur_custom_border_color_samplers;
RENDERDOC_API_1_0_0 *renderdoc_api;
bool needs_mesa_wsi;
bool needs_mesa_flush_wsi;
......@@ -168,6 +172,7 @@ struct zink_screen {
PFN_vkCreateDebugUtilsMessengerEXT vk_CreateDebugUtilsMessengerEXT;
PFN_vkDestroyDebugUtilsMessengerEXT vk_DestroyDebugUtilsMessengerEXT;
PFN_vkCmdInsertDebugUtilsLabelEXT vk_CmdInsertDebugUtilsLabelEXT;
#if defined(MVK_VERSION)
PFN_vkGetMoltenVKConfigurationMVK vk_GetMoltenVKConfigurationMVK;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment