nir: factor out nir_verts_in_output_prim helper
very useful for geometry shader lowering code. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34638>
This commit is contained in:
committed by
Marge Bot
parent
6c33b1e8c1
commit
f1aeb46a34
@@ -6447,6 +6447,13 @@ void nir_print_use_dominators(nir_use_dominance_state *state,
|
||||
nir_instr **instructions,
|
||||
unsigned num_instructions);
|
||||
|
||||
static inline unsigned
|
||||
nir_verts_in_output_prim(nir_shader *gs)
|
||||
{
|
||||
assert(gs->info.stage == MESA_SHADER_GEOMETRY);
|
||||
return mesa_vertices_per_prim(gs->info.gs.output_primitive);
|
||||
}
|
||||
|
||||
#include "nir_inline_helpers.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -142,8 +142,7 @@ rewrite_emit_vertex(nir_intrinsic_instr *intrin, struct state *state)
|
||||
/* We form a new primitive for every vertex emitted after the first
|
||||
* complete primitive (since we're outputting strips).
|
||||
*/
|
||||
unsigned min_verts =
|
||||
mesa_vertices_per_prim(b->shader->info.gs.output_primitive);
|
||||
unsigned min_verts = nir_verts_in_output_prim(b->shader);
|
||||
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
|
||||
@@ -185,8 +184,6 @@ overwrite_incomplete_primitives(struct state *state, unsigned stream)
|
||||
assert(state->count_vtx_per_prim);
|
||||
|
||||
nir_builder *b = state->builder;
|
||||
unsigned outprim_min_vertices =
|
||||
mesa_vertices_per_prim(b->shader->info.gs.output_primitive);
|
||||
|
||||
/* Total count of vertices emitted so far. */
|
||||
nir_def *vtxcnt_total =
|
||||
@@ -198,7 +195,7 @@ overwrite_incomplete_primitives(struct state *state, unsigned stream)
|
||||
|
||||
/* See if the current primitive is a incomplete */
|
||||
nir_def *is_inc_prim =
|
||||
nir_ilt_imm(b, vtxcnt_per_primitive, outprim_min_vertices);
|
||||
nir_ilt_imm(b, vtxcnt_per_primitive, nir_verts_in_output_prim(b->shader));
|
||||
|
||||
/* Number of vertices in the incomplete primitive */
|
||||
nir_def *num_inc_vtx =
|
||||
|
||||
Reference in New Issue
Block a user