mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
compiler: Extract num_mesh_vertices_per_primitive function.
Prevent code duplication. Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Marcin Ślusarz <marcin.slusarz@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15005>
This commit is contained in:
parent
32155851f1
commit
0445802ab2
4 changed files with 24 additions and 19 deletions
|
|
@ -2412,11 +2412,8 @@ ac_nir_lower_ngg_ms(nir_shader *shader,
|
|||
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||
assert(impl);
|
||||
|
||||
unsigned vertices_per_prim = 3;
|
||||
if (shader->info.mesh.primitive_type == SHADER_PRIM_POINTS)
|
||||
vertices_per_prim = 1;
|
||||
else if (shader->info.mesh.primitive_type == SHADER_PRIM_LINES)
|
||||
vertices_per_prim = 2;
|
||||
unsigned vertices_per_prim =
|
||||
num_mesh_vertices_per_primitive(shader->info.mesh.primitive_type);
|
||||
|
||||
uint64_t per_vertex_outputs = shader->info.outputs_written & ~shader->info.per_primitive_outputs
|
||||
& ~BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_COUNT)
|
||||
|
|
|
|||
|
|
@ -375,3 +375,18 @@ gl_frag_result_name(gl_frag_result result)
|
|||
STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX);
|
||||
return NAME(result);
|
||||
}
|
||||
|
||||
unsigned
|
||||
num_mesh_vertices_per_primitive(unsigned prim)
|
||||
{
|
||||
switch (prim) {
|
||||
case SHADER_PRIM_POINTS:
|
||||
return 1;
|
||||
case SHADER_PRIM_LINES:
|
||||
return 2;
|
||||
case SHADER_PRIM_TRIANGLES:
|
||||
return 3;
|
||||
default:
|
||||
unreachable("invalid mesh shader primitive type");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1045,6 +1045,11 @@ enum shader_prim
|
|||
SHADER_PRIM_UNKNOWN = (SHADER_PRIM_MAX * 2),
|
||||
};
|
||||
|
||||
/**
|
||||
* Number of vertices per mesh shader primitive.
|
||||
*/
|
||||
unsigned num_mesh_vertices_per_primitive(unsigned prim);
|
||||
|
||||
/**
|
||||
* A compare function enum for use in compiler lowering passes. This is in
|
||||
* the same order as GL's compare functions (shifted down by GL_NEVER), and is
|
||||
|
|
|
|||
|
|
@ -300,20 +300,8 @@ brw_compute_mue_map(struct nir_shader *nir, struct brw_mue_map *map)
|
|||
for (int i = 0; i < VARYING_SLOT_MAX; i++)
|
||||
map->start_dw[i] = -1;
|
||||
|
||||
unsigned vertices_per_primitive = 0;
|
||||
switch (nir->info.mesh.primitive_type) {
|
||||
case SHADER_PRIM_POINTS:
|
||||
vertices_per_primitive = 1;
|
||||
break;
|
||||
case SHADER_PRIM_LINES:
|
||||
vertices_per_primitive = 2;
|
||||
break;
|
||||
case SHADER_PRIM_TRIANGLES:
|
||||
vertices_per_primitive = 3;
|
||||
break;
|
||||
default:
|
||||
unreachable("invalid primitive type");
|
||||
}
|
||||
unsigned vertices_per_primitive =
|
||||
num_mesh_vertices_per_primitive(nir->info.mesh.primitive_type);
|
||||
|
||||
map->max_primitives = nir->info.mesh.max_primitives_out;
|
||||
map->max_vertices = nir->info.mesh.max_vertices_out;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue