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 <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3421>
This commit is contained in:
Marek Olšák 2020-01-15 17:28:29 -05:00 committed by Marge Bot
parent 594f085cfa
commit d1c42e2c6a
4 changed files with 31 additions and 37 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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)

View file

@ -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);