mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-18 06:10:36 +01:00
radeonsi: move llvm compiler alloc/free into create/destroy funcntion
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25632>
This commit is contained in:
parent
79009811a2
commit
5bae345fb7
4 changed files with 26 additions and 35 deletions
|
|
@ -100,10 +100,8 @@ static void si_create_compute_state_async(void *job, void *gdata, int thread_ind
|
|||
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
|
||||
compiler = &sscreen->compiler[thread_index];
|
||||
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
if (!*compiler)
|
||||
*compiler = si_create_llvm_compiler(sscreen);
|
||||
|
||||
assert(program->ir_type == PIPE_SHADER_IR_NIR);
|
||||
si_nir_scan_shader(sscreen, sel->nir, &sel->info);
|
||||
|
|
|
|||
|
|
@ -130,8 +130,12 @@ static const struct debug_named_value test_options[] = {
|
|||
DEBUG_NAMED_VALUE_END /* must be last */
|
||||
};
|
||||
|
||||
bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler)
|
||||
struct ac_llvm_compiler *si_create_llvm_compiler(struct si_screen *sscreen)
|
||||
{
|
||||
struct ac_llvm_compiler *compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
if (!compiler)
|
||||
return NULL;
|
||||
|
||||
/* Only create the less-optimizing version of the compiler on APUs
|
||||
* predating Ryzen (Raven). */
|
||||
bool create_low_opt_compiler =
|
||||
|
|
@ -142,13 +146,13 @@ bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compil
|
|||
(create_low_opt_compiler ? AC_TM_CREATE_LOW_OPT : 0);
|
||||
|
||||
if (!ac_init_llvm_compiler(compiler, sscreen->info.family, tm_options))
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
compiler->passes = ac_create_llvm_passes(compiler->tm);
|
||||
if (compiler->low_opt_tm)
|
||||
compiler->low_opt_passes = ac_create_llvm_passes(compiler->low_opt_tm);
|
||||
|
||||
return true;
|
||||
return compiler;
|
||||
}
|
||||
|
||||
void si_init_aux_async_compute_ctx(struct si_screen *sscreen)
|
||||
|
|
@ -166,9 +170,10 @@ void si_init_aux_async_compute_ctx(struct si_screen *sscreen)
|
|||
((struct si_context*)sscreen->async_compute_context)->cs_max_waves_per_sh = 2;
|
||||
}
|
||||
|
||||
static void si_destroy_compiler(struct ac_llvm_compiler *compiler)
|
||||
static void si_destroy_llvm_compiler(struct ac_llvm_compiler *compiler)
|
||||
{
|
||||
ac_destroy_llvm_compiler(compiler);
|
||||
FREE(compiler);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -341,10 +346,8 @@ static void si_destroy_context(struct pipe_context *context)
|
|||
si_resource_reference(&sctx->shadowing.registers, NULL);
|
||||
si_resource_reference(&sctx->shadowing.csa, NULL);
|
||||
|
||||
if (sctx->compiler) {
|
||||
si_destroy_compiler(sctx->compiler);
|
||||
FREE(sctx->compiler);
|
||||
}
|
||||
if (sctx->compiler)
|
||||
si_destroy_llvm_compiler(sctx->compiler);
|
||||
|
||||
si_saved_cs_reference(&sctx->current_saved_cs, NULL);
|
||||
|
||||
|
|
@ -996,17 +999,13 @@ static void si_destroy_screen(struct pipe_screen *pscreen)
|
|||
glsl_type_singleton_decref();
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sscreen->compiler); i++) {
|
||||
if (sscreen->compiler[i]) {
|
||||
si_destroy_compiler(sscreen->compiler[i]);
|
||||
FREE(sscreen->compiler[i]);
|
||||
}
|
||||
if (sscreen->compiler[i])
|
||||
si_destroy_llvm_compiler(sscreen->compiler[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sscreen->compiler_lowp); i++) {
|
||||
if (sscreen->compiler_lowp[i]) {
|
||||
si_destroy_compiler(sscreen->compiler_lowp[i]);
|
||||
FREE(sscreen->compiler_lowp[i]);
|
||||
}
|
||||
if (sscreen->compiler_lowp[i])
|
||||
si_destroy_llvm_compiler(sscreen->compiler_lowp[i]);
|
||||
}
|
||||
|
||||
/* Free shader parts. */
|
||||
|
|
@ -1209,8 +1208,8 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
/* Initialize just one compiler instance to check for errors. The other compiler instances are
|
||||
* initialized on demand.
|
||||
*/
|
||||
sscreen->compiler[0] = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
if (!si_init_compiler(sscreen, sscreen->compiler[0])) {
|
||||
sscreen->compiler[0] = si_create_llvm_compiler(sscreen);
|
||||
if (!sscreen->compiler[0]) {
|
||||
/* The callee prints the error message. */
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
|
|
|
|||
|
|
@ -1585,7 +1585,7 @@ void si_emit_initial_compute_regs(struct si_context *sctx, struct radeon_cmdbuf
|
|||
void si_init_compute_functions(struct si_context *sctx);
|
||||
|
||||
/* si_pipe.c */
|
||||
bool si_init_compiler(struct si_screen *sscreen, struct ac_llvm_compiler *compiler);
|
||||
struct ac_llvm_compiler *si_create_llvm_compiler(struct si_screen *sscreen);
|
||||
void si_init_aux_async_compute_ctx(struct si_screen *sscreen);
|
||||
struct si_context *si_get_aux_context(struct si_aux_context *ctx);
|
||||
void si_put_aux_context_flush(struct si_aux_context *ctx);
|
||||
|
|
|
|||
|
|
@ -2482,10 +2482,8 @@ static void si_build_shader_variant(struct si_shader *shader, int thread_index,
|
|||
compiler = &shader->compiler_ctx_state.compiler;
|
||||
}
|
||||
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
if (!*compiler)
|
||||
*compiler = si_create_llvm_compiler(sscreen);
|
||||
|
||||
if (unlikely(!si_create_shader_variant(sscreen, *compiler, shader, debug))) {
|
||||
PRINT_ERR("Failed to build shader variant (type=%u)\n", sel->stage);
|
||||
|
|
@ -2700,10 +2698,8 @@ current_not_ready:
|
|||
|
||||
util_queue_fence_init(&shader->ready);
|
||||
|
||||
if (!sctx->compiler) {
|
||||
sctx->compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sctx->screen, sctx->compiler);
|
||||
}
|
||||
if (!sctx->compiler)
|
||||
sctx->compiler = si_create_llvm_compiler(sctx->screen);
|
||||
|
||||
shader->selector = sel;
|
||||
*((SHADER_KEY_TYPE*)&shader->key) = *key;
|
||||
|
|
@ -2912,10 +2908,8 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind
|
|||
assert(thread_index < (int)ARRAY_SIZE(sscreen->compiler));
|
||||
compiler = &sscreen->compiler[thread_index];
|
||||
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
if (!*compiler)
|
||||
*compiler = si_create_llvm_compiler(sscreen);
|
||||
|
||||
/* Serialize NIR to save memory. Monolithic shader variants
|
||||
* have to deserialize NIR before compilation.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue