radv: add llvm_compiler_shader() helper

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>
This commit is contained in:
Samuel Pitoiset
2020-03-12 14:49:55 +01:00
committed by Marge Bot
parent 4d991c2de4
commit 2d295ab3f3
3 changed files with 44 additions and 40 deletions

View 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);
}

View 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,

View File

@@ -1119,36 +1119,11 @@ 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);
llvm_compile_shader(device, shader_count, shaders, &binary, &args);
}
binary->info = *info;
radv_destroy_llvm_compiler(&ac_llvm, thread_compiler);
}
struct radv_shader_variant *variant = radv_shader_variant_create(device, binary,
keep_shader_info);