gallium: add pipe_screen::driver_thread_add_job

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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18198>
This commit is contained in:
Mike Blumenkrantz 2022-08-12 14:30:58 -04:00 committed by Marge Bot
parent 6b8339fa54
commit b36a741aa4
2 changed files with 31 additions and 0 deletions

View file

@ -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;

View file

@ -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.