mirror of https://gitlab.freedesktop.org/mesa/mesa
asahi: mv vertex_id_for_topology_class into GS lowering
not used with tess. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
parent
a76e8447ac
commit
5af1828440
|
@ -167,6 +167,41 @@ load_instance_id(nir_builder *b)
|
||||||
return nir_channel(b, nir_load_global_invocation_id(b, 32), 1);
|
return nir_channel(b, nir_load_global_invocation_id(b, 32), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Geometry shaders use software input assembly. The software vertex shader
|
||||||
|
* is invoked for each index, and the geometry shader applies the topology. This
|
||||||
|
* helper applies the topology.
|
||||||
|
*/
|
||||||
|
static nir_def *
|
||||||
|
vertex_id_for_topology_class(nir_builder *b, nir_def *vert, enum mesa_prim cls)
|
||||||
|
{
|
||||||
|
nir_def *prim = nir_load_primitive_id(b);
|
||||||
|
nir_def *flatshade_first = nir_ieq_imm(b, nir_load_provoking_last(b), 0);
|
||||||
|
nir_def *nr = nir_load_num_vertices(b);
|
||||||
|
nir_def *topology = nir_load_input_topology_agx(b);
|
||||||
|
|
||||||
|
switch (cls) {
|
||||||
|
case MESA_PRIM_POINTS:
|
||||||
|
return prim;
|
||||||
|
|
||||||
|
case MESA_PRIM_LINES:
|
||||||
|
return libagx_vertex_id_for_line_class(b, topology, prim, vert, nr);
|
||||||
|
|
||||||
|
case MESA_PRIM_TRIANGLES:
|
||||||
|
return libagx_vertex_id_for_tri_class(b, topology, prim, vert,
|
||||||
|
flatshade_first);
|
||||||
|
|
||||||
|
case MESA_PRIM_LINES_ADJACENCY:
|
||||||
|
return libagx_vertex_id_for_line_adj_class(b, topology, prim, vert);
|
||||||
|
|
||||||
|
case MESA_PRIM_TRIANGLES_ADJACENCY:
|
||||||
|
return libagx_vertex_id_for_tri_adj_class(b, topology, prim, vert, nr,
|
||||||
|
flatshade_first);
|
||||||
|
|
||||||
|
default:
|
||||||
|
unreachable("invalid topology class");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nir_def *
|
nir_def *
|
||||||
agx_load_per_vertex_input(nir_builder *b, nir_intrinsic_instr *intr,
|
agx_load_per_vertex_input(nir_builder *b, nir_intrinsic_instr *intr,
|
||||||
nir_def *vertex)
|
nir_def *vertex)
|
||||||
|
@ -193,7 +228,7 @@ lower_gs_inputs(nir_builder *b, nir_intrinsic_instr *intr, void *_)
|
||||||
|
|
||||||
/* Calculate the vertex ID we're pulling, based on the topology class */
|
/* Calculate the vertex ID we're pulling, based on the topology class */
|
||||||
nir_def *vert_in_prim = intr->src[0].ssa;
|
nir_def *vert_in_prim = intr->src[0].ssa;
|
||||||
nir_def *vertex = agx_vertex_id_for_topology_class(
|
nir_def *vertex = vertex_id_for_topology_class(
|
||||||
b, vert_in_prim, b->shader->info.gs.input_primitive);
|
b, vert_in_prim, b->shader->info.gs.input_primitive);
|
||||||
|
|
||||||
/* The unrolled vertex ID uses the input_vertices, which differs from what
|
/* The unrolled vertex ID uses the input_vertices, which differs from what
|
||||||
|
|
|
@ -23,10 +23,6 @@ struct nir_def *agx_load_per_vertex_input(struct nir_builder *b,
|
||||||
nir_intrinsic_instr *intr,
|
nir_intrinsic_instr *intr,
|
||||||
struct nir_def *vertex);
|
struct nir_def *vertex);
|
||||||
|
|
||||||
struct nir_def *agx_vertex_id_for_topology_class(struct nir_builder *b,
|
|
||||||
struct nir_def *vert,
|
|
||||||
enum mesa_prim clas);
|
|
||||||
|
|
||||||
bool agx_nir_lower_index_buffer(struct nir_shader *s, unsigned index_size_B,
|
bool agx_nir_lower_index_buffer(struct nir_shader *s, unsigned index_size_B,
|
||||||
bool patches);
|
bool patches);
|
||||||
|
|
||||||
|
|
|
@ -15,43 +15,10 @@
|
||||||
#include "shader_enums.h"
|
#include "shader_enums.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file implements input assembly in software for geometry/tessellation
|
* This file implements basic input assembly in software. It runs on software
|
||||||
* shaders. load_vertex_id is lowered based on the topology. Most of the logic
|
* vertex shaders, as part of geometry/tessellation lowering. It does not apply
|
||||||
* lives in CL library routines.
|
* the topology, which happens in the geometry shader.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nir_def *
|
|
||||||
agx_vertex_id_for_topology_class(nir_builder *b, nir_def *vert,
|
|
||||||
enum mesa_prim cls)
|
|
||||||
{
|
|
||||||
nir_def *prim = nir_load_primitive_id(b);
|
|
||||||
nir_def *flatshade_first = nir_ieq_imm(b, nir_load_provoking_last(b), 0);
|
|
||||||
nir_def *nr = nir_load_num_vertices(b);
|
|
||||||
nir_def *topology = nir_load_input_topology_agx(b);
|
|
||||||
|
|
||||||
switch (cls) {
|
|
||||||
case MESA_PRIM_POINTS:
|
|
||||||
return prim;
|
|
||||||
|
|
||||||
case MESA_PRIM_LINES:
|
|
||||||
return libagx_vertex_id_for_line_class(b, topology, prim, vert, nr);
|
|
||||||
|
|
||||||
case MESA_PRIM_TRIANGLES:
|
|
||||||
return libagx_vertex_id_for_tri_class(b, topology, prim, vert,
|
|
||||||
flatshade_first);
|
|
||||||
|
|
||||||
case MESA_PRIM_LINES_ADJACENCY:
|
|
||||||
return libagx_vertex_id_for_line_adj_class(b, topology, prim, vert);
|
|
||||||
|
|
||||||
case MESA_PRIM_TRIANGLES_ADJACENCY:
|
|
||||||
return libagx_vertex_id_for_tri_adj_class(b, topology, prim, vert, nr,
|
|
||||||
flatshade_first);
|
|
||||||
|
|
||||||
default:
|
|
||||||
unreachable("invalid topology class");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct state {
|
struct state {
|
||||||
unsigned index_size;
|
unsigned index_size;
|
||||||
bool patches;
|
bool patches;
|
||||||
|
|
Loading…
Reference in New Issue