glsl: couple shader_enums cleanups
authorRob Clark <robclark@freedesktop.org>
Fri, 9 Oct 2015 20:27:45 +0000 (16:27 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 16 Oct 2015 23:33:37 +0000 (19:33 -0400)
Add missing enum to gl_system_value_name() and move VARYING_SLOT_MAX /
FRAG_RESULT_MAX / etc into shader_enums.h as suggested by Emil.

v2: add STATIC_ASSERT()'s

Reported-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/glsl/nir/shader_enums.c
src/glsl/nir/shader_enums.h
src/mesa/main/mtypes.h

index 3722475731b8551f34414ab41f8d3c8ace9c2267..66a25e72344fb373285a26f07929a840daeb1263 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "shader_enums.h"
 #include "util/macros.h"
+#include "mesa/main/config.h"
 
 #define ENUM(x) [x] = #x
 #define NAME(val) ((((val) < ARRAY_SIZE(names)) && names[(val)]) ? names[(val)] : "UNKNOWN")
@@ -42,6 +43,7 @@ const char * gl_shader_stage_name(gl_shader_stage stage)
       ENUM(MESA_SHADER_FRAGMENT),
       ENUM(MESA_SHADER_COMPUTE),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == MESA_SHADER_STAGES);
    return NAME(stage);
 }
 
@@ -82,6 +84,7 @@ const char * gl_vert_attrib_name(gl_vert_attrib attrib)
       ENUM(VERT_ATTRIB_GENERIC14),
       ENUM(VERT_ATTRIB_GENERIC15),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == VERT_ATTRIB_MAX);
    return NAME(attrib);
 }
 
@@ -147,6 +150,7 @@ const char * gl_varying_slot_name(gl_varying_slot slot)
       ENUM(VARYING_SLOT_VAR30),
       ENUM(VARYING_SLOT_VAR31),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == VARYING_SLOT_MAX);
    return NAME(slot);
 }
 
@@ -169,8 +173,10 @@ const char * gl_system_value_name(gl_system_value sysval)
      ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER),
      ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID),
      ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
+     ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
      ENUM(SYSTEM_VALUE_VERTEX_CNT),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX);
    return NAME(sysval);
 }
 
@@ -182,6 +188,7 @@ const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)
       ENUM(INTERP_QUALIFIER_FLAT),
       ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == INTERP_QUALIFIER_COUNT);
    return NAME(qual);
 }
 
@@ -201,5 +208,6 @@ const char * gl_frag_result_name(gl_frag_result result)
       ENUM(FRAG_RESULT_DATA6),
       ENUM(FRAG_RESULT_DATA7),
    };
+   STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX);
    return NAME(result);
 }
index 2a5d2c5bfa75199c13718c317c2b77020dd87919..77638ba4e34c60f47a21d7e4570f85f2d17dd433 100644 (file)
@@ -233,6 +233,11 @@ typedef enum
    VARYING_SLOT_VAR31,
 } gl_varying_slot;
 
+
+#define VARYING_SLOT_MAX       (VARYING_SLOT_VAR0 + MAX_VARYING)
+#define VARYING_SLOT_PATCH0    (VARYING_SLOT_MAX)
+#define VARYING_SLOT_TESS_MAX  (VARYING_SLOT_PATCH0 + MAX_VARYING)
+
 const char * gl_varying_slot_name(gl_varying_slot slot);
 
 /**
@@ -473,4 +478,6 @@ typedef enum
 
 const char * gl_frag_result_name(gl_frag_result result);
 
+#define FRAG_RESULT_MAX                (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
+
 #endif /* SHADER_ENUMS_H */
index f7118c1e7a6436fa24fa8ff9fe3e912b4aa1641c..e9d8ea42bce471e843f7f65307dc9200e0b59a43 100644 (file)
@@ -94,11 +94,6 @@ struct vbo_context;
 #define PRIM_OUTSIDE_BEGIN_END   (PRIM_MAX + 1)
 #define PRIM_UNKNOWN             (PRIM_MAX + 2)
 
-#define VARYING_SLOT_MAX       (VARYING_SLOT_VAR0 + MAX_VARYING)
-#define VARYING_SLOT_PATCH0    (VARYING_SLOT_MAX)
-#define VARYING_SLOT_TESS_MAX  (VARYING_SLOT_PATCH0 + MAX_VARYING)
-#define FRAG_RESULT_MAX                (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
-
 /**
  * Determine if the given gl_varying_slot appears in the fragment shader.
  */