mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
nir: rework nir_lower_color_inputs to work with lowered IO intrinsics
also only call it from radeonsi and remove the option Reviewed-by: Qiang Yu <yuq825@gmail.com> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21861>
This commit is contained in:
parent
28374b466c
commit
9d78fec684
4 changed files with 51 additions and 36 deletions
|
|
@ -3826,13 +3826,6 @@ typedef struct nir_shader_compiler_options {
|
||||||
*/
|
*/
|
||||||
bool lower_io_variables;
|
bool lower_io_variables;
|
||||||
|
|
||||||
/**
|
|
||||||
* Lower color inputs to load_colorN that are kind of like system values
|
|
||||||
* if lower_io_variables is also set. shader_info will contain
|
|
||||||
* the interpolation settings. This is used by nir_lower_io_passes.
|
|
||||||
*/
|
|
||||||
bool lower_fs_color_inputs;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The masks of shader stages that support indirect indexing with
|
* The masks of shader stages that support indirect indexing with
|
||||||
* load_input and store_output intrinsics. It's used when
|
* load_input and store_output intrinsics. It's used when
|
||||||
|
|
@ -4824,10 +4817,8 @@ bool nir_lower_io(nir_shader *shader,
|
||||||
nir_lower_io_options);
|
nir_lower_io_options);
|
||||||
|
|
||||||
bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
|
bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
|
||||||
|
bool nir_lower_color_inputs(nir_shader *nir);
|
||||||
void
|
void nir_lower_io_passes(nir_shader *nir);
|
||||||
nir_lower_io_passes(nir_shader *nir);
|
|
||||||
|
|
||||||
bool nir_io_add_intrinsic_xfb_info(nir_shader *nir);
|
bool nir_io_add_intrinsic_xfb_info(nir_shader *nir);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -2984,7 +2984,7 @@ nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes)
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
nir_lower_color_inputs(nir_shader *nir)
|
nir_lower_color_inputs(nir_shader *nir)
|
||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
|
|
@ -3000,32 +3000,58 @@ nir_lower_color_inputs(nir_shader *nir)
|
||||||
|
|
||||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||||
|
|
||||||
if (intrin->intrinsic != nir_intrinsic_load_deref)
|
if (intrin->intrinsic != nir_intrinsic_load_input &&
|
||||||
|
intrin->intrinsic != nir_intrinsic_load_interpolated_input)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
nir_io_semantics sem = nir_intrinsic_io_semantics(intrin);
|
||||||
if (!nir_deref_mode_is(deref, nir_var_shader_in))
|
|
||||||
|
if (sem.location != VARYING_SLOT_COL0 &&
|
||||||
|
sem.location != VARYING_SLOT_COL1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
b.cursor = nir_before_instr(instr);
|
/* Default to FLAT (for load_input) */
|
||||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
enum glsl_interp_mode interp = INTERP_MODE_FLAT;
|
||||||
nir_ssa_def *def;
|
bool sample = false;
|
||||||
|
bool centroid = false;
|
||||||
|
|
||||||
if (var->data.location == VARYING_SLOT_COL0) {
|
if (intrin->intrinsic == nir_intrinsic_load_interpolated_input) {
|
||||||
def = nir_load_color0(&b);
|
nir_intrinsic_instr *baryc =
|
||||||
nir->info.fs.color0_interp = var->data.interpolation;
|
nir_instr_as_intrinsic(intrin->src[0].ssa->parent_instr);
|
||||||
nir->info.fs.color0_sample = var->data.sample;
|
|
||||||
nir->info.fs.color0_centroid = var->data.centroid;
|
centroid =
|
||||||
} else if (var->data.location == VARYING_SLOT_COL1) {
|
baryc->intrinsic == nir_intrinsic_load_barycentric_centroid;
|
||||||
def = nir_load_color1(&b);
|
sample =
|
||||||
nir->info.fs.color1_interp = var->data.interpolation;
|
baryc->intrinsic == nir_intrinsic_load_barycentric_sample;
|
||||||
nir->info.fs.color1_sample = var->data.sample;
|
assert(centroid || sample ||
|
||||||
nir->info.fs.color1_centroid = var->data.centroid;
|
baryc->intrinsic == nir_intrinsic_load_barycentric_pixel);
|
||||||
} else {
|
|
||||||
continue;
|
interp = nir_intrinsic_interp_mode(baryc);
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa, def);
|
b.cursor = nir_before_instr(instr);
|
||||||
|
nir_ssa_def *load = NULL;
|
||||||
|
|
||||||
|
if (sem.location == VARYING_SLOT_COL0) {
|
||||||
|
load = nir_load_color0(&b);
|
||||||
|
nir->info.fs.color0_interp = interp;
|
||||||
|
nir->info.fs.color0_sample = sample;
|
||||||
|
nir->info.fs.color0_centroid = centroid;
|
||||||
|
} else {
|
||||||
|
assert(sem.location == VARYING_SLOT_COL1);
|
||||||
|
load = nir_load_color1(&b);
|
||||||
|
nir->info.fs.color1_interp = interp;
|
||||||
|
nir->info.fs.color1_sample = sample;
|
||||||
|
nir->info.fs.color1_centroid = centroid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intrin->num_components != 4) {
|
||||||
|
unsigned start = nir_intrinsic_component(intrin);
|
||||||
|
unsigned count = intrin->num_components;
|
||||||
|
load = nir_channels(&b, load, BITFIELD_RANGE(start, count));
|
||||||
|
}
|
||||||
|
|
||||||
|
nir_ssa_def_rewrite_uses(&intrin->dest.ssa, load);
|
||||||
nir_instr_remove(instr);
|
nir_instr_remove(instr);
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
|
|
@ -3154,10 +3180,6 @@ nir_lower_io_passes(nir_shader *nir)
|
||||||
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
|
NIR_PASS_V(nir, nir_lower_global_vars_to_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nir->info.stage == MESA_SHADER_FRAGMENT &&
|
|
||||||
nir->options->lower_fs_color_inputs)
|
|
||||||
NIR_PASS_V(nir, nir_lower_color_inputs);
|
|
||||||
|
|
||||||
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_out | nir_var_shader_in,
|
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_out | nir_var_shader_in,
|
||||||
type_size_vec4, nir_lower_io_lower_64bit_to_32);
|
type_size_vec4, nir_lower_io_lower_64bit_to_32);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1268,7 +1268,6 @@ void si_init_screen_get_functions(struct si_screen *sscreen)
|
||||||
nir_pack_varying_interp_loc_sample |
|
nir_pack_varying_interp_loc_sample |
|
||||||
nir_pack_varying_interp_loc_centroid,
|
nir_pack_varying_interp_loc_centroid,
|
||||||
.lower_io_variables = true,
|
.lower_io_variables = true,
|
||||||
.lower_fs_color_inputs = true,
|
|
||||||
/* HW supports indirect indexing for: | Enabled in driver
|
/* HW supports indirect indexing for: | Enabled in driver
|
||||||
* -------------------------------------------------------
|
* -------------------------------------------------------
|
||||||
* TCS inputs | Yes
|
* TCS inputs | Yes
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,9 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr)
|
||||||
nir_lower_io_passes(nir);
|
nir_lower_io_passes(nir);
|
||||||
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out, NULL);
|
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out, NULL);
|
||||||
|
|
||||||
|
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||||
|
NIR_PASS_V(nir, nir_lower_color_inputs);
|
||||||
|
|
||||||
NIR_PASS_V(nir, ac_nir_lower_subdword_loads,
|
NIR_PASS_V(nir, ac_nir_lower_subdword_loads,
|
||||||
(ac_nir_lower_subdword_options) {
|
(ac_nir_lower_subdword_options) {
|
||||||
.modes_1_comp = nir_var_mem_ubo,
|
.modes_1_comp = nir_var_mem_ubo,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue