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,
}
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));
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)) {
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);
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);
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)
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,
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)