mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 07:30:37 +02:00
nir: move nir_lower_color_inputs into radeonsi
it's the only user Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34492>
This commit is contained in:
parent
70aa58cc95
commit
deda05e2b7
6 changed files with 94 additions and 100 deletions
|
|
@ -5006,7 +5006,6 @@ bool nir_lower_io(nir_shader *shader,
|
|||
nir_lower_io_options);
|
||||
|
||||
bool nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes);
|
||||
bool nir_lower_color_inputs(nir_shader *nir);
|
||||
void nir_lower_io_passes(nir_shader *nir, bool renumber_vs_inputs);
|
||||
bool nir_io_add_intrinsic_xfb_info(nir_shader *nir);
|
||||
|
||||
|
|
|
|||
|
|
@ -3230,90 +3230,6 @@ nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes)
|
|||
return progress;
|
||||
}
|
||||
|
||||
bool
|
||||
nir_lower_color_inputs(nir_shader *nir)
|
||||
{
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
bool progress = false;
|
||||
|
||||
/* Both flat and non-flat can occur with nir_io_mix_convergent_flat_with_interpolated,
|
||||
* but we want to save only the non-flat interp mode in that case.
|
||||
*
|
||||
* Start with flat and set to non-flat only if it's present.
|
||||
*/
|
||||
nir->info.fs.color0_interp = INTERP_MODE_FLAT;
|
||||
nir->info.fs.color1_interp = INTERP_MODE_FLAT;
|
||||
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||
|
||||
if (intrin->intrinsic != nir_intrinsic_load_input &&
|
||||
intrin->intrinsic != nir_intrinsic_load_interpolated_input)
|
||||
continue;
|
||||
|
||||
nir_io_semantics sem = nir_intrinsic_io_semantics(intrin);
|
||||
|
||||
if (sem.location != VARYING_SLOT_COL0 &&
|
||||
sem.location != VARYING_SLOT_COL1)
|
||||
continue;
|
||||
|
||||
/* Default to FLAT (for load_input) */
|
||||
enum glsl_interp_mode interp = INTERP_MODE_FLAT;
|
||||
bool sample = false;
|
||||
bool centroid = false;
|
||||
|
||||
if (intrin->intrinsic == nir_intrinsic_load_interpolated_input) {
|
||||
nir_intrinsic_instr *baryc =
|
||||
nir_instr_as_intrinsic(intrin->src[0].ssa->parent_instr);
|
||||
|
||||
centroid =
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_centroid;
|
||||
sample =
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_sample;
|
||||
assert(centroid || sample ||
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_pixel);
|
||||
|
||||
interp = nir_intrinsic_interp_mode(baryc);
|
||||
}
|
||||
|
||||
b.cursor = nir_before_instr(instr);
|
||||
nir_def *load = NULL;
|
||||
|
||||
if (sem.location == VARYING_SLOT_COL0) {
|
||||
load = nir_load_color0(&b);
|
||||
if (interp != INTERP_MODE_FLAT)
|
||||
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);
|
||||
if (interp != INTERP_MODE_FLAT)
|
||||
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_def_replace(&intrin->def, load);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
return nir_progress(progress, impl, nir_metadata_control_flow);
|
||||
}
|
||||
|
||||
bool
|
||||
nir_io_add_intrinsic_xfb_info(nir_shader *nir)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ files_libradeonsi = files(
|
|||
'si_nir_clamp_shadow_comparison_value.c',
|
||||
'si_nir_kill_outputs.c',
|
||||
'si_nir_lower_abi.c',
|
||||
'si_nir_lower_color_inputs_to_sysvals.c',
|
||||
'si_nir_lower_polygon_stipple.c',
|
||||
'si_nir_lower_ps_color_inputs.c',
|
||||
'si_nir_lower_resource.c',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
/* Copyright 2025 Advanced Micro Devices, Inc.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "si_shader_internal.h"
|
||||
#include "nir_builder.h"
|
||||
|
||||
bool si_nir_lower_color_inputs_to_sysvals(nir_shader *nir)
|
||||
{
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
bool progress = false;
|
||||
|
||||
/* Both flat and non-flat can occur with nir_io_mix_convergent_flat_with_interpolated,
|
||||
* but we want to save only the non-flat interp mode in that case.
|
||||
*
|
||||
* Start with flat and set to non-flat only if it's present.
|
||||
*/
|
||||
nir->info.fs.color0_interp = INTERP_MODE_FLAT;
|
||||
nir->info.fs.color1_interp = INTERP_MODE_FLAT;
|
||||
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||
|
||||
if (intrin->intrinsic != nir_intrinsic_load_input &&
|
||||
intrin->intrinsic != nir_intrinsic_load_interpolated_input)
|
||||
continue;
|
||||
|
||||
nir_io_semantics sem = nir_intrinsic_io_semantics(intrin);
|
||||
|
||||
if (sem.location != VARYING_SLOT_COL0 &&
|
||||
sem.location != VARYING_SLOT_COL1)
|
||||
continue;
|
||||
|
||||
/* Default to FLAT (for load_input) */
|
||||
enum glsl_interp_mode interp = INTERP_MODE_FLAT;
|
||||
bool sample = false;
|
||||
bool centroid = false;
|
||||
|
||||
if (intrin->intrinsic == nir_intrinsic_load_interpolated_input) {
|
||||
nir_intrinsic_instr *baryc =
|
||||
nir_instr_as_intrinsic(intrin->src[0].ssa->parent_instr);
|
||||
|
||||
centroid =
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_centroid;
|
||||
sample =
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_sample;
|
||||
assert(centroid || sample ||
|
||||
baryc->intrinsic == nir_intrinsic_load_barycentric_pixel);
|
||||
|
||||
interp = nir_intrinsic_interp_mode(baryc);
|
||||
}
|
||||
|
||||
b.cursor = nir_before_instr(instr);
|
||||
nir_def *load = NULL;
|
||||
|
||||
if (sem.location == VARYING_SLOT_COL0) {
|
||||
load = nir_load_color0(&b);
|
||||
if (interp != INTERP_MODE_FLAT)
|
||||
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);
|
||||
if (interp != INTERP_MODE_FLAT)
|
||||
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_def_replace(&intrin->def, load);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
return nir_progress(progress, impl, nir_metadata_control_flow);
|
||||
}
|
||||
|
|
@ -142,29 +142,18 @@ bool gfx10_ngg_calculate_subgroup_info(struct si_shader *shader);
|
|||
struct nir_def;
|
||||
typedef struct nir_def nir_def;
|
||||
|
||||
/* si_nir_clamp_shadow_comparison_value.c */
|
||||
/* si_nir_*.c */
|
||||
bool si_nir_clamp_shadow_comparison_value(nir_shader *nir);
|
||||
|
||||
/* si_nir_kill_outputs.c */
|
||||
bool si_nir_kill_outputs(nir_shader *nir, const union si_shader_key *key);
|
||||
|
||||
/* si_nir_lower_abi.c */
|
||||
nir_def *si_nir_load_internal_binding(nir_builder *b, struct si_shader_args *args,
|
||||
unsigned slot, unsigned num_components);
|
||||
bool si_nir_lower_abi(nir_shader *nir, struct si_shader *shader, struct si_shader_args *args);
|
||||
|
||||
/* si_nir_lower_polygon_stipple.c */
|
||||
bool si_nir_lower_color_inputs_to_sysvals(nir_shader *nir);
|
||||
bool si_nir_lower_polygon_stipple(nir_shader *nir);
|
||||
|
||||
/* si_nir_lower_ps_color_inputs.c */
|
||||
bool si_nir_lower_ps_color_inputs(nir_shader *nir, const union si_shader_key *key,
|
||||
const struct si_shader_info *info);
|
||||
|
||||
/* si_nir_lower_resource.c */
|
||||
bool si_nir_lower_resource(nir_shader *nir, struct si_shader *shader,
|
||||
struct si_shader_args *args);
|
||||
|
||||
/* si_nir_lower_vs_inputs.c */
|
||||
bool si_nir_lower_vs_inputs(nir_shader *nir, struct si_shader *shader,
|
||||
struct si_shader_args *args);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "si_pipe.h"
|
||||
#include "ac_nir.h"
|
||||
#include "aco_interface.h"
|
||||
|
||||
#include "si_shader_internal.h"
|
||||
|
||||
bool si_alu_to_scalar_packed_math_filter(const nir_instr *instr, const void *data)
|
||||
{
|
||||
|
|
@ -414,7 +414,7 @@ char *si_finalize_nir(struct pipe_screen *screen, struct nir_shader *nir)
|
|||
}
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
NIR_PASS_V(nir, nir_lower_color_inputs);
|
||||
NIR_PASS_V(nir, si_nir_lower_color_inputs_to_sysvals);
|
||||
|
||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue