From: Samuel Pitoiset Date: Thu, 12 Mar 2020 13:49:55 +0000 (+0100) Subject: radv: add llvm_compiler_shader() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d295ab3f35acd796826d6f06f798d8618b1d814;p=mesa.git radv: add llvm_compiler_shader() helper To match aco_compile_shader(). Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Tested-by: Marge Bot Part-of: --- diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 961d6db0ba0..d833bc2477d 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -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); +} diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index fc63818adce..d8e0763f8fc 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -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, diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index 37c85ea95f4..30e46340520 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -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) {