From: Marek Olšák <marek.ol...@amd.com> --- src/gallium/drivers/radeonsi/si_shader.h | 20 ++++++++++++++------ src/gallium/drivers/radeonsi/si_state_shaders.c | 16 ++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 7584035..5a24318 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -244,32 +244,40 @@ enum { SI_FIX_FETCH_RGBA_32_SNORM, SI_FIX_FETCH_RGBX_32_SNORM, SI_FIX_FETCH_RGBA_32_USCALED, SI_FIX_FETCH_RGBA_32_SSCALED, SI_FIX_FETCH_RGBA_32_FIXED, SI_FIX_FETCH_RGBX_32_FIXED, }; struct si_shader; +/* State of the context creating the shader object. */ +struct si_compiler_ctx_state { + /* Should only be used by si_init_shader_selector_async and + * si_build_shader_variant if thread_index == -1 (non-threaded). */ + LLVMTargetMachineRef tm; + + /* Used if thread_index == -1 or if debug.async is true. */ + struct pipe_debug_callback debug; + + /* Used for creating the log string for gallium/ddebug. */ + bool is_debug_context; +}; + /* A shader selector is a gallium CSO and contains shader variants and * binaries for one TGSI program. This can be shared by multiple contexts. */ struct si_shader_selector { struct si_screen *screen; struct util_queue_fence ready; - - /* Should only be used by si_init_shader_selector_async - * if thread_index == -1 (non-threaded). */ - LLVMTargetMachineRef tm; - struct pipe_debug_callback debug; - bool is_debug_context; + struct si_compiler_ctx_state compiler_ctx_state; pipe_mutex mutex; struct si_shader *first_variant; /* immutable after the first variant */ struct si_shader *last_variant; /* mutable */ /* The compiled TGSI shader expecting a prolog and/or epilog (not * uploaded to a buffer). */ struct si_shader *main_shader_part; diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 1ae344a..eaba19a 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1079,41 +1079,41 @@ static inline void si_shader_selector_key(struct pipe_context *ctx, assert(0); } } static void si_build_shader_variant(void *job, int thread_index) { struct si_shader *shader = (struct si_shader *)job; struct si_shader_selector *sel = shader->selector; struct si_screen *sscreen = sel->screen; LLVMTargetMachineRef tm; - struct pipe_debug_callback *debug = &sel->debug; + struct pipe_debug_callback *debug = &sel->compiler_ctx_state.debug; int r; if (thread_index >= 0) { assert(thread_index < ARRAY_SIZE(sscreen->tm)); tm = sscreen->tm[thread_index]; if (!debug->async) debug = NULL; } else { - tm = sel->tm; + tm = sel->compiler_ctx_state.tm; } r = si_shader_create(sscreen, tm, shader, debug); if (unlikely(r)) { R600_ERR("Failed to build shader variant (type=%u) %d\n", sel->type, r); shader->compilation_failed = true; return; } - if (sel->is_debug_context) { + if (sel->compiler_ctx_state.is_debug_context) { FILE *f = open_memstream(&shader->shader_log, &shader->shader_log_size); if (f) { si_shader_dump(sscreen, shader, NULL, sel->type, f, false); fclose(f); } } si_shader_init_pm4_state(sscreen, shader); } @@ -1285,30 +1285,30 @@ static void si_parse_next_shader_property(const struct tgsi_shader_info *info, /** * Compile the main shader part or the monolithic shader as part of * si_shader_selector initialization. Since it can be done asynchronously, * there is no way to report compile failures to applications. */ void si_init_shader_selector_async(void *job, int thread_index) { struct si_shader_selector *sel = (struct si_shader_selector *)job; struct si_screen *sscreen = sel->screen; LLVMTargetMachineRef tm; - struct pipe_debug_callback *debug = &sel->debug; + struct pipe_debug_callback *debug = &sel->compiler_ctx_state.debug; unsigned i; if (thread_index >= 0) { assert(thread_index < ARRAY_SIZE(sscreen->tm)); tm = sscreen->tm[thread_index]; if (!debug->async) debug = NULL; } else { - tm = sel->tm; + tm = sel->compiler_ctx_state.tm; } /* Compile the main shader part for use with a prolog and/or epilog. * If this fails, the driver will try to compile a monolithic shader * on demand. */ if (!sscreen->use_monolithic_shaders) { struct si_shader *shader = CALLOC_STRUCT(si_shader); void *tgsi_binary; @@ -1448,23 +1448,23 @@ static void *si_create_shader_selector(struct pipe_context *ctx, { struct si_screen *sscreen = (struct si_screen *)ctx->screen; struct si_context *sctx = (struct si_context*)ctx; struct si_shader_selector *sel = CALLOC_STRUCT(si_shader_selector); int i; if (!sel) return NULL; sel->screen = sscreen; - sel->tm = sctx->tm; - sel->debug = sctx->b.debug; - sel->is_debug_context = sctx->is_debug; + sel->compiler_ctx_state.tm = sctx->tm; + sel->compiler_ctx_state.debug = sctx->b.debug; + sel->compiler_ctx_state.is_debug_context = sctx->is_debug; sel->tokens = tgsi_dup_tokens(state->tokens); if (!sel->tokens) { FREE(sel); return NULL; } sel->so = state->stream_output; tgsi_scan_shader(state->tokens, &sel->info); sel->type = sel->info.processor; p_atomic_inc(&sscreen->b.num_shaders_created); -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev