compiler: Make u_decomposed_prims_for_vertices available to CL
For indirect geometry shader setup. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Antonino Maniscalco <antonino.maniscalco@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26056>
This commit is contained in:

committed by
Marge Bot

parent
64f7b70763
commit
a147801f9b
@@ -1235,6 +1235,57 @@ mesa_vertices_per_prim(enum mesa_prim prim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of decomposed primitives for the given
|
||||||
|
* vertex count.
|
||||||
|
* Parts of the pipline are invoked once for each triangle in
|
||||||
|
* triangle strip, triangle fans and triangles and once
|
||||||
|
* for each line in line strip, line loop, lines. Also
|
||||||
|
* statistics depend on knowing the exact number of decomposed
|
||||||
|
* primitives for a set of vertices.
|
||||||
|
*/
|
||||||
|
static inline unsigned
|
||||||
|
u_decomposed_prims_for_vertices(enum mesa_prim primitive, int vertices)
|
||||||
|
{
|
||||||
|
switch (primitive) {
|
||||||
|
case MESA_PRIM_POINTS:
|
||||||
|
return vertices;
|
||||||
|
case MESA_PRIM_LINES:
|
||||||
|
return vertices / 2;
|
||||||
|
case MESA_PRIM_LINE_LOOP:
|
||||||
|
return (vertices >= 2) ? vertices : 0;
|
||||||
|
case MESA_PRIM_LINE_STRIP:
|
||||||
|
return (vertices >= 2) ? vertices - 1 : 0;
|
||||||
|
case MESA_PRIM_TRIANGLES:
|
||||||
|
return vertices / 3;
|
||||||
|
case MESA_PRIM_TRIANGLE_STRIP:
|
||||||
|
return (vertices >= 3) ? vertices - 2 : 0;
|
||||||
|
case MESA_PRIM_TRIANGLE_FAN:
|
||||||
|
return (vertices >= 3) ? vertices - 2 : 0;
|
||||||
|
case MESA_PRIM_LINES_ADJACENCY:
|
||||||
|
return vertices / 4;
|
||||||
|
case MESA_PRIM_LINE_STRIP_ADJACENCY:
|
||||||
|
return (vertices >= 4) ? vertices - 3 : 0;
|
||||||
|
case MESA_PRIM_TRIANGLES_ADJACENCY:
|
||||||
|
return vertices / 6;
|
||||||
|
case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
|
||||||
|
return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0;
|
||||||
|
case MESA_PRIM_QUADS:
|
||||||
|
return vertices / 4;
|
||||||
|
case MESA_PRIM_QUAD_STRIP:
|
||||||
|
return (vertices >= 4) ? (vertices - 2) / 2 : 0;
|
||||||
|
/* Polygons can't be decomposed
|
||||||
|
* because the number of their vertices isn't known so
|
||||||
|
* for them and whatever else we don't recognize just
|
||||||
|
* return 1 if the number of vertices is greater than
|
||||||
|
* or equal to 3 and zero otherwise */
|
||||||
|
case MESA_PRIM_POLYGON:
|
||||||
|
default:
|
||||||
|
debug_printf("Invalid decomposition primitive!\n");
|
||||||
|
return (vertices >= 3) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A compare function enum for use in compiler lowering passes. This is in
|
* 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
|
* the same order as GL's compare functions (shifted down by GL_NEVER), and is
|
||||||
|
@@ -182,57 +182,6 @@ u_trim_pipe_prim(enum mesa_prim pipe_prim, unsigned *nr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of decomposed primitives for the given
|
|
||||||
* vertex count.
|
|
||||||
* Parts of the pipline are invoked once for each triangle in
|
|
||||||
* triangle strip, triangle fans and triangles and once
|
|
||||||
* for each line in line strip, line loop, lines. Also
|
|
||||||
* statistics depend on knowing the exact number of decomposed
|
|
||||||
* primitives for a set of vertices.
|
|
||||||
*/
|
|
||||||
static inline unsigned
|
|
||||||
u_decomposed_prims_for_vertices(enum mesa_prim primitive, int vertices)
|
|
||||||
{
|
|
||||||
switch (primitive) {
|
|
||||||
case MESA_PRIM_POINTS:
|
|
||||||
return vertices;
|
|
||||||
case MESA_PRIM_LINES:
|
|
||||||
return vertices / 2;
|
|
||||||
case MESA_PRIM_LINE_LOOP:
|
|
||||||
return (vertices >= 2) ? vertices : 0;
|
|
||||||
case MESA_PRIM_LINE_STRIP:
|
|
||||||
return (vertices >= 2) ? vertices - 1 : 0;
|
|
||||||
case MESA_PRIM_TRIANGLES:
|
|
||||||
return vertices / 3;
|
|
||||||
case MESA_PRIM_TRIANGLE_STRIP:
|
|
||||||
return (vertices >= 3) ? vertices - 2 : 0;
|
|
||||||
case MESA_PRIM_TRIANGLE_FAN:
|
|
||||||
return (vertices >= 3) ? vertices - 2 : 0;
|
|
||||||
case MESA_PRIM_LINES_ADJACENCY:
|
|
||||||
return vertices / 4;
|
|
||||||
case MESA_PRIM_LINE_STRIP_ADJACENCY:
|
|
||||||
return (vertices >= 4) ? vertices - 3 : 0;
|
|
||||||
case MESA_PRIM_TRIANGLES_ADJACENCY:
|
|
||||||
return vertices / 6;
|
|
||||||
case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
|
|
||||||
return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0;
|
|
||||||
case MESA_PRIM_QUADS:
|
|
||||||
return vertices / 4;
|
|
||||||
case MESA_PRIM_QUAD_STRIP:
|
|
||||||
return (vertices >= 4) ? (vertices - 2) / 2 : 0;
|
|
||||||
/* Polygons can't be decomposed
|
|
||||||
* because the number of their vertices isn't known so
|
|
||||||
* for them and whatever else we don't recognize just
|
|
||||||
* return 1 if the number of vertices is greater than
|
|
||||||
* or equal to 3 and zero otherwise */
|
|
||||||
case MESA_PRIM_POLYGON:
|
|
||||||
default:
|
|
||||||
debug_printf("Invalid decomposition primitive!\n");
|
|
||||||
return (vertices >= 3) ? 1 : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of reduced/tessellated primitives for the given vertex
|
* Returns the number of reduced/tessellated primitives for the given vertex
|
||||||
* count. Each quad is treated as two triangles. Polygons are treated as
|
* count. Each quad is treated as two triangles. Polygons are treated as
|
||||||
|
Reference in New Issue
Block a user