[Mesa-dev] [PATCH 2/6] radeonsi: pass si_context down into si_shader_binary_read
Nicolai Hähnle
nhaehnle at gmail.com
Wed Dec 30 18:30:44 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/radeonsi/si_compute.c | 4 ++--
src/gallium/drivers/radeonsi/si_shader.c | 19 +++++++++++--------
src/gallium/drivers/radeonsi/si_shader.h | 6 +++---
src/gallium/drivers/radeonsi/si_state_shaders.c | 2 +-
4 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
index 47a74ee..0e22909 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -122,7 +122,7 @@ static void *si_create_compute_state(
for (i = 0; i < program->num_kernels; i++) {
LLVMModuleRef mod = radeon_llvm_get_kernel_module(program->llvm_ctx, i,
code, header->num_bytes);
- si_compile_llvm(sctx->screen, &program->kernels[i], sctx->tm,
+ si_compile_llvm(sctx, &program->kernels[i], sctx->tm,
mod);
LLVMDisposeModule(mod);
}
@@ -136,7 +136,7 @@ static void *si_create_compute_state(
* the shader code to the GPU.
*/
init_scratch_buffer(sctx, program);
- si_shader_binary_read(sctx->screen, &program->shader);
+ si_shader_binary_read(sctx, &program->shader);
#endif
program->input_buffer = si_resource_create_custom(sctx->b.b.screen,
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 0e98784..606d571 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3840,8 +3840,9 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
return 0;
}
-int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader)
+int si_shader_binary_read(struct si_context *sctx, struct si_shader *shader)
{
+ struct si_screen *sscreen = sctx->screen;
const struct radeon_shader_binary *binary = &shader->binary;
unsigned i;
int r;
@@ -3877,9 +3878,10 @@ int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader)
return 0;
}
-int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
+int si_compile_llvm(struct si_context *sctx, struct si_shader *shader,
LLVMTargetMachineRef tm, LLVMModuleRef mod)
{
+ struct si_screen *sscreen = sctx->screen;
int r = 0;
bool dump_asm = r600_can_dump_shader(&sscreen->b,
shader->selector ? shader->selector->tokens : NULL);
@@ -3896,7 +3898,7 @@ int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
return r;
}
- r = si_shader_binary_read(sscreen, shader);
+ r = si_shader_binary_read(sctx, shader);
FREE(shader->binary.config);
FREE(shader->binary.rodata);
@@ -3911,7 +3913,7 @@ int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
}
/* Generate code for the hardware VS shader stage to go with a geometry shader */
-static int si_generate_gs_copy_shader(struct si_screen *sscreen,
+static int si_generate_gs_copy_shader(struct si_context *sctx,
struct si_shader_context *si_shader_ctx,
struct si_shader *gs, bool dump)
{
@@ -3979,7 +3981,7 @@ static int si_generate_gs_copy_shader(struct si_screen *sscreen,
if (dump)
fprintf(stderr, "Copy Vertex Shader for Geometry Shader:\n\n");
- r = si_compile_llvm(sscreen, si_shader_ctx->shader,
+ r = si_compile_llvm(sctx, si_shader_ctx->shader,
si_shader_ctx->tm, bld_base->base.gallivm->module);
radeon_llvm_dispose(&si_shader_ctx->radeon_bld);
@@ -4033,9 +4035,10 @@ void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f)
}
}
-int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
+int si_shader_create(struct si_context *sctx, LLVMTargetMachineRef tm,
struct si_shader *shader)
{
+ struct si_screen *sscreen = sctx->screen;
struct si_shader_selector *sel = shader->selector;
struct tgsi_token *tokens = sel->tokens;
struct si_shader_context si_shader_ctx;
@@ -4188,7 +4191,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
mod = bld_base->base.gallivm->module;
- r = si_compile_llvm(sscreen, shader, tm, mod);
+ r = si_compile_llvm(sctx, shader, tm, mod);
if (r) {
fprintf(stderr, "LLVM failed to compile shader\n");
goto out;
@@ -4201,7 +4204,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
shader->gs_copy_shader->selector = shader->selector;
shader->gs_copy_shader->key = shader->key;
si_shader_ctx.shader = shader->gs_copy_shader;
- if ((r = si_generate_gs_copy_shader(sscreen, &si_shader_ctx,
+ if ((r = si_generate_gs_copy_shader(sctx, &si_shader_ctx,
shader, dump))) {
free(shader->gs_copy_shader);
shader->gs_copy_shader = NULL;
diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
index b0c8680..f2a9943 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -326,15 +326,15 @@ static inline bool si_vs_exports_prim_id(struct si_shader *shader)
}
/* radeonsi_shader.c */
-int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
+int si_shader_create(struct si_context *sctx, LLVMTargetMachineRef tm,
struct si_shader *shader);
void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f);
-int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
+int si_compile_llvm(struct si_context *sctx, struct si_shader *shader,
LLVMTargetMachineRef tm, LLVMModuleRef mod);
void si_shader_destroy(struct si_shader *shader);
unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
-int si_shader_binary_read(struct si_screen *sscreen, struct si_shader *shader);
+int si_shader_binary_read(struct si_context *sctx, struct si_shader *shader);
void si_shader_apply_scratch_relocs(struct si_context *sctx,
struct si_shader *shader,
uint64_t scratch_va);
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8700590..b904d70 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -616,7 +616,7 @@ static int si_shader_select(struct pipe_context *ctx,
shader->selector = sel;
shader->key = key;
- r = si_shader_create(sctx->screen, sctx->tm, shader);
+ r = si_shader_create(sctx, sctx->tm, shader);
if (unlikely(r)) {
R600_ERR("Failed to build shader variant (type=%u) %d\n",
sel->type, r);
--
2.5.0
More information about the mesa-dev
mailing list