[Mesa-dev] [PATCH 5/7] glsl: move glsl_interp_qualifier_name() definition to shader_enums.h
Emil Velikov
emil.l.velikov at gmail.com
Thu Oct 8 10:09:29 PDT 2015
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/glsl/shader_enums.c | 11 -----------
src/glsl/shader_enums.h | 16 +++++++++++++++-
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index 9b9ec2b..1e8ea66 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,17 +32,6 @@
#define ENUM(x) [x] = #x
#define NAME(val) ((((val) < ARRAY_SIZE(names)) && names[(val)]) ? names[(val)] : "UNKNOWN")
-const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)
-{
- static const char *names[] = {
- ENUM(INTERP_QUALIFIER_NONE),
- ENUM(INTERP_QUALIFIER_SMOOTH),
- ENUM(INTERP_QUALIFIER_FLAT),
- ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),
- };
- return NAME(qual);
-}
-
const char * gl_frag_result_name(gl_frag_result result)
{
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index a560017..0305f5d 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -598,7 +598,21 @@ enum glsl_interp_qualifier
INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */
};
-const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual);
+static const char *glsl_interp_qualifier_names[] = {
+ ENUM(INTERP_QUALIFIER_NONE),
+ ENUM(INTERP_QUALIFIER_SMOOTH),
+ ENUM(INTERP_QUALIFIER_FLAT),
+ ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),
+};
+
+static inline const char *glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)
+{
+ STATIC_ASSERT(ARRAY_SIZE(glsl_interp_qualifier_names) == INTERP_QUALIFIER_COUNT);
+ if (qual < ARRAY_SIZE(glsl_interp_qualifier_names))
+ return glsl_interp_qualifier_names[qual];
+ else
+ return "UNKNOWN";
+}
/**
* Fragment program results
--
2.5.0
More information about the mesa-dev
mailing list