treewide: Merge num_mesh_vertices_per_primitive and u_vertices_per_prim into mesa_vertices_per_prim

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25880>
This commit is contained in:
Yonggang Luo 2023-10-10 05:22:15 +08:00 committed by Marge Bot
parent be431e0dc7
commit 43715516fc
22 changed files with 24 additions and 73 deletions

View file

@ -4912,7 +4912,7 @@ ac_nir_lower_ngg_ms(nir_shader *shader,
bool fast_launch_2)
{
unsigned vertices_per_prim =
num_mesh_vertices_per_primitive(shader->info.mesh.primitive_type);
mesa_vertices_per_prim(shader->info.mesh.primitive_type);
uint64_t per_vertex_outputs =
shader->info.outputs_written & ~shader->info.per_primitive_outputs & ~SPECIAL_MS_OUT_MASK;

View file

@ -33,7 +33,6 @@
#include "nir/nir_serialize.h"
#include "util/u_atomic.h"
#include "util/u_prim.h"
#include "util/os_time.h"
#include "util/u_helpers.h"
@ -2211,7 +2210,7 @@ pipeline_add_multiview_gs(struct v3dv_pipeline *pipeline,
nir->info.outputs_written = vs_nir->info.outputs_written |
(1ull << VARYING_SLOT_LAYER);
uint32_t vertex_count = u_vertices_per_prim(pipeline->topology);
uint32_t vertex_count = mesa_vertices_per_prim(pipeline->topology);
nir->info.gs.input_primitive =
multiview_gs_input_primitive_from_pipeline(pipeline);
nir->info.gs.output_primitive =

View file

@ -22,7 +22,6 @@
*/
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "nir.h"
#include "nir_builder.h"
#include "nir_xfb_info.h"
@ -138,7 +137,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 ? MESA_PRIM_LINE_STRIP : original_our_prim;
nir->info.gs.vertices_in = u_vertices_per_prim(primitive_type);
nir->info.gs.vertices_in = mesa_vertices_per_prim(primitive_type);
nir->info.gs.vertices_out = needs_closing ? vertices_out + 1 : vertices_out;
nir->info.gs.invocations = 1;
nir->info.gs.active_stream_mask = 1;

View file

@ -434,7 +434,7 @@ gl_frag_result_name(gl_frag_result result)
}
unsigned
num_mesh_vertices_per_primitive(enum mesa_prim prim)
mesa_vertices_per_prim(enum mesa_prim prim)
{
switch(prim) {
case MESA_PRIM_POINTS:

View file

@ -1191,7 +1191,7 @@ enum ENUM_PACKED mesa_prim
/**
* Number of vertices per primitive as seen by a geometry or mesh shader.
*/
unsigned num_mesh_vertices_per_primitive(enum mesa_prim prim);
unsigned mesa_vertices_per_prim(enum mesa_prim prim);
/**
* A compare function enum for use in compiler lowering passes. This is in

View file

@ -5996,7 +5996,7 @@ vtn_handle_write_packed_primitive_indices(struct vtn_builder *b, SpvOp opcode,
if (!indices) {
unsigned vertices_per_prim =
num_mesh_vertices_per_primitive(b->shader->info.mesh.primitive_type);
mesa_vertices_per_prim(b->shader->info.mesh.primitive_type);
unsigned max_prim_indices =
vertices_per_prim * b->shader->info.mesh.max_primitives_out;
const struct glsl_type *t =

View file

@ -35,7 +35,6 @@
#include "draw/draw_private.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "pipe/p_defines.h"
@ -187,7 +186,7 @@ draw_mesh_prim_run(struct draw_context *draw,
struct draw_mesh_prim *asmblr = &asmblr_mesh;
unsigned start, i;
unsigned max_primitives = input_prims->primitive_count;
unsigned max_verts = u_vertices_per_prim(input_prims->prim) * max_primitives;
unsigned max_verts = mesa_vertices_per_prim(input_prims->prim) * max_primitives;
asmblr->output_prims = output_prims;
asmblr->output_verts = output_verts;

View file

@ -276,7 +276,7 @@ draw_prim_assembler_run(struct draw_context *draw,
MESA_PRIM_QUADS : u_reduced_prim(input_prims->prim);
unsigned max_primitives = u_decomposed_prims_for_vertices(
input_prims->prim, input_prims->count);
unsigned max_verts = u_vertices_per_prim(assembled_prim) * max_primitives;
unsigned max_verts = mesa_vertices_per_prim(assembled_prim) * max_primitives;
asmblr->output_prims = output_prims;
asmblr->output_verts = output_verts;

View file

@ -41,7 +41,6 @@
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_info.h"
@ -1169,7 +1168,7 @@ emit_fetch_gs_input(
/*
* A fixed 6 should do as well (which is what we allocate).
*/
int index_limit = u_vertices_per_prim(info->properties[TGSI_PROPERTY_GS_INPUT_PRIM]);
int index_limit = mesa_vertices_per_prim(info->properties[TGSI_PROPERTY_GS_INPUT_PRIM]);
vertex_index = get_indirect_index(bld,
reg->Register.File,
reg->Dimension.Index,

View file

@ -27,7 +27,6 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "cso_cache/cso_hash.h"
#include "tgsi_sanity.h"
#include "tgsi_info.h"
@ -490,7 +489,7 @@ iter_property(
if (iter->processor.Processor == PIPE_SHADER_GEOMETRY &&
prop->Property.PropertyName == TGSI_PROPERTY_GS_INPUT_PRIM) {
ctx->implied_array_size = u_vertices_per_prim(prop->u[0].Data);
ctx->implied_array_size = mesa_vertices_per_prim(prop->u[0].Data);
}
if (iter->processor.Processor == PIPE_SHADER_TESS_CTRL &&
prop->Property.PropertyName == TGSI_PROPERTY_TCS_VERTICES_OUT)

View file

@ -37,7 +37,6 @@
#include "util/u_debug.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "tgsi/tgsi_info.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
@ -656,7 +655,7 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
if (procType == PIPE_SHADER_GEOMETRY) {
unsigned input_primitive =
info->properties[TGSI_PROPERTY_GS_INPUT_PRIM];
int num_verts = u_vertices_per_prim(input_primitive);
int num_verts = mesa_vertices_per_prim(input_primitive);
int j;
info->file_count[TGSI_FILE_INPUT] = num_verts;
info->file_max[TGSI_FILE_INPUT] =

View file

@ -27,7 +27,6 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/strtod.h"
@ -1758,7 +1757,7 @@ static bool parse_property( struct translate_ctx *ctx )
}
if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM &&
ctx->processor == PIPE_SHADER_GEOMETRY) {
ctx->implied_array_size = u_vertices_per_prim(values[0]);
ctx->implied_array_size = mesa_vertices_per_prim(values[0]);
}
break;
case TGSI_PROPERTY_FS_COORD_ORIGIN:

View file

@ -181,42 +181,6 @@ u_trim_pipe_prim(enum mesa_prim pipe_prim, unsigned *nr)
}
}
static inline unsigned
u_vertices_per_prim(enum mesa_prim primitive)
{
switch(primitive) {
case MESA_PRIM_POINTS:
return 1;
case MESA_PRIM_LINES:
case MESA_PRIM_LINE_LOOP:
case MESA_PRIM_LINE_STRIP:
return 2;
case MESA_PRIM_TRIANGLES:
case MESA_PRIM_TRIANGLE_STRIP:
case MESA_PRIM_TRIANGLE_FAN:
return 3;
case MESA_PRIM_LINES_ADJACENCY:
case MESA_PRIM_LINE_STRIP_ADJACENCY:
return 4;
case MESA_PRIM_TRIANGLES_ADJACENCY:
case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
return 6;
case MESA_PRIM_QUADS:
case MESA_PRIM_QUAD_STRIP:
/* these won't be seen from geometry shaders
but prim assembly might for prim id. */
return 4;
/* following primitives should never be used
* with geometry shaders abd their size is
* undefined */
case MESA_PRIM_POLYGON:
default:
debug_printf("Unrecognized geometry shader primitive");
return 3;
}
}
/**
* Returns the number of decomposed primitives for the given

View file

@ -287,7 +287,7 @@ primitive_fits(nir_builder *b, struct agx_xfb_key *key)
/* Get the number of vertices per primitive in the current mode, usually just
* the base number but quads are tessellated.
*/
uint32_t verts_per_prim = u_vertices_per_prim(key->mode);
uint32_t verts_per_prim = mesa_vertices_per_prim(key->mode);
if (u_decomposed_prim(key->mode) == MESA_PRIM_QUADS)
verts_per_prim = 6;

View file

@ -24,7 +24,6 @@
#define FD_BO_NO_HARDPIN 1
#include "pipe/p_state.h"
#include "util/u_prim.h"
#include "freedreno_batch.h"
#include "freedreno_gmem.h"
@ -69,7 +68,7 @@ prim_count(const struct pipe_draw_info *info,
{
/* MESA_PRIM_COUNT used internally for RECTLIST blits on 3d pipe: */
unsigned vtx_per_prim =
(info->mode == MESA_PRIM_COUNT) ? 2 : u_vertices_per_prim(info->mode);
(info->mode == MESA_PRIM_COUNT) ? 2 : mesa_vertices_per_prim(info->mode);
return MAX2(1, (draw->count * info->instance_count) / vtx_per_prim);
}
@ -157,7 +156,7 @@ fd6_vsc_update_sizes(struct fd_batch *batch, const struct pipe_draw_info *info,
prim_strm_bits, draw_strm_bits, batch->num_bins_per_pipe,
info->instance_count, info->count,
(info->count * info->instance_count) /
u_vertices_per_prim(info->mode),
mesa_vertices_per_prim(info->mode),
u_prim_name(info->mode));
#endif

View file

@ -26,7 +26,6 @@
#include "util/u_memory.h"
#include "util/os_time.h"
#include "util/u_dump.h"
#include "util/u_prim.h"
#include "util/u_string.h"
#include "gallivm/lp_bld_const.h"
#include "gallivm/lp_bld_debug.h"
@ -2042,7 +2041,7 @@ lp_mesh_call_draw(struct llvmpipe_context *lp,
int vsize, int psize, int per_prim_count,
size_t prim_offset)
{
unsigned prim_len = u_vertices_per_prim(prim);
unsigned prim_len = mesa_vertices_per_prim(prim);
uint32_t *ptr = (uint32_t *)((char *)vbuf + task_out_size * task_idx);
uint32_t vertex_count = ptr[1];
uint32_t prim_count = ptr[2];

View file

@ -7,14 +7,13 @@
#include "si_pipe.h"
#include "si_query.h"
#include "si_shader_internal.h"
#include "util/u_prim.h"
unsigned gfx10_ngg_get_vertices_per_prim(struct si_shader *shader)
{
const struct si_shader_info *info = &shader->selector->info;
if (shader->selector->stage == MESA_SHADER_GEOMETRY)
return u_vertices_per_prim(info->base.gs.output_primitive);
return mesa_vertices_per_prim(info->base.gs.output_primitive);
else if (shader->selector->stage == MESA_SHADER_VERTEX) {
if (info->base.vs.blit_sgprs_amd) {
/* Blits always use axis-aligned rectangles with 3 vertices. */
@ -86,7 +85,7 @@ bool gfx10_ngg_calculate_subgroup_info(struct si_shader *shader)
const unsigned input_prim = si_get_input_prim(gs_sel, &shader->key);
const bool use_adjacency =
input_prim >= MESA_PRIM_LINES_ADJACENCY && input_prim <= MESA_PRIM_TRIANGLE_STRIP_ADJACENCY;
const unsigned max_verts_per_prim = u_vertices_per_prim(input_prim);
const unsigned max_verts_per_prim = mesa_vertices_per_prim(input_prim);
const unsigned min_verts_per_prim = gs_stage == MESA_SHADER_GEOMETRY ? max_verts_per_prim : 1;
/* All these are in dwords. The maximum is 16K dwords (64KB) of LDS per workgroup. */

View file

@ -5,7 +5,6 @@
*/
#include "nir_builder.h"
#include "util/u_prim.h"
#include "ac_nir.h"
#include "si_pipe.h"
@ -41,7 +40,7 @@ static nir_def *get_num_vert_per_prim(nir_builder *b, struct si_shader *shader,
unsigned num_vertices;
if (stage == MESA_SHADER_GEOMETRY) {
num_vertices = u_vertices_per_prim(info->base.gs.output_primitive);
num_vertices = mesa_vertices_per_prim(info->base.gs.output_primitive);
} else if (stage == MESA_SHADER_VERTEX) {
if (info->base.vs.blit_sgprs_amd)
num_vertices = 3;

View file

@ -7,7 +7,6 @@
#include "si_pipe.h"
#include "si_shader_internal.h"
#include "util/mesa-sha1.h"
#include "util/u_prim.h"
#include "sid.h"
#include "nir.h"
@ -797,7 +796,7 @@ void si_nir_scan_shader(struct si_screen *sscreen, const struct nir_shader *nir,
info->gsvs_vertex_size = info->num_outputs * 16;
info->max_gsvs_emit_size = info->gsvs_vertex_size * info->base.gs.vertices_out;
info->gs_input_verts_per_prim =
u_vertices_per_prim((enum mesa_prim)info->base.gs.input_primitive);
mesa_vertices_per_prim((enum mesa_prim)info->base.gs.input_primitive);
}
info->clipdist_mask = info->writes_clipvertex ? SI_USER_CLIP_PLANE_MASK :

View file

@ -35,7 +35,6 @@
#include "util/hash_table.h"
#include "util/ralloc.h"
#include "util/set.h"
#include "util/u_prim.h"
#include "broadcom/clif/clif_dump.h"
void
@ -479,7 +478,7 @@ v3d_read_and_accumulate_primitive_counters(struct v3d_context *v3d)
v3d->prog.gs ? v3d->prog.gs->prog_data.gs->out_prim_type
: v3d->prim_mode;
uint32_t vertices_written =
map[V3D_PRIM_COUNTS_TF_WRITTEN] * u_vertices_per_prim(prim_mode);
map[V3D_PRIM_COUNTS_TF_WRITTEN] * mesa_vertices_per_prim(prim_mode);
for (int i = 0; i < v3d->streamout.num_targets; i++) {
v3d_stream_output_target(v3d->streamout.targets[i])->offset +=
vertices_written;

View file

@ -771,7 +771,7 @@ brw_compute_mue_map(const struct brw_compiler *compiler,
memset(&map->len_dw[0], 0, sizeof(map->len_dw));
unsigned vertices_per_primitive =
num_mesh_vertices_per_primitive(nir->info.mesh.primitive_type);
mesa_vertices_per_prim(nir->info.mesh.primitive_type);
map->max_primitives = nir->info.mesh.max_primitives_out;
map->max_vertices = nir->info.mesh.max_vertices_out;
@ -1317,7 +1317,7 @@ brw_can_pack_primitive_indices(nir_shader *nir, struct index_packing_state *stat
return false;
state->vertices_per_primitive =
num_mesh_vertices_per_primitive(nir->info.mesh.primitive_type);
mesa_vertices_per_prim(nir->info.mesh.primitive_type);
/* packing point indices doesn't help */
if (state->vertices_per_primitive == 1)
return false;

View file

@ -150,7 +150,7 @@ anv_mesh_convert_attrs_prim_to_vert(struct nir_shader *nir,
provoking_vertex = 2;
unsigned vertices_per_primitive =
num_mesh_vertices_per_primitive(nir->info.mesh.primitive_type);
mesa_vertices_per_prim(nir->info.mesh.primitive_type);
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
nir_builder b = nir_builder_at(nir_after_impl(impl));