Mesa (master): radeonsi: require that compiler threads are enabled

Marek Olšák mareko at kemper.freedesktop.org
Fri Mar 17 17:31:42 UTC 2017


Module: Mesa
Branch: master
Commit: e9c6953ddb6baa68ef4704104744934e194c089d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9c6953ddb6baa68ef4704104744934e194c089d

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Mar  3 00:24:03 2017 +0100

radeonsi: require that compiler threads are enabled

threaded gallium can't use pipe_context's LLVM target machine, because
create_shader_selector can be called from a non-driver thread.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/gallium/drivers/radeonsi/si_pipe.c          | 21 ++++++++++++---------
 src/gallium/drivers/radeonsi/si_state_shaders.c |  3 +--
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index a9a7c8fa42..a3e001c747 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -690,8 +690,7 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
 	if (!sscreen->b.ws->unref(sscreen->b.ws))
 		return;
 
-	if (util_queue_is_initialized(&sscreen->shader_compiler_queue))
-		util_queue_destroy(&sscreen->shader_compiler_queue);
+	util_queue_destroy(&sscreen->shader_compiler_queue);
 
 	for (i = 0; i < ARRAY_SIZE(sscreen->tm); i++)
 		if (sscreen->tm[i])
@@ -797,6 +796,17 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 		return NULL;
 	}
 
+	/* Only enable as many threads as we have target machines and CPUs. */
+	num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+	num_compiler_threads = MIN2(num_cpus, ARRAY_SIZE(sscreen->tm));
+
+	if (!util_queue_init(&sscreen->shader_compiler_queue, "si_shader",
+			     32, num_compiler_threads)) {
+		si_destroy_shader_cache(sscreen);
+		FREE(sscreen);
+		return NULL;
+	}
+
 	si_handle_env_var_force_family(sscreen);
 
 	if (!debug_get_bool_option("RADEON_DISABLE_PERFCOUNTERS", false))
@@ -841,16 +851,9 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
 	if (debug_get_bool_option("RADEON_DUMP_SHADERS", false))
 		sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS;
 
-	/* Only enable as many threads as we have target machines and CPUs. */
-	num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-	num_compiler_threads = MIN2(num_cpus, ARRAY_SIZE(sscreen->tm));
-
 	for (i = 0; i < num_compiler_threads; i++)
 		sscreen->tm[i] = si_create_llvm_target_machine(sscreen);
 
-	util_queue_init(&sscreen->shader_compiler_queue, "si_shader",
-                        32, num_compiler_threads);
-
 	/* Create the auxiliary context. This must be done last. */
 	sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL, 0);
 
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 9cde0aabad..3596f5af72 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -1769,8 +1769,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
 
 	if ((sctx->b.debug.debug_message && !sctx->b.debug.async) ||
 	    sctx->is_debug ||
-	    r600_can_dump_shader(&sscreen->b, sel->info.processor) ||
-	    !util_queue_is_initialized(&sscreen->shader_compiler_queue))
+	    r600_can_dump_shader(&sscreen->b, sel->info.processor))
 		si_init_shader_selector_async(sel, -1);
 	else
 		util_queue_add_job(&sscreen->shader_compiler_queue, sel,




More information about the mesa-commit mailing list