mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 14:20:35 +01:00
nir,radeonsi: simplify load_color0 & load_color1 intrinsics and shader_info
We don't need the shader_info fields anymore. sample and centroid fields are unused. The interp field is already available from si_shader_info::color_interpolate. The loads don't need to be sysvals. Add also the _amd suffix. Don't handle it in st_nir_lower_drawpixels either because the intrinsics are created much later in compilation now. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38802>
This commit is contained in:
parent
86fc413098
commit
99a42bdd4b
12 changed files with 18 additions and 100 deletions
|
|
@ -2466,10 +2466,6 @@ nir_intrinsic_from_system_value(gl_system_value val)
|
|||
return nir_intrinsic_load_patch_vertices_in;
|
||||
case SYSTEM_VALUE_HELPER_INVOCATION:
|
||||
return nir_intrinsic_load_helper_invocation;
|
||||
case SYSTEM_VALUE_COLOR0:
|
||||
return nir_intrinsic_load_color0;
|
||||
case SYSTEM_VALUE_COLOR1:
|
||||
return nir_intrinsic_load_color1;
|
||||
case SYSTEM_VALUE_VIEW_INDEX:
|
||||
return nir_intrinsic_load_view_index;
|
||||
case SYSTEM_VALUE_AMPLIFICATION_ID_KK:
|
||||
|
|
@ -2650,10 +2646,6 @@ nir_system_value_from_intrinsic(nir_intrinsic_op intrin)
|
|||
return SYSTEM_VALUE_VERTICES_IN;
|
||||
case nir_intrinsic_load_helper_invocation:
|
||||
return SYSTEM_VALUE_HELPER_INVOCATION;
|
||||
case nir_intrinsic_load_color0:
|
||||
return SYSTEM_VALUE_COLOR0;
|
||||
case nir_intrinsic_load_color1:
|
||||
return SYSTEM_VALUE_COLOR1;
|
||||
case nir_intrinsic_load_view_index:
|
||||
return SYSTEM_VALUE_VIEW_INDEX;
|
||||
case nir_intrinsic_load_amplification_id_kk:
|
||||
|
|
|
|||
|
|
@ -822,8 +822,8 @@ visit_intrinsic(nir_intrinsic_instr *instr, struct divergence_state *state)
|
|||
|
||||
/* Intrinsics which are always divergent */
|
||||
case nir_intrinsic_inverse_ballot:
|
||||
case nir_intrinsic_load_color0:
|
||||
case nir_intrinsic_load_color1:
|
||||
case nir_intrinsic_load_color0_amd:
|
||||
case nir_intrinsic_load_color1_amd:
|
||||
case nir_intrinsic_load_sample_id:
|
||||
case nir_intrinsic_load_sample_mask_in:
|
||||
case nir_intrinsic_load_interpolated_input:
|
||||
|
|
|
|||
|
|
@ -687,11 +687,6 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
|
|||
shader->info.fs.accesses_pixel_local_storage = true;
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_color0:
|
||||
case nir_intrinsic_load_color1:
|
||||
shader->info.inputs_read |=
|
||||
BITFIELD64_BIT(VARYING_SLOT_COL0 << (instr->intrinsic == nir_intrinsic_load_color1));
|
||||
FALLTHROUGH;
|
||||
case nir_intrinsic_load_subgroup_size:
|
||||
case nir_intrinsic_load_subgroup_invocation:
|
||||
case nir_intrinsic_load_subgroup_eq_mask:
|
||||
|
|
|
|||
|
|
@ -1098,15 +1098,17 @@ system_value("blend_const_color_rgba", 4)
|
|||
system_value("blend_const_color_rgba8888_unorm", 1)
|
||||
system_value("blend_const_color_aaaa8888_unorm", 1)
|
||||
|
||||
# System values for gl_Color, for radeonsi which interpolates these in the
|
||||
# shader prolog to handle two-sided color without recompiles and therefore
|
||||
# doesn't handle these in the main shader part like normal varyings.
|
||||
system_value("color0", 4)
|
||||
system_value("color1", 4)
|
||||
|
||||
# System value for internal compute shaders in radeonsi.
|
||||
system_value("user_data_amd", 8)
|
||||
|
||||
# Loads for gl_Color, for radeonsi which interpolates these in the shader
|
||||
# prolog to handle flatshading and front/back color selection without
|
||||
# recompiles and therefore doesn't handle them like normal varyings.
|
||||
intrinsic("load_color0_amd", src_comp=[], dest_comp=4, indices=[],
|
||||
flags=[CAN_ELIMINATE, CAN_REORDER])
|
||||
intrinsic("load_color1_amd", src_comp=[], dest_comp=4, indices=[],
|
||||
flags=[CAN_ELIMINATE, CAN_REORDER])
|
||||
|
||||
# In a fragment shader, the current sample mask. At the beginning of the shader,
|
||||
# this is the same as load_sample_mask_in, but as the shader is executed, it may
|
||||
# be affected by writes, discards, etc.
|
||||
|
|
|
|||
|
|
@ -2890,21 +2890,6 @@ print_shader_info(const struct shader_info *info, FILE *fp)
|
|||
print_nz_bool(fp, "untyped_color_outputs", info->fs.untyped_color_outputs);
|
||||
|
||||
print_nz_unsigned(fp, "depth_layout", info->fs.depth_layout);
|
||||
|
||||
if (info->fs.color0_interp != INTERP_MODE_NONE) {
|
||||
fprintf(fp, "color0_interp: %s\n",
|
||||
glsl_interp_mode_name(info->fs.color0_interp));
|
||||
}
|
||||
print_nz_bool(fp, "color0_sample", info->fs.color0_sample);
|
||||
print_nz_bool(fp, "color0_centroid", info->fs.color0_centroid);
|
||||
|
||||
if (info->fs.color1_interp != INTERP_MODE_NONE) {
|
||||
fprintf(fp, "color1_interp: %s\n",
|
||||
glsl_interp_mode_name(info->fs.color1_interp));
|
||||
}
|
||||
print_nz_bool(fp, "color1_sample", info->fs.color1_sample);
|
||||
print_nz_bool(fp, "color1_centroid", info->fs.color1_centroid);
|
||||
|
||||
print_nz_x32(fp, "advanced_blend_modes", info->fs.advanced_blend_modes);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -366,8 +366,6 @@ gl_system_value_name(gl_system_value sysval)
|
|||
ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN),
|
||||
ENUM(SYSTEM_VALUE_LAYER_ID),
|
||||
ENUM(SYSTEM_VALUE_HELPER_INVOCATION),
|
||||
ENUM(SYSTEM_VALUE_COLOR0),
|
||||
ENUM(SYSTEM_VALUE_COLOR1),
|
||||
ENUM(SYSTEM_VALUE_TESS_COORD),
|
||||
ENUM(SYSTEM_VALUE_VERTICES_IN),
|
||||
ENUM(SYSTEM_VALUE_PRIMITIVE_ID),
|
||||
|
|
|
|||
|
|
@ -813,8 +813,6 @@ typedef enum
|
|||
SYSTEM_VALUE_SAMPLE_MASK_IN,
|
||||
SYSTEM_VALUE_LAYER_ID,
|
||||
SYSTEM_VALUE_HELPER_INVOCATION,
|
||||
SYSTEM_VALUE_COLOR0,
|
||||
SYSTEM_VALUE_COLOR1,
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -492,17 +492,6 @@ typedef struct shader_info {
|
|||
/** gl_FragDepth layout for ARB_conservative_depth. */
|
||||
enum gl_frag_depth_layout depth_layout:3;
|
||||
|
||||
/**
|
||||
* Interpolation qualifiers for drivers that lowers color inputs
|
||||
* to system values.
|
||||
*/
|
||||
unsigned color0_interp:3; /* glsl_interp_mode */
|
||||
bool color0_sample:1;
|
||||
bool color0_centroid:1;
|
||||
unsigned color1_interp:3; /* glsl_interp_mode */
|
||||
bool color1_sample:1;
|
||||
bool color1_centroid:1;
|
||||
|
||||
/* Bitmask of gl_advanced_blend_mode values that may be used with this
|
||||
* shader.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -564,12 +564,12 @@ static bool lower_intrinsic(nir_builder *b, nir_instr *instr, struct lower_abi_s
|
|||
case nir_intrinsic_load_alpha_reference_amd:
|
||||
replacement = ac_nir_load_arg(b, &args->ac, args->alpha_reference);
|
||||
break;
|
||||
case nir_intrinsic_load_color0:
|
||||
case nir_intrinsic_load_color1: {
|
||||
case nir_intrinsic_load_color0_amd:
|
||||
case nir_intrinsic_load_color1_amd: {
|
||||
uint32_t colors_read = sel->info.colors_read;
|
||||
|
||||
int start, offset;
|
||||
if (intrin->intrinsic == nir_intrinsic_load_color0) {
|
||||
if (intrin->intrinsic == nir_intrinsic_load_color0_amd) {
|
||||
start = 0;
|
||||
offset = 0;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,6 @@ 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.
|
||||
*/
|
||||
bool color0_interp_mode_set = false;
|
||||
bool color1_interp_mode_set = false;
|
||||
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
|
|
@ -35,45 +29,14 @@ bool si_nir_lower_color_inputs_to_sysvals(nir_shader *nir)
|
|||
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_def_as_intrinsic(intrin->src[0].ssa);
|
||||
|
||||
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 both flat and non-flat are used, set non-flat. */
|
||||
if (!color0_interp_mode_set || interp != INTERP_MODE_FLAT)
|
||||
nir->info.fs.color0_interp = interp;
|
||||
nir->info.fs.color0_sample = sample;
|
||||
nir->info.fs.color0_centroid = centroid;
|
||||
color0_interp_mode_set = true;
|
||||
load = nir_load_color0_amd(&b, 32);
|
||||
} else {
|
||||
assert(sem.location == VARYING_SLOT_COL1);
|
||||
load = nir_load_color1(&b);
|
||||
/* If both flat and non-flat are used, set non-flat. */
|
||||
if (!color1_interp_mode_set || interp != INTERP_MODE_FLAT)
|
||||
nir->info.fs.color1_interp = interp;
|
||||
nir->info.fs.color1_sample = sample;
|
||||
nir->info.fs.color1_centroid = centroid;
|
||||
color1_interp_mode_set = true;
|
||||
load = nir_load_color1_amd(&b, 32);
|
||||
}
|
||||
|
||||
if (intrin->num_components != 4) {
|
||||
|
|
|
|||
|
|
@ -132,11 +132,11 @@ void si_get_shader_variant_info(struct si_shader *shader,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case nir_intrinsic_load_color0:
|
||||
case nir_intrinsic_load_color0_amd:
|
||||
assert(!shader->is_monolithic);
|
||||
shader->info.ps_colors_read |= nir_def_components_read(&intr->def);
|
||||
break;
|
||||
case nir_intrinsic_load_color1:
|
||||
case nir_intrinsic_load_color1_amd:
|
||||
assert(!shader->is_monolithic);
|
||||
shader->info.ps_colors_read |= nir_def_components_read(&intr->def) << 4;
|
||||
break;
|
||||
|
|
@ -273,8 +273,7 @@ void si_get_shader_variant_info(struct si_shader *shader,
|
|||
shader->info.ps_inputs[index].semantic =
|
||||
(back ? VARYING_SLOT_BFC0 : VARYING_SLOT_COL0) + i;
|
||||
|
||||
enum glsl_interp_mode mode = i ? nir->info.fs.color1_interp
|
||||
: nir->info.fs.color0_interp;
|
||||
enum glsl_interp_mode mode = shader->selector->info.color_interpolate[i];
|
||||
shader->info.ps_inputs[index].interpolate =
|
||||
mode == INTERP_MODE_NONE ? INTERP_MODE_COLOR : mode;
|
||||
index++;
|
||||
|
|
|
|||
|
|
@ -199,9 +199,6 @@ lower_drawpixels_instr(nir_builder *b, nir_instr *instr, void *cb_data)
|
|||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
switch (intr->intrinsic) {
|
||||
case nir_intrinsic_load_color0:
|
||||
return lower_color(b, state, intr);
|
||||
|
||||
case nir_intrinsic_load_interpolated_input:
|
||||
case nir_intrinsic_load_input: {
|
||||
if (nir_intrinsic_io_semantics(intr).location == VARYING_SLOT_TEX0)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue