mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 13:10:10 +01:00
gallium/ntt: Take ownership of the NIR shader we're passed.
It makes no sense for the caller to keep it, since we've throughly changed it to be suitable to NTT. All callers just freed it afterward anyway. Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8422>
This commit is contained in:
parent
a4a5045d59
commit
46fe700585
5 changed files with 12 additions and 18 deletions
|
|
@ -227,7 +227,6 @@ draw_create_vs_exec(struct draw_context *draw,
|
|||
if (state->type == PIPE_SHADER_IR_NIR) {
|
||||
vs->base.state.type = PIPE_SHADER_IR_TGSI;
|
||||
vs->base.state.tokens = nir_to_tgsi(state->ir.nir, draw->pipe->screen);
|
||||
ralloc_free(state->ir.nir);
|
||||
} else {
|
||||
assert(state->type == PIPE_SHADER_IR_TGSI);
|
||||
vs->base.state.type = state->type;
|
||||
|
|
|
|||
|
|
@ -2539,8 +2539,8 @@ ntt_fix_nir_options(struct nir_shader *s)
|
|||
!options->lower_rotate ||
|
||||
!options->lower_uniforms_to_ubo ||
|
||||
!options->lower_vector_cmp) {
|
||||
struct nir_shader_compiler_options *new_options =
|
||||
mem_dup(s->options, sizeof(*s->options));
|
||||
nir_shader_compiler_options *new_options = ralloc(s, nir_shader_compiler_options);
|
||||
*new_options = *s->options;
|
||||
|
||||
new_options->lower_extract_byte = true;
|
||||
new_options->lower_extract_word = true;
|
||||
|
|
@ -2555,6 +2555,13 @@ ntt_fix_nir_options(struct nir_shader *s)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the NIR shader to TGSI.
|
||||
*
|
||||
* This requires some lowering of the NIR shader to prepare it for translation.
|
||||
* We take ownership of the NIR shader passed, returning a reference to the new
|
||||
* TGSI tokens instead. If you need to keep the NIR, then pass us a clone.
|
||||
*/
|
||||
const void *
|
||||
nir_to_tgsi(struct nir_shader *s,
|
||||
struct pipe_screen *screen)
|
||||
|
|
@ -2688,11 +2695,7 @@ nir_to_tgsi(struct nir_shader *s,
|
|||
ureg_destroy(c->ureg);
|
||||
|
||||
ralloc_free(c);
|
||||
|
||||
if (s->options != original_options) {
|
||||
free((void*)s->options);
|
||||
s->options = original_options;
|
||||
}
|
||||
ralloc_free(s);
|
||||
|
||||
return tgsi_tokens;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,15 +143,10 @@ softpipe_create_shader_state(struct pipe_context *pipe,
|
|||
bool debug)
|
||||
{
|
||||
if (templ->type == PIPE_SHADER_IR_NIR) {
|
||||
shader->tokens = nir_to_tgsi(templ->ir.nir, pipe->screen);
|
||||
|
||||
/* Note: Printing the final NIR after nir-to-tgsi transformed and
|
||||
* optimized it
|
||||
*/
|
||||
if (debug)
|
||||
nir_print_shader(templ->ir.nir, stderr);
|
||||
|
||||
ralloc_free(templ->ir.nir);
|
||||
shader->tokens = nir_to_tgsi(templ->ir.nir, pipe->screen);
|
||||
} else {
|
||||
assert(templ->type == PIPE_SHADER_IR_TGSI);
|
||||
/* we need to keep a local copy of the tokens */
|
||||
|
|
@ -433,7 +428,6 @@ softpipe_create_compute_state(struct pipe_context *pipe,
|
|||
nir_print_shader(s, stderr);
|
||||
|
||||
state->tokens = (void *)nir_to_tgsi(s, pipe->screen);
|
||||
ralloc_free(s);
|
||||
} else {
|
||||
assert(templ->ir_type == PIPE_SHADER_IR_TGSI);
|
||||
/* we need to keep a local copy of the tokens */
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ st_nir_finish_builtin_shader(struct st_context *st,
|
|||
screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_PREFERRED_IR)) {
|
||||
state.type = PIPE_SHADER_IR_TGSI;
|
||||
state.tokens = nir_to_tgsi(nir, screen);
|
||||
ralloc_free(nir);
|
||||
}
|
||||
|
||||
struct pipe_shader_state *shader;
|
||||
|
|
|
|||
|
|
@ -730,6 +730,7 @@ st_create_vp_variant(struct st_context *st,
|
|||
nir_print_shader(state.ir.nir, stderr);
|
||||
|
||||
/* If the driver wants TGSI, then translate before handing off. */
|
||||
|
||||
if (st->pipe->screen->get_shader_param(st->pipe->screen,
|
||||
PIPE_SHADER_VERTEX,
|
||||
PIPE_SHADER_CAP_PREFERRED_IR) !=
|
||||
|
|
@ -737,7 +738,6 @@ st_create_vp_variant(struct st_context *st,
|
|||
nir_shader *s = state.ir.nir;
|
||||
state.tokens = nir_to_tgsi(s, st->pipe->screen);
|
||||
state.type = PIPE_SHADER_IR_TGSI;
|
||||
ralloc_free(s);
|
||||
}
|
||||
|
||||
if (key->is_draw_shader)
|
||||
|
|
@ -1348,7 +1348,6 @@ st_create_fp_variant(struct st_context *st,
|
|||
nir_shader *s = state.ir.nir;
|
||||
state.tokens = nir_to_tgsi(s, st->pipe->screen);
|
||||
state.type = PIPE_SHADER_IR_TGSI;
|
||||
ralloc_free(s);
|
||||
}
|
||||
|
||||
variant->base.driver_shader = pipe->create_fs_state(pipe, &state);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue