compiler: add mesa_prim_has_adjacency helper

hk will use this, it's a pretty obvious thing to want.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32529>
This commit is contained in:
Alyssa Rosenzweig 2024-12-07 19:50:26 -05:00 committed by Marge Bot
parent e4f61771d8
commit 8abb043c19

View file

@ -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