radv: add llvm_compiler_shader() helper
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 12 Mar 2020 13:49:55 +0000 (14:49 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 13 Mar 2020 10:22:13 +0000 (10:22 +0000)
To match aco_compile_shader().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4163>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4163>

src/amd/vulkan/radv_nir_to_llvm.c
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_shader.c

index 961d6db0ba0e0c866c3899ed1e9a6222fccd096f..d833bc2477dc5b945d5f28f8742898782cfe241b 100644 (file)
@@ -29,6 +29,7 @@
 #include "radv_shader.h"
 #include "radv_shader_helper.h"
 #include "radv_shader_args.h"
+#include "radv_debug.h"
 #include "nir/nir.h"
 
 #include "sid.h"
@@ -4266,7 +4267,7 @@ static void ac_compile_llvm_module(struct ac_llvm_compiler *ac_llvm,
        free(elf_buffer);
 }
 
-void
+static void
 radv_compile_nir_shader(struct ac_llvm_compiler *ac_llvm,
                        struct radv_shader_binary **rbinary,
                        const struct radv_shader_args *args,
@@ -4392,7 +4393,7 @@ ac_gs_copy_shader_emit(struct radv_shader_context *ctx)
        LLVMPositionBuilderAtEnd(ctx->ac.builder, end_bb);
 }
 
-void
+static void
 radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
                            struct nir_shader *geom_shader,
                            struct radv_shader_binary **rbinary,
@@ -4431,3 +4432,36 @@ radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
        (*rbinary)->is_gs_copy_shader = true;
        
 }
+
+void
+llvm_compile_shader(struct radv_device *device,
+                   unsigned shader_count,
+                   struct nir_shader *const *shaders,
+                   struct radv_shader_binary **binary,
+                   struct radv_shader_args *args)
+{
+       enum ac_target_machine_options tm_options = 0;
+       struct ac_llvm_compiler ac_llvm;
+       bool thread_compiler;
+
+       tm_options |= AC_TM_SUPPORTS_SPILL;
+       if (args->options->check_ir)
+               tm_options |= AC_TM_CHECK_IR;
+       if (device->instance->debug_flags & RADV_DEBUG_NO_LOAD_STORE_OPT)
+               tm_options |= AC_TM_NO_LOAD_STORE_OPT;
+
+       thread_compiler = !(device->instance->debug_flags & RADV_DEBUG_NOTHREADLLVM);
+
+       radv_init_llvm_compiler(&ac_llvm, thread_compiler,
+                               args->options->family, tm_options,
+                               args->shader_info->wave_size);
+
+       if (args->is_gs_copy_shader) {
+               radv_compile_gs_copy_shader(&ac_llvm, *shaders, binary, args);
+       } else {
+               radv_compile_nir_shader(&ac_llvm, binary, args,
+                                       shaders, shader_count);
+       }
+
+       radv_destroy_llvm_compiler(&ac_llvm, thread_compiler);
+}
index fc63818adce3b550fa9b96ee5a68d3b321b72c52..d8e0763f8fc202f9275c414f0bbfdd6bfffa23eb 100644 (file)
@@ -2361,16 +2361,11 @@ struct radv_fence {
 /* radv_nir_to_llvm.c */
 struct radv_shader_args;
 
-void radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
-                                struct nir_shader *geom_shader,
-                                struct radv_shader_binary **rbinary,
-                                const struct radv_shader_args *args);
-
-void radv_compile_nir_shader(struct ac_llvm_compiler *ac_llvm,
-                            struct radv_shader_binary **rbinary,
-                            const struct radv_shader_args *args,
-                            struct nir_shader *const *nir,
-                            int nir_count);
+void llvm_compile_shader(struct radv_device *device,
+                        unsigned shader_count,
+                        struct nir_shader *const *shaders,
+                        struct radv_shader_binary **binary,
+                        struct radv_shader_args *args);
 
 unsigned radv_nir_get_max_workgroup_size(enum chip_class chip_class,
                                         gl_shader_stage stage,
index 37c85ea95f4221aab32a4a98f9f926386b9a995b..30e46340520293d40d80f2f210d6fec743c38fba 100644 (file)
@@ -1119,37 +1119,12 @@ shader_variant_compile(struct radv_device *device,
 
        if (device->physical_device->use_aco) {
                aco_compile_shader(shader_count, shaders, &binary, &args);
-               binary->info = *info;
        } else {
-               enum ac_target_machine_options tm_options = 0;
-               struct ac_llvm_compiler ac_llvm;
-               bool thread_compiler;
-
-               tm_options |= AC_TM_SUPPORTS_SPILL;
-               if (options->check_ir)
-                       tm_options |= AC_TM_CHECK_IR;
-               if (device->instance->debug_flags & RADV_DEBUG_NO_LOAD_STORE_OPT)
-                       tm_options |= AC_TM_NO_LOAD_STORE_OPT;
-
-               thread_compiler = !(device->instance->debug_flags & RADV_DEBUG_NOTHREADLLVM);
-               radv_init_llvm_compiler(&ac_llvm,
-                                       thread_compiler,
-                                       chip_family, tm_options,
-                                       info->wave_size);
-
-               if (gs_copy_shader) {
-                       assert(shader_count == 1);
-                       radv_compile_gs_copy_shader(&ac_llvm, *shaders, &binary,
-                                                   &args);
-               } else {
-                       radv_compile_nir_shader(&ac_llvm, &binary, &args,
-                                               shaders, shader_count);
-               }
-
-               binary->info = *info;
-               radv_destroy_llvm_compiler(&ac_llvm, thread_compiler);
+               llvm_compile_shader(device, shader_count, shaders, &binary, &args);
        }
 
+       binary->info = *info;
+
        struct radv_shader_variant *variant = radv_shader_variant_create(device, binary,
                                                                         keep_shader_info);
        if (!variant) {