[Mesa-dev] [PATCH 1/6] glsl: couple shader_enums cleanups

Jason Ekstrand jason at jlekstrand.net
Tue Oct 13 08:37:48 PDT 2015


On Oct 13, 2015 8:26 AM, "Emil Velikov" <emil.l.velikov at gmail.com> wrote:
>
> On 10 October 2015 at 19:47, Rob Clark <robdclark at gmail.com> wrote:
> > From: Rob Clark <robclark at freedesktop.org>
> >
> > 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 at gmail.com>
> > Signed-off-by: Rob Clark <robclark at freedesktop.org>
> > ---
> >  src/glsl/nir/shader_enums.c | 8 ++++++++
> >  src/glsl/nir/shader_enums.h | 7 +++++++
> >  src/mesa/main/mtypes.h      | 5 -----
> >  3 files changed, 15 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/glsl/nir/shader_enums.c b/src/glsl/nir/shader_enums.c
> > index 3722475..66a25e7 100644
> > --- a/src/glsl/nir/shader_enums.c
> > +++ b/src/glsl/nir/shader_enums.c
> > @@ -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);
> >  }
> > diff --git a/src/glsl/nir/shader_enums.h b/src/glsl/nir/shader_enums.h
> > index 2a5d2c5..77638ba 100644
> > --- a/src/glsl/nir/shader_enums.h
> > +++ b/src/glsl/nir/shader_enums.h
> > @@ -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)
> > +
> As mentioned before I'm not sure (and perhaps not the best person to
> comment) on the correct definition of the macros, so I'd call this
> Acked-by: Emil Velikov <emil.velikov at collabora.com>
>
> For patches 2,3,4 and 6
> Reviewed-by: Emil Velikov <emil.velikov at collabora.com>

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.
--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151013/0843922d/attachment-0001.html>


More information about the mesa-dev mailing list