[Mesa-dev] [PATCH 13/13] radeonsi: enable threaded_context
Marek Olšák
maraeo at gmail.com
Wed May 10 22:45:46 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/drivers/radeonsi/si_pipe.c | 37 +++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 53738a5..c7ca928 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -131,21 +131,21 @@ si_create_llvm_target_machine(struct si_screen *sscreen)
r600_get_llvm_processor_name(sscreen->b.family),
sscreen->b.debug_flags & DBG_SI_SCHED ?
SI_LLVM_DEFAULT_FEATURES ",+si-scheduler" :
SI_LLVM_DEFAULT_FEATURES,
LLVMCodeGenLevelDefault,
LLVMRelocDefault,
LLVMCodeModelDefault);
}
static struct pipe_context *si_create_context(struct pipe_screen *screen,
- void *priv, unsigned flags)
+ unsigned flags)
{
struct si_context *sctx = CALLOC_STRUCT(si_context);
struct si_screen* sscreen = (struct si_screen *)screen;
struct radeon_winsys *ws = sscreen->b.ws;
int shader, i;
if (!sctx)
return NULL;
if (sscreen->b.debug_flags & DBG_CHECK_VM)
@@ -313,20 +313,51 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
sctx->tm = si_create_llvm_target_machine(sscreen);
return &sctx->b.b;
fail:
fprintf(stderr, "radeonsi: Failed to create a context.\n");
si_destroy_context(&sctx->b.b);
return NULL;
}
+static struct pipe_context *si_pipe_create_context(struct pipe_screen *screen,
+ void *priv, unsigned flags)
+{
+ struct si_screen *sscreen = (struct si_screen *)screen;
+ struct pipe_context *ctx = si_create_context(screen, flags);
+
+ if (!(flags & PIPE_CONTEXT_PREFER_THREADED))
+ return ctx;
+
+ /* Clover (compute-only) is unsupported.
+ *
+ * Since the threaded context creates shader states from the non-driver
+ * thread, asynchronous compilation is required for create_{shader}_-
+ * state not to use pipe_context. Debug contexts (ddebug) disable
+ * asynchronous compilation, so don't use the threaded context with
+ * those.
+ */
+ if (flags & (PIPE_CONTEXT_COMPUTE_ONLY | PIPE_CONTEXT_DEBUG))
+ return ctx;
+
+ /* When shaders are logged to stderr, asynchronous compilation is
+ * disabled too. */
+ if (sscreen->b.debug_flags & (DBG_VS | DBG_TCS | DBG_TES | DBG_GS |
+ DBG_PS | DBG_CS))
+ return ctx;
+
+ return threaded_context_create(ctx, &sscreen->b.pool_transfers,
+ r600_replace_buffer_storage,
+ &((struct si_context*)ctx)->b.tc);
+}
+
/*
* pipe_screen
*/
static bool si_have_tgsi_compute(struct si_screen *sscreen)
{
/* Old kernels disallowed some register writes for SI
* that are used for indirect dispatches. */
return (sscreen->b.chip_class >= CIK ||
sscreen->b.info.drm_major == 3 ||
(sscreen->b.info.drm_major == 2 &&
@@ -823,21 +854,21 @@ static void si_test_vmfault(struct si_screen *sscreen)
struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
{
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
unsigned num_cpus, num_compiler_threads, i;
if (!sscreen) {
return NULL;
}
/* Set functions first. */
- sscreen->b.b.context_create = si_create_context;
+ sscreen->b.b.context_create = si_pipe_create_context;
sscreen->b.b.destroy = si_destroy_screen;
sscreen->b.b.get_param = si_get_param;
sscreen->b.b.get_shader_param = si_get_shader_param;
sscreen->b.b.resource_create = r600_resource_create_common;
si_init_screen_state_functions(sscreen);
if (!r600_common_screen_init(&sscreen->b, ws) ||
!si_init_gs_info(sscreen) ||
!si_init_shader_cache(sscreen)) {
@@ -912,21 +943,21 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
SI_CONTEXT_INV_GLOBAL_L2;
sscreen->b.barrier_flags.compute_to_L2 = SI_CONTEXT_CS_PARTIAL_FLUSH;
if (debug_get_bool_option("RADEON_DUMP_SHADERS", false))
sscreen->b.debug_flags |= DBG_FS | DBG_VS | DBG_GS | DBG_PS | DBG_CS;
for (i = 0; i < num_compiler_threads; i++)
sscreen->tm[i] = si_create_llvm_target_machine(sscreen);
/* Create the auxiliary context. This must be done last. */
- sscreen->b.aux_context = sscreen->b.b.context_create(&sscreen->b.b, NULL, 0);
+ sscreen->b.aux_context = si_create_context(&sscreen->b.b, 0);
if (sscreen->b.debug_flags & DBG_TEST_DMA)
r600_test_dma(&sscreen->b);
if (sscreen->b.debug_flags & (DBG_TEST_VMFAULT_CP |
DBG_TEST_VMFAULT_SDMA |
DBG_TEST_VMFAULT_SHADER))
si_test_vmfault(sscreen);
return &sscreen->b.b;
--
2.7.4
More information about the mesa-dev
mailing list