intel/compiler: Use a struct for brw_compile_gs parameters
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14139>
This commit is contained in:
@@ -1739,12 +1739,16 @@ crocus_compile_gs(struct crocus_context *ice,
|
||||
struct brw_gs_prog_key key_clean = *key;
|
||||
crocus_sanitize_tex_key(&key_clean.base.tex);
|
||||
|
||||
char *error_str = NULL;
|
||||
const unsigned *program =
|
||||
brw_compile_gs(compiler, &ice->dbg, mem_ctx, &key_clean, gs_prog_data, nir,
|
||||
NULL, &error_str);
|
||||
struct brw_compile_gs_params params = {
|
||||
.nir = nir,
|
||||
.key = &key_clean,
|
||||
.prog_data = gs_prog_data,
|
||||
.log_data = &ice->dbg,
|
||||
};
|
||||
|
||||
const unsigned *program = brw_compile_gs(compiler, mem_ctx, ¶ms);
|
||||
if (program == NULL) {
|
||||
dbg_printf("Failed to compile geometry shader: %s\n", error_str);
|
||||
dbg_printf("Failed to compile geometry shader: %s\n", params.error_str);
|
||||
ralloc_free(mem_ctx);
|
||||
return false;
|
||||
}
|
||||
|
@@ -1850,12 +1850,16 @@ iris_compile_gs(struct iris_screen *screen,
|
||||
|
||||
struct brw_gs_prog_key brw_key = iris_to_brw_gs_key(devinfo, key);
|
||||
|
||||
char *error_str = NULL;
|
||||
const unsigned *program =
|
||||
brw_compile_gs(compiler, dbg, mem_ctx, &brw_key, gs_prog_data,
|
||||
nir, NULL, &error_str);
|
||||
struct brw_compile_gs_params params = {
|
||||
.nir = nir,
|
||||
.key = &brw_key,
|
||||
.prog_data = gs_prog_data,
|
||||
.log_data = dbg,
|
||||
};
|
||||
|
||||
const unsigned *program = brw_compile_gs(compiler, mem_ctx, ¶ms);
|
||||
if (program == NULL) {
|
||||
dbg_printf("Failed to compile geometry shader: %s\n", error_str);
|
||||
dbg_printf("Failed to compile geometry shader: %s\n", params.error_str);
|
||||
ralloc_free(mem_ctx);
|
||||
|
||||
shader->compilation_failed = true;
|
||||
|
@@ -1624,18 +1624,32 @@ brw_compile_tes(const struct brw_compiler *compiler,
|
||||
struct brw_compile_tes_params *params);
|
||||
|
||||
/**
|
||||
* Compile a vertex shader.
|
||||
* Parameters for compiling a geometry shader.
|
||||
*
|
||||
* Returns the final assembly and the program's size.
|
||||
* Some of these will be modified during the shader compilation.
|
||||
*/
|
||||
struct brw_compile_gs_params {
|
||||
nir_shader *nir;
|
||||
|
||||
const struct brw_gs_prog_key *key;
|
||||
struct brw_gs_prog_data *prog_data;
|
||||
|
||||
struct brw_compile_stats *stats;
|
||||
|
||||
void *log_data;
|
||||
|
||||
char *error_str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Compile a geometry shader.
|
||||
*
|
||||
* Returns the final assembly and updates the parameters structure.
|
||||
*/
|
||||
const unsigned *
|
||||
brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
brw_compile_gs(const struct brw_compiler *compiler,
|
||||
void *mem_ctx,
|
||||
const struct brw_gs_prog_key *key,
|
||||
struct brw_gs_prog_data *prog_data,
|
||||
nir_shader *nir,
|
||||
struct brw_compile_stats *stats,
|
||||
char **error_str);
|
||||
struct brw_compile_gs_params *params);
|
||||
|
||||
/**
|
||||
* Compile a strips and fans shader.
|
||||
|
@@ -580,14 +580,14 @@ static const GLuint gl_prim_to_hw_prim[GL_TRIANGLE_STRIP_ADJACENCY+1] = {
|
||||
} /* namespace brw */
|
||||
|
||||
extern "C" const unsigned *
|
||||
brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
brw_compile_gs(const struct brw_compiler *compiler,
|
||||
void *mem_ctx,
|
||||
const struct brw_gs_prog_key *key,
|
||||
struct brw_gs_prog_data *prog_data,
|
||||
nir_shader *nir,
|
||||
struct brw_compile_stats *stats,
|
||||
char **error_str)
|
||||
struct brw_compile_gs_params *params)
|
||||
{
|
||||
nir_shader *nir = params->nir;
|
||||
const struct brw_gs_prog_key *key = params->key;
|
||||
struct brw_gs_prog_data *prog_data = params->prog_data;
|
||||
|
||||
struct brw_gs_compile c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
c.key = *key;
|
||||
@@ -816,13 +816,13 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
}
|
||||
|
||||
if (is_scalar) {
|
||||
fs_visitor v(compiler, log_data, mem_ctx, &c, prog_data, nir,
|
||||
fs_visitor v(compiler, params->log_data, mem_ctx, &c, prog_data, nir,
|
||||
debug_enabled);
|
||||
if (v.run_gs()) {
|
||||
prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
|
||||
prog_data->base.base.dispatch_grf_start_reg = v.payload.num_regs;
|
||||
|
||||
fs_generator g(compiler, log_data, mem_ctx,
|
||||
fs_generator g(compiler, params->log_data, mem_ctx,
|
||||
&prog_data->base.base, false, MESA_SHADER_GEOMETRY);
|
||||
if (unlikely(debug_enabled)) {
|
||||
const char *label =
|
||||
@@ -832,13 +832,12 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
g.enable_debug(name);
|
||||
}
|
||||
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);
|
||||
return g.get_assembly();
|
||||
}
|
||||
|
||||
if (error_str)
|
||||
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
params->error_str = ralloc_strdup(mem_ctx, v.fail_msg);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -852,7 +851,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
!INTEL_DEBUG(DEBUG_NO_DUAL_OBJECT_GS)) {
|
||||
prog_data->base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
|
||||
|
||||
brw::vec4_gs_visitor v(compiler, log_data, &c, prog_data, nir,
|
||||
brw::vec4_gs_visitor v(compiler, params->log_data, &c, prog_data, nir,
|
||||
mem_ctx, true /* no_spills */,
|
||||
debug_enabled);
|
||||
|
||||
@@ -869,11 +868,11 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
if (v.run()) {
|
||||
/* Success! Backup is not needed */
|
||||
ralloc_free(param);
|
||||
return brw_vec4_generate_assembly(compiler, log_data, mem_ctx,
|
||||
return 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);
|
||||
} else {
|
||||
/* These variables could be modified by the execution of the GS
|
||||
* visitor if it packed the uniforms in the push constant buffer.
|
||||
@@ -922,22 +921,21 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
|
||||
const unsigned *ret = NULL;
|
||||
|
||||
if (compiler->devinfo->ver >= 7)
|
||||
gs = new brw::vec4_gs_visitor(compiler, log_data, &c, prog_data,
|
||||
gs = new brw::vec4_gs_visitor(compiler, params->log_data, &c, prog_data,
|
||||
nir, mem_ctx, false /* no_spills */,
|
||||
debug_enabled);
|
||||
else
|
||||
gs = new brw::gfx6_gs_visitor(compiler, log_data, &c, prog_data,
|
||||
gs = new brw::gfx6_gs_visitor(compiler, params->log_data, &c, prog_data,
|
||||
nir, mem_ctx, false /* no_spills */,
|
||||
debug_enabled);
|
||||
|
||||
if (!gs->run()) {
|
||||
if (error_str)
|
||||
*error_str = ralloc_strdup(mem_ctx, gs->fail_msg);
|
||||
params->error_str = ralloc_strdup(mem_ctx, gs->fail_msg);
|
||||
} else {
|
||||
ret = brw_vec4_generate_assembly(compiler, log_data, mem_ctx, nir,
|
||||
ret = brw_vec4_generate_assembly(compiler, params->log_data, mem_ctx, nir,
|
||||
&prog_data->base, gs->cfg,
|
||||
gs->performance_analysis.require(),
|
||||
stats, debug_enabled);
|
||||
params->stats, debug_enabled);
|
||||
}
|
||||
|
||||
delete gs;
|
||||
|
@@ -1079,11 +1079,16 @@ anv_pipeline_compile_gs(const struct brw_compiler *compiler,
|
||||
gs_stage->nir->info.separate_shader, 1);
|
||||
|
||||
gs_stage->num_stats = 1;
|
||||
gs_stage->code = brw_compile_gs(compiler, device, mem_ctx,
|
||||
&gs_stage->key.gs,
|
||||
&gs_stage->prog_data.gs,
|
||||
gs_stage->nir,
|
||||
gs_stage->stats, NULL);
|
||||
|
||||
struct brw_compile_gs_params params = {
|
||||
.nir = gs_stage->nir,
|
||||
.key = &gs_stage->key.gs,
|
||||
.prog_data = &gs_stage->prog_data.gs,
|
||||
.stats = gs_stage->stats,
|
||||
.log_data = device,
|
||||
};
|
||||
|
||||
gs_stage->code = brw_compile_gs(compiler, mem_ctx, ¶ms);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user