Mesa (main): panfrost: Use C11 static_assert for enums
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jun 4 12:38:52 UTC 2022
Module: Mesa
Branch: main
Commit: 2ee6206751bf456e337d5144e4a697e69d8a04dc
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ee6206751bf456e337d5144e4a697e69d8a04dc
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Fri Jun 3 14:33:58 2022 -0400
panfrost: Use C11 static_assert for enums
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 at collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16856>
---
src/gallium/drivers/panfrost/pan_cmdstream.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 37b55719180..3f6dd1cdcdb 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -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)
More information about the mesa-commit
mailing list