From b36a741aa4342a147772c7d2026c8dfd2936ce12 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 12 Aug 2022 14:30:58 -0400 Subject: [PATCH] gallium: add pipe_screen::driver_thread_add_job MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this allows a frontend to punt creation of a nir shader down to the driver's compilation thread, which is useful in the event that the shader being created is so big that it will cause immediate blocking from running common nir passes Acked-by: Marek Olšák Part-of: --- .../auxiliary/driver_trace/tr_screen.c | 22 +++++++++++++++++++ src/gallium/include/pipe/p_screen.h | 9 ++++++++ 2 files changed, 31 insertions(+) diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c index d964b42b0ad..9a5c4e06a0b 100644 --- a/src/gallium/auxiliary/driver_trace/tr_screen.c +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c @@ -279,6 +279,27 @@ trace_screen_is_format_supported(struct pipe_screen *_screen, return result; } +static void +trace_screen_driver_thread_add_job(struct pipe_screen *_screen, + void *data, struct util_queue_fence *fence, + pipe_driver_thread_func execute, + pipe_driver_thread_func cleanup, + const size_t job_size) +{ + struct trace_screen *tr_scr = trace_screen(_screen); + struct pipe_screen *screen = tr_scr->screen; + + trace_dump_call_begin("pipe_screen", "driver_thread_add_job"); + + trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, data); + trace_dump_arg(ptr, fence); + + screen->driver_thread_add_job(screen, data, fence, execute, cleanup, job_size); + + trace_dump_call_end(); +} + static void trace_context_replace_buffer_storage(struct pipe_context *_pipe, struct pipe_resource *dst, @@ -1453,6 +1474,7 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.transfer_helper = screen->transfer_helper; SCR_INIT(get_sparse_texture_virtual_page_size); SCR_INIT(set_fence_timeline_value); + SCR_INIT(driver_thread_add_job); tr_scr->screen = screen; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 8bc1a2de2d8..77730206134 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -65,6 +65,7 @@ struct disk_cache; struct driOptionCache; struct u_transfer_helper; struct pipe_screen; +struct util_queue_fence; typedef struct pipe_vertex_state * (*pipe_create_vertex_state_func)(struct pipe_screen *screen, @@ -75,6 +76,7 @@ typedef struct pipe_vertex_state * uint32_t full_velem_mask); typedef void (*pipe_vertex_state_destroy_func)(struct pipe_screen *screen, struct pipe_vertex_state *); +typedef void (*pipe_driver_thread_func)(void *job, void *gdata, int thread_index); /** * Gallium screen/adapter context. Basically everything @@ -573,6 +575,13 @@ struct pipe_screen { void *shader, enum pipe_shader_type shader_type); + void (*driver_thread_add_job)(struct pipe_screen *screen, + void *job, + struct util_queue_fence *fence, + pipe_driver_thread_func execute, + pipe_driver_thread_func cleanup, + const size_t job_size); + /** * Set the damage region (called when KHR_partial_update() is invoked). * This function is passed an array of rectangles encoding the damage area.