zink: add ZINK_DEBUG=flushsync

this disables the submission thread

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22040>
This commit is contained in:
Mike Blumenkrantz
2023-03-16 08:41:55 -04:00
parent 6a45e0d991
commit 270f9c0b06
6 changed files with 20 additions and 10 deletions

View File

@@ -297,6 +297,8 @@ variable:
Disable renderpass optimizations (for tiling GPUs)
``map``
Print info about mapped VRAM
``flushsync``
Force synchronous flushes/presents
Vulkan Validation Layers
^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -679,7 +679,7 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch)
if (screen->device_lost)
return;
if (screen->threaded) {
if (screen->threaded_submit) {
util_queue_add_job(&screen->flush_queue, bs, &bs->flush_completed,
submit_queue, post_submit, 0);
} else {

View File

@@ -237,7 +237,7 @@ zink_fence_server_signal(struct pipe_context *pctx, struct pipe_fence_handle *pf
struct zink_batch_state *bs = ctx->batch.state;
/* this must produce a synchronous flush that completes before the function returns */
pctx->flush(pctx, NULL, 0);
if (zink_screen(ctx->base.screen)->threaded)
if (zink_screen(ctx->base.screen)->threaded_submit)
util_queue_fence_wait(&bs->flush_completed);
}

View File

@@ -839,7 +839,7 @@ zink_kopper_present_readback(struct zink_context *ctx, struct zink_resource *res
si.pWaitDstStageMask = &mask;
VkSemaphore acquire = zink_kopper_acquire_submit(screen, res);
VkSemaphore present = res->obj->present ? res->obj->present : zink_kopper_present(screen, res);
if (screen->threaded)
if (screen->threaded_submit)
util_queue_finish(&screen->flush_queue);
si.waitSemaphoreCount = !!acquire;
si.pWaitSemaphores = &acquire;

View File

@@ -86,6 +86,7 @@ zink_debug_options[] = {
{ "rp", ZINK_DEBUG_RP, "Enable renderpass tracking/optimizations" },
{ "norp", ZINK_DEBUG_NORP, "Disable renderpass tracking/optimizations" },
{ "map", ZINK_DEBUG_MAP, "Track amount of mapped VRAM" },
{ "flushsync", ZINK_DEBUG_FLUSHSYNC, "Force synchronous flushes/presents" },
DEBUG_NAMED_VALUE_END
};
@@ -1462,7 +1463,7 @@ zink_destroy_screen(struct pipe_screen *pscreen)
if (screen->fence)
VKSCR(DestroyFence)(screen->dev, screen->fence, NULL);
if (screen->threaded)
if (screen->threaded_submit)
util_queue_destroy(&screen->flush_queue);
simple_mtx_destroy(&screen->semaphores_lock);
@@ -2041,7 +2042,7 @@ setup_renderdoc(struct zink_screen *screen)
return;
/* need synchronous dispatch for renderdoc coherency */
screen->threaded = false;
screen->threaded_submit = false;
get_api(eRENDERDOC_API_Version_1_0_0, (void*)&screen->renderdoc_api);
screen->renderdoc_api->SetActiveWindow(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL);
@@ -2678,12 +2679,17 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
if (!screen)
return NULL;
screen->threaded = util_get_cpu_caps()->nr_cpus > 1 && debug_get_bool_option("GALLIUM_THREAD", util_get_cpu_caps()->nr_cpus > 1);
screen->abort_on_hang = debug_get_bool_option("ZINK_HANG_ABORT", false);
zink_debug = debug_get_option_zink_debug();
zink_descriptor_mode = debug_get_option_zink_descriptor_mode();
screen->threaded = util_get_cpu_caps()->nr_cpus > 1 && debug_get_bool_option("GALLIUM_THREAD", util_get_cpu_caps()->nr_cpus > 1);
if (zink_debug & ZINK_DEBUG_FLUSHSYNC)
screen->threaded_submit = false;
else
screen->threaded_submit = screen->threaded;
screen->abort_on_hang = debug_get_bool_option("ZINK_HANG_ABORT", false);
u_trace_state_init();
screen->loader_lib = util_dl_open(VK_LIBNAME);
@@ -2750,7 +2756,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
}
setup_renderdoc(screen);
if (screen->threaded && !util_queue_init(&screen->flush_queue, "zfq", 8, 1, UTIL_QUEUE_INIT_RESIZE_IF_FULL, screen)) {
if (screen->threaded_submit && !util_queue_init(&screen->flush_queue, "zfq", 8, 1, UTIL_QUEUE_INIT_RESIZE_IF_FULL, screen)) {
mesa_loge("zink: Failed to create flush queue.\n");
goto fail;
}
@@ -3066,7 +3072,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
fail:
if (screen->loader_lib)
util_dl_close(screen->loader_lib);
if (screen->threaded)
if (screen->threaded_submit)
util_queue_destroy(&screen->flush_queue);
ralloc_free(screen);

View File

@@ -220,6 +220,7 @@ enum zink_debug {
ZINK_DEBUG_RP = (1<<9),
ZINK_DEBUG_NORP = (1<<10),
ZINK_DEBUG_MAP = (1<<11),
ZINK_DEBUG_FLUSHSYNC = (1<<12),
};
/** fence types */
@@ -1282,6 +1283,7 @@ struct zink_screen {
PFN_vkGetDeviceProcAddr vk_GetDeviceProcAddr;
bool threaded;
bool threaded_submit;
bool is_cpu;
bool abort_on_hang;
bool frame_marker_emitted;