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:
Caio Oliveira
2021-03-23 15:03:50 -07:00
committed by Marge Bot
parent 7372a48a4a
commit acf2d3c78b
5 changed files with 69 additions and 43 deletions

View File

@@ -1599,12 +1599,18 @@ crocus_compile_tes(struct crocus_context *ice,
struct brw_tes_prog_key key_clean = *key; struct brw_tes_prog_key key_clean = *key;
crocus_sanitize_tex_key(&key_clean.base.tex); crocus_sanitize_tex_key(&key_clean.base.tex);
char *error_str = NULL;
const unsigned *program = struct brw_compile_tes_params params = {
brw_compile_tes(compiler, &ice->dbg, mem_ctx, &key_clean, &input_vue_map, .nir = nir,
tes_prog_data, nir, NULL, &error_str); .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, &params);
if (program == NULL) { 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); ralloc_free(mem_ctx);
return false; return false;
} }

View File

@@ -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); struct brw_tes_prog_key brw_key = iris_to_brw_tes_key(devinfo, key);
char *error_str = NULL; struct brw_compile_tes_params params = {
const unsigned *program = .nir = nir,
brw_compile_tes(compiler, dbg, mem_ctx, &brw_key, &input_vue_map, .key = &brw_key,
tes_prog_data, nir, NULL, &error_str); .prog_data = tes_prog_data,
.input_vue_map = &input_vue_map,
.log_data = dbg,
};
const unsigned *program = brw_compile_tes(compiler, mem_ctx, &params);
if (program == NULL) { 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); ralloc_free(mem_ctx);
shader->compilation_failed = true; shader->compilation_failed = true;

View File

@@ -1594,20 +1594,34 @@ brw_compile_tcs(const struct brw_compiler *compiler,
void *mem_ctx, void *mem_ctx,
struct brw_compile_tcs_params *params); 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. * 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 * const unsigned *
brw_compile_tes(const struct brw_compiler *compiler, void *log_data, brw_compile_tes(const struct brw_compiler *compiler,
void *mem_ctx, void *mem_ctx,
const struct brw_tes_prog_key *key, struct brw_compile_tes_params *params);
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);
/** /**
* Compile a vertex shader. * Compile a vertex shader.

View File

@@ -1328,16 +1328,15 @@ backend_shader::invalidate_analysis(brw::analysis_dependency_class c)
extern "C" const unsigned * extern "C" const unsigned *
brw_compile_tes(const struct brw_compiler *compiler, brw_compile_tes(const struct brw_compiler *compiler,
void *log_data,
void *mem_ctx, void *mem_ctx,
const struct brw_tes_prog_key *key, brw_compile_tes_params *params)
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)
{ {
const struct intel_device_info *devinfo = compiler->devinfo; 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 is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
const bool debug_enabled = INTEL_DEBUG(DEBUG_TES); const bool debug_enabled = INTEL_DEBUG(DEBUG_TES);
const unsigned *assembly; const unsigned *assembly;
@@ -1361,8 +1360,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
assert(output_size_bytes >= 1); assert(output_size_bytes >= 1);
if (output_size_bytes > GFX7_MAX_DS_URB_ENTRY_SIZE_BYTES) { if (output_size_bytes > GFX7_MAX_DS_URB_ENTRY_SIZE_BYTES) {
if (error_str) params->error_str = ralloc_strdup(mem_ctx, "DS outputs exceed maximum size");
*error_str = ralloc_strdup(mem_ctx, "DS outputs exceed maximum size");
return NULL; return NULL;
} }
@@ -1423,19 +1421,18 @@ brw_compile_tes(const struct brw_compiler *compiler,
} }
if (is_scalar) { 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, &prog_data->base.base, nir, 8,
debug_enabled); debug_enabled);
if (!v.run_tes()) { if (!v.run_tes()) {
if (error_str) params->error_str = ralloc_strdup(mem_ctx, v.fail_msg);
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
return NULL; return NULL;
} }
prog_data->base.base.dispatch_grf_start_reg = v.payload.num_regs; prog_data->base.base.dispatch_grf_start_reg = v.payload.num_regs;
prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8; 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); &prog_data->base.base, false, MESA_SHADER_TESS_EVAL);
if (unlikely(debug_enabled)) { if (unlikely(debug_enabled)) {
g.enable_debug(ralloc_asprintf(mem_ctx, 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, 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); g.add_const_data(nir->constant_data, nir->constant_data_size);
assembly = g.get_assembly(); assembly = g.get_assembly();
} else { } 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); nir, mem_ctx, debug_enabled);
if (!v.run()) { if (!v.run()) {
if (error_str) params->error_str = ralloc_strdup(mem_ctx, v.fail_msg);
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
return NULL; return NULL;
} }
if (unlikely(debug_enabled)) if (unlikely(debug_enabled))
v.dump_instructions(); 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, &prog_data->base, v.cfg,
v.performance_analysis.require(), v.performance_analysis.require(),
stats, debug_enabled); params->stats, debug_enabled);
} }
return assembly; return assembly;

View File

@@ -1044,12 +1044,17 @@ anv_pipeline_compile_tes(const struct brw_compiler *compiler,
tcs_stage->nir->info.patch_outputs_written; tcs_stage->nir->info.patch_outputs_written;
tes_stage->num_stats = 1; tes_stage->num_stats = 1;
tes_stage->code = brw_compile_tes(compiler, device, mem_ctx,
&tes_stage->key.tes, struct brw_compile_tes_params params = {
&tcs_stage->prog_data.tcs.base.vue_map, .nir = tes_stage->nir,
&tes_stage->prog_data.tes, .key = &tes_stage->key.tes,
tes_stage->nir, .prog_data = &tes_stage->prog_data.tes,
tes_stage->stats, NULL); .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, &params);
} }
static void static void