panfrost: Use C11 static_assert for enums
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 3 Jun 2022 18:33:58 +0000 (14:33 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sat, 4 Jun 2022 12:19:54 +0000 (12:19 +0000)
Rather than asserting everything in an unused function, just do it in global
context with C11 static_asserts. This is a bit neater now that we depend on C11
projectwide.

Obvious follow-on from !16670.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16856>

src/gallium/drivers/panfrost/pan_cmdstream.c

index 37b5571..3f6dd1c 100644 (file)
@@ -120,21 +120,14 @@ struct panfrost_vertex_state {
 /* Statically assert that PIPE_* enums match the hardware enums.
  * (As long as they match, we don't need to translate them.)
  */
-UNUSED static void
-pan_pipe_asserts()
-{
-#define PIPE_ASSERT(x) STATIC_ASSERT((int)x)
-
-        /* Compare functions are natural in both Gallium and Mali */
-        PIPE_ASSERT(PIPE_FUNC_NEVER    == MALI_FUNC_NEVER);
-        PIPE_ASSERT(PIPE_FUNC_LESS     == MALI_FUNC_LESS);
-        PIPE_ASSERT(PIPE_FUNC_EQUAL    == MALI_FUNC_EQUAL);
-        PIPE_ASSERT(PIPE_FUNC_LEQUAL   == MALI_FUNC_LEQUAL);
-        PIPE_ASSERT(PIPE_FUNC_GREATER  == MALI_FUNC_GREATER);
-        PIPE_ASSERT(PIPE_FUNC_NOTEQUAL == MALI_FUNC_NOT_EQUAL);
-        PIPE_ASSERT(PIPE_FUNC_GEQUAL   == MALI_FUNC_GEQUAL);
-        PIPE_ASSERT(PIPE_FUNC_ALWAYS   == MALI_FUNC_ALWAYS);
-}
+static_assert((int)PIPE_FUNC_NEVER    == MALI_FUNC_NEVER,     "must match");
+static_assert((int)PIPE_FUNC_LESS     == MALI_FUNC_LESS,      "must match");
+static_assert((int)PIPE_FUNC_EQUAL    == MALI_FUNC_EQUAL,     "must match");
+static_assert((int)PIPE_FUNC_LEQUAL   == MALI_FUNC_LEQUAL,    "must match");
+static_assert((int)PIPE_FUNC_GREATER  == MALI_FUNC_GREATER,   "must match");
+static_assert((int)PIPE_FUNC_NOTEQUAL == MALI_FUNC_NOT_EQUAL, "must match");
+static_assert((int)PIPE_FUNC_GEQUAL   == MALI_FUNC_GEQUAL,    "must match");
+static_assert((int)PIPE_FUNC_ALWAYS   == MALI_FUNC_ALWAYS,    "must match");
 
 static inline enum mali_sample_pattern
 panfrost_sample_pattern(unsigned samples)