intel/compiler: Use a struct for brw_compile_tes parameters
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14139>
This commit is contained in:
@@ -1599,12 +1599,18 @@ crocus_compile_tes(struct crocus_context *ice,
|
||||
|
||||
struct brw_tes_prog_key key_clean = *key;
|
||||
crocus_sanitize_tex_key(&key_clean.base.tex);
|
||||
char *error_str = NULL;
|
||||
const unsigned *program =
|
||||
brw_compile_tes(compiler, &ice->dbg, mem_ctx, &key_clean, &input_vue_map,
|
||||
tes_prog_data, nir, NULL, &error_str);
|
||||
|
||||
struct brw_compile_tes_params params = {
|
||||
.nir = nir,
|
||||
.key = &key_clean,
|
||||
.prog_data = tes_prog_data,
|
||||
.input_vue_map = &input_vue_map,
|
||||
.log_data = &ice->dbg,
|
||||
};
|
||||
|
||||
const unsigned *program = brw_compile_tes(compiler, mem_ctx, ¶ms);
|
||||
if (program == NULL) {
|
||||
dbg_printf("Failed to compile evaluation shader: %s\n", error_str);
|
||||
dbg_printf("Failed to compile evaluation shader: %s\n", params.error_str);
|
||||
ralloc_free(mem_ctx);
|
||||
return false;
|
||||
}
|
||||
|
@@ -1711,12 +1711,17 @@ iris_compile_tes(struct iris_screen *screen,
|
||||
|
||||
struct brw_tes_prog_key brw_key = iris_to_brw_tes_key(devinfo, key);
|
||||
|
||||
char *error_str = NULL;
|
||||
const unsigned *program =
|
||||
brw_compile_tes(compiler, dbg, mem_ctx, &brw_key, &input_vue_map,
|
||||
tes_prog_data, nir, NULL, &error_str);
|
||||
struct brw_compile_tes_params params = {
|
||||
.nir = nir,
|
||||
.key = &brw_key,
|
||||
.prog_data = tes_prog_data,
|
||||
.input_vue_map = &input_vue_map,
|
||||
.log_data = dbg,
|
||||
};
|
||||
|
||||
const unsigned *program = brw_compile_tes(compiler, mem_ctx, ¶ms);
|
||||
if (program == NULL) {
|
||||
dbg_printf("Failed to compile evaluation shader: %s\n", error_str);
|
||||
dbg_printf("Failed to compile evaluation shader: %s\n", params.error_str);
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
shader->compilation_failed = true;
|
||||
|
@@ -1594,20 +1594,34 @@ brw_compile_tcs(const struct brw_compiler *compiler,
|
||||
void *mem_ctx,
|
||||
struct brw_compile_tcs_params *params);
|
||||
|
||||
/**
|
||||
* Parameters for compiling a tessellation evaluation shader.
|
||||
*
|
||||
* Some of these will be modified during the shader compilation.
|
||||
*/
|
||||
struct brw_compile_tes_params {
|
||||
nir_shader *nir;
|
||||
|
||||
const struct brw_tes_prog_key *key;
|
||||
struct brw_tes_prog_data *prog_data;
|
||||
const struct brw_vue_map *input_vue_map;
|
||||
|
||||
struct brw_compile_stats *stats;
|
||||
|
||||
void *log_data;
|
||||
|
||||
char *error_str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile a tessellation evaluation shader.
|
||||
*
|
||||
* Returns the final assembly and the program's size.
|
||||
* Returns the final assembly and updates the parameters structure.
|
||||
*/
|
||||
const unsigned *
|
||||
brw_compile_tes(const struct brw_compiler *compiler, void *log_data,
|
||||
brw_compile_tes(const struct brw_compiler *compiler,
|
||||
void *mem_ctx,
|
||||
const struct brw_tes_prog_key *key,
|
||||
const struct brw_vue_map *input_vue_map,
|
||||
struct brw_tes_prog_data *prog_data,
|
||||
nir_shader *nir,
|
||||
struct brw_compile_stats *stats,
|
||||
char **error_str);
|
||||
struct brw_compile_tes_params *params);
|
||||
|
||||
/**
|
||||
* Compile a vertex shader.
|
||||
|
@@ -1328,16 +1328,15 @@ backend_shader::invalidate_analysis(brw::analysis_dependency_class c)
|
||||
|
||||
extern "C" const unsigned *
|
||||
brw_compile_tes(const struct brw_compiler *compiler,
|
||||
void *log_data,
|
||||
void *mem_ctx,
|
||||
const struct brw_tes_prog_key *key,
|
||||
const struct brw_vue_map *input_vue_map,
|
||||
struct brw_tes_prog_data *prog_data,
|
||||
nir_shader *nir,
|
||||
struct brw_compile_stats *stats,
|
||||
char **error_str)
|
||||
brw_compile_tes_params *params)
|
||||
{
|
||||
const struct intel_device_info *devinfo = compiler->devinfo;
|
||||
nir_shader *nir = params->nir;
|
||||
const struct brw_tes_prog_key *key = params->key;
|
||||
const struct brw_vue_map *input_vue_map = params->input_vue_map;
|
||||
struct brw_tes_prog_data *prog_data = params->prog_data;
|
||||
|
||||
const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
|
||||
const bool debug_enabled = INTEL_DEBUG(DEBUG_TES);
|
||||
const unsigned *assembly;
|
||||
@@ -1361,8 +1360,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
|
||||
|
||||
assert(output_size_bytes >= 1);
|
||||
if (output_size_bytes > GFX7_MAX_DS_URB_ENTRY_SIZE_BYTES) {
|
||||
if (error_str)
|
||||
*error_str = ralloc_strdup(mem_ctx, "DS outputs exceed maximum size");
|
||||
params->error_str = ralloc_strdup(mem_ctx, "DS outputs exceed maximum size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1423,19 +1421,18 @@ brw_compile_tes(const struct brw_compiler *compiler,
|
||||
}
|
||||
|
||||
if (is_scalar) {
|
||||
fs_visitor v(compiler, log_data, mem_ctx, &key->base,
|
||||
fs_visitor v(compiler, params->log_data, mem_ctx, &key->base,
|
||||
&prog_data->base.base, nir, 8,
|
||||
debug_enabled);
|
||||
if (!v.run_tes()) {
|
||||
if (error_str)
|
||||
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
params->error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prog_data->base.base.dispatch_grf_start_reg = v.payload.num_regs;
|
||||
prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
|
||||
|
||||
fs_generator g(compiler, log_data, mem_ctx,
|
||||
fs_generator g(compiler, params->log_data, mem_ctx,
|
||||
&prog_data->base.base, false, MESA_SHADER_TESS_EVAL);
|
||||
if (unlikely(debug_enabled)) {
|
||||
g.enable_debug(ralloc_asprintf(mem_ctx,
|
||||
@@ -1446,27 +1443,26 @@ brw_compile_tes(const struct brw_compiler *compiler,
|
||||
}
|
||||
|
||||
g.generate_code(v.cfg, 8, v.shader_stats,
|
||||
v.performance_analysis.require(), stats);
|
||||
v.performance_analysis.require(), params->stats);
|
||||
|
||||
g.add_const_data(nir->constant_data, nir->constant_data_size);
|
||||
|
||||
assembly = g.get_assembly();
|
||||
} else {
|
||||
brw::vec4_tes_visitor v(compiler, log_data, key, prog_data,
|
||||
brw::vec4_tes_visitor v(compiler, params->log_data, key, prog_data,
|
||||
nir, mem_ctx, debug_enabled);
|
||||
if (!v.run()) {
|
||||
if (error_str)
|
||||
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
params->error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (unlikely(debug_enabled))
|
||||
v.dump_instructions();
|
||||
|
||||
assembly = brw_vec4_generate_assembly(compiler, log_data, mem_ctx, nir,
|
||||
assembly = brw_vec4_generate_assembly(compiler, params->log_data, mem_ctx, nir,
|
||||
&prog_data->base, v.cfg,
|
||||
v.performance_analysis.require(),
|
||||
stats, debug_enabled);
|
||||
params->stats, debug_enabled);
|
||||
}
|
||||
|
||||
return assembly;
|
||||
|
@@ -1044,12 +1044,17 @@ anv_pipeline_compile_tes(const struct brw_compiler *compiler,
|
||||
tcs_stage->nir->info.patch_outputs_written;
|
||||
|
||||
tes_stage->num_stats = 1;
|
||||
tes_stage->code = brw_compile_tes(compiler, device, mem_ctx,
|
||||
&tes_stage->key.tes,
|
||||
&tcs_stage->prog_data.tcs.base.vue_map,
|
||||
&tes_stage->prog_data.tes,
|
||||
tes_stage->nir,
|
||||
tes_stage->stats, NULL);
|
||||
|
||||
struct brw_compile_tes_params params = {
|
||||
.nir = tes_stage->nir,
|
||||
.key = &tes_stage->key.tes,
|
||||
.prog_data = &tes_stage->prog_data.tes,
|
||||
.input_vue_map = &tcs_stage->prog_data.tcs.base.vue_map,
|
||||
.stats = tes_stage->stats,
|
||||
.log_data = device,
|
||||
};
|
||||
|
||||
tes_stage->code = brw_compile_tes(compiler, mem_ctx, ¶ms);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user