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

Author: Marek Olšák <[email protected]>
Date:   Wed Jan 15 17:28:29 2020 -0500

radeonsi: move non-LLVM code out of si_shader_llvm.c

There was also some redundant code in si_shader_nir.c

Reviewed-by: Timothy Arceri <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3421>

---

 src/gallium/drivers/radeonsi/si_shader.c          | 35 ++++++++++++++++++++---
 src/gallium/drivers/radeonsi/si_shader_internal.h |  3 --
 src/gallium/drivers/radeonsi/si_shader_llvm.c     | 27 -----------------
 src/gallium/drivers/radeonsi/si_shader_nir.c      |  3 --
 4 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 65daaa5dc0b..9f8be2b7214 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2909,6 +2909,24 @@ static struct nir_shader *get_nir_shader(struct 
si_shader_selector *sel,
        return NULL;
 }
 
+/* Set the context to a certain shader. Can be called repeatedly
+ * to change the shader. */
+static void si_shader_context_set_ir(struct si_shader_context *ctx,
+                                    struct si_shader *shader)
+{
+       struct si_shader_selector *sel = shader->selector;
+       const struct si_shader_info *info = &sel->info;
+
+       ctx->shader = shader;
+       ctx->type = sel->type;
+
+       ctx->num_const_buffers = util_last_bit(info->const_buffers_declared);
+       ctx->num_shader_buffers = util_last_bit(info->shader_buffers_declared);
+
+       ctx->num_samplers = util_last_bit(info->samplers_declared);
+       ctx->num_images = util_last_bit(info->images_declared);
+}
+
 int si_compile_shader(struct si_screen *sscreen,
                      struct ac_llvm_compiler *compiler,
                      struct si_shader *shader,
@@ -2929,7 +2947,7 @@ int si_compile_shader(struct si_screen *sscreen,
        }
 
        si_llvm_context_init(&ctx, sscreen, compiler, 
si_get_shader_wave_size(shader));
-       si_llvm_context_set_ir(&ctx, shader);
+       si_shader_context_set_ir(&ctx, shader);
 
        memset(shader->info.vs_output_param_offset, AC_EXP_PARAM_UNDEFINED,
               sizeof(shader->info.vs_output_param_offset));
@@ -2945,7 +2963,7 @@ int si_compile_shader(struct si_screen *sscreen,
                ngg_cull_main_fn = ctx.main_fn;
                ctx.main_fn = NULL;
                /* Re-set the IR. */
-               si_llvm_context_set_ir(&ctx, shader);
+               si_shader_context_set_ir(&ctx, shader);
        }
 
        if (!si_build_main_function(&ctx, nir, free_nir, false)) {
@@ -3030,7 +3048,7 @@ int si_compile_shader(struct si_screen *sscreen,
                        shader_ls.key.mono = shader->key.mono;
                        shader_ls.key.opt = shader->key.opt;
                        shader_ls.is_monolithic = true;
-                       si_llvm_context_set_ir(&ctx, &shader_ls);
+                       si_shader_context_set_ir(&ctx, &shader_ls);
 
                        if (!si_build_main_function(&ctx, nir, free_nir, 
false)) {
                                si_llvm_dispose(&ctx);
@@ -3099,7 +3117,7 @@ int si_compile_shader(struct si_screen *sscreen,
                        shader_es.key.mono = shader->key.mono;
                        shader_es.key.opt = shader->key.opt;
                        shader_es.is_monolithic = true;
-                       si_llvm_context_set_ir(&ctx, &shader_es);
+                       si_shader_context_set_ir(&ctx, &shader_es);
 
                        if (!si_build_main_function(&ctx, nir, free_nir, 
false)) {
                                si_llvm_dispose(&ctx);
@@ -4138,6 +4156,15 @@ bool si_create_shader_variant(struct si_screen *sscreen,
        return true;
 }
 
+void si_shader_binary_clean(struct si_shader_binary *binary)
+{
+       free((void *)binary->elf_buffer);
+       binary->elf_buffer = NULL;
+
+       free(binary->llvm_ir_string);
+       binary->llvm_ir_string = NULL;
+}
+
 void si_shader_destroy(struct si_shader *shader)
 {
        if (shader->scratch_bo)
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h 
b/src/gallium/drivers/radeonsi/si_shader_internal.h
index a3f43358e39..91b581294d2 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -200,9 +200,6 @@ void si_llvm_context_init(struct si_shader_context *ctx,
                          struct si_screen *sscreen,
                          struct ac_llvm_compiler *compiler,
                          unsigned wave_size);
-void si_llvm_context_set_ir(struct si_shader_context *ctx,
-                           struct si_shader *shader);
-
 void si_llvm_create_func(struct si_shader_context *ctx, const char *name,
                         LLVMTypeRef *return_types, unsigned num_return_elems,
                         unsigned max_workgroup_size);
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index 7fa067f5e44..0ea102624e9 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -149,15 +149,6 @@ int si_compile_llvm(struct si_screen *sscreen,
        return 0;
 }
 
-void si_shader_binary_clean(struct si_shader_binary *binary)
-{
-       free((void *)binary->elf_buffer);
-       binary->elf_buffer = NULL;
-
-       free(binary->llvm_ir_string);
-       binary->llvm_ir_string = NULL;
-}
-
 void si_llvm_context_init(struct si_shader_context *ctx,
                          struct si_screen *sscreen,
                          struct ac_llvm_compiler *compiler,
@@ -173,24 +164,6 @@ void si_llvm_context_init(struct si_shader_context *ctx,
                             wave_size, 64);
 }
 
-/* Set the context to a certain shader. Can be called repeatedly
- * to change the shader. */
-void si_llvm_context_set_ir(struct si_shader_context *ctx,
-                           struct si_shader *shader)
-{
-       struct si_shader_selector *sel = shader->selector;
-       const struct si_shader_info *info = &sel->info;
-
-       ctx->shader = shader;
-       ctx->type = sel->type;
-
-       ctx->num_const_buffers = util_last_bit(info->const_buffers_declared);
-       ctx->num_shader_buffers = util_last_bit(info->shader_buffers_declared);
-
-       ctx->num_samplers = util_last_bit(info->samplers_declared);
-       ctx->num_images = util_last_bit(info->images_declared);
-}
-
 void si_llvm_create_func(struct si_shader_context *ctx, const char *name,
                         LLVMTypeRef *return_types, unsigned num_return_elems,
                         unsigned max_workgroup_size)
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index aa16f865288..243feba7417 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -1096,9 +1096,6 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
        ctx->abi.clamp_shadow_reference = true;
        ctx->abi.robust_buffer_access = true;
 
-       ctx->num_samplers = util_last_bit(info->samplers_declared);
-       ctx->num_images = util_last_bit(info->images_declared);
-
        if 
(ctx->shader->selector->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE]) {
                assert(gl_shader_stage_is_compute(nir->info.stage));
                si_declare_compute_memory(ctx);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to