nir: only handle flat interpolation when needed in nir_create_passthrough_gs

When turning primitives into line strips this function needs to move
attributes around, but this is not needed in other cases.

Fixes: 1a5bdca2dd ("zink: implement flat shading using inlined uniforms")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22162>
This commit is contained in:
antonino
2023-03-30 17:45:15 +02:00
committed by Marge Bot
parent 744cdf4262
commit 15b3d77b40

View File

@@ -139,6 +139,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
unsigned int vertices_out = vertices_for_prim(primitive_type);
emulate_edgeflags = emulate_edgeflags && (prev_stage->info.outputs_written & VARYING_BIT_EDGE);
bool needs_closing = (force_line_strip_out || emulate_edgeflags) && vertices_out >= 3;
enum shader_prim original_our_prim = gs_out_prim_for_topology(primitive_type);
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_GEOMETRY,
options,
"gs passthrough");
@@ -146,7 +147,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
nir_shader *nir = b.shader;
nir->info.gs.input_primitive = gs_in_prim_for_topology(primitive_type);
nir->info.gs.output_primitive = (force_line_strip_out || emulate_edgeflags) ?
SHADER_PRIM_LINE_STRIP : gs_out_prim_for_topology(primitive_type);
SHADER_PRIM_LINE_STRIP : original_our_prim;
nir->info.gs.vertices_in = vertices_out;
nir->info.gs.vertices_out = needs_closing ? vertices_out + 1 : vertices_out;
nir->info.gs.invocations = 1;
@@ -158,6 +159,8 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
nir->xfb_info = mem_dup(prev_stage->xfb_info, sizeof(nir_xfb_info));
}
bool handle_flat = nir->info.gs.output_primitive == SHADER_PRIM_LINE_STRIP &&
nir->info.gs.output_primitive != original_our_prim;
nir_variable *in_vars[VARYING_SLOT_MAX];
nir_variable *out_vars[VARYING_SLOT_MAX];
unsigned num_inputs = 0, num_outputs = 0;
@@ -252,7 +255,7 @@ nir_create_passthrough_gs(const nir_shader_compiler_options *options,
}
/* no need to use copy_var to save a lower pass */
nir_ssa_def *index;
if (in_vars[j]->data.location == VARYING_SLOT_POS)
if (in_vars[j]->data.location == VARYING_SLOT_POS || !handle_flat)
index = nir_imm_int(&b, idx);
else {
unsigned mask = 1u << (of++);