nir/zink: drop NIH helper in favor of mesa_vertices_per_prim

`lower_pv_mode_vertices_for_prim` and `decomposed_primitive_size` return
the same values as `mesa_vertices_per_prim` for the primitives that can
be used as output in geometry shaders.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26117>
This commit is contained in:
antonino
2023-11-06 12:26:23 +01:00
committed by Marge Bot
parent f4f4d80096
commit 0976dfeca2
2 changed files with 5 additions and 33 deletions

View File

@@ -69,21 +69,6 @@ struct state {
bool progress; bool progress;
}; };
static unsigned
decomposed_primitive_size(nir_builder *b)
{
enum mesa_prim outprim = b->shader->info.gs.output_primitive;
if (outprim == MESA_PRIM_POINTS)
return 1;
else if (outprim == MESA_PRIM_LINE_STRIP)
return 2;
else if (outprim == MESA_PRIM_TRIANGLE_STRIP)
return 3;
else
unreachable("Invalid GS output primitive type.");
}
/** /**
* Replace emit_vertex intrinsics with: * Replace emit_vertex intrinsics with:
* *
@@ -158,7 +143,8 @@ rewrite_emit_vertex(nir_intrinsic_instr *intrin, struct state *state)
/* We form a new primitive for every vertex emitted after the first /* We form a new primitive for every vertex emitted after the first
* complete primitive (since we're outputting strips). * complete primitive (since we're outputting strips).
*/ */
unsigned min_verts = decomposed_primitive_size(b); unsigned min_verts =
mesa_vertices_per_prim(b->shader->info.gs.output_primitive);
nir_def *new_prim = nir_uge_imm(b, vtx_per_prim_cnt, min_verts); nir_def *new_prim = nir_uge_imm(b, vtx_per_prim_cnt, min_verts);
/* Increment the decomposed primitive count by 1 if we formed a complete /* Increment the decomposed primitive count by 1 if we formed a complete
@@ -200,7 +186,8 @@ overwrite_incomplete_primitives(struct state *state, unsigned stream)
assert(state->count_vtx_per_prim); assert(state->count_vtx_per_prim);
nir_builder *b = state->builder; nir_builder *b = state->builder;
unsigned outprim_min_vertices = decomposed_primitive_size(b); unsigned outprim_min_vertices =
mesa_vertices_per_prim(b->shader->info.gs.output_primitive);
/* Total count of vertices emitted so far. */ /* Total count of vertices emitted so far. */
nir_def *vtxcnt_total = nir_def *vtxcnt_total =

View File

@@ -484,21 +484,6 @@ lower_pv_mode_gs_instr(nir_builder *b, nir_instr *instr, void *data)
} }
} }
static unsigned int
lower_pv_mode_vertices_for_prim(enum mesa_prim prim)
{
switch (prim) {
case MESA_PRIM_POINTS:
return 1;
case MESA_PRIM_LINE_STRIP:
return 2;
case MESA_PRIM_TRIANGLE_STRIP:
return 3;
default:
unreachable("unsupported primitive for gs output");
}
}
static bool static bool
lower_pv_mode_gs(nir_shader *shader, unsigned prim) lower_pv_mode_gs(nir_shader *shader, unsigned prim)
{ {
@@ -510,7 +495,7 @@ lower_pv_mode_gs(nir_shader *shader, unsigned prim)
b = nir_builder_at(nir_before_impl(entry)); b = nir_builder_at(nir_before_impl(entry));
state.primitive_vert_count = state.primitive_vert_count =
lower_pv_mode_vertices_for_prim(shader->info.gs.output_primitive); mesa_vertices_per_prim(shader->info.gs.output_primitive);
state.ring_size = shader->info.gs.vertices_out; state.ring_size = shader->info.gs.vertices_out;
nir_foreach_variable_with_modes(var, shader, nir_var_shader_out) { nir_foreach_variable_with_modes(var, shader, nir_var_shader_out) {