diff options
author | Marek Olšák <[email protected]> | 2018-06-14 02:09:05 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2018-06-28 22:27:25 -0400 |
commit | d13f240269cd55030f10b3d2e6fc4997c5fe4d14 (patch) | |
tree | 843e3bfbc5dc0e7bbacc8adcdd1c2ffe435cc0b4 /src | |
parent | 8e9c57a7fefe2f6ddbc1434ad38829c0aebf82fb (diff) |
radeonsi: unify duplicated code for initial shader compilation
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_compute.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 53 |
3 files changed, 39 insertions, 43 deletions
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index cb320323db3..fc419823bfa 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -188,28 +188,11 @@ static void *si_create_compute_state( program->compiler_ctx_state.debug = sctx->debug; program->compiler_ctx_state.is_debug_context = sctx->is_debug; p_atomic_inc(&sscreen->num_shaders_created); - util_queue_fence_init(&program->ready); - struct util_async_debug_callback async_debug; - bool wait = - (sctx->debug.debug_message && !sctx->debug.async) || - sctx->is_debug || - si_can_dump_shader(sscreen, PIPE_SHADER_COMPUTE); - - if (wait) { - u_async_debug_init(&async_debug); - program->compiler_ctx_state.debug = async_debug.base; - } - - util_queue_add_job(&sscreen->shader_compiler_queue, - program, &program->ready, - si_create_compute_state_async, NULL); - - if (wait) { - util_queue_fence_wait(&program->ready); - u_async_debug_drain(&async_debug, &sctx->debug); - u_async_debug_cleanup(&async_debug); - } + si_schedule_initial_compile(sctx, PIPE_SHADER_COMPUTE, + &program->ready, + &program->compiler_ctx_state, + program, si_create_compute_state_async); } else { const struct pipe_llvm_program_header *header; const char *code; diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h index 4f62c8b98f3..8fd80f73eff 100644 --- a/src/gallium/drivers/radeonsi/si_state.h +++ b/src/gallium/drivers/radeonsi/si_state.h @@ -492,6 +492,10 @@ bool si_update_shaders(struct si_context *sctx); void si_init_shader_functions(struct si_context *sctx); bool si_init_shader_cache(struct si_screen *sscreen); void si_destroy_shader_cache(struct si_screen *sscreen); +void si_schedule_initial_compile(struct si_context *sctx, unsigned processor, + struct util_queue_fence *ready_fence, + struct si_compiler_ctx_state *compiler_ctx_state, + void *job, util_queue_execute_func execute); void si_get_active_slot_masks(const struct tgsi_shader_info *info, uint32_t *const_and_shader_buffers, uint64_t *samplers_and_images); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index f2569a53be3..1a8b2c08524 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1976,6 +1976,34 @@ static void si_init_shader_selector_async(void *job, int thread_index) } } +void si_schedule_initial_compile(struct si_context *sctx, unsigned processor, + struct util_queue_fence *ready_fence, + struct si_compiler_ctx_state *compiler_ctx_state, + void *job, util_queue_execute_func execute) +{ + util_queue_fence_init(ready_fence); + + struct util_async_debug_callback async_debug; + bool wait = + (sctx->debug.debug_message && !sctx->debug.async) || + sctx->is_debug || + si_can_dump_shader(sctx->screen, processor); + + if (wait) { + u_async_debug_init(&async_debug); + compiler_ctx_state->debug = async_debug.base; + } + + util_queue_add_job(&sctx->screen->shader_compiler_queue, job, + ready_fence, execute, NULL); + + if (wait) { + util_queue_fence_wait(ready_fence); + u_async_debug_drain(&async_debug, &sctx->debug); + u_async_debug_cleanup(&async_debug); + } +} + /* Return descriptor slot usage masks from the given shader info. */ void si_get_active_slot_masks(const struct tgsi_shader_info *info, uint32_t *const_and_shader_buffers, @@ -2244,29 +2272,10 @@ static void *si_create_shader_selector(struct pipe_context *ctx, } (void) mtx_init(&sel->mutex, mtx_plain); - util_queue_fence_init(&sel->ready); - - struct util_async_debug_callback async_debug; - bool wait = - (sctx->debug.debug_message && !sctx->debug.async) || - sctx->is_debug || - si_can_dump_shader(sscreen, sel->info.processor); - - if (wait) { - u_async_debug_init(&async_debug); - sel->compiler_ctx_state.debug = async_debug.base; - } - - util_queue_add_job(&sscreen->shader_compiler_queue, sel, - &sel->ready, si_init_shader_selector_async, - NULL); - - if (wait) { - util_queue_fence_wait(&sel->ready); - u_async_debug_drain(&async_debug, &sctx->debug); - u_async_debug_cleanup(&async_debug); - } + si_schedule_initial_compile(sctx, sel->info.processor, &sel->ready, + &sel->compiler_ctx_state, sel, + si_init_shader_selector_async); return sel; } |