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@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16856>
This commit is contained in:
Alyssa Rosenzweig 2022-06-03 14:33:58 -04:00 committed by Marge Bot
parent 20a57f8a05
commit 2ee6206751

View 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)