From a147801f9b3e2f5910efb73d4825b507e2dfd7e7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 27 Oct 2023 15:09:01 -0400 Subject: [PATCH] compiler: Make u_decomposed_prims_for_vertices available to CL For indirect geometry shader setup. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Antonino Maniscalco Part-of: --- src/compiler/shader_enums.h | 51 +++++++++++++++++++++++++++++ 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 @@ -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 * the same order as GL's compare functions (shifted down by GL_NEVER), and is 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 @@ -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 * count. Each quad is treated as two triangles. Polygons are treated as