diff options
| author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2023-10-27 15:09:01 -0400 |
|---|---|---|
| committer | Marge Bot <emma+marge@anholt.net> | 2023-11-07 00:05:54 +0000 |
| commit | a147801f9b3e2f5910efb73d4825b507e2dfd7e7 (patch) | |
| tree | 0585a2b757b7ada4b1f415170b6d42ebaa16ff02 | |
| parent | 64f7b70763db56e3c3aebd391726e8c2a9566517 (diff) | |
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>
| -rw-r--r-- | src/compiler/shader_enums.h | 51 | ||||
| -rw-r--r-- | src/gallium/auxiliary/util/u_prim.h | 51 |
2 files changed, 51 insertions, 51 deletions
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index e7ef27bc493..45c89d49d65 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -1236,6 +1236,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 * the same order as GL's compare functions (shifted down by GL_NEVER), and is * exactly the same as gallium's PIPE_FUNC_*. diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h index c073ce5c9d3..26df9108572 100644 --- a/src/gallium/auxiliary/util/u_prim.h +++ b/src/gallium/auxiliary/util/u_prim.h @@ -183,57 +183,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 * count. Each quad is treated as two triangles. Polygons are treated as * triangle fans. |
