[Mesa-dev] [PATCH 4/6] gallium/radeon: pass r600_common_context into radeon_llvm_compile

Nicolai Hähnle nhaehnle at gmail.com
Wed Dec 30 18:30:46 PST 2015


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

This will allow us to send shader debug info via the context's debug callback.
---
 src/gallium/drivers/r600/evergreen_compute.c  | 2 +-
 src/gallium/drivers/r600/r600_llvm.c          | 3 ++-
 src/gallium/drivers/r600/r600_llvm.h          | 2 ++
 src/gallium/drivers/r600/r600_shader.c        | 2 +-
 src/gallium/drivers/radeon/radeon_llvm_emit.c | 5 ++++-
 src/gallium/drivers/radeon/radeon_llvm_emit.h | 4 +++-
 src/gallium/drivers/radeonsi/si_shader.c      | 2 +-
 7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index d83eb17..1db107a 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -600,7 +600,7 @@ static void evergreen_launch_grid(
                            ctx->screen->has_compressed_msaa_texturing);
                 bc->type = TGSI_PROCESSOR_COMPUTE;
                 bc->isa = ctx->isa;
-                r600_llvm_compile(mod, ctx->b.family, bc, &use_kill, dump);
+                r600_llvm_compile(&rctx->b, mod, ctx->b.family, bc, &use_kill, dump);
 
                 if (dump && !sb_disasm) {
                         r600_bytecode_disasm(bc);
diff --git a/src/gallium/drivers/r600/r600_llvm.c b/src/gallium/drivers/r600/r600_llvm.c
index 1cc3031..a68f265 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -911,6 +911,7 @@ unsigned r600_create_shader(struct r600_bytecode *bc,
 }
 
 unsigned r600_llvm_compile(
+	struct r600_common_context *rctx,
 	LLVMModuleRef mod,
 	enum radeon_family family,
 	struct r600_bytecode *bc,
@@ -922,7 +923,7 @@ unsigned r600_llvm_compile(
 	const char * gpu_family = r600_get_llvm_processor_name(family);
 
 	memset(&binary, 0, sizeof(struct radeon_shader_binary));
-	r = radeon_llvm_compile(mod, &binary, gpu_family, dump, dump, NULL);
+	r = radeon_llvm_compile(rctx, mod, &binary, gpu_family, dump, dump, NULL);
 
 	r = r600_create_shader(bc, &binary, use_kill);
 
diff --git a/src/gallium/drivers/r600/r600_llvm.h b/src/gallium/drivers/r600/r600_llvm.h
index 9b5304d..5b091b9 100644
--- a/src/gallium/drivers/r600/r600_llvm.h
+++ b/src/gallium/drivers/r600/r600_llvm.h
@@ -7,6 +7,7 @@
 #include "radeon/radeon_llvm.h"
 #include <llvm-c/Core.h>
 
+struct r600_common_context;
 struct r600_bytecode;
 struct r600_shader_ctx;
 struct radeon_llvm_context;
@@ -18,6 +19,7 @@ LLVMModuleRef r600_tgsi_llvm(
 	const struct tgsi_token * tokens);
 
 unsigned r600_llvm_compile(
+	struct r600_common_context *rctx,
 	LLVMModuleRef mod,
 	enum radeon_family family,
 	struct r600_bytecode *bc,
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index d411b0b..60d98a9 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -3259,7 +3259,7 @@ static int r600_shader_from_tgsi(struct r600_context *rctx,
 		ctx.shader->has_txq_cube_array_z_comp = radeon_llvm_ctx.has_txq_cube_array_z_comp;
 		ctx.shader->uses_tex_buffers = radeon_llvm_ctx.uses_tex_buffers;
 
-		if (r600_llvm_compile(mod, rscreen->b.family, ctx.bc, &use_kill, dump)) {
+		if (r600_llvm_compile(&rctx->b, mod, rscreen->b.family, ctx.bc, &use_kill, dump)) {
 			radeon_llvm_dispose(&radeon_llvm_ctx);
 			use_llvm = 0;
 			fprintf(stderr, "R600 LLVM backend failed to compile "
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c
index 61ed940..d0168f1 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
@@ -23,8 +23,10 @@
  * Authors: Tom Stellard <thomas.stellard at amd.com>
  *
  */
+
 #include "radeon_llvm_emit.h"
 #include "radeon_elf_util.h"
+#include "r600_pipe_common.h"
 #include "c11/threads.h"
 #include "gallivm/lp_bld_misc.h"
 #include "util/u_memory.h"
@@ -140,7 +142,8 @@ static void radeonDiagnosticHandler(LLVMDiagnosticInfoRef di, void *context)
  *
  * @returns 0 for success, 1 for failure
  */
-unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binary,
+unsigned radeon_llvm_compile(struct r600_common_context *rctx,
+			     LLVMModuleRef M, struct radeon_shader_binary *binary,
 			     const char *gpu_family, bool dump_ir, bool dump_asm,
 			     LLVMTargetMachineRef tm)
 {
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h b/src/gallium/drivers/radeon/radeon_llvm_emit.h
index e20aed9..be72c6b 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.h
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h
@@ -31,13 +31,15 @@
 #include <llvm-c/TargetMachine.h>
 #include <stdbool.h>
 
+struct r600_common_context;
 struct radeon_shader_binary;
 
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
 
 LLVMTargetRef radeon_llvm_get_r600_target(const char *triple);
 
-unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary *binary,
+unsigned radeon_llvm_compile(struct r600_common_context *rctx,
+			     LLVMModuleRef M, struct radeon_shader_binary *binary,
 			     const char *gpu_family, bool dump_ir, bool dump_asm,
 			     LLVMTargetMachineRef tm);
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index bc9887b..3f5690e 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3933,7 +3933,7 @@ int si_compile_llvm(struct si_context *sctx, struct si_shader *shader,
 		fprintf(stderr, "radeonsi: Compiling shader %d\n", count);
 
 	if (!si_replace_shader(count, &shader->binary)) {
-		r = radeon_llvm_compile(mod, &shader->binary,
+		r = radeon_llvm_compile(&sctx->b, mod, &shader->binary,
 			r600_get_llvm_processor_name(sscreen->b.family), dump_ir, dump_asm, tm);
 		if (r)
 			return r;
-- 
2.5.0



More information about the mesa-dev mailing list