<p dir="ltr"><br>
On Oct 13, 2015 8:26 AM, "Emil Velikov" <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>> wrote:<br>
><br>
> On 10 October 2015 at 19:47, Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br>
> > From: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
> ><br>
> > Add missing enum to gl_system_value_name() and move VARYING_SLOT_MAX /<br>
> > FRAG_RESULT_MAX / etc into shader_enums.h as suggested by Emil.<br>
> ><br>
> > v2: add STATIC_ASSERT()'s<br>
> ><br>
> > Reported-by: Emil Velikov <<a href="mailto:emil.l.velikov@gmail.com">emil.l.velikov@gmail.com</a>><br>
> > Signed-off-by: Rob Clark <<a href="mailto:robclark@freedesktop.org">robclark@freedesktop.org</a>><br>
> > ---<br>
> > src/glsl/nir/shader_enums.c | 8 ++++++++<br>
> > src/glsl/nir/shader_enums.h | 7 +++++++<br>
> > src/mesa/main/mtypes.h | 5 -----<br>
> > 3 files changed, 15 insertions(+), 5 deletions(-)<br>
> ><br>
> > diff --git a/src/glsl/nir/shader_enums.c b/src/glsl/nir/shader_enums.c<br>
> > index 3722475..66a25e7 100644<br>
> > --- a/src/glsl/nir/shader_enums.c<br>
> > +++ b/src/glsl/nir/shader_enums.c<br>
> > @@ -28,6 +28,7 @@<br>
> ><br>
> > #include "shader_enums.h"<br>
> > #include "util/macros.h"<br>
> > +#include "mesa/main/config.h"<br>
> ><br>
> > #define ENUM(x) [x] = #x<br>
> > #define NAME(val) ((((val) < ARRAY_SIZE(names)) && names[(val)]) ? names[(val)] : "UNKNOWN")<br>
> > @@ -42,6 +43,7 @@ const char * gl_shader_stage_name(gl_shader_stage stage)<br>
> > ENUM(MESA_SHADER_FRAGMENT),<br>
> > ENUM(MESA_SHADER_COMPUTE),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == MESA_SHADER_STAGES);<br>
> > return NAME(stage);<br>
> > }<br>
> ><br>
> > @@ -82,6 +84,7 @@ const char * gl_vert_attrib_name(gl_vert_attrib attrib)<br>
> > ENUM(VERT_ATTRIB_GENERIC14),<br>
> > ENUM(VERT_ATTRIB_GENERIC15),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == VERT_ATTRIB_MAX);<br>
> > return NAME(attrib);<br>
> > }<br>
> ><br>
> > @@ -147,6 +150,7 @@ const char * gl_varying_slot_name(gl_varying_slot slot)<br>
> > ENUM(VARYING_SLOT_VAR30),<br>
> > ENUM(VARYING_SLOT_VAR31),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == VARYING_SLOT_MAX);<br>
> > return NAME(slot);<br>
> > }<br>
> ><br>
> > @@ -169,8 +173,10 @@ const char * gl_system_value_name(gl_system_value sysval)<br>
> > ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER),<br>
> > ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID),<br>
> > ENUM(SYSTEM_VALUE_WORK_GROUP_ID),<br>
> > + ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),<br>
> > ENUM(SYSTEM_VALUE_VERTEX_CNT),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX);<br>
> > return NAME(sysval);<br>
> > }<br>
> ><br>
> > @@ -182,6 +188,7 @@ const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)<br>
> > ENUM(INTERP_QUALIFIER_FLAT),<br>
> > ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == INTERP_QUALIFIER_COUNT);<br>
> > return NAME(qual);<br>
> > }<br>
> ><br>
> > @@ -201,5 +208,6 @@ const char * gl_frag_result_name(gl_frag_result result)<br>
> > ENUM(FRAG_RESULT_DATA6),<br>
> > ENUM(FRAG_RESULT_DATA7),<br>
> > };<br>
> > + STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX);<br>
> > return NAME(result);<br>
> > }<br>
> > diff --git a/src/glsl/nir/shader_enums.h b/src/glsl/nir/shader_enums.h<br>
> > index 2a5d2c5..77638ba 100644<br>
> > --- a/src/glsl/nir/shader_enums.h<br>
> > +++ b/src/glsl/nir/shader_enums.h<br>
> > @@ -233,6 +233,11 @@ typedef enum<br>
> > VARYING_SLOT_VAR31,<br>
> > } gl_varying_slot;<br>
> ><br>
> > +<br>
> > +#define VARYING_SLOT_MAX (VARYING_SLOT_VAR0 + MAX_VARYING)<br>
> > +#define VARYING_SLOT_PATCH0 (VARYING_SLOT_MAX)<br>
> > +#define VARYING_SLOT_TESS_MAX (VARYING_SLOT_PATCH0 + MAX_VARYING)<br>
> > +<br>
> As mentioned before I'm not sure (and perhaps not the best person to<br>
> comment) on the correct definition of the macros, so I'd call this<br>
> Acked-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>><br>
><br>
> For patches 2,3,4 and 6<br>
> Reviewed-by: Emil Velikov <<a href="mailto:emil.velikov@collabora.com">emil.velikov@collabora.com</a>></p>
<p dir="ltr">You can have my R-B on the series as well. I think we're going to do even more compiler source shuffling soon but this is at least the right direction.<br>
--Jason<br>
</p>