[Mesa-dev] [PATCH 03/10] radeonsi: prevent a crash with DBG_CHECK_VM and u_threaded_context

Marek Olšák maraeo at gmail.com
Mon Jul 10 21:21:38 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

by setting PIPE_CONTEXT_DEBUG in the caller
---
 src/gallium/drivers/radeonsi/si_pipe.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 8a4bc41..371d337 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -158,23 +158,20 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
                                               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)
-		flags |= PIPE_CONTEXT_DEBUG;
-
 	if (flags & PIPE_CONTEXT_DEBUG)
 		sscreen->record_llvm_ir = true; /* racy but not critical */
 
 	sctx->b.b.screen = screen; /* this must be set first */
 	sctx->b.b.priv = NULL;
 	sctx->b.b.destroy = si_destroy_context;
 	sctx->b.b.emit_string_marker = si_emit_string_marker;
 	sctx->b.set_atom_dirty = (void *)si_set_atom_dirty;
 	sctx->screen = sscreen; /* Easy accessing of screen/winsys. */
 	sctx->is_debug = (flags & PIPE_CONTEXT_DEBUG) != 0;
@@ -371,21 +368,26 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
 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);
+	struct pipe_context *ctx;
+
+	if (sscreen->b.debug_flags & DBG_CHECK_VM)
+		flags |= PIPE_CONTEXT_DEBUG;
+
+	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
-- 
2.7.4



More information about the mesa-dev mailing list