mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-31 20:40:09 +01:00
radeonsi: declare compiler[] and nir_options as pointers to reduce #includes
so that we don't have to include the structure definitions. (ac_llvm_compiler includes LLVM, and nir_options includes NIR) Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23517>
This commit is contained in:
parent
620ff256a2
commit
56c787b36d
5 changed files with 56 additions and 28 deletions
|
|
@ -93,7 +93,7 @@ static void si_create_compute_state_async(void *job, void *gdata, int thread_ind
|
|||
struct si_compute *program = (struct si_compute *)job;
|
||||
struct si_shader_selector *sel = &program->sel;
|
||||
struct si_shader *shader = &program->shader;
|
||||
struct ac_llvm_compiler *compiler;
|
||||
struct ac_llvm_compiler **compiler;
|
||||
struct util_debug_callback *debug = &sel->compiler_ctx_state.debug;
|
||||
struct si_screen *sscreen = sel->screen;
|
||||
|
||||
|
|
@ -102,8 +102,10 @@ 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->passes)
|
||||
si_init_compiler(sscreen, compiler);
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
|
||||
assert(program->ir_type == PIPE_SHADER_IR_NIR);
|
||||
si_nir_scan_shader(sscreen, sel->nir, &sel->info);
|
||||
|
|
@ -172,7 +174,7 @@ static void si_create_compute_state_async(void *job, void *gdata, int thread_ind
|
|||
} else {
|
||||
simple_mtx_unlock(&sscreen->shader_cache_mutex);
|
||||
|
||||
if (!si_create_shader_variant(sscreen, compiler, &program->shader, debug)) {
|
||||
if (!si_create_shader_variant(sscreen, *compiler, &program->shader, debug)) {
|
||||
program->shader.compilation_failed = true;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ static const void *si_get_compiler_options(struct pipe_screen *screen, enum pipe
|
|||
struct si_screen *sscreen = (struct si_screen *)screen;
|
||||
|
||||
assert(ir == PIPE_SHADER_IR_NIR);
|
||||
return &sscreen->nir_options;
|
||||
return sscreen->nir_options;
|
||||
}
|
||||
|
||||
static void si_get_driver_uuid(struct pipe_screen *pscreen, char *uuid)
|
||||
|
|
@ -1324,5 +1324,5 @@ void si_init_screen_get_functions(struct si_screen *sscreen)
|
|||
nir_lower_divmod64 | nir_lower_minmax64 | nir_lower_iabs64 |
|
||||
nir_lower_iadd_sat64,
|
||||
};
|
||||
sscreen->nir_options = nir_options;
|
||||
*sscreen->nir_options = nir_options;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,7 +335,10 @@ static void si_destroy_context(struct pipe_context *context)
|
|||
si_resource_reference(&sctx->shadowing.registers, NULL);
|
||||
si_resource_reference(&sctx->shadowing.csa, NULL);
|
||||
|
||||
si_destroy_compiler(&sctx->compiler);
|
||||
if (sctx->compiler) {
|
||||
si_destroy_compiler(sctx->compiler);
|
||||
FREE(sctx->compiler);
|
||||
}
|
||||
|
||||
si_saved_cs_reference(&sctx->current_saved_cs, NULL);
|
||||
|
||||
|
|
@ -968,11 +971,19 @@ static void si_destroy_screen(struct pipe_screen *pscreen)
|
|||
/* Release the reference on glsl types of the compiler threads. */
|
||||
glsl_type_singleton_decref();
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sscreen->compiler); i++)
|
||||
si_destroy_compiler(&sscreen->compiler[i]);
|
||||
for (i = 0; i < ARRAY_SIZE(sscreen->compiler); i++) {
|
||||
if (sscreen->compiler[i]) {
|
||||
si_destroy_compiler(sscreen->compiler[i]);
|
||||
FREE(sscreen->compiler[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sscreen->compiler_lowp); i++)
|
||||
si_destroy_compiler(&sscreen->compiler_lowp[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]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free shader parts. */
|
||||
for (i = 0; i < ARRAY_SIZE(parts); i++) {
|
||||
|
|
@ -1003,6 +1014,7 @@ static void si_destroy_screen(struct pipe_screen *pscreen)
|
|||
util_vertex_state_cache_deinit(&sscreen->vertex_state_cache);
|
||||
|
||||
sscreen->ws->destroy(sscreen->ws);
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
}
|
||||
|
||||
|
|
@ -1158,6 +1170,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
if ((sscreen->debug_flags & DBG(TMZ)) &&
|
||||
!sscreen->info.has_tmz_support) {
|
||||
fprintf(stderr, "radeonsi: requesting TMZ features but TMZ is not supported\n");
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1165,8 +1178,10 @@ 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.
|
||||
*/
|
||||
if (!si_init_compiler(sscreen, &sscreen->compiler[0])) {
|
||||
sscreen->compiler[0] = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
if (!si_init_compiler(sscreen, sscreen->compiler[0])) {
|
||||
/* The callee prints the error message. */
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1180,6 +1195,8 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
sscreen->b.is_parallel_shader_compilation_finished = si_is_parallel_shader_compilation_finished;
|
||||
sscreen->b.finalize_nir = si_finalize_nir;
|
||||
|
||||
sscreen->nir_options = CALLOC_STRUCT(nir_shader_compiler_options);
|
||||
|
||||
si_init_screen_get_functions(sscreen);
|
||||
si_init_screen_buffer_functions(sscreen);
|
||||
si_init_screen_fence_functions(sscreen);
|
||||
|
|
@ -1214,6 +1231,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
|
||||
si_init_gs_info(sscreen);
|
||||
if (!si_init_shader_cache(sscreen)) {
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1270,6 +1288,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
UTIL_QUEUE_INIT_SCALE_THREADS |
|
||||
UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY, NULL)) {
|
||||
si_destroy_shader_cache(sscreen);
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
glsl_type_singleton_decref();
|
||||
return NULL;
|
||||
|
|
@ -1282,6 +1301,7 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
|||
UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY |
|
||||
UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY, NULL)) {
|
||||
si_destroy_shader_cache(sscreen);
|
||||
FREE(sscreen->nir_options);
|
||||
FREE(sscreen);
|
||||
glsl_type_singleton_decref();
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -538,7 +538,7 @@ struct si_screen {
|
|||
struct disk_cache *disk_shader_cache;
|
||||
|
||||
struct radeon_info info;
|
||||
struct nir_shader_compiler_options nir_options;
|
||||
struct nir_shader_compiler_options *nir_options;
|
||||
uint64_t debug_flags;
|
||||
char renderer_string[183];
|
||||
|
||||
|
|
@ -675,12 +675,12 @@ struct si_screen {
|
|||
/* Use at most 3 normal compiler threads on quadcore and better.
|
||||
* Hyperthreaded CPUs report the number of threads, but we want
|
||||
* the number of cores. We only need this many threads for shader-db. */
|
||||
struct ac_llvm_compiler compiler[24]; /* used by the queue only */
|
||||
struct ac_llvm_compiler *compiler[24]; /* used by the queue only */
|
||||
|
||||
struct util_queue shader_compiler_queue_low_priority;
|
||||
/* Use at most 2 low priority threads on quadcore and better.
|
||||
* We want to minimize the impact on multithreaded Mesa. */
|
||||
struct ac_llvm_compiler compiler_lowp[10];
|
||||
struct ac_llvm_compiler *compiler_lowp[10];
|
||||
|
||||
struct util_idalloc_mt buffer_ids;
|
||||
struct util_vertex_state_cache vertex_state_cache;
|
||||
|
|
@ -997,7 +997,7 @@ struct si_context {
|
|||
struct hash_table *cs_blit_shaders;
|
||||
struct si_screen *screen;
|
||||
struct util_debug_callback debug;
|
||||
struct ac_llvm_compiler compiler; /* only non-threaded compilation */
|
||||
struct ac_llvm_compiler *compiler; /* only non-threaded compilation */
|
||||
struct hash_table *fixed_func_tcs_shader_cache;
|
||||
struct si_resource *wait_mem_scratch;
|
||||
struct si_resource *wait_mem_scratch_tmz;
|
||||
|
|
|
|||
|
|
@ -2493,7 +2493,7 @@ static void si_build_shader_variant(struct si_shader *shader, int thread_index,
|
|||
{
|
||||
struct si_shader_selector *sel = shader->selector;
|
||||
struct si_screen *sscreen = sel->screen;
|
||||
struct ac_llvm_compiler *compiler;
|
||||
struct ac_llvm_compiler **compiler;
|
||||
struct util_debug_callback *debug = &shader->compiler_ctx_state.debug;
|
||||
|
||||
if (thread_index >= 0) {
|
||||
|
|
@ -2508,13 +2508,15 @@ static void si_build_shader_variant(struct si_shader *shader, int thread_index,
|
|||
debug = NULL;
|
||||
} else {
|
||||
assert(!low_priority);
|
||||
compiler = shader->compiler_ctx_state.compiler;
|
||||
compiler = &shader->compiler_ctx_state.compiler;
|
||||
}
|
||||
|
||||
if (!compiler->passes)
|
||||
si_init_compiler(sscreen, compiler);
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
|
||||
if (unlikely(!si_create_shader_variant(sscreen, compiler, shader, debug))) {
|
||||
if (unlikely(!si_create_shader_variant(sscreen, *compiler, shader, debug))) {
|
||||
PRINT_ERR("Failed to build shader variant (type=%u)\n", sel->stage);
|
||||
shader->compilation_failed = true;
|
||||
return;
|
||||
|
|
@ -2727,13 +2729,15 @@ current_not_ready:
|
|||
|
||||
util_queue_fence_init(&shader->ready);
|
||||
|
||||
if (!sctx->compiler.passes)
|
||||
si_init_compiler(sctx->screen, &sctx->compiler);
|
||||
if (!sctx->compiler) {
|
||||
sctx->compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sctx->screen, sctx->compiler);
|
||||
}
|
||||
|
||||
shader->selector = sel;
|
||||
*((SHADER_KEY_TYPE*)&shader->key) = *key;
|
||||
shader->wave_size = si_determine_wave_size(sscreen, shader);
|
||||
shader->compiler_ctx_state.compiler = &sctx->compiler;
|
||||
shader->compiler_ctx_state.compiler = sctx->compiler;
|
||||
shader->compiler_ctx_state.debug = sctx->debug;
|
||||
shader->compiler_ctx_state.is_debug_context = sctx->is_debug;
|
||||
|
||||
|
|
@ -2929,7 +2933,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind
|
|||
{
|
||||
struct si_shader_selector *sel = (struct si_shader_selector *)job;
|
||||
struct si_screen *sscreen = sel->screen;
|
||||
struct ac_llvm_compiler *compiler;
|
||||
struct ac_llvm_compiler **compiler;
|
||||
struct util_debug_callback *debug = &sel->compiler_ctx_state.debug;
|
||||
|
||||
assert(!debug->debug_message || debug->async);
|
||||
|
|
@ -2937,8 +2941,10 @@ 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->passes)
|
||||
si_init_compiler(sscreen, compiler);
|
||||
if (!*compiler) {
|
||||
*compiler = CALLOC_STRUCT(ac_llvm_compiler);
|
||||
si_init_compiler(sscreen, *compiler);
|
||||
}
|
||||
|
||||
/* Serialize NIR to save memory. Monolithic shader variants
|
||||
* have to deserialize NIR before compilation.
|
||||
|
|
@ -3008,7 +3014,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind
|
|||
simple_mtx_unlock(&sscreen->shader_cache_mutex);
|
||||
|
||||
/* Compile the shader if it hasn't been loaded from the cache. */
|
||||
if (!si_compile_shader(sscreen, compiler, shader, debug)) {
|
||||
if (!si_compile_shader(sscreen, *compiler, shader, debug)) {
|
||||
fprintf(stderr,
|
||||
"radeonsi: can't compile a main shader part (type: %s, name: %s).\n"
|
||||
"This is probably a driver bug, please report "
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue