From 8abb043c19f30c30ab92d3d3d389ca77a77ad3ea Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 7 Dec 2024 19:50:26 -0500 Subject: [PATCH] compiler: add mesa_prim_has_adjacency helper hk will use this, it's a pretty obvious thing to want. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Mary Guillemard Part-of: --- src/compiler/shader_enums.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h index 5cf53f9077e..f696c9fe984 100644 --- a/src/compiler/shader_enums.h +++ b/src/compiler/shader_enums.h @@ -1388,6 +1388,18 @@ u_reduced_prim(enum mesa_prim prim) } } +static inline bool +mesa_prim_has_adjacency(enum mesa_prim prim) +{ + static_assert(MESA_PRIM_LINE_STRIP_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 1, ""); + static_assert(MESA_PRIM_TRIANGLES_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 2, ""); + static_assert(MESA_PRIM_TRIANGLE_STRIP_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 3, ""); + + /* Adjacency primitives are together so we can do a simple comparison */ + return prim >= MESA_PRIM_LINES_ADJACENCY && + prim <= MESA_PRIM_TRIANGLE_STRIP_ADJACENCY; +} + /** * 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