[Mesa-dev] [PATCH 01/20] mesa: replace GLenum with GLenum16 in common structures (v2)

Marek Olšák maraeo at gmail.com
Tue Nov 21 18:01:43 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

For lower CPU cache usage. All enums fit within 2 bytes.

v2: - fix glGet*
    - also use GLenum16 for DrawBuffers

gl_context = 152488 -> 136896 bytes
vbo_context = 22696 -> 21520 bytes
---
 src/mesa/drivers/common/meta.h                 |   2 +-
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   4 +-
 src/mesa/drivers/dri/nouveau/nv10_state_frag.c |   4 +-
 src/mesa/main/attrib.c                         |  13 +-
 src/mesa/main/buffers.c                        |  12 +-
 src/mesa/main/buffers.h                        |   2 +-
 src/mesa/main/context.c                        |   2 +-
 src/mesa/main/get.c                            |  38 +++++
 src/mesa/main/get_hash_params.py               | 152 +++++++++---------
 src/mesa/main/glheader.h                       |   1 +
 src/mesa/main/mtypes.h                         | 210 ++++++++++++-------------
 src/mesa/vbo/vbo_exec.h                        |   2 +-
 src/mesa/vbo/vbo_save.h                        |   4 +-
 src/mesa/vbo/vbo_save_draw.c                   |   2 +-
 14 files changed, 249 insertions(+), 199 deletions(-)

diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index af23996..976cea2 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -183,21 +183,21 @@ struct save_state
 
    /** Miscellaneous (always disabled) */
    GLboolean Lighting;
    GLboolean RasterDiscard;
    GLboolean TransformFeedbackNeedsResume;
 
    struct gl_framebuffer *DrawBuffer;
    struct gl_framebuffer *ReadBuffer;
 
    /** MESA_META_DRAW_BUFFERS */
-   GLenum ColorDrawBuffers[MAX_DRAW_BUFFERS];
+   GLenum16 ColorDrawBuffers[MAX_DRAW_BUFFERS];
 };
 
 /**
  * Temporary texture used for glBlitFramebuffer, glDrawPixels, etc.
  * This is currently shared by all the meta ops.  But we could create a
  * separate one for each of glDrawPixel, glBlitFramebuffer, glCopyPixels, etc.
  */
 struct temp_texture
 {
    GLuint TexObj;
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
index 248a7d2..bfe8eae 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
@@ -42,22 +42,22 @@
 	NV04_MULTITEX_TRIANGLE_COMBINE_COLOR_ALPHA0
 
 struct combiner_state {
 	struct gl_context *ctx;
 	int unit;
 	GLboolean alpha;
 	GLboolean premodulate;
 
 	/* GL state */
 	GLenum mode;
-	GLenum *source;
-	GLenum *operand;
+	GLenum16 *source;
+	GLenum16 *operand;
 	GLuint logscale;
 
 	/* Derived HW state */
 	uint32_t hw;
 };
 
 #define __INIT_COMBINER_ALPHA_A GL_TRUE
 #define __INIT_COMBINER_ALPHA_RGB GL_FALSE
 
 /* Initialize a combiner_state struct from the texture unit
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
index c6e4bb0..42dff08 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
@@ -60,22 +60,22 @@
 /* spare0_i = A_i * B_i + C_i * D_i */
 #define RC_OUT_SUM	NV10_3D_RC_OUT_RGB_SUM_OUTPUT_SPARE0
 
 struct combiner_state {
 	struct gl_context *ctx;
 	int unit;
 	GLboolean premodulate;
 
 	/* GL state */
 	GLenum mode;
-	GLenum *source;
-	GLenum *operand;
+	GLenum16 *source;
+	GLenum16 *operand;
 	GLuint logscale;
 
 	/* Derived HW state */
 	uint64_t in;
 	uint32_t out;
 };
 
 /* Initialize a combiner_state struct from the texture unit
  * context. */
 #define INIT_COMBINER(chan, ctx, rc, i) do {			\
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 43b5856..0cfd5f0 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -998,25 +998,30 @@ _mesa_PopAttrib(void)
 			break;
 		     }
                   }
                   /* Call the API_level functions, not _mesa_drawbuffers()
                    * since we need to do error checking on the pop'd
                    * GL_DRAW_BUFFER.
                    * Ex: if GL_FRONT were pushed, but we're popping with a
                    * user FBO bound, GL_FRONT will be illegal and we'll need
                    * to record that error.  Per OpenGL ARB decision.
                    */
-                  if (multipleBuffers)
-                     _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers,
-                                          color->DrawBuffer);
-                  else
+                  if (multipleBuffers) {
+                     GLenum buffers[MAX_DRAW_BUFFERS];
+
+                     for (unsigned i = 0; i < ctx->Const.MaxDrawBuffers; i++)
+                        buffers[i] = color->DrawBuffer[i];
+
+                     _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, buffers);
+                  } else {
                      _mesa_DrawBuffer(color->DrawBuffer[0]);
+                  }
                }
                _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
                _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped);
                if (ctx->Color.BlendEnabled != color->BlendEnabled) {
                   if (ctx->Extensions.EXT_draw_buffers2) {
                      GLuint i;
                      for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
                         _mesa_set_enablei(ctx, GL_BLEND, i,
                                           (color->BlendEnabled >> i) & 1);
                      }
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index d364047..7086686 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -292,21 +292,22 @@ draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
       destMask &= supportedMask;
       if (!no_error && destMask == 0x0) {
          /* none of the named color buffers exist! */
          _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffer %s)",
                      caller, _mesa_enum_to_string(buffer));
          return;
       }
    }
 
    /* if we get here, there's no error so set new state */
-   _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
+   GLenum16 buffer16 = buffer;
+   _mesa_drawbuffers(ctx, fb, 1, &buffer16, &destMask);
 
    /* Call device driver function only if fb is the bound draw buffer */
    if (fb == ctx->DrawBuffer) {
       if (ctx->Driver.DrawBuffers)
          ctx->Driver.DrawBuffers(ctx, 1, &buffer);
       else if (ctx->Driver.DrawBuffer)
          ctx->Driver.DrawBuffer(ctx, buffer);
    }
 }
 
@@ -566,21 +567,25 @@ draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb, GLsizei n,
                return;
             }
          }
 
          /* update bitmask */
          usedBufferMask |= destMask[output];
       }
    }
 
    /* OK, if we get here, there were no errors so set the new state */
-   _mesa_drawbuffers(ctx, fb, n, buffers, destMask);
+   GLenum16 buffers16[MAX_DRAW_BUFFERS];
+   for (unsigned i = 0; i < n; i++)
+      buffers16[i] = buffers[i];
+
+   _mesa_drawbuffers(ctx, fb, n, buffers16, destMask);
 
    /*
     * Call device driver function if fb is the bound draw buffer.
     * Note that n can be equal to 0,
     * in which case we don't want to reference buffers[0], which
     * may not be valid.
     */
    if (fb == ctx->DrawBuffer) {
       if (ctx->Driver.DrawBuffers)
          ctx->Driver.DrawBuffers(ctx, n, buffers);
@@ -687,21 +692,22 @@ updated_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb)
  * \param ctx  current context
  * \param fb   the desired draw buffer
  * \param n    number of color outputs to set
  * \param buffers  array[n] of colorbuffer names, like GL_LEFT.
  * \param destMask  array[n] of BUFFER_BIT_* bitmasks which correspond to the
  *                  colorbuffer names.  (i.e. GL_FRONT_AND_BACK =>
  *                  BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
  */
 void
 _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
-                  GLuint n, const GLenum *buffers, const GLbitfield *destMask)
+                  GLuint n, const GLenum16 *buffers,
+                  const GLbitfield *destMask)
 {
    GLbitfield mask[MAX_DRAW_BUFFERS];
    GLuint buf;
 
    if (!destMask) {
       /* compute destMask values now */
       const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb);
       GLuint output;
       for (output = 0; output < n; output++) {
          mask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]);
diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h
index e484006..c438107 100644
--- a/src/mesa/main/buffers.h
+++ b/src/mesa/main/buffers.h
@@ -61,21 +61,21 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
 void GLAPIENTRY
 _mesa_NamedFramebufferDrawBuffers_no_error(GLuint framebuffer, GLsizei n,
                                            const GLenum *bufs);
 
 extern void GLAPIENTRY
 _mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
                                   const GLenum *bufs);
 
 extern void
 _mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
-                  GLuint n, const GLenum *buffers,
+                  GLuint n, const GLenum16 *buffers,
                   const GLbitfield *destMask);
 
 extern void
 _mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
                  GLenum buffer, gl_buffer_index bufferIndex);
 
 extern void
 _mesa_update_draw_buffers(struct gl_context *ctx);
 
 void GLAPIENTRY
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 25dd59a..0b17c0b 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1577,21 +1577,21 @@ handle_first_current(struct gl_context *ctx)
    }
 
    check_context_limits(ctx);
 
    /* According to GL_MESA_configless_context the default value of
     * glDrawBuffers depends on the config of the first surface it is bound to.
     * For GLES it is always GL_BACK which has a magic interpretation.
     */
    if (!ctx->HasConfig && _mesa_is_desktop_gl(ctx)) {
       if (ctx->DrawBuffer != _mesa_get_incomplete_framebuffer()) {
-         GLenum buffer;
+         GLenum16 buffer;
 
          if (ctx->DrawBuffer->Visual.doubleBufferMode)
             buffer = GL_BACK;
          else
             buffer = GL_FRONT;
 
          _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer,
                            NULL /* destMask */);
       }
 
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index ea8d932..83838d8 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -94,20 +94,21 @@ enum value_type {
    TYPE_INT,
    TYPE_INT_2,
    TYPE_INT_3,
    TYPE_INT_4,
    TYPE_INT_N,
    TYPE_UINT,
    TYPE_UINT_2,
    TYPE_UINT_3,
    TYPE_UINT_4,
    TYPE_INT64,
+   TYPE_ENUM16,
    TYPE_ENUM,
    TYPE_ENUM_2,
    TYPE_BOOLEAN,
    TYPE_BIT_0,
    TYPE_BIT_1,
    TYPE_BIT_2,
    TYPE_BIT_3,
    TYPE_BIT_4,
    TYPE_BIT_5,
    TYPE_BIT_6,
@@ -199,26 +200,28 @@ union value {
 #define CONTEXT_FIELD(field, type) \
    LOC_CONTEXT, type, offsetof(struct gl_context, field)
 #define ARRAY_FIELD(field, type) \
    LOC_ARRAY, type, offsetof(struct gl_vertex_array_object, field)
 #undef CONST /* already defined through windows.h */
 #define CONST(value) \
    LOC_CONTEXT, TYPE_CONST, value
 
 #define BUFFER_INT(field) BUFFER_FIELD(field, TYPE_INT)
 #define BUFFER_ENUM(field) BUFFER_FIELD(field, TYPE_ENUM)
+#define BUFFER_ENUM16(field) BUFFER_FIELD(field, TYPE_ENUM16)
 #define BUFFER_BOOL(field) BUFFER_FIELD(field, TYPE_BOOLEAN)
 
 #define CONTEXT_INT(field) CONTEXT_FIELD(field, TYPE_INT)
 #define CONTEXT_INT2(field) CONTEXT_FIELD(field, TYPE_INT_2)
 #define CONTEXT_INT64(field) CONTEXT_FIELD(field, TYPE_INT64)
 #define CONTEXT_UINT(field) CONTEXT_FIELD(field, TYPE_UINT)
+#define CONTEXT_ENUM16(field) CONTEXT_FIELD(field, TYPE_ENUM16)
 #define CONTEXT_ENUM(field) CONTEXT_FIELD(field, TYPE_ENUM)
 #define CONTEXT_ENUM2(field) CONTEXT_FIELD(field, TYPE_ENUM_2)
 #define CONTEXT_BOOL(field) CONTEXT_FIELD(field, TYPE_BOOLEAN)
 #define CONTEXT_BIT0(field) CONTEXT_FIELD(field, TYPE_BIT_0)
 #define CONTEXT_BIT1(field) CONTEXT_FIELD(field, TYPE_BIT_1)
 #define CONTEXT_BIT2(field) CONTEXT_FIELD(field, TYPE_BIT_2)
 #define CONTEXT_BIT3(field) CONTEXT_FIELD(field, TYPE_BIT_3)
 #define CONTEXT_BIT4(field) CONTEXT_FIELD(field, TYPE_BIT_4)
 #define CONTEXT_BIT5(field) CONTEXT_FIELD(field, TYPE_BIT_5)
 #define CONTEXT_BIT6(field) CONTEXT_FIELD(field, TYPE_BIT_6)
@@ -226,20 +229,21 @@ union value {
 #define CONTEXT_FLOAT(field) CONTEXT_FIELD(field, TYPE_FLOAT)
 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
 #define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
 
 #define ARRAY_INT(field) ARRAY_FIELD(field, TYPE_INT)
 #define ARRAY_ENUM(field) ARRAY_FIELD(field, TYPE_ENUM)
+#define ARRAY_ENUM16(field) ARRAY_FIELD(field, TYPE_ENUM16)
 #define ARRAY_BOOL(field) ARRAY_FIELD(field, TYPE_BOOLEAN)
 
 #define EXT(f)					\
    offsetof(struct gl_extensions, f)
 
 #define EXTRA_EXT(e)				\
    static const int extra_##e[] = {		\
       EXT(e), EXTRA_END				\
    }
 
@@ -1455,20 +1459,22 @@ get_value_size(enum value_type type, const union value *v)
    case TYPE_UINT_3:
       return sizeof(GLint) * 3;
    case TYPE_INT_4:
    case TYPE_UINT_4:
       return sizeof(GLint) * 4;
    case TYPE_INT_N:
       return sizeof(GLint) * v->value_int_n.n;
    case TYPE_INT64:
       return sizeof(GLint64);
       break;
+   case TYPE_ENUM16:
+      return sizeof(GLenum16);
    case TYPE_ENUM:
       return sizeof(GLenum);
    case TYPE_ENUM_2:
       return sizeof(GLenum) * 2;
    case TYPE_BOOLEAN:
       return sizeof(GLboolean);
    case TYPE_BIT_0:
    case TYPE_BIT_1:
    case TYPE_BIT_2:
    case TYPE_BIT_3:
@@ -1555,20 +1561,24 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params)
    case TYPE_INT_2:
    case TYPE_UINT_2:
    case TYPE_ENUM_2:
       params[1] = INT_TO_BOOLEAN(((GLint *) p)[1]);
    case TYPE_INT:
    case TYPE_UINT:
    case TYPE_ENUM:
       params[0] = INT_TO_BOOLEAN(((GLint *) p)[0]);
       break;
 
+   case TYPE_ENUM16:
+      params[0] = INT_TO_BOOLEAN(((GLenum16 *) p)[0]);
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
       break;
 
    case TYPE_INT64:
       params[0] = INT64_TO_BOOLEAN(((GLint64 *) p)[0]);
       break;
 
    case TYPE_BOOLEAN:
@@ -1648,20 +1658,24 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
    case TYPE_INT_3:
       params[2] = (GLfloat) (((GLint *) p)[2]);
    case TYPE_INT_2:
    case TYPE_ENUM_2:
       params[1] = (GLfloat) (((GLint *) p)[1]);
    case TYPE_INT:
    case TYPE_ENUM:
       params[0] = (GLfloat) (((GLint *) p)[0]);
       break;
 
+   case TYPE_ENUM16:
+      params[0] = (GLfloat) (((GLenum16 *) p)[0]);
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = (GLfloat) v.value_int_n.ints[i];
       break;
 
    case TYPE_UINT_4:
       params[3] = (GLfloat) (((GLuint *) p)[3]);
    case TYPE_UINT_3:
       params[2] = (GLfloat) (((GLuint *) p)[2]);
    case TYPE_UINT_2:
@@ -1761,20 +1775,24 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
    case TYPE_INT_2:
    case TYPE_UINT_2:
    case TYPE_ENUM_2:
       params[1] = ((GLint *) p)[1];
    case TYPE_INT:
    case TYPE_UINT:
    case TYPE_ENUM:
       params[0] = ((GLint *) p)[0];
       break;
 
+   case TYPE_ENUM16:
+      params[0] = ((GLenum16 *) p)[0];
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = v.value_int_n.ints[i];
       break;
 
    case TYPE_INT64:
       params[0] = INT64_TO_INT(((GLint64 *) p)[0]);
       break;
 
    case TYPE_BOOLEAN:
@@ -1860,20 +1878,24 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
    case TYPE_INT_3:
       params[2] = ((GLint *) p)[2];
    case TYPE_INT_2:
    case TYPE_ENUM_2:
       params[1] = ((GLint *) p)[1];
    case TYPE_INT:
    case TYPE_ENUM:
       params[0] = ((GLint *) p)[0];
       break;
 
+   case TYPE_ENUM16:
+      params[0] = ((GLenum16 *) p)[0];
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = INT_TO_BOOLEAN(v.value_int_n.ints[i]);
       break;
 
    case TYPE_UINT_4:
       params[3] = ((GLuint *) p)[3];
    case TYPE_UINT_3:
       params[2] = ((GLuint *) p)[2];
    case TYPE_UINT_2:
@@ -1963,20 +1985,24 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
    case TYPE_INT_3:
       params[2] = ((GLint *) p)[2];
    case TYPE_INT_2:
    case TYPE_ENUM_2:
       params[1] = ((GLint *) p)[1];
    case TYPE_INT:
    case TYPE_ENUM:
       params[0] = ((GLint *) p)[0];
       break;
 
+   case TYPE_ENUM16:
+      params[0] = ((GLenum16 *) p)[0];
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = v.value_int_n.ints[i];
       break;
 
    case TYPE_UINT_4:
       params[3] = ((GLuint *) p)[3];
    case TYPE_UINT_3:
       params[2] = ((GLuint *) p)[2];
    case TYPE_UINT_2:
@@ -2080,20 +2106,25 @@ _mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
    case TYPE_FLOATN_3:
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
    case TYPE_FLOAT_8:
    case TYPE_DOUBLEN:
    case TYPE_DOUBLEN_2:
    case TYPE_MATRIX:
    case TYPE_MATRIX_T:
       memcpy(data, p, size);
       break;
+   case TYPE_ENUM16: {
+      GLenum e = *(GLenum16 *)p;
+      memcpy(data, &e, sizeof(e));
+      break;
+   }
    default:
       break; /* nothing - GL error was recorded */
    }
 }
 
 /**
  * Convert a GL texture binding enum such as GL_TEXTURE_BINDING_2D
  * into the corresponding Mesa texture target index.
  * \return TEXTURE_x_INDEX or -1 if binding is invalid
  */
@@ -2675,20 +2706,21 @@ _mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
 
    case TYPE_INT_4:
       params[3] = (GLfloat) v.value_int_4[3];
    case TYPE_INT_3:
       params[2] = (GLfloat) v.value_int_4[2];
    case TYPE_INT_2:
    case TYPE_ENUM_2:
       params[1] = (GLfloat) v.value_int_4[1];
    case TYPE_INT:
    case TYPE_ENUM:
+   case TYPE_ENUM16:
       params[0] = (GLfloat) v.value_int_4[0];
       break;
 
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = (GLfloat) v.value_int_n.ints[i];
       break;
 
    case TYPE_UINT_4:
       params[3] = (GLfloat) ((GLuint) v.value_int_4[3]);
@@ -2757,20 +2789,21 @@ _mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
 
    case TYPE_INT_4:
       params[3] = (GLdouble) v.value_int_4[3];
    case TYPE_INT_3:
       params[2] = (GLdouble) v.value_int_4[2];
    case TYPE_INT_2:
    case TYPE_ENUM_2:
       params[1] = (GLdouble) v.value_int_4[1];
    case TYPE_INT:
    case TYPE_ENUM:
+   case TYPE_ENUM16:
       params[0] = (GLdouble) v.value_int_4[0];
       break;
 
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = (GLdouble) v.value_int_n.ints[i];
       break;
 
    case TYPE_UINT_4:
       params[3] = (GLdouble) ((GLuint) v.value_int_4[3]);
@@ -2831,20 +2864,21 @@ _mesa_GetUnsignedBytei_vEXT(GLenum target, GLuint index, GLubyte *data)
    switch (type) {
    case TYPE_UINT:
    case TYPE_INT:
    case TYPE_INT_2:
    case TYPE_UINT_2:
    case TYPE_INT_3:
    case TYPE_UINT_3:
    case TYPE_INT_4:
    case TYPE_UINT_4:
    case TYPE_INT64:
+   case TYPE_ENUM16:
    case TYPE_ENUM:
    case TYPE_ENUM_2:
    case TYPE_BOOLEAN:
    case TYPE_FLOAT:
    case TYPE_FLOATN:
    case TYPE_FLOAT_2:
    case TYPE_FLOATN_2:
    case TYPE_FLOAT_3:
    case TYPE_FLOATN_3:
    case TYPE_FLOAT_4:
@@ -2910,20 +2944,24 @@ _mesa_GetFixedv(GLenum pname, GLfixed *params)
    case TYPE_INT_2:
    case TYPE_UINT_2:
    case TYPE_ENUM_2:
       params[1] = INT_TO_FIXED(((GLint *) p)[1]);
    case TYPE_INT:
    case TYPE_UINT:
    case TYPE_ENUM:
       params[0] = INT_TO_FIXED(((GLint *) p)[0]);
       break;
 
+   case TYPE_ENUM16:
+      params[0] = INT_TO_FIXED(((GLenum16 *) p)[0]);
+      break;
+
    case TYPE_INT_N:
       for (i = 0; i < v.value_int_n.n; i++)
          params[i] = INT_TO_FIXED(v.value_int_n.ints[i]);
       break;
 
    case TYPE_INT64:
       params[0] = ((GLint64 *) p)[0];
       break;
 
    case TYPE_BOOLEAN:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 20ef6e4..5a2c982 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -1,49 +1,49 @@
 descriptor=[
 { "apis": ["GL", "GLES", "GLES2", "GL_CORE"], "params": [
   [ "ALPHA_BITS", "BUFFER_INT(Visual.alphaBits), extra_new_buffers" ],
   [ "BLEND", "CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA" ],
-  [ "BLEND_SRC", "CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA" ],
+  [ "BLEND_SRC", "CONTEXT_ENUM16(Color.Blend[0].SrcRGB), NO_EXTRA" ],
   [ "BLUE_BITS", "BUFFER_INT(Visual.blueBits), extra_new_buffers" ],
   [ "COLOR_CLEAR_VALUE", "LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp" ],
   [ "COLOR_WRITEMASK", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ],
   [ "CULL_FACE", "CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA" ],
-  [ "CULL_FACE_MODE", "CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA" ],
+  [ "CULL_FACE_MODE", "CONTEXT_ENUM16(Polygon.CullFaceMode), NO_EXTRA" ],
   [ "DEPTH_BITS", "BUFFER_INT(Visual.depthBits), extra_new_buffers" ],
   [ "DEPTH_CLEAR_VALUE", "CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA" ],
-  [ "DEPTH_FUNC", "CONTEXT_ENUM(Depth.Func), NO_EXTRA" ],
+  [ "DEPTH_FUNC", "CONTEXT_ENUM16(Depth.Func), NO_EXTRA" ],
   [ "DEPTH_RANGE", "LOC_CUSTOM, TYPE_DOUBLEN_2, 0, NO_EXTRA" ],
   [ "DEPTH_TEST", "CONTEXT_BOOL(Depth.Test), NO_EXTRA" ],
   [ "DEPTH_WRITEMASK", "CONTEXT_BOOL(Depth.Mask), NO_EXTRA" ],
   [ "DITHER", "CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA" ],
-  [ "FRONT_FACE", "CONTEXT_ENUM(Polygon.FrontFace), NO_EXTRA" ],
+  [ "FRONT_FACE", "CONTEXT_ENUM16(Polygon.FrontFace), NO_EXTRA" ],
   [ "GREEN_BITS", "BUFFER_INT(Visual.greenBits), extra_new_buffers" ],
   [ "LINE_WIDTH", "CONTEXT_FLOAT(Line.Width), NO_EXTRA" ],
   [ "ALIASED_LINE_WIDTH_RANGE", "CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA" ],
   [ "MAX_ELEMENTS_VERTICES", "CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA" ],
   [ "MAX_ELEMENTS_INDICES", "CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA" ],
   [ "MAX_TEXTURE_SIZE", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA" ],
   [ "MAX_VIEWPORT_DIMS", "CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA" ],
   [ "PACK_ALIGNMENT", "CONTEXT_INT(Pack.Alignment), NO_EXTRA" ],
   [ "ALIASED_POINT_SIZE_RANGE", "CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA" ],
   [ "POLYGON_OFFSET_FACTOR", "CONTEXT_FLOAT(Polygon.OffsetFactor ), NO_EXTRA" ],
   [ "POLYGON_OFFSET_UNITS", "CONTEXT_FLOAT(Polygon.OffsetUnits ), NO_EXTRA" ],
   [ "POLYGON_OFFSET_FILL", "CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA" ],
   [ "RED_BITS", "BUFFER_INT(Visual.redBits), extra_new_buffers" ],
   [ "SCISSOR_BOX", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ],
   [ "SCISSOR_TEST", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
   [ "STENCIL_BITS", "BUFFER_INT(Visual.stencilBits), extra_new_buffers" ],
   [ "STENCIL_CLEAR_VALUE", "CONTEXT_INT(Stencil.Clear), NO_EXTRA" ],
-  [ "STENCIL_FAIL", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
-  [ "STENCIL_FUNC", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
-  [ "STENCIL_PASS_DEPTH_FAIL", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
-  [ "STENCIL_PASS_DEPTH_PASS", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
+  [ "STENCIL_FAIL", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, NO_EXTRA" ],
+  [ "STENCIL_FUNC", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, NO_EXTRA" ],
+  [ "STENCIL_PASS_DEPTH_FAIL", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, NO_EXTRA" ],
+  [ "STENCIL_PASS_DEPTH_PASS", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, NO_EXTRA" ],
   [ "STENCIL_REF", "LOC_CUSTOM, TYPE_UINT, NO_OFFSET, NO_EXTRA" ],
   [ "STENCIL_TEST", "CONTEXT_BOOL(Stencil.Enabled), NO_EXTRA" ],
   [ "STENCIL_VALUE_MASK", "LOC_CUSTOM, TYPE_UINT, NO_OFFSET, NO_EXTRA" ],
   [ "STENCIL_WRITEMASK", "LOC_CUSTOM, TYPE_UINT, NO_OFFSET, NO_EXTRA" ],
   [ "SUBPIXEL_BITS", "CONTEXT_INT(Const.SubPixelBits), NO_EXTRA" ],
   [ "TEXTURE_BINDING_2D", "LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA" ],
   [ "UNPACK_ALIGNMENT", "CONTEXT_INT(Unpack.Alignment), NO_EXTRA" ],
   [ "VIEWPORT", "LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA" ],
 
 # GL_ARB_multitexture
@@ -54,60 +54,60 @@ descriptor=[
 # That structure does not yet include OES extensions (and we're
 # not sure whether it will).  If it does, all the OES_*
 # extensions below should mark the dependency.
 
 # GL_ARB_texture_cube_map
   [ "TEXTURE_BINDING_CUBE_MAP_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_CUBE_INDEX, extra_ARB_texture_cube_map" ],
 # XXX: OES_texture_cube_map
   [ "MAX_CUBE_MAP_TEXTURE_SIZE_ARB", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, Const.MaxCubeTextureLevels), extra_ARB_texture_cube_map" ],
 
 # XXX: OES_blend_subtract
-  [ "BLEND_SRC_RGB", "CONTEXT_ENUM(Color.Blend[0].SrcRGB), NO_EXTRA" ],
-  [ "BLEND_DST_RGB", "CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA" ],
-  [ "BLEND_SRC_ALPHA", "CONTEXT_ENUM(Color.Blend[0].SrcA), NO_EXTRA" ],
-  [ "BLEND_DST_ALPHA", "CONTEXT_ENUM(Color.Blend[0].DstA), NO_EXTRA" ],
+  [ "BLEND_SRC_RGB", "CONTEXT_ENUM16(Color.Blend[0].SrcRGB), NO_EXTRA" ],
+  [ "BLEND_DST_RGB", "CONTEXT_ENUM16(Color.Blend[0].DstRGB), NO_EXTRA" ],
+  [ "BLEND_SRC_ALPHA", "CONTEXT_ENUM16(Color.Blend[0].SrcA), NO_EXTRA" ],
+  [ "BLEND_DST_ALPHA", "CONTEXT_ENUM16(Color.Blend[0].DstA), NO_EXTRA" ],
 
 # GL_BLEND_EQUATION_RGB, which is what we're really after, is
 # defined identically to GL_BLEND_EQUATION.
-  [ "BLEND_EQUATION", "CONTEXT_ENUM(Color.Blend[0].EquationRGB), NO_EXTRA" ],
-  [ "BLEND_EQUATION_ALPHA_EXT", "CONTEXT_ENUM(Color.Blend[0].EquationA), NO_EXTRA" ],
+  [ "BLEND_EQUATION", "CONTEXT_ENUM16(Color.Blend[0].EquationRGB), NO_EXTRA" ],
+  [ "BLEND_EQUATION_ALPHA_EXT", "CONTEXT_ENUM16(Color.Blend[0].EquationA), NO_EXTRA" ],
 
 # GL_ARB_texture_compression
   [ "NUM_COMPRESSED_TEXTURE_FORMATS_ARB", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
   [ "COMPRESSED_TEXTURE_FORMATS", "LOC_CUSTOM, TYPE_INT_N, 0, NO_EXTRA" ],
 
 # GL_ARB_multisample
   [ "SAMPLE_ALPHA_TO_COVERAGE_ARB", "CONTEXT_BOOL(Multisample.SampleAlphaToCoverage), NO_EXTRA" ],
   [ "SAMPLE_COVERAGE_ARB", "CONTEXT_BOOL(Multisample.SampleCoverage), NO_EXTRA" ],
   [ "SAMPLE_COVERAGE_VALUE_ARB", "CONTEXT_FLOAT(Multisample.SampleCoverageValue), NO_EXTRA" ],
   [ "SAMPLE_COVERAGE_INVERT_ARB", "CONTEXT_BOOL(Multisample.SampleCoverageInvert), NO_EXTRA" ],
   [ "SAMPLE_BUFFERS_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_new_buffers" ],
   [ "SAMPLES_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_new_buffers" ],
 
 # GL_ARB_sample_shading
   [ "SAMPLE_SHADING_ARB", "CONTEXT_BOOL(Multisample.SampleShading), extra_gl40_ARB_sample_shading" ],
   [ "MIN_SAMPLE_SHADING_VALUE_ARB", "CONTEXT_FLOAT(Multisample.MinSampleShadingValue), extra_gl40_ARB_sample_shading" ],
 
 # GL_SGIS_generate_mipmap
-  [ "GENERATE_MIPMAP_HINT_SGIS", "CONTEXT_ENUM(Hint.GenerateMipmap), NO_EXTRA" ],
+  [ "GENERATE_MIPMAP_HINT_SGIS", "CONTEXT_ENUM16(Hint.GenerateMipmap), NO_EXTRA" ],
 
 # GL_ARB_vertex_buffer_object
   [ "ARRAY_BUFFER_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # GL_ARB_vertex_buffer_object
 # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported
   [ "ELEMENT_ARRAY_BUFFER_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # GL_ARB_color_buffer_float
-  [ "CLAMP_VERTEX_COLOR", "CONTEXT_ENUM(Light.ClampVertexColor), extra_ARB_color_buffer_float" ],
-  [ "CLAMP_FRAGMENT_COLOR", "CONTEXT_ENUM(Color.ClampFragmentColor), extra_ARB_color_buffer_float" ],
-  [ "CLAMP_READ_COLOR", "CONTEXT_ENUM(Color.ClampReadColor), extra_ARB_color_buffer_float_or_glcore" ],
+  [ "CLAMP_VERTEX_COLOR", "CONTEXT_ENUM16(Light.ClampVertexColor), extra_ARB_color_buffer_float" ],
+  [ "CLAMP_FRAGMENT_COLOR", "CONTEXT_ENUM16(Color.ClampFragmentColor), extra_ARB_color_buffer_float" ],
+  [ "CLAMP_READ_COLOR", "CONTEXT_ENUM16(Color.ClampReadColor), extra_ARB_color_buffer_float_or_glcore" ],
 
 # GL_ARB_copy_buffer
   [ "COPY_READ_BUFFER", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
   [ "COPY_WRITE_BUFFER", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # GL_OES_read_format
   [ "IMPLEMENTATION_COLOR_READ_TYPE_OES", "LOC_CUSTOM, TYPE_INT, 0, extra_new_buffers" ],
   [ "IMPLEMENTATION_COLOR_READ_FORMAT_OES", "LOC_CUSTOM, TYPE_INT, 0, extra_new_buffers" ],
 
 # GL_EXT_framebuffer_object
@@ -148,85 +148,85 @@ descriptor=[
   [ "LIGHT2", "CONTEXT_BOOL(Light.Light[2].Enabled), NO_EXTRA" ],
   [ "LIGHT3", "CONTEXT_BOOL(Light.Light[3].Enabled), NO_EXTRA" ],
   [ "LIGHT4", "CONTEXT_BOOL(Light.Light[4].Enabled), NO_EXTRA" ],
   [ "LIGHT5", "CONTEXT_BOOL(Light.Light[5].Enabled), NO_EXTRA" ],
   [ "LIGHT6", "CONTEXT_BOOL(Light.Light[6].Enabled), NO_EXTRA" ],
   [ "LIGHT7", "CONTEXT_BOOL(Light.Light[7].Enabled), NO_EXTRA" ],
   [ "LIGHTING", "CONTEXT_BOOL(Light.Enabled), NO_EXTRA" ],
   [ "LIGHT_MODEL_AMBIENT", "CONTEXT_FIELD(Light.Model.Ambient[0], TYPE_FLOATN_4), NO_EXTRA" ],
   [ "LIGHT_MODEL_TWO_SIDE", "CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA" ],
   [ "ALPHA_TEST", "CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA" ],
-  [ "ALPHA_TEST_FUNC", "CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA" ],
+  [ "ALPHA_TEST_FUNC", "CONTEXT_ENUM16(Color.AlphaFunc), NO_EXTRA" ],
   [ "ALPHA_TEST_REF", "LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp" ],
-  [ "BLEND_DST", "CONTEXT_ENUM(Color.Blend[0].DstRGB), NO_EXTRA" ],
+  [ "BLEND_DST", "CONTEXT_ENUM16(Color.Blend[0].DstRGB), NO_EXTRA" ],
   [ "CLIP_DISTANCE0", "CONTEXT_BIT0(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE1", "CONTEXT_BIT1(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE2", "CONTEXT_BIT2(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE3", "CONTEXT_BIT3(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE4", "CONTEXT_BIT4(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE5", "CONTEXT_BIT5(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE6", "CONTEXT_BIT6(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "CLIP_DISTANCE7", "CONTEXT_BIT7(Transform.ClipPlanesEnabled), extra_valid_clip_distance" ],
   [ "COLOR_MATERIAL", "CONTEXT_BOOL(Light.ColorMaterialEnabled), NO_EXTRA" ],
   [ "CURRENT_COLOR", "CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR0][0], TYPE_FLOATN_4), extra_flush_current" ],
   [ "CURRENT_NORMAL", "CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_NORMAL][0], TYPE_FLOATN_3), extra_flush_current" ],
   [ "CURRENT_TEXTURE_COORDS", "LOC_CUSTOM, TYPE_FLOAT_4, 0, extra_flush_current_valid_texture_unit" ],
   [ "POINT_DISTANCE_ATTENUATION", "CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA" ],
   [ "FOG", "CONTEXT_BOOL(Fog.Enabled), NO_EXTRA" ],
   [ "FOG_COLOR", "LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp" ],
   [ "FOG_DENSITY", "CONTEXT_FLOAT(Fog.Density), NO_EXTRA" ],
   [ "FOG_END", "CONTEXT_FLOAT(Fog.End), NO_EXTRA" ],
-  [ "FOG_HINT", "CONTEXT_ENUM(Hint.Fog), NO_EXTRA" ],
-  [ "FOG_MODE", "CONTEXT_ENUM(Fog.Mode), NO_EXTRA" ],
+  [ "FOG_HINT", "CONTEXT_ENUM16(Hint.Fog), NO_EXTRA" ],
+  [ "FOG_MODE", "CONTEXT_ENUM16(Fog.Mode), NO_EXTRA" ],
   [ "FOG_START", "CONTEXT_FLOAT(Fog.Start), NO_EXTRA" ],
   [ "LINE_SMOOTH", "CONTEXT_BOOL(Line.SmoothFlag), NO_EXTRA" ],
-  [ "LINE_SMOOTH_HINT", "CONTEXT_ENUM(Hint.LineSmooth), NO_EXTRA" ],
+  [ "LINE_SMOOTH_HINT", "CONTEXT_ENUM16(Hint.LineSmooth), NO_EXTRA" ],
   [ "LINE_WIDTH_RANGE", "CONTEXT_FLOAT2(Const.MinLineWidthAA), NO_EXTRA" ],
   [ "COLOR_LOGIC_OP", "CONTEXT_BOOL(Color.ColorLogicOpEnabled), NO_EXTRA" ],
-  [ "LOGIC_OP_MODE", "CONTEXT_ENUM(Color.LogicOp), NO_EXTRA" ],
-  [ "MATRIX_MODE", "CONTEXT_ENUM(Transform.MatrixMode), NO_EXTRA" ],
+  [ "LOGIC_OP_MODE", "CONTEXT_ENUM16(Color.LogicOp), NO_EXTRA" ],
+  [ "MATRIX_MODE", "CONTEXT_ENUM16(Transform.MatrixMode), NO_EXTRA" ],
   [ "MAX_MODELVIEW_STACK_DEPTH", "CONST(MAX_MODELVIEW_STACK_DEPTH), NO_EXTRA" ],
   [ "MAX_PROJECTION_STACK_DEPTH", "CONST(MAX_PROJECTION_STACK_DEPTH), NO_EXTRA" ],
   [ "MAX_TEXTURE_STACK_DEPTH", "CONST(MAX_TEXTURE_STACK_DEPTH), NO_EXTRA" ],
   [ "MODELVIEW_MATRIX", "CONTEXT_MATRIX(ModelviewMatrixStack.Top), NO_EXTRA" ],
   [ "MODELVIEW_STACK_DEPTH", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, ModelviewMatrixStack.Depth), NO_EXTRA" ],
   [ "NORMALIZE", "CONTEXT_BOOL(Transform.Normalize), NO_EXTRA" ],
   [ "PACK_SKIP_IMAGES", "CONTEXT_INT(Pack.SkipImages), NO_EXTRA" ],
-  [ "PERSPECTIVE_CORRECTION_HINT", "CONTEXT_ENUM(Hint.PerspectiveCorrection), NO_EXTRA" ],
+  [ "PERSPECTIVE_CORRECTION_HINT", "CONTEXT_ENUM16(Hint.PerspectiveCorrection), NO_EXTRA" ],
   [ "POINT_SIZE", "CONTEXT_FLOAT(Point.Size), NO_EXTRA" ],
   [ "POINT_SIZE_RANGE", "CONTEXT_FLOAT2(Const.MinPointSizeAA), NO_EXTRA" ],
   [ "POINT_SMOOTH", "CONTEXT_BOOL(Point.SmoothFlag), NO_EXTRA" ],
-  [ "POINT_SMOOTH_HINT", "CONTEXT_ENUM(Hint.PointSmooth), NO_EXTRA" ],
+  [ "POINT_SMOOTH_HINT", "CONTEXT_ENUM16(Hint.PointSmooth), NO_EXTRA" ],
   [ "POINT_SIZE_MIN_EXT", "CONTEXT_FLOAT(Point.MinSize), NO_EXTRA" ],
   [ "POINT_SIZE_MAX_EXT", "CONTEXT_FLOAT(Point.MaxSize), NO_EXTRA" ],
   [ "POINT_FADE_THRESHOLD_SIZE_EXT", "CONTEXT_FLOAT(Point.Threshold), NO_EXTRA" ],
   [ "PROJECTION_MATRIX", "CONTEXT_MATRIX(ProjectionMatrixStack.Top), NO_EXTRA" ],
   [ "PROJECTION_STACK_DEPTH", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, ProjectionMatrixStack.Depth), NO_EXTRA" ],
   [ "RESCALE_NORMAL", "CONTEXT_BOOL(Transform.RescaleNormals), NO_EXTRA" ],
-  [ "SHADE_MODEL", "CONTEXT_ENUM(Light.ShadeModel), NO_EXTRA" ],
+  [ "SHADE_MODEL", "CONTEXT_ENUM16(Light.ShadeModel), NO_EXTRA" ],
   [ "TEXTURE_2D", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
   [ "TEXTURE_MATRIX", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_valid_texture_unit" ],
   [ "TEXTURE_STACK_DEPTH", "LOC_CUSTOM, TYPE_INT, 0, extra_valid_texture_unit" ],
   [ "VERTEX_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_POS].Enabled), NO_EXTRA" ],
   [ "VERTEX_ARRAY_SIZE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Size), NO_EXTRA" ],
-  [ "VERTEX_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_POS].Type), NO_EXTRA" ],
+  [ "VERTEX_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_POS].Type), NO_EXTRA" ],
   [ "VERTEX_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Stride), NO_EXTRA" ],
   [ "NORMAL_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_NORMAL].Enabled), NO_EXTRA" ],
-  [ "NORMAL_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_NORMAL].Type), NO_EXTRA" ],
+  [ "NORMAL_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_NORMAL].Type), NO_EXTRA" ],
   [ "NORMAL_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_NORMAL].Stride), NO_EXTRA" ],
   [ "COLOR_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR0].Enabled), NO_EXTRA" ],
   [ "COLOR_ARRAY_SIZE", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
-  [ "COLOR_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR0].Type), NO_EXTRA" ],
+  [ "COLOR_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_COLOR0].Type), NO_EXTRA" ],
   [ "COLOR_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Stride), NO_EXTRA" ],
   [ "TEXTURE_COORD_ARRAY", "LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_array_attributes, Enabled), NO_EXTRA" ],
   [ "TEXTURE_COORD_ARRAY_SIZE", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_array_attributes, Size), NO_EXTRA" ],
-  [ "TEXTURE_COORD_ARRAY_TYPE", "LOC_CUSTOM, TYPE_ENUM, offsetof(struct gl_array_attributes, Type), NO_EXTRA" ],
+  [ "TEXTURE_COORD_ARRAY_TYPE", "LOC_CUSTOM, TYPE_ENUM16, offsetof(struct gl_array_attributes, Type), NO_EXTRA" ],
   [ "TEXTURE_COORD_ARRAY_STRIDE", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_array_attributes, Stride), NO_EXTRA" ],
 
 # GL_ARB_multitexture
   [ "MAX_TEXTURE_UNITS", "CONTEXT_INT(Const.MaxTextureUnits), NO_EXTRA" ],
   [ "CLIENT_ACTIVE_TEXTURE", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # GL_ARB_texture_cube_map
   [ "TEXTURE_CUBE_MAP_ARB", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
 # S, T, and R are always set at the same time
   [ "TEXTURE_GEN_STR_OES", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
@@ -242,21 +242,21 @@ descriptor=[
   [ "TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, NO_EXTRA" ],
 
 # GL_OES_point_sprite
   [ "POINT_SPRITE_NV", "CONTEXT_BOOL(Point.PointSprite), extra_NV_point_sprite_ARB_point_sprite" ],
 ]},
 
 
 { "apis": ["GLES"], "params": [
 # OES_point_size_array
   [ "POINT_SIZE_ARRAY_OES", "ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled, TYPE_BOOLEAN), NO_EXTRA" ],
-  [ "POINT_SIZE_ARRAY_TYPE_OES", "ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Type, TYPE_ENUM), NO_EXTRA" ],
+  [ "POINT_SIZE_ARRAY_TYPE_OES", "ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Type, TYPE_ENUM16), NO_EXTRA" ],
   [ "POINT_SIZE_ARRAY_STRIDE_OES", "ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Stride, TYPE_INT), NO_EXTRA" ],
   [ "POINT_SIZE_ARRAY_BUFFER_BINDING_OES", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 ]},
 
 { "apis": ["GL", "GL_CORE", "GLES2"], "params": [
 # == GL_MAX_TEXTURE_COORDS_NV
   [ "MAX_TEXTURE_COORDS_ARB", "CONTEXT_INT(Const.MaxTextureCoordUnits), extra_ARB_fragment_program" ],
   [ "PACK_IMAGE_HEIGHT", "CONTEXT_INT(Pack.ImageHeight), NO_EXTRA" ],
   [ "PACK_ROW_LENGTH", "CONTEXT_INT(Pack.RowLength), NO_EXTRA" ],
   [ "PACK_SKIP_PIXELS", "CONTEXT_INT(Pack.SkipPixels), NO_EXTRA" ],
@@ -267,91 +267,91 @@ descriptor=[
   [ "UNPACK_SKIP_IMAGES", "CONTEXT_INT(Unpack.SkipImages), NO_EXTRA" ],
   [ "UNPACK_IMAGE_HEIGHT", "CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA" ],
 
 # GL_ARB_draw_buffers
   [ "MAX_DRAW_BUFFERS_ARB", "CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA" ],
 
 # GL_EXT_framebuffer_object / GL_NV_fbo_color_attachments
   [ "MAX_COLOR_ATTACHMENTS", "CONTEXT_INT(Const.MaxColorAttachments), NO_EXTRA" ],
 
 # GL_ARB_draw_buffers / GL_NV_draw_buffers (for ES 2.0)
-  [ "DRAW_BUFFER0_ARB", "BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA" ],
-  [ "DRAW_BUFFER1_ARB", "BUFFER_ENUM(ColorDrawBuffer[1]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER2_ARB", "BUFFER_ENUM(ColorDrawBuffer[2]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER3_ARB", "BUFFER_ENUM(ColorDrawBuffer[3]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER4_ARB", "BUFFER_ENUM(ColorDrawBuffer[4]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER5_ARB", "BUFFER_ENUM(ColorDrawBuffer[5]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER6_ARB", "BUFFER_ENUM(ColorDrawBuffer[6]), extra_valid_draw_buffer" ],
-  [ "DRAW_BUFFER7_ARB", "BUFFER_ENUM(ColorDrawBuffer[7]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER0_ARB", "BUFFER_ENUM16(ColorDrawBuffer[0]), NO_EXTRA" ],
+  [ "DRAW_BUFFER1_ARB", "BUFFER_ENUM16(ColorDrawBuffer[1]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER2_ARB", "BUFFER_ENUM16(ColorDrawBuffer[2]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER3_ARB", "BUFFER_ENUM16(ColorDrawBuffer[3]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER4_ARB", "BUFFER_ENUM16(ColorDrawBuffer[4]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER5_ARB", "BUFFER_ENUM16(ColorDrawBuffer[5]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER6_ARB", "BUFFER_ENUM16(ColorDrawBuffer[6]), extra_valid_draw_buffer" ],
+  [ "DRAW_BUFFER7_ARB", "BUFFER_ENUM16(ColorDrawBuffer[7]), extra_valid_draw_buffer" ],
   [ "BLEND_COLOR_EXT", "LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp" ],
 
 # GL_ARB_fragment_program
 # == GL_MAX_TEXTURE_IMAGE_UNITS_NV
   [ "MAX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits), extra_ARB_fragment_program" ],
   [ "MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits), extra_ARB_vertex_shader" ],
   [ "MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.MaxCombinedTextureImageUnits), extra_ARB_vertex_shader" ],
 
 # GL_ARB_shader_objects
 # Actually, this token isn't part of GL_ARB_shader_objects, but is
 # close enough for now.
   [ "CURRENT_PROGRAM", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # OpenGL 2.0
-  [ "STENCIL_BACK_FUNC", "CONTEXT_ENUM(Stencil.Function[1]), NO_EXTRA" ],
+  [ "STENCIL_BACK_FUNC", "CONTEXT_ENUM16(Stencil.Function[1]), NO_EXTRA" ],
   [ "STENCIL_BACK_VALUE_MASK", "CONTEXT_UINT(Stencil.ValueMask[1]), NO_EXTRA" ],
   [ "STENCIL_BACK_WRITEMASK", "CONTEXT_UINT(Stencil.WriteMask[1]), NO_EXTRA" ],
   [ "STENCIL_BACK_REF", "LOC_CUSTOM, TYPE_UINT, NO_OFFSET, NO_EXTRA" ],
-  [ "STENCIL_BACK_FAIL", "CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA" ],
-  [ "STENCIL_BACK_PASS_DEPTH_FAIL", "CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA" ],
-  [ "STENCIL_BACK_PASS_DEPTH_PASS", "CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA" ],
+  [ "STENCIL_BACK_FAIL", "CONTEXT_ENUM16(Stencil.FailFunc[1]), NO_EXTRA" ],
+  [ "STENCIL_BACK_PASS_DEPTH_FAIL", "CONTEXT_ENUM16(Stencil.ZFailFunc[1]), NO_EXTRA" ],
+  [ "STENCIL_BACK_PASS_DEPTH_PASS", "CONTEXT_ENUM16(Stencil.ZPassFunc[1]), NO_EXTRA" ],
   [ "MAX_VERTEX_ATTRIBS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxAttribs), extra_ARB_vertex_program_api_es2" ],
 
 # OES_texture_3D
   [ "TEXTURE_BINDING_3D", "LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA" ],
   [ "MAX_3D_TEXTURE_SIZE", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, Const.Max3DTextureLevels), NO_EXTRA" ],
 
 # GL_ARB_fragment_program/OES_standard_derivatives
-  [ "FRAGMENT_SHADER_DERIVATIVE_HINT", "CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader" ],
+  [ "FRAGMENT_SHADER_DERIVATIVE_HINT", "CONTEXT_ENUM16(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader" ],
 
 # GL_NV_read_buffer
-  [ "READ_BUFFER", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, extra_NV_read_buffer_api_gl" ],
+  [ "READ_BUFFER", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, extra_NV_read_buffer_api_gl" ],
 
 # GL_ARB_ES2_compatibility
   [ "SHADER_COMPILER", "CONST(1), extra_ARB_ES2_compatibility_api_es2" ],
   [ "MAX_VARYING_VECTORS", "CONTEXT_INT(Const.MaxVarying), extra_ARB_ES2_compatibility_api_es2" ],
   [ "MAX_VERTEX_UNIFORM_VECTORS", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_ES2_compatibility_api_es2" ],
   [ "MAX_FRAGMENT_UNIFORM_VECTORS", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_ES2_compatibility_api_es2" ],
   [ "NUM_SHADER_BINARY_FORMATS", "CONST(0), extra_ARB_ES2_compatibility_api_es2" ],
   [ "SHADER_BINARY_FORMATS", "LOC_CUSTOM, TYPE_INVALID, 0, extra_ARB_ES2_compatibility_api_es2" ],
 
 # GL_ARB_get_program_binary / GL_OES_get_program_binary
   [ "NUM_PROGRAM_BINARY_FORMATS", "CONST(0), NO_EXTRA" ],
   [ "PROGRAM_BINARY_FORMATS", "LOC_CUSTOM, TYPE_INVALID, 0, NO_EXTRA" ],
 
 # GL_INTEL_performance_query
   [ "PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_QUERY_NAME_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_NAME_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL", "CONST(MAX_PERFQUERY_COUNTER_DESC_LENGTH), extra_INTEL_performance_query" ],
   [ "PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL", "CONST(PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS), extra_INTEL_performance_query" ],
 
 # GL_KHR_context_flush_control
-  [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM(Const.ContextReleaseBehavior), NO_EXTRA" ],
+  [ "CONTEXT_RELEASE_BEHAVIOR", "CONTEXT_ENUM16(Const.ContextReleaseBehavior), NO_EXTRA" ],
 
 # blend_func_extended
   [ "MAX_DUAL_SOURCE_DRAW_BUFFERS", "CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended" ],
 
 # GL_KHR_blend_equation_advanced_coherent
   [ "BLEND_ADVANCED_COHERENT_KHR", "CONTEXT_BOOL(Color.BlendCoherent), extra_KHR_blend_equation_advanced_coherent" ],
 
 # GL_ARB_robustness / GL_KHR_robustness
-  [ "CONTEXT_ROBUST_ACCESS", "CONTEXT_ENUM(Const.RobustAccess), extra_KHR_robustness" ],
-  [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), extra_KHR_robustness_or_GL" ],
+  [ "CONTEXT_ROBUST_ACCESS", "CONTEXT_ENUM16(Const.RobustAccess), extra_KHR_robustness" ],
+  [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM16(Const.ResetStrategy), extra_KHR_robustness_or_GL" ],
 ]},
 
 # GLES3 is not a typo.
 { "apis": ["GL", "GLES", "GLES3", "GL_CORE"], "params": [
 # GL_EXT_texture_lod_bias
   [ "MAX_TEXTURE_LOD_BIAS_EXT", "CONTEXT_FLOAT(Const.MaxTextureLodBias), NO_EXTRA" ],
 ]},
 
 
 # Enums in  OpenGL and ES 3.0
@@ -420,21 +420,21 @@ descriptor=[
 # GL_EXT_transform_feedback
   [ "TRANSFORM_FEEDBACK_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_EXT_transform_feedback" ],
   [ "RASTERIZER_DISCARD", "CONTEXT_BOOL(RasterDiscard), extra_EXT_transform_feedback" ],
   [ "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", "CONTEXT_INT(Const.MaxTransformFeedbackInterleavedComponents), extra_EXT_transform_feedback" ],
   [ "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", "CONTEXT_INT(Const.MaxTransformFeedbackBuffers), extra_EXT_transform_feedback" ],
   [ "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", "CONTEXT_INT(Const.MaxTransformFeedbackSeparateComponents), extra_EXT_transform_feedback" ],
 
 # GL_EXT_window_rectangles
   [ "MAX_WINDOW_RECTANGLES_EXT", "CONTEXT_INT(Const.MaxWindowRectangles), extra_EXT_window_rectangles" ],
   [ "NUM_WINDOW_RECTANGLES_EXT", "CONTEXT_INT(Scissor.NumWindowRects), extra_EXT_window_rectangles" ],
-  [ "WINDOW_RECTANGLE_MODE_EXT", "CONTEXT_ENUM(Scissor.WindowRectMode), extra_EXT_window_rectangles" ],
+  [ "WINDOW_RECTANGLE_MODE_EXT", "CONTEXT_ENUM16(Scissor.WindowRectMode), extra_EXT_window_rectangles" ],
 ]},
 
 { "apis": ["GLES", "GLES2"], "params": [
 # GL_EXT_shader_framebuffer_fetch.  Should be true if the MESA framebuffer
 # fetch extension is supported since the latter imposes no restrictions on
 # non-uniform per-sample discard.
   [ "FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT", "CONTEXT_BOOL(Extensions.MESA_shader_framebuffer_fetch), extra_EXT_shader_framebuffer_fetch" ],
 # GL_OES_EGL_image_external
   [ "TEXTURE_BINDING_EXTERNAL_OES", "LOC_CUSTOM, TYPE_INT, TEXTURE_EXTERNAL_INDEX, extra_OES_EGL_image_external" ],
   [ "TEXTURE_EXTERNAL_OES", "LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_OES_EGL_image_external" ],
@@ -504,25 +504,25 @@ descriptor=[
 # GL_ARB_framebuffer_no_attachments / geometry shader
   [ "MAX_FRAMEBUFFER_LAYERS", "CONTEXT_INT(Const.MaxFramebufferLayers), extra_ARB_framebuffer_no_attachments_and_geometry_shader" ],
 
 # GL_ARB_explicit_uniform_location / GLES 3.1
   [ "MAX_UNIFORM_LOCATIONS", "CONTEXT_INT(Const.MaxUserAssignableUniformLocations), extra_ARB_explicit_uniform_location" ],
 
 # GL_ARB_separate_shader_objects / GLES 3.1
   [ "PROGRAM_PIPELINE_BINDING", "LOC_CUSTOM, TYPE_INT, GL_PROGRAM_PIPELINE_BINDING, NO_EXTRA" ],
 
 # GL_ARB_vertex_attrib_binding / GLES 3.1
-  [ "MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA" ],
-  [ "MAX_VERTEX_ATTRIB_BINDINGS", "CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA" ],
+  [ "MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "CONTEXT_ENUM16(Const.MaxVertexAttribRelativeOffset), NO_EXTRA" ],
+  [ "MAX_VERTEX_ATTRIB_BINDINGS", "CONTEXT_ENUM16(Const.MaxVertexAttribBindings), NO_EXTRA" ],
 
 # GL 4.4 / GLES 3.1
-  [ "MAX_VERTEX_ATTRIB_STRIDE", "CONTEXT_ENUM(Const.MaxVertexAttribStride), NO_EXTRA" ],
+  [ "MAX_VERTEX_ATTRIB_STRIDE", "CONTEXT_ENUM16(Const.MaxVertexAttribStride), NO_EXTRA" ],
 
   # GL_ARB_shader_storage_buffer_object / GLES 3.1
   [ "MAX_VERTEX_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "MAX_FRAGMENT_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "MAX_COMPUTE_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_COMPUTE].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "MAX_COMBINED_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.MaxCombinedShaderStorageBlocks), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "MAX_SHADER_STORAGE_BLOCK_SIZE", "CONTEXT_INT(Const.MaxShaderStorageBlockSize), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "MAX_SHADER_STORAGE_BUFFER_BINDINGS", "CONTEXT_INT(Const.MaxShaderStorageBufferBindings), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.ShaderStorageBufferOffsetAlignment), extra_ARB_shader_storage_buffer_object_es31" ],
   [ "SHADER_STORAGE_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_storage_buffer_object_es31" ],
@@ -600,33 +600,33 @@ descriptor=[
 
 # GL_ARB_shader_storage_buffer_object / tessellation shader
   [ "MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
   [ "MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks), extra_ARB_shader_storage_buffer_object" ],
 
 # GL_ARB_uniform_buffer_object / geometry shader
   [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
   [ "MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
 
 # GL_ARB_viewport_array / GL_OES_geometry_shader
-  [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Const.LayerAndVPIndexProvokingVertex), extra_ARB_viewport_array_or_oes_geometry_shader" ],
+  [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM16(Const.LayerAndVPIndexProvokingVertex), extra_ARB_viewport_array_or_oes_geometry_shader" ],
 
 # GL_ARB_gpu_shader5 / GL_OES_geometry_shader
   [ "MAX_GEOMETRY_SHADER_INVOCATIONS", "CONST(MAX_GEOMETRY_SHADER_INVOCATIONS), extra_ARB_gpu_shader5_or_oes_geometry_shader" ],
 
 # GL_OES_primitive_bounding_box
   [ "PRIMITIVE_BOUNDING_BOX_ARB", "CONTEXT_FLOAT8(PrimitiveBoundingBox), extra_OES_primitive_bounding_box" ],
 
 # GL_ARB_viewport_array / GL_OES_viewport_array
   [ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array_or_oes_viewport_array" ],
   [ "VIEWPORT_SUBPIXEL_BITS", "CONTEXT_INT(Const.ViewportSubpixelBits), extra_ARB_viewport_array_or_oes_viewport_array" ],
   [ "VIEWPORT_BOUNDS_RANGE", "CONTEXT_FLOAT2(Const.ViewportBounds), extra_ARB_viewport_array_or_oes_viewport_array" ],
-  [ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM(Const.LayerAndVPIndexProvokingVertex), extra_ARB_viewport_array_or_oes_viewport_array" ],
+  [ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM16(Const.LayerAndVPIndexProvokingVertex), extra_ARB_viewport_array_or_oes_viewport_array" ],
 
 # INTEL_conservative_rasterization
   [ "CONSERVATIVE_RASTERIZATION_INTEL", "CONTEXT_BOOL(IntelConservativeRasterization), extra_INTEL_conservative_rasterization" ],
 ]},
 
 { "apis": ["GL_CORE", "GLES32"], "params": [
   [ "MULTISAMPLE_LINE_WIDTH_RANGE_ARB", "CONTEXT_FLOAT2(Const.MinLineWidthAA), extra_ES32" ],
   [ "MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB", "CONTEXT_FLOAT(Const.LineWidthGranularity), extra_ES32" ],
 ]},
 
@@ -642,58 +642,58 @@ descriptor=[
   [ "ACCUM_BLUE_BITS", "BUFFER_INT(Visual.accumBlueBits), NO_EXTRA" ],
   [ "ACCUM_ALPHA_BITS", "BUFFER_INT(Visual.accumAlphaBits), NO_EXTRA" ],
   [ "ACCUM_CLEAR_VALUE", "CONTEXT_FIELD(Accum.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA" ],
   [ "ALPHA_BIAS", "CONTEXT_FLOAT(Pixel.AlphaBias), NO_EXTRA" ],
   [ "ALPHA_SCALE", "CONTEXT_FLOAT(Pixel.AlphaScale), NO_EXTRA" ],
   [ "ATTRIB_STACK_DEPTH", "CONTEXT_INT(AttribStackDepth), NO_EXTRA" ],
   [ "AUTO_NORMAL", "CONTEXT_BOOL(Eval.AutoNormal), NO_EXTRA" ],
   [ "AUX_BUFFERS", "BUFFER_INT(Visual.numAuxBuffers), NO_EXTRA" ],
   [ "BLUE_BIAS", "CONTEXT_FLOAT(Pixel.BlueBias), NO_EXTRA" ],
   [ "BLUE_SCALE", "CONTEXT_FLOAT(Pixel.BlueScale), NO_EXTRA" ],
-  [ "CLIP_DEPTH_MODE", "CONTEXT_ENUM(Transform.ClipDepthMode), extra_ARB_clip_control" ],
-  [ "CLIP_ORIGIN", "CONTEXT_ENUM(Transform.ClipOrigin), extra_ARB_clip_control" ],
+  [ "CLIP_DEPTH_MODE", "CONTEXT_ENUM16(Transform.ClipDepthMode), extra_ARB_clip_control" ],
+  [ "CLIP_ORIGIN", "CONTEXT_ENUM16(Transform.ClipOrigin), extra_ARB_clip_control" ],
   [ "CLIENT_ATTRIB_STACK_DEPTH", "CONTEXT_INT(ClientAttribStackDepth), NO_EXTRA" ],
-  [ "COLOR_MATERIAL_FACE", "CONTEXT_ENUM(Light.ColorMaterialFace), NO_EXTRA" ],
-  [ "COLOR_MATERIAL_PARAMETER", "CONTEXT_ENUM(Light.ColorMaterialMode), NO_EXTRA" ],
+  [ "COLOR_MATERIAL_FACE", "CONTEXT_ENUM16(Light.ColorMaterialFace), NO_EXTRA" ],
+  [ "COLOR_MATERIAL_PARAMETER", "CONTEXT_ENUM16(Light.ColorMaterialMode), NO_EXTRA" ],
   [ "CURRENT_INDEX", "CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0]), extra_flush_current" ],
   [ "CURRENT_RASTER_COLOR", "CONTEXT_FIELD(Current.RasterColor[0], TYPE_FLOATN_4), NO_EXTRA" ],
   [ "CURRENT_RASTER_DISTANCE", "CONTEXT_FLOAT(Current.RasterDistance), NO_EXTRA" ],
   [ "CURRENT_RASTER_INDEX", "CONST(1), NO_EXTRA" ],
   [ "CURRENT_RASTER_POSITION", "CONTEXT_FLOAT4(Current.RasterPos[0]), NO_EXTRA" ],
   [ "CURRENT_RASTER_SECONDARY_COLOR", "CONTEXT_FIELD(Current.RasterSecondaryColor[0], TYPE_FLOATN_4), NO_EXTRA" ],
   [ "CURRENT_RASTER_TEXTURE_COORDS", "LOC_CUSTOM, TYPE_FLOAT_4, 0, extra_valid_texture_unit" ],
   [ "CURRENT_RASTER_POSITION_VALID", "CONTEXT_BOOL(Current.RasterPosValid), NO_EXTRA" ],
   [ "DEPTH_BIAS", "CONTEXT_FLOAT(Pixel.DepthBias), NO_EXTRA" ],
   [ "DEPTH_SCALE", "CONTEXT_FLOAT(Pixel.DepthScale), NO_EXTRA" ],
   [ "DOUBLEBUFFER", "BUFFER_INT(Visual.doubleBufferMode), NO_EXTRA" ],
-  [ "DRAW_BUFFER", "BUFFER_ENUM(ColorDrawBuffer[0]), NO_EXTRA" ],
+  [ "DRAW_BUFFER", "BUFFER_ENUM16(ColorDrawBuffer[0]), NO_EXTRA" ],
   [ "EDGE_FLAG", "LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_flush_current" ],
   [ "FEEDBACK_BUFFER_SIZE", "CONTEXT_INT(Feedback.BufferSize), NO_EXTRA" ],
-  [ "FEEDBACK_BUFFER_TYPE", "CONTEXT_ENUM(Feedback.Type), NO_EXTRA" ],
+  [ "FEEDBACK_BUFFER_TYPE", "CONTEXT_ENUM16(Feedback.Type), NO_EXTRA" ],
   [ "FOG_INDEX", "CONTEXT_FLOAT(Fog.Index), NO_EXTRA" ],
   [ "GREEN_BIAS", "CONTEXT_FLOAT(Pixel.GreenBias), NO_EXTRA" ],
   [ "GREEN_SCALE", "CONTEXT_FLOAT(Pixel.GreenScale), NO_EXTRA" ],
   [ "INDEX_BITS", "BUFFER_INT(Visual.indexBits), extra_new_buffers" ],
   [ "INDEX_CLEAR_VALUE", "CONTEXT_INT(Color.ClearIndex), NO_EXTRA" ],
   [ "INDEX_MODE", "CONST(0) , NO_EXTRA" ],
   [ "INDEX_OFFSET", "CONTEXT_INT(Pixel.IndexOffset), NO_EXTRA" ],
   [ "INDEX_SHIFT", "CONTEXT_INT(Pixel.IndexShift), NO_EXTRA" ],
   [ "INDEX_WRITEMASK", "CONTEXT_INT(Color.IndexMask), NO_EXTRA" ],
-  [ "LIGHT_MODEL_COLOR_CONTROL", "CONTEXT_ENUM(Light.Model.ColorControl), NO_EXTRA" ],
+  [ "LIGHT_MODEL_COLOR_CONTROL", "CONTEXT_ENUM16(Light.Model.ColorControl), NO_EXTRA" ],
   [ "LIGHT_MODEL_LOCAL_VIEWER", "CONTEXT_BOOL(Light.Model.LocalViewer), NO_EXTRA" ],
   [ "LINE_STIPPLE", "CONTEXT_BOOL(Line.StippleFlag), NO_EXTRA" ],
   [ "LINE_STIPPLE_PATTERN", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
   [ "LINE_STIPPLE_REPEAT", "CONTEXT_INT(Line.StippleFactor), NO_EXTRA" ],
   [ "LINE_WIDTH_GRANULARITY", "CONTEXT_FLOAT(Const.LineWidthGranularity), NO_EXTRA" ],
   [ "LIST_BASE", "CONTEXT_INT(List.ListBase), NO_EXTRA" ],
   [ "LIST_INDEX", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
-  [ "LIST_MODE", "LOC_CUSTOM, TYPE_ENUM, 0, NO_EXTRA" ],
+  [ "LIST_MODE", "LOC_CUSTOM, TYPE_ENUM16, 0, NO_EXTRA" ],
   [ "INDEX_LOGIC_OP", "CONTEXT_BOOL(Color.IndexLogicOpEnabled), NO_EXTRA" ],
   [ "MAP1_COLOR_4", "CONTEXT_BOOL(Eval.Map1Color4), NO_EXTRA" ],
   [ "MAP1_GRID_DOMAIN", "CONTEXT_FLOAT2(Eval.MapGrid1u1), NO_EXTRA" ],
   [ "MAP1_GRID_SEGMENTS", "CONTEXT_INT(Eval.MapGrid1un), NO_EXTRA" ],
   [ "MAP1_INDEX", "CONTEXT_BOOL(Eval.Map1Index), NO_EXTRA" ],
   [ "MAP1_NORMAL", "CONTEXT_BOOL(Eval.Map1Normal), NO_EXTRA" ],
   [ "MAP1_TEXTURE_COORD_1", "CONTEXT_BOOL(Eval.Map1TextureCoord1), NO_EXTRA" ],
   [ "MAP1_TEXTURE_COORD_2", "CONTEXT_BOOL(Eval.Map1TextureCoord2), NO_EXTRA" ],
   [ "MAP1_TEXTURE_COORD_3", "CONTEXT_BOOL(Eval.Map1TextureCoord3), NO_EXTRA" ],
   [ "MAP1_TEXTURE_COORD_4", "CONTEXT_BOOL(Eval.Map1TextureCoord4), NO_EXTRA" ],
@@ -726,30 +726,30 @@ descriptor=[
   [ "PIXEL_MAP_B_TO_B_SIZE", "CONTEXT_INT(PixelMaps.BtoB.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_G_TO_G_SIZE", "CONTEXT_INT(PixelMaps.GtoG.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_I_TO_A_SIZE", "CONTEXT_INT(PixelMaps.ItoA.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_I_TO_B_SIZE", "CONTEXT_INT(PixelMaps.ItoB.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_I_TO_G_SIZE", "CONTEXT_INT(PixelMaps.ItoG.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_I_TO_I_SIZE", "CONTEXT_INT(PixelMaps.ItoI.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_I_TO_R_SIZE", "CONTEXT_INT(PixelMaps.ItoR.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_R_TO_R_SIZE", "CONTEXT_INT(PixelMaps.RtoR.Size), NO_EXTRA" ],
   [ "PIXEL_MAP_S_TO_S_SIZE", "CONTEXT_INT(PixelMaps.StoS.Size), NO_EXTRA" ],
   [ "POINT_SIZE_GRANULARITY", "CONTEXT_FLOAT(Const.PointSizeGranularity), NO_EXTRA" ],
-  [ "POLYGON_MODE", "CONTEXT_ENUM2(Polygon.FrontMode), NO_EXTRA" ],
+  [ "POLYGON_MODE", "CONTEXT_ENUM16(Polygon.FrontMode), NO_EXTRA" ],
   [ "POLYGON_OFFSET_BIAS_EXT", "CONTEXT_FLOAT(Polygon.OffsetUnits), NO_EXTRA" ],
   [ "POLYGON_OFFSET_POINT", "CONTEXT_BOOL(Polygon.OffsetPoint), NO_EXTRA" ],
   [ "POLYGON_OFFSET_LINE", "CONTEXT_BOOL(Polygon.OffsetLine), NO_EXTRA" ],
   [ "POLYGON_SMOOTH", "CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA" ],
-  [ "POLYGON_SMOOTH_HINT", "CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA" ],
+  [ "POLYGON_SMOOTH_HINT", "CONTEXT_ENUM16(Hint.PolygonSmooth), NO_EXTRA" ],
   [ "POLYGON_STIPPLE", "CONTEXT_BOOL(Polygon.StippleFlag), NO_EXTRA" ],
   [ "RED_BIAS", "CONTEXT_FLOAT(Pixel.RedBias), NO_EXTRA" ],
   [ "RED_SCALE", "CONTEXT_FLOAT(Pixel.RedScale), NO_EXTRA" ],
-  [ "RENDER_MODE", "CONTEXT_ENUM(RenderMode), NO_EXTRA" ],
+  [ "RENDER_MODE", "CONTEXT_ENUM16(RenderMode), NO_EXTRA" ],
   [ "RGBA_MODE", "CONST(1), NO_EXTRA" ],
   [ "SELECTION_BUFFER_SIZE", "CONTEXT_INT(Select.BufferSize), NO_EXTRA" ],
   [ "STEREO", "BUFFER_INT(Visual.stereoMode), NO_EXTRA" ],
   [ "TEXTURE_1D", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
   [ "TEXTURE_3D", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
   [ "TEXTURE_BINDING_1D", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA" ],
   [ "TEXTURE_BINDING_1D_ARRAY", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_ARRAY_INDEX, extra_EXT_texture_array" ],
   [ "TEXTURE_GEN_S", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
   [ "TEXTURE_GEN_T", "LOC_TEXUNIT, TYPE_BIT_1, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
   [ "TEXTURE_GEN_R", "LOC_TEXUNIT, TYPE_BIT_2, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
@@ -757,21 +757,21 @@ descriptor=[
   [ "UNPACK_LSB_FIRST", "CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA" ],
   [ "UNPACK_SWAP_BYTES", "CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA" ],
   [ "ZOOM_X", "CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA" ],
   [ "ZOOM_Y", "CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA" ],
 
 # Vertex arrays
   [ "VERTEX_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
   [ "NORMAL_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
   [ "COLOR_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
   [ "INDEX_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled), NO_EXTRA" ],
-  [ "INDEX_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Type), NO_EXTRA" ],
+  [ "INDEX_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Type), NO_EXTRA" ],
   [ "INDEX_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Stride), NO_EXTRA" ],
   [ "INDEX_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
   [ "TEXTURE_COORD_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
   [ "EDGE_FLAG_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled), NO_EXTRA" ],
   [ "EDGE_FLAG_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Stride), NO_EXTRA" ],
   [ "EDGE_FLAG_ARRAY_COUNT_EXT", "CONST(0), NO_EXTRA" ],
 
 # GL_ARB_texture_compression
   [ "TEXTURE_COMPRESSION_HINT_ARB", "CONTEXT_INT(Hint.TextureCompression), NO_EXTRA" ],
 
@@ -791,49 +791,49 @@ descriptor=[
 
 # GL_ARB_transpose_matrix
   [ "TRANSPOSE_MODELVIEW_MATRIX_ARB", "CONTEXT_MATRIX_T(ModelviewMatrixStack), NO_EXTRA" ],
   [ "TRANSPOSE_PROJECTION_MATRIX_ARB", "CONTEXT_MATRIX_T(ProjectionMatrixStack.Top), NO_EXTRA" ],
   [ "TRANSPOSE_TEXTURE_MATRIX_ARB", "CONTEXT_MATRIX_T(TextureMatrixStack), NO_EXTRA" ],
 
 # GL_EXT_secondary_color
   [ "COLOR_SUM", "CONTEXT_BOOL(Fog.ColorSumEnabled), NO_EXTRA" ],
   [ "CURRENT_SECONDARY_COLOR", "CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4), extra_flush_current" ],
   [ "SECONDARY_COLOR_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR1].Enabled), NO_EXTRA" ],
-  [ "SECONDARY_COLOR_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR1].Type), NO_EXTRA" ],
+  [ "SECONDARY_COLOR_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_COLOR1].Type), NO_EXTRA" ],
   [ "SECONDARY_COLOR_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Stride), NO_EXTRA" ],
   [ "SECONDARY_COLOR_ARRAY_SIZE", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
 
 # GL_EXT_fog_coord
   [ "CURRENT_FOG_COORDINATE", "CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), extra_flush_current" ],
   [ "FOG_COORDINATE_ARRAY", "ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_FOG].Enabled), NO_EXTRA" ],
-  [ "FOG_COORDINATE_ARRAY_TYPE", "ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_FOG].Type), NO_EXTRA" ],
+  [ "FOG_COORDINATE_ARRAY_TYPE", "ARRAY_ENUM16(VertexAttrib[VERT_ATTRIB_FOG].Type), NO_EXTRA" ],
   [ "FOG_COORDINATE_ARRAY_STRIDE", "ARRAY_INT(VertexAttrib[VERT_ATTRIB_FOG].Stride), NO_EXTRA" ],
-  [ "FOG_COORDINATE_SOURCE", "CONTEXT_ENUM(Fog.FogCoordinateSource), NO_EXTRA" ],
+  [ "FOG_COORDINATE_SOURCE", "CONTEXT_ENUM16(Fog.FogCoordinateSource), NO_EXTRA" ],
 
 # GL_NV_fog_distance
-  [ "FOG_DISTANCE_MODE_NV", "CONTEXT_ENUM(Fog.FogDistanceMode), extra_NV_fog_distance" ],
+  [ "FOG_DISTANCE_MODE_NV", "CONTEXT_ENUM16(Fog.FogDistanceMode), extra_NV_fog_distance" ],
 
 # GL_IBM_rasterpos_clip
   [ "RASTER_POSITION_UNCLIPPED_IBM", "CONTEXT_BOOL(Transform.RasterPositionUnclipped), NO_EXTRA" ],
 
 # GL_NV_point_sprite
-  [ "POINT_SPRITE_R_MODE_NV", "CONTEXT_ENUM(Point.SpriteRMode), extra_NV_point_sprite" ],
-  [ "POINT_SPRITE_COORD_ORIGIN", "CONTEXT_ENUM(Point.SpriteOrigin), extra_NV_point_sprite_ARB_point_sprite" ],
+  [ "POINT_SPRITE_R_MODE_NV", "CONTEXT_ENUM16(Point.SpriteRMode), extra_NV_point_sprite" ],
+  [ "POINT_SPRITE_COORD_ORIGIN", "CONTEXT_ENUM16(Point.SpriteOrigin), extra_NV_point_sprite_ARB_point_sprite" ],
 
 # GL_NV_texture_rectangle
   [ "TEXTURE_RECTANGLE_NV", "LOC_CUSTOM, TYPE_BOOLEAN, 0, extra_NV_texture_rectangle" ],
   [ "TEXTURE_BINDING_RECTANGLE_NV", "LOC_CUSTOM, TYPE_INT, TEXTURE_RECT_INDEX, extra_NV_texture_rectangle" ],
   [ "MAX_RECTANGLE_TEXTURE_SIZE_NV", "CONTEXT_INT(Const.MaxTextureRectSize), extra_NV_texture_rectangle" ],
 
 # GL_EXT_stencil_two_side
   [ "STENCIL_TEST_TWO_SIDE_EXT", "CONTEXT_BOOL(Stencil.TestTwoSide), extra_EXT_stencil_two_side" ],
-  [ "ACTIVE_STENCIL_FACE_EXT", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
+  [ "ACTIVE_STENCIL_FACE_EXT", "LOC_CUSTOM, TYPE_ENUM16, NO_OFFSET, NO_EXTRA" ],
 
 # GL_NV_light_max_exponent
   [ "MAX_SHININESS_NV", "CONTEXT_FLOAT(Const.MaxShininess), NO_EXTRA" ],
   [ "MAX_SPOT_EXPONENT_NV", "CONTEXT_FLOAT(Const.MaxSpotExponent), NO_EXTRA" ],
 
 # GL_NV_primitive_restart
   [ "PRIMITIVE_RESTART_NV", "CONTEXT_BOOL(Array.PrimitiveRestart), extra_NV_primitive_restart" ],
   [ "PRIMITIVE_RESTART_INDEX_NV", "CONTEXT_INT(Array.RestartIndex), extra_NV_primitive_restart" ],
 
 # GL_ARB_vertex_buffer_object
@@ -880,21 +880,21 @@ descriptor=[
   [ "NUM_FRAGMENT_REGISTERS_ATI", "CONST(6), extra_ATI_fragment_shader" ],
   [ "NUM_FRAGMENT_CONSTANTS_ATI", "CONST(8), extra_ATI_fragment_shader" ],
   [ "NUM_PASSES_ATI", "CONST(2), extra_ATI_fragment_shader" ],
   [ "NUM_INSTRUCTIONS_PER_PASS_ATI", "CONST(8), extra_ATI_fragment_shader" ],
   [ "NUM_INSTRUCTIONS_TOTAL_ATI", "CONST(16), extra_ATI_fragment_shader" ],
   [ "COLOR_ALPHA_PAIRING_ATI", "CONST(GL_TRUE), extra_ATI_fragment_shader" ],
   [ "NUM_LOOPBACK_COMPONENTS_ATI", "CONST(3), extra_ATI_fragment_shader" ],
   [ "NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", "CONST(3), extra_ATI_fragment_shader" ],
 
 # GL_EXT_provoking_vertex
-  [ "PROVOKING_VERTEX_EXT", "CONTEXT_ENUM(Light.ProvokingVertex), extra_EXT_provoking_vertex" ],
+  [ "PROVOKING_VERTEX_EXT", "CONTEXT_ENUM16(Light.ProvokingVertex), extra_EXT_provoking_vertex" ],
   [ "QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT", "CONTEXT_BOOL(Const.QuadsFollowProvokingVertexConvention), extra_EXT_provoking_vertex_32" ],
 
 # GL_ARB_seamless_cube_map
   [ "TEXTURE_CUBE_MAP_SEAMLESS", "CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map" ],
 
 # GL_EXT_texture_integer
   [ "RGBA_INTEGER_MODE_EXT", "LOC_CUSTOM, TYPE_INT, 0, extra_EXT_texture_integer_and_new_buffers" ],
 
 # GL_ARB_transform_feedback3
   [ "MAX_TRANSFORM_FEEDBACK_BUFFERS", "CONTEXT_INT(Const.MaxTransformFeedbackBuffers), extra_ARB_transform_feedback3" ],
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 3f2a923..3729604 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -36,20 +36,21 @@
 #define GL_GLEXT_PROTOTYPES
 #include "GL/gl.h"
 #include "GL/glext.h"
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
+typedef unsigned short GLenum16; /* custom Mesa type to save space */
 typedef int GLclampx;
 
 
 #ifndef GL_OES_EGL_image
 typedef void *GLeglImageOES;
 #endif
 
 
 #ifndef GL_OES_EGL_image_external
 #define GL_TEXTURE_EXTERNAL_OES                                 0x8D65
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4682e02..0b544c0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -376,21 +376,21 @@ struct gl_light
 
 
 /**
  * Light model state.
  */
 struct gl_lightmodel
 {
    GLfloat Ambient[4];		/**< ambient color */
    GLboolean LocalViewer;	/**< Local (or infinite) view point? */
    GLboolean TwoSide;		/**< Two (or one) sided lighting? */
-   GLenum ColorControl;		/**< either GL_SINGLE_COLOR
+   GLenum16 ColorControl;	/**< either GL_SINGLE_COLOR
 				 *    or GL_SEPARATE_SPECULAR_COLOR */
 };
 
 
 /**
  * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
  */
 struct gl_accum_attrib
 {
    GLfloat ClearColor[4];	/**< Accumulation buffer clear color */
@@ -412,53 +412,53 @@ union gl_color_union
 /**
  * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
  */
 struct gl_colorbuffer_attrib
 {
    GLuint ClearIndex;                      /**< Index for glClear */
    union gl_color_union ClearColor;        /**< Color for glClear, unclamped */
    GLuint IndexMask;                       /**< Color index write mask */
    GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; /**< Each flag is 0xff or 0x0 */
 
-   GLenum DrawBuffer[MAX_DRAW_BUFFERS];	/**< Which buffer to draw into */
+   GLenum16 DrawBuffer[MAX_DRAW_BUFFERS];  /**< Which buffer to draw into */
 
    /** 
     * \name alpha testing
     */
    /*@{*/
    GLboolean AlphaEnabled;		/**< Alpha test enabled flag */
-   GLenum AlphaFunc;			/**< Alpha test function */
+   GLenum16 AlphaFunc;			/**< Alpha test function */
    GLfloat AlphaRefUnclamped;
    GLclampf AlphaRef;			/**< Alpha reference value */
    /*@}*/
 
    /** 
     * \name Blending
     */
    /*@{*/
    GLbitfield BlendEnabled;		/**< Per-buffer blend enable flags */
 
    /* NOTE: this does _not_ depend on fragment clamping or any other clamping
     * control, only on the fixed-pointness of the render target.
     * The query does however depend on fragment color clamping.
     */
    GLfloat BlendColorUnclamped[4];               /**< Blending color */
    GLfloat BlendColor[4];		/**< Blending color */
 
    struct
    {
-      GLenum SrcRGB;             /**< RGB blend source term */
-      GLenum DstRGB;             /**< RGB blend dest term */
-      GLenum SrcA;               /**< Alpha blend source term */
-      GLenum DstA;               /**< Alpha blend dest term */
-      GLenum EquationRGB;        /**< GL_ADD, GL_SUBTRACT, etc. */
-      GLenum EquationA;          /**< GL_ADD, GL_SUBTRACT, etc. */
+      GLenum16 SrcRGB;           /**< RGB blend source term */
+      GLenum16 DstRGB;           /**< RGB blend dest term */
+      GLenum16 SrcA;             /**< Alpha blend source term */
+      GLenum16 DstA;             /**< Alpha blend dest term */
+      GLenum16 EquationRGB;      /**< GL_ADD, GL_SUBTRACT, etc. */
+      GLenum16 EquationA;        /**< GL_ADD, GL_SUBTRACT, etc. */
       /**
        * Set if any blend factor uses SRC1.  Computed at the time blend factors
        * get set.
        */
       GLboolean _UsesDualSrc;
    } Blend[MAX_DRAW_BUFFERS];
    /** Are the blend func terms currently different for each buffer/target? */
    GLboolean _BlendFuncPerBuffer;
    /** Are the blend equations currently different for each buffer/target? */
    GLboolean _BlendEquationPerBuffer;
@@ -475,29 +475,29 @@ struct gl_colorbuffer_attrib
    /** Coherency requested via glEnable(GL_BLEND_ADVANCED_COHERENT_KHR)? */
    bool BlendCoherent;
    /*@}*/
 
    /** 
     * \name Logic op
     */
    /*@{*/
    GLboolean IndexLogicOpEnabled;	/**< Color index logic op enabled flag */
    GLboolean ColorLogicOpEnabled;	/**< RGBA logic op enabled flag */
-   GLenum LogicOp;			/**< Logic operator */
+   GLenum16 LogicOp;			/**< Logic operator */
 
    /*@}*/
 
    GLboolean DitherFlag;		/**< Dither enable flag */
 
    GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
-   GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
-   GLenum ClampReadColor;     /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
+   GLenum16 ClampFragmentColor;   /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
+   GLenum16 ClampReadColor;       /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
 
    GLboolean sRGBEnabled;    /**< Framebuffer sRGB blending/updating requested */
 };
 
 
 /**
  * Current attribute group (GL_CURRENT_BIT).
  */
 struct gl_current_attrib
 {
@@ -521,21 +521,21 @@ struct gl_current_attrib
    GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
    GLboolean RasterPosValid;
 };
 
 
 /**
  * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
  */
 struct gl_depthbuffer_attrib
 {
-   GLenum Func;			/**< Function for depth buffer compare */
+   GLenum16 Func;		/**< Function for depth buffer compare */
    GLclampd Clear;		/**< Value to clear depth buffer to */
    GLboolean Test;		/**< Depth buffering enabled flag */
    GLboolean Mask;		/**< Depth buffer writable? */
    GLboolean BoundsTest;        /**< GL_EXT_depth_bounds_test */
    GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
 };
 
 
 /**
  * Evaluator attribute group (GL_EVAL_BIT).
@@ -600,71 +600,71 @@ struct gl_fog_attrib
    GLboolean Enabled;		/**< Fog enabled flag */
    GLboolean ColorSumEnabled;
    uint8_t _PackedMode;		/**< Fog mode as 2 bits */
    uint8_t _PackedEnabledMode;	/**< Masked CompressedMode */
    GLfloat ColorUnclamped[4];            /**< Fog color */
    GLfloat Color[4];		/**< Fog color */
    GLfloat Density;		/**< Density >= 0.0 */
    GLfloat Start;		/**< Start distance in eye coords */
    GLfloat End;			/**< End distance in eye coords */
    GLfloat Index;		/**< Fog index */
-   GLenum Mode;			/**< Fog mode */
-   GLenum FogCoordinateSource;  /**< GL_EXT_fog_coord */
+   GLenum16 Mode;		/**< Fog mode */
+   GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */
    GLfloat _Scale;		/**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
-   GLenum FogDistanceMode;     /**< GL_NV_fog_distance */
+   GLenum16 FogDistanceMode;    /**< GL_NV_fog_distance */
 };
 
 
 /** 
  * Hint attribute group (GL_HINT_BIT).
  * 
  * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
  */
 struct gl_hint_attrib
 {
-   GLenum PerspectiveCorrection;
-   GLenum PointSmooth;
-   GLenum LineSmooth;
-   GLenum PolygonSmooth;
-   GLenum Fog;
-   GLenum TextureCompression;   /**< GL_ARB_texture_compression */
-   GLenum GenerateMipmap;       /**< GL_SGIS_generate_mipmap */
-   GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
+   GLenum16 PerspectiveCorrection;
+   GLenum16 PointSmooth;
+   GLenum16 LineSmooth;
+   GLenum16 PolygonSmooth;
+   GLenum16 Fog;
+   GLenum16 TextureCompression; /**< GL_ARB_texture_compression */
+   GLenum16 GenerateMipmap;     /**< GL_SGIS_generate_mipmap */
+   GLenum16 FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
 };
 
 
 /**
  * Lighting attribute group (GL_LIGHT_BIT).
  */
 struct gl_light_attrib
 {
    struct gl_light Light[MAX_LIGHTS];	/**< Array of light sources */
    struct gl_lightmodel Model;		/**< Lighting model */
 
    /**
     * Front and back material values.
     * Note: must call FLUSH_VERTICES() before using.
     */
    struct gl_material Material;
 
    GLboolean Enabled;			/**< Lighting enabled flag */
    GLboolean ColorMaterialEnabled;
 
-   GLenum ShadeModel;			/**< GL_FLAT or GL_SMOOTH */
-   GLenum ProvokingVertex;              /**< GL_EXT_provoking_vertex */
-   GLenum ColorMaterialFace;		/**< GL_FRONT, BACK or FRONT_AND_BACK */
-   GLenum ColorMaterialMode;		/**< GL_AMBIENT, GL_DIFFUSE, etc */
+   GLenum16 ShadeModel;			/**< GL_FLAT or GL_SMOOTH */
+   GLenum16 ProvokingVertex;            /**< GL_EXT_provoking_vertex */
+   GLenum16 ColorMaterialFace;		/**< GL_FRONT, BACK or FRONT_AND_BACK */
+   GLenum16 ColorMaterialMode;		/**< GL_AMBIENT, GL_DIFFUSE, etc */
    GLbitfield _ColorMaterialBitmask;	/**< bitmask formed from Face and Mode */
 
 
    GLboolean _ClampVertexColor;
-   GLenum ClampVertexColor;             /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
+   GLenum16 ClampVertexColor;           /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
 
    /** 
     * Derived state for optimizations: 
     */
    /*@{*/
    GLbitfield _EnabledLights;	/**< bitmask containing enabled lights */
 
    GLboolean _NeedEyeCoords;		
    GLboolean _NeedVertices;		/**< Use fast shader? */
 
@@ -744,21 +744,21 @@ struct gl_pixelmaps
    struct gl_pixelmap ItoI;
    struct gl_pixelmap StoS;
 };
 
 
 /**
  * Pixel attribute group (GL_PIXEL_MODE_BIT).
  */
 struct gl_pixel_attrib
 {
-   GLenum ReadBuffer;		/**< source buffer for glRead/CopyPixels() */
+   GLenum16 ReadBuffer;		/**< source buffer for glRead/CopyPixels() */
 
    /*--- Begin Pixel Transfer State ---*/
    /* Fields are in the order in which they're applied... */
 
    /** Scale & Bias (index shift, offset) */
    /*@{*/
    GLfloat RedBias, RedScale;
    GLfloat GreenBias, GreenScale;
    GLfloat BlueBias, BlueScale;
    GLfloat AlphaBias, AlphaScale;
@@ -784,37 +784,37 @@ struct gl_pixel_attrib
 struct gl_point_attrib
 {
    GLfloat Size;		/**< User-specified point size */
    GLfloat Params[3];		/**< GL_EXT_point_parameters */
    GLfloat MinSize, MaxSize;	/**< GL_EXT_point_parameters */
    GLfloat Threshold;		/**< GL_EXT_point_parameters */
    GLboolean SmoothFlag;	/**< True if GL_POINT_SMOOTH is enabled */
    GLboolean _Attenuated;	/**< True if Params != [1, 0, 0] */
    GLboolean PointSprite;	/**< GL_NV/ARB_point_sprite */
    GLbitfield CoordReplace;     /**< GL_ARB_point_sprite*/
-   GLenum SpriteRMode;		/**< GL_NV_point_sprite (only!) */
-   GLenum SpriteOrigin;		/**< GL_ARB_point_sprite */
+   GLenum16 SpriteRMode;	/**< GL_NV_point_sprite (only!) */
+   GLenum16 SpriteOrigin;	/**< GL_ARB_point_sprite */
 };
 
 
 /**
  * Polygon attribute group (GL_POLYGON_BIT).
  */
 struct gl_polygon_attrib
 {
-   GLenum FrontFace;		/**< Either GL_CW or GL_CCW */
-   GLenum FrontMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
-   GLenum BackMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
+   GLenum16 FrontFace;		/**< Either GL_CW or GL_CCW */
+   GLenum16 FrontMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
+   GLenum16 BackMode;		/**< Either GL_POINT, GL_LINE or GL_FILL */
    GLboolean CullFlag;		/**< Culling on/off flag */
    GLboolean SmoothFlag;	/**< True if GL_POLYGON_SMOOTH is enabled */
    GLboolean StippleFlag;	/**< True if GL_POLYGON_STIPPLE is enabled */
-   GLenum CullFaceMode;		/**< Culling mode GL_FRONT or GL_BACK */
+   GLenum16 CullFaceMode;	/**< Culling mode GL_FRONT or GL_BACK */
    GLfloat OffsetFactor;	/**< Polygon offset factor, from user */
    GLfloat OffsetUnits;		/**< Polygon offset units, from user */
    GLfloat OffsetClamp;		/**< Polygon offset clamp, from user */
    GLboolean OffsetPoint;	/**< Offset in GL_POINT mode */
    GLboolean OffsetLine;	/**< Offset in GL_LINE mode */
    GLboolean OffsetFill;	/**< Offset in GL_FILL mode */
 };
 
 
 /**
@@ -823,21 +823,21 @@ struct gl_polygon_attrib
 struct gl_scissor_rect
 {
    GLint X, Y;			/**< Lower left corner of box */
    GLsizei Width, Height;	/**< Size of box */
 };
 struct gl_scissor_attrib
 {
    GLbitfield EnableFlags;	/**< Scissor test enabled? */
    struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
    GLint NumWindowRects;        /**< Count of enabled window rectangles */
-   GLenum WindowRectMode;       /**< Whether to include or exclude the rects */
+   GLenum16 WindowRectMode;     /**< Whether to include or exclude the rects */
    struct gl_scissor_rect WindowRects[MAX_WINDOW_RECTANGLES];
 };
 
 
 /**
  * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
  *
  * Three sets of stencil data are tracked so that OpenGL 2.0,
  * GL_EXT_stencil_two_side, and GL_ATI_separate_stencil can all be supported
  * simultaneously.  In each of the stencil state arrays, element 0 corresponds
@@ -850,24 +850,24 @@ struct gl_scissor_attrib
  *
  * The derived value \c _TestTwoSide is set when the front-face and back-face
  * stencil state are different.
  */
 struct gl_stencil_attrib
 {
    GLboolean Enabled;		/**< Enabled flag */
    GLboolean TestTwoSide;	/**< GL_EXT_stencil_two_side */
    GLubyte ActiveFace;		/**< GL_EXT_stencil_two_side (0 or 2) */
    GLubyte _BackFace;           /**< Current back stencil state (1 or 2) */
-   GLenum Function[3];		/**< Stencil function */
-   GLenum FailFunc[3];		/**< Fail function */
-   GLenum ZPassFunc[3];		/**< Depth buffer pass function */
-   GLenum ZFailFunc[3];		/**< Depth buffer fail function */
+   GLenum16 Function[3];	/**< Stencil function */
+   GLenum16 FailFunc[3];	/**< Fail function */
+   GLenum16 ZPassFunc[3];	/**< Depth buffer pass function */
+   GLenum16 ZFailFunc[3];	/**< Depth buffer fail function */
    GLint Ref[3];		/**< Reference value */
    GLuint ValueMask[3];		/**< Value mask */
    GLuint WriteMask[3];		/**< Write mask */
    GLuint Clear;		/**< Clear value */
 };
 
 
 /**
  * An index for each type of texture object.  These correspond to the GL
  * texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
@@ -910,21 +910,21 @@ typedef enum
 /*@}*/
 
 
 /**
  * Texture image state.  Drivers will typically create a subclass of this
  * with extra fields for memory buffers, etc.
  */
 struct gl_texture_image
 {
    GLint InternalFormat;	/**< Internal format as given by the user */
-   GLenum _BaseFormat;		/**< Either GL_RGB, GL_RGBA, GL_ALPHA,
+   GLenum16 _BaseFormat;	/**< Either GL_RGB, GL_RGBA, GL_ALPHA,
 				 *   GL_LUMINANCE, GL_LUMINANCE_ALPHA,
 				 *   GL_INTENSITY, GL_DEPTH_COMPONENT or
 				 *   GL_DEPTH_STENCIL_EXT only. Used for
 				 *   choosing TexEnv arithmetic.
 				 */
    mesa_format TexFormat;         /**< The actual texture memory format */
 
    GLuint Border;		/**< 0 or 1 */
    GLuint Width;		/**< = 2^WidthLog2 + 2*Border */
    GLuint Height;		/**< = 2^HeightLog2 + 2*Border */
@@ -968,130 +968,130 @@ typedef enum
  * Sampler object state.  These objects are new with GL_ARB_sampler_objects
  * and OpenGL 3.3.  Legacy texture objects also contain a sampler object.
  */
 struct gl_sampler_object
 {
    simple_mtx_t Mutex;
    GLuint Name;
    GLint RefCount;
    GLchar *Label;               /**< GL_KHR_debug */
 
-   GLenum WrapS;		/**< S-axis texture image wrap mode */
-   GLenum WrapT;		/**< T-axis texture image wrap mode */
-   GLenum WrapR;		/**< R-axis texture image wrap mode */
-   GLenum MinFilter;		/**< minification filter */
-   GLenum MagFilter;		/**< magnification filter */
+   GLenum16 WrapS;		/**< S-axis texture image wrap mode */
+   GLenum16 WrapT;		/**< T-axis texture image wrap mode */
+   GLenum16 WrapR;		/**< R-axis texture image wrap mode */
+   GLenum16 MinFilter;		/**< minification filter */
+   GLenum16 MagFilter;		/**< magnification filter */
    union gl_color_union BorderColor;  /**< Interpreted according to texture format */
    GLfloat MinLod;		/**< min lambda, OpenGL 1.2 */
    GLfloat MaxLod;		/**< max lambda, OpenGL 1.2 */
    GLfloat LodBias;		/**< OpenGL 1.4 */
    GLfloat MaxAnisotropy;	/**< GL_EXT_texture_filter_anisotropic */
-   GLenum CompareMode;		/**< GL_ARB_shadow */
-   GLenum CompareFunc;		/**< GL_ARB_shadow */
-   GLenum sRGBDecode;           /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
+   GLenum16 CompareMode;	/**< GL_ARB_shadow */
+   GLenum16 CompareFunc;	/**< GL_ARB_shadow */
+   GLenum16 sRGBDecode;         /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
    GLboolean CubeMapSeamless;   /**< GL_AMD_seamless_cubemap_per_texture */
 
    /** GL_ARB_bindless_texture */
    bool HandleAllocated;
    struct util_dynarray Handles;
 };
 
 
 /**
  * Texture object state.  Contains the array of mipmap images, border color,
  * wrap modes, filter modes, and shadow/texcompare state.
  */
 struct gl_texture_object
 {
    simple_mtx_t Mutex;      /**< for thread safety */
    GLint RefCount;             /**< reference count */
    GLuint Name;                /**< the user-visible texture object ID */
    GLchar *Label;               /**< GL_KHR_debug */
-   GLenum Target;              /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
+   GLenum16 Target;            /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
    gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
                                       Only valid when Target is valid. */
 
    struct gl_sampler_object Sampler;
 
-   GLenum DepthMode;           /**< GL_ARB_depth_texture */
+   GLenum16 DepthMode;         /**< GL_ARB_depth_texture */
 
    GLfloat Priority;           /**< in [0,1] */
    GLint BaseLevel;            /**< min mipmap level, OpenGL 1.2 */
    GLint MaxLevel;             /**< max mipmap level, OpenGL 1.2 */
    GLint ImmutableLevels;      /**< ES 3.0 / ARB_texture_view */
    GLint _MaxLevel;            /**< actual max mipmap level (q in the spec) */
    GLfloat _MaxLambda;         /**< = _MaxLevel - BaseLevel (q - p in spec) */
    GLint CropRect[4];          /**< GL_OES_draw_texture */
-   GLenum Swizzle[4];          /**< GL_EXT_texture_swizzle */
+   GLenum16 Swizzle[4];        /**< GL_EXT_texture_swizzle */
    GLuint _Swizzle;            /**< same as Swizzle, but SWIZZLE_* format */
    GLboolean GenerateMipmap;   /**< GL_SGIS_generate_mipmap */
    GLboolean _BaseComplete;    /**< Is the base texture level valid? */
    GLboolean _MipmapComplete;  /**< Is the whole mipmap valid? */
    GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */
    GLboolean _RenderToTexture; /**< Any rendering to this texture? */
    GLboolean Purgeable;        /**< Is the buffer purgeable under memory
                                     pressure? */
    GLboolean Immutable;        /**< GL_ARB_texture_storage */
    GLboolean _IsFloat;         /**< GL_OES_float_texture */
    GLboolean _IsHalfFloat;     /**< GL_OES_half_float_texture */
    bool StencilSampling;       /**< Should we sample stencil instead of depth? */
    bool HandleAllocated;       /**< GL_ARB_bindless_texture */
 
    GLuint MinLevel;            /**< GL_ARB_texture_view */
    GLuint MinLayer;            /**< GL_ARB_texture_view */
    GLuint NumLevels;           /**< GL_ARB_texture_view */
    GLuint NumLayers;           /**< GL_ARB_texture_view */
 
    /** GL_EXT_memory_object */
-   GLenum TextureTiling;
+   GLenum16 TextureTiling;
 
    /** Actual texture images, indexed by [cube face] and [mipmap level] */
    struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
 
    /** GL_ARB_texture_buffer_object */
    struct gl_buffer_object *BufferObject;
-   GLenum BufferObjectFormat;
+   GLenum16 BufferObjectFormat;
    /** Equivalent Mesa format for BufferObjectFormat. */
    mesa_format _BufferObjectFormat;
    /** GL_ARB_texture_buffer_range */
    GLintptr BufferOffset;
    GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
 
    /** GL_OES_EGL_image_external */
    GLint RequiredTextureImageUnits;
 
    /** GL_ARB_shader_image_load_store */
-   GLenum ImageFormatCompatibilityType;
+   GLenum16 ImageFormatCompatibilityType;
 
    /** GL_ARB_bindless_texture */
    struct util_dynarray SamplerHandles;
    struct util_dynarray ImageHandles;
 };
 
 
 /** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
 #define MAX_COMBINER_TERMS 4
 
 
 /**
  * Texture combine environment state.
  */
 struct gl_tex_env_combine_state
 {
-   GLenum ModeRGB;       /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
-   GLenum ModeA;         /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+   GLenum16 ModeRGB;     /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+   GLenum16 ModeA;       /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
    /** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
-   GLenum SourceRGB[MAX_COMBINER_TERMS];
-   GLenum SourceA[MAX_COMBINER_TERMS];
+   GLenum16 SourceRGB[MAX_COMBINER_TERMS];
+   GLenum16 SourceA[MAX_COMBINER_TERMS];
    /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
-   GLenum OperandRGB[MAX_COMBINER_TERMS];
-   GLenum OperandA[MAX_COMBINER_TERMS];
+   GLenum16 OperandRGB[MAX_COMBINER_TERMS];
+   GLenum16 OperandA[MAX_COMBINER_TERMS];
    GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
    GLuint ScaleShiftA;   /**< 0, 1 or 2 */
    GLuint _NumArgsRGB;   /**< Number of inputs used for the RGB combiner */
    GLuint _NumArgsA;     /**< Number of inputs used for the A combiner */
 };
 
 
 /** Compressed TexEnv effective Combine mode */
 enum gl_tex_env_mode
 {
@@ -1211,36 +1211,36 @@ struct gl_tex_env_combine_packed
 
 /** Non-identity texture matrix for texture unit? */
 #define ENABLE_TEXMAT(unit) (1 << (unit))
 
 
 /**
  * Texture coord generation state.
  */
 struct gl_texgen
 {
-   GLenum Mode;         /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
+   GLenum16 Mode;       /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
    GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
    GLfloat ObjectPlane[4];
    GLfloat EyePlane[4];
 };
 
 
 /**
  * Texture unit state.  Contains enable flags, texture environment/function/
  * combiners, texgen state, and pointers to current texture objects.
  */
 struct gl_texture_unit
 {
    GLbitfield Enabled;          /**< bitmask of TEXTURE_*_BIT flags */
 
-   GLenum EnvMode;              /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
+   GLenum16 EnvMode;            /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
    GLclampf EnvColor[4];
    GLfloat EnvColorUnclamped[4];
 
    struct gl_texgen GenS;
    struct gl_texgen GenT;
    struct gl_texgen GenR;
    struct gl_texgen GenQ;
    GLbitfield TexGenEnabled;	/**< Bitwise-OR of [STRQ]_BIT values */
    GLbitfield _GenFlags;	/**< Bitwise-OR of Gen[STRQ]._ModeBit */
 
@@ -1322,31 +1322,31 @@ struct gl_texture_attrib
  * of the ctx->Transform.EyeUserPlane or ctx->Transform._ClipUserPlane array).
  */
 typedef GLfloat gl_clip_plane[4];
 
 
 /**
  * Transformation attribute group (GL_TRANSFORM_BIT).
  */
 struct gl_transform_attrib
 {
-   GLenum MatrixMode;				/**< Matrix mode */
+   GLenum16 MatrixMode;				/**< Matrix mode */
    gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES];	/**< User clip planes */
    gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
    GLbitfield ClipPlanesEnabled;                /**< on/off bitmask */
    GLboolean Normalize;				/**< Normalize all normals? */
    GLboolean RescaleNormals;			/**< GL_EXT_rescale_normal */
    GLboolean RasterPositionUnclipped;           /**< GL_IBM_rasterpos_clip */
    GLboolean DepthClamp;			/**< GL_ARB_depth_clamp */
    /** GL_ARB_clip_control */
-   GLenum ClipOrigin;     /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
-   GLenum ClipDepthMode;  /**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
+   GLenum16 ClipOrigin;   /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
+   GLenum16 ClipDepthMode;/**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
 };
 
 
 /**
  * Viewport attribute group (GL_VIEWPORT_BIT).
  */
 struct gl_viewport_attrib
 {
    GLfloat X, Y;		/**< position */
    GLfloat Width, Height;	/**< size */
@@ -1389,21 +1389,21 @@ typedef enum {
 
 /**
  * GL_ARB_vertex/pixel_buffer_object buffer object
  */
 struct gl_buffer_object
 {
    simple_mtx_t Mutex;
    GLint RefCount;
    GLuint Name;
    GLchar *Label;       /**< GL_KHR_debug */
-   GLenum Usage;        /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
+   GLenum16 Usage;      /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
    GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
    GLsizeiptrARB Size;  /**< Size of buffer storage in bytes */
    GLubyte *Data;       /**< Location of storage either in RAM or VRAM. */
    GLboolean DeletePending;   /**< true if buffer object is removed from the hash */
    GLboolean Written;   /**< Ever written to? (for debugging) */
    GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
    GLboolean Immutable; /**< GL_ARB_buffer_storage */
    gl_buffer_usage UsageHistory; /**< How has this buffer been used so far? */
 
    /** Counters used for buffer usage warnings */
@@ -1445,22 +1445,22 @@ struct gl_pixelstore_attrib
 
 
 /**
  * Vertex array information which is derived from gl_array_attributes
  * and gl_vertex_buffer_binding information.  Used by the VBO module and
  * device drivers.
  */
 struct gl_vertex_array
 {
    GLint Size;                  /**< components per element (1,2,3,4) */
-   GLenum Type;                 /**< datatype: GL_FLOAT, GL_INT, etc */
-   GLenum Format;               /**< default: GL_RGBA, but may be GL_BGRA */
+   GLenum16 Type;               /**< datatype: GL_FLOAT, GL_INT, etc */
+   GLenum16 Format;             /**< default: GL_RGBA, but may be GL_BGRA */
    GLsizei StrideB;		/**< actual stride in bytes */
    GLuint _ElementSize;         /**< size of each element in bytes */
    const GLubyte *Ptr;          /**< Points to array data */
    GLboolean Normalized;        /**< GL_ARB_vertex_program */
    GLboolean Integer;           /**< Integer-valued? */
    GLboolean Doubles;       /**< double precision values are not converted to floats */
    GLuint InstanceDivisor;      /**< GL_ARB_instanced_arrays */
 
    struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
 };
@@ -1475,22 +1475,22 @@ struct gl_vertex_array
  * Note that the Stride field corresponds to VERTEX_ATTRIB_ARRAY_STRIDE
  * and is only present for backwards compatibility reasons.
  * Rendering always uses VERTEX_BINDING_STRIDE.
  * The gl*Pointer() functions will set VERTEX_ATTRIB_ARRAY_STRIDE
  * and VERTEX_BINDING_STRIDE to the same value, while
  * glBindVertexBuffer() will only set VERTEX_BINDING_STRIDE.
  */
 struct gl_array_attributes
 {
    GLint Size;              /**< Components per element (1,2,3,4) */
-   GLenum Type;             /**< Datatype: GL_FLOAT, GL_INT, etc */
-   GLenum Format;           /**< Default: GL_RGBA, but may be GL_BGRA */
+   GLenum16 Type;           /**< Datatype: GL_FLOAT, GL_INT, etc */
+   GLenum16 Format;         /**< Default: GL_RGBA, but may be GL_BGRA */
    GLsizei Stride;          /**< Stride as specified with gl*Pointer() */
    const GLubyte *Ptr;      /**< Points to client array data. Not used when a VBO is bound */
    GLintptr RelativeOffset; /**< Offset of the first element relative to the binding offset */
    GLboolean Enabled;       /**< Whether the array is enabled */
    GLboolean Normalized;    /**< Fixed-point values are normalized when converted to floats */
    GLboolean Integer;       /**< Fixed-point values are not converted to floats */
    GLboolean Doubles;       /**< double precision values are not converted to floats */
    GLuint _ElementSize;     /**< Size of each element in bytes */
    GLuint BufferBindingIndex;    /**< Vertex buffer binding */
 };
@@ -1632,21 +1632,21 @@ struct gl_array_attrib
    GLbitfield LegalTypesMask;
    gl_api LegalTypesMaskAPI;
 };
 
 
 /**
  * Feedback buffer state
  */
 struct gl_feedback
 {
-   GLenum Type;
+   GLenum16 Type;
    GLbitfield _Mask;    /**< FB_* bits */
    GLfloat *Buffer;
    GLuint BufferSize;
    GLuint Count;
 };
 
 
 /**
  * Selection buffer state
  */
@@ -1721,21 +1721,21 @@ struct gl_evaluators
    struct gl_2d_map Map2Texture2;
    struct gl_2d_map Map2Texture3;
    struct gl_2d_map Map2Texture4;
    /*@}*/
 };
 
 
 struct gl_transform_feedback_varying_info
 {
    char *Name;
-   GLenum Type;
+   GLenum16 Type;
    GLint BufferIndex;
    GLint Size;
    GLint Offset;
 };
 
 
 /**
  * Per-output info vertex shaders for transform feedback.
  */
 struct gl_transform_feedback_output
@@ -1854,21 +1854,21 @@ struct gl_transform_feedback_object
     */
    GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS];
 };
 
 
 /**
  * Context state for transform feedback.
  */
 struct gl_transform_feedback_state
 {
-   GLenum Mode;       /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
+   GLenum16 Mode;     /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
 
    /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
    struct gl_buffer_object *CurrentBuffer;
 
    /** The table of all transform feedback objects */
    struct _mesa_HashTable *Objects;
 
    /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */
    struct gl_transform_feedback_object *CurrentObject;
 
@@ -1922,21 +1922,21 @@ union gl_perf_monitor_counter_value
 
 struct gl_perf_monitor_counter
 {
    /** Human readable name for the counter. */
    const char *Name;
 
    /**
     * Data type of the counter.  Valid values are FLOAT, UNSIGNED_INT,
     * UNSIGNED_INT64_AMD, and PERCENTAGE_AMD.
     */
-   GLenum Type;
+   GLenum16 Type;
 
    /** Minimum counter value. */
    union gl_perf_monitor_counter_value Minimum;
 
    /** Maximum counter value. */
    union gl_perf_monitor_counter_value Maximum;
 };
 
 
 struct gl_perf_monitor_group
@@ -2019,21 +2019,21 @@ struct gl_bindless_sampler
  */
 struct gl_bindless_image
 {
    /** Image unit (set by glUniform1()). */
    GLubyte unit;
 
    /** Whether this bindless image is bound to a unit. */
    GLboolean bound;
 
    /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
-   GLenum access;
+   GLenum16 access;
 
    /** Pointer to the base of the data. */
    GLvoid *data;
 };
 
 /**
  * Names of the various vertex/fragment program register files, etc.
  *
  * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
  * All values should fit in a 4-bit field.
@@ -2070,22 +2070,22 @@ typedef enum
  */
 struct gl_program
 {
    /** FIXME: This must be first until we split shader_info from nir_shader */
    struct shader_info info;
 
    GLuint Id;
    GLint RefCount;
    GLubyte *String;  /**< Null-terminated program text */
 
-   GLenum Target;    /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
-   GLenum Format;    /**< String encoding format */
+   GLenum16 Target;  /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
+   GLenum16 Format;  /**< String encoding format */
 
    GLboolean _Used;        /**< Ever used for drawing? Used for debugging */
 
    struct nir_shader *nir;
 
    /* Saved and restored with metadata. Freed with ralloc. */
    void *driver_cache_blob;
    size_t driver_cache_blob_size;
 
    bool is_arb_asm; /** Is this an ARB assembly-style program */
@@ -2154,21 +2154,21 @@ struct gl_program
          GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
 
          /**
           * Access qualifier specified in the shader for each image uniform
           * index.  Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
           * GL_READ_WRITE.
           *
           * It may be different, though only more strict than the value of
           * \c gl_image_unit::Access for the corresponding image unit.
           */
-         GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
+         GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
 
          struct gl_uniform_block **UniformBlocks;
          struct gl_uniform_block **ShaderStorageBlocks;
 
          /** Which texture target is being sampled
           * (TEXTURE_1D/2D/3D/etc_INDEX)
           */
          gl_texture_index SamplerTargets[MAX_SAMPLERS];
 
          /**
@@ -2427,28 +2427,28 @@ struct gl_shader_info
    } TessCtrl;
 
    /**
     * Tessellation Evaluation shader state from layout qualifiers.
     */
    struct {
       /**
        * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
        * in this shader.
        */
-      GLenum PrimitiveMode;
+      GLenum16 PrimitiveMode;
 
       enum gl_tess_spacing Spacing;
 
       /**
        * GL_CW, GL_CCW, or 0 if it's not set in this shader.
        */
-      GLenum VertexOrder;
+      GLenum16 VertexOrder;
       /**
        * 1, 0, or -1 if it's not set in this shader.
        */
       int PointMode;
    } TessEval;
 
    /**
     * Geometry shader state from GLSL 1.50 layout qualifiers.
     */
    struct {
@@ -2456,26 +2456,26 @@ struct gl_shader_info
       /**
        * 0 - Invocations count not declared in shader, or
        * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
        */
       GLint Invocations;
       /**
        * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
        * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
        * shader.
        */
-      GLenum InputType;
+      GLenum16 InputType;
        /**
         * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
         * it's not set in this shader.
         */
-      GLenum OutputType;
+      GLenum16 OutputType;
    } Geom;
 
    /**
     * Compute shader state from ARB_compute_shader and
     * ARB_compute_variable_group_size layout qualifiers.
     */
    struct {
       /**
        * Size specified using local_size_{x,y,z}, or all 0's to indicate that
        * it's not set in this shader.
@@ -2565,21 +2565,21 @@ enum gl_compile_status
 
 /**
  * A GLSL shader object.
  */
 struct gl_shader
 {
    /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
     *  GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
     * Must be the first field.
     */
-   GLenum Type;
+   GLenum16 Type;
    gl_shader_stage Stage;
    GLuint Name;  /**< AKA the handle */
    GLint RefCount;  /**< Reference count */
    GLchar *Label;   /**< GL_KHR_debug */
    unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
    GLboolean DeletePending;
    bool IsES;              /**< True if this shader uses GLSL ES */
 
    enum gl_compile_status CompileStatus;
 
@@ -2827,21 +2827,21 @@ struct gl_shader_variable
     * Precision qualifier.
     */
    unsigned precision:2;
 };
 
 /**
  * Active resource in a gl_shader_program
  */
 struct gl_program_resource
 {
-   GLenum Type; /** Program interface type. */
+   GLenum16 Type; /** Program interface type. */
    const void *Data; /** Pointer to resource associated data structure. */
    uint8_t StageReferences; /** Bitmask of shader stage references. */
 };
 
 /**
  * Link status enum. linking_skipped is used to indicate linking
  * was skipped due to the shader being loaded from the on-disk cache.
  */
 enum gl_link_status
 {
@@ -2898,21 +2898,21 @@ struct gl_shader_program_data
    /* Mask of stages this program was linked against */
    unsigned linked_stages;
 };
 
 /**
  * A GLSL program object.
  * Basically a linked collection of vertex and fragment shaders.
  */
 struct gl_shader_program
 {
-   GLenum Type;  /**< Always GL_SHADER_PROGRAM (internal token) */
+   GLenum16 Type;   /**< Always GL_SHADER_PROGRAM (internal token) */
    GLuint Name;  /**< aka handle or ID */
    GLchar *Label;   /**< GL_KHR_debug */
    GLint RefCount;  /**< Reference count */
    GLboolean DeletePending;
 
    /**
     * Is the application intending to glGetProgramBinary this program?
     */
    GLboolean BinaryRetreivableHint;
 
@@ -2945,21 +2945,21 @@ struct gl_shader_program
    struct string_to_uint_map *FragDataIndexBindings;
 
    /**
     * Transform feedback varyings last specified by
     * glTransformFeedbackVaryings().
     *
     * For the current set of transform feedback varyings used for transform
     * feedback output, see LinkedTransformFeedback.
     */
    struct {
-      GLenum BufferMode;
+      GLenum16 BufferMode;
       /** Global xfb_stride out qualifier if any */
       GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
       GLuint NumVarying;
       GLchar **VaryingNames;  /**< Array [NumVarying] of char * */
    } TransformFeedback;
 
    struct gl_program *last_vert_prog;
 
    /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
    enum gl_frag_depth_layout FragDepthLayout;
@@ -3152,21 +3152,21 @@ struct gl_shader_compiler_options
 
    const struct nir_shader_compiler_options *NirOptions;
 };
 
 
 /**
  * Occlusion/timer query object.
  */
 struct gl_query_object
 {
-   GLenum Target;      /**< The query target, when active */
+   GLenum16 Target;    /**< The query target, when active */
    GLuint Id;          /**< hash table ID/name */
    GLchar *Label;       /**< GL_KHR_debug */
    GLuint64EXT Result; /**< the counter */
    GLboolean Active;   /**< inside Begin/EndQuery */
    GLboolean Ready;    /**< result is ready? */
    GLboolean EverBound;/**< has query object ever been bound */
    GLuint Stream;      /**< The stream */
 };
 
 
@@ -3189,34 +3189,34 @@ struct gl_query_state
    /** GL_ARB_transform_feedback_overflow_query */
    struct gl_query_object *TransformFeedbackOverflow[MAX_VERTEX_STREAMS];
    struct gl_query_object *TransformFeedbackOverflowAny;
 
    /** GL_ARB_timer_query */
    struct gl_query_object *TimeElapsed;
 
    /** GL_ARB_pipeline_statistics_query */
    struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
 
-   GLenum CondRenderMode;
+   GLenum16 CondRenderMode;
 };
 
 
 /** Sync object state */
 struct gl_sync_object
 {
    GLuint Name;               /**< Fence name */
    GLint RefCount;            /**< Reference count */
    GLchar *Label;             /**< GL_KHR_debug */
    GLboolean DeletePending;   /**< Object was deleted while there were still
 			       * live references (e.g., sync not yet finished)
 			       */
-   GLenum SyncCondition;
+   GLenum16 SyncCondition;
    GLbitfield Flags;          /**< Flags passed to glFenceSync */
    GLuint StatusFlag:1;       /**< Has the sync object been signaled? */
 };
 
 
 /**
  * State which can be shared by multiple contexts:
  */
 struct gl_shared_state
 {
@@ -3316,22 +3316,22 @@ struct gl_renderbuffer
    /**
     * True for renderbuffers that wrap textures, giving the driver a chance to
     * flush render caches through the FinishRenderTexture hook.
     *
     * Drivers may also set this on renderbuffers other than those generated by
     * glFramebufferTexture(), though it means FinishRenderTexture() would be
     * called without a rb->TexImage.
     */
    GLboolean NeedsFinishRenderTexture;
    GLubyte NumSamples;    /**< zero means not multisampled */
-   GLenum InternalFormat; /**< The user-specified format */
-   GLenum _BaseFormat;    /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
+   GLenum16 InternalFormat; /**< The user-specified format */
+   GLenum16 _BaseFormat;    /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or
                                GL_STENCIL_INDEX. */
    mesa_format Format;      /**< The actual renderbuffer memory format */
    /**
     * Pointer to the texture image if this renderbuffer wraps a texture,
     * otherwise NULL.
     *
     * Note that the reference on the gl_texture_object containing this
     * TexImage is held by the gl_renderbuffer_attachment.
     */
    struct gl_texture_image *TexImage;
@@ -3346,21 +3346,21 @@ struct gl_renderbuffer
                              GLuint width, GLuint height);
 };
 
 
 /**
  * A renderbuffer attachment points to either a texture object (and specifies
  * a mipmap level, cube face or 3D texture slice) or points to a renderbuffer.
  */
 struct gl_renderbuffer_attachment
 {
-   GLenum Type;  /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
+   GLenum16 Type; /**< \c GL_NONE or \c GL_TEXTURE or \c GL_RENDERBUFFER_EXT */
    GLboolean Complete;
 
    /**
     * If \c Type is \c GL_RENDERBUFFER_EXT, this stores a pointer to the
     * application supplied renderbuffer object.
     */
    struct gl_renderbuffer *Renderbuffer;
 
    /**
     * If \c Type is \c GL_TEXTURE, this stores a pointer to the application
@@ -3433,21 +3433,21 @@ struct gl_framebuffer
    /*@}*/
 
    /** \name  Derived Z buffer stuff */
    /*@{*/
    GLuint _DepthMax;	/**< Max depth buffer value */
    GLfloat _DepthMaxF;	/**< Float max depth buffer value */
    GLfloat _MRD;	/**< minimum resolvable difference in Z values */
    /*@}*/
 
    /** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
-   GLenum _Status;
+   GLenum16 _Status;
 
    /** Whether one of Attachment has Type != GL_NONE
     * NOTE: the values for Width and Height are set to 0 in case of having
     * no attachments, a backend driver supporting the extension
     * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
     * and if GL_FALSE, must then use the values in DefaultGeometry to initialize
     * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
     * _Ymax do NOT take into account _HasAttachments being false). To get the
     * geometry of the framebuffer, the  helper functions
     *   _mesa_geometric_width(),
@@ -3472,22 +3472,22 @@ struct gl_framebuffer
     * in the case that _HasAttachments is false
     */
    GLuint MaxNumLayers;
 
    /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
    struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
 
    /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
     * attribute group and GL_PIXEL attribute group, respectively.
     */
-   GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
-   GLenum ColorReadBuffer;
+   GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS];
+   GLenum16 ColorReadBuffer;
 
    /** Computed from ColorDraw/ReadBuffer above */
    GLuint _NumColorDrawBuffers;
    gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
    gl_buffer_index _ColorReadBufferIndex;
    struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
    /** Delete this framebuffer */
    void (*Delete)(struct gl_framebuffer *fb);
@@ -3755,21 +3755,21 @@ struct gl_constants
 
    /**
     * Maximum amount of time, measured in nanseconds, that the server can wait.
     */
    GLuint64 MaxServerWaitTimeout;
 
    /** GL_EXT_provoking_vertex */
    GLboolean QuadsFollowProvokingVertexConvention;
 
    /** GL_ARB_viewport_array */
-   GLenum LayerAndVPIndexProvokingVertex;
+   GLenum16 LayerAndVPIndexProvokingVertex;
 
    /** OpenGL version 3.0 */
    GLbitfield ContextFlags;  /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
 
    /** OpenGL version 3.2 */
    GLbitfield ProfileMask;   /**< Mask of CONTEXT_x_PROFILE_BIT */
 
    /** OpenGL version 4.4 */
    GLuint MaxVertexAttribStride;
 
@@ -3781,21 +3781,21 @@ struct gl_constants
 
    /** GL_EXT_gpu_shader4 */
    GLint MinProgramTexelOffset, MaxProgramTexelOffset;
 
    /** GL_ARB_texture_gather */
    GLuint MinProgramTextureGatherOffset;
    GLuint MaxProgramTextureGatherOffset;
    GLuint MaxProgramTextureGatherComponents;
 
    /* GL_ARB_robustness */
-   GLenum ResetStrategy;
+   GLenum16 ResetStrategy;
 
    /* GL_KHR_robustness */
    GLboolean RobustAccess;
 
    /* GL_ARB_blend_func_extended */
    GLuint MaxDualSourceDrawBuffers;
 
    /**
     * Whether the implementation strips out and ignores texture borders.
     *
@@ -3970,21 +3970,21 @@ struct gl_constants
    GLuint MaxComputeVariableGroupSize[3]; /* Array of x, y, z dimensions */
    GLuint MaxComputeVariableGroupInvocations;
 
    /** GL_ARB_gpu_shader5 */
    GLfloat MinFragmentInterpolationOffset;
    GLfloat MaxFragmentInterpolationOffset;
 
    GLboolean FakeSWMSAA;
 
    /** GL_KHR_context_flush_control */
-   GLenum ContextReleaseBehavior;
+   GLenum16 ContextReleaseBehavior;
 
    struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
 
    /** GL_ARB_tessellation_shader */
    GLuint MaxPatchVertices;
    GLuint MaxTessGenLevel;
    GLuint MaxTessPatchComponents;
    GLuint MaxTessControlTotalOutputComponents;
    bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
    bool LowerTCSPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
@@ -4384,21 +4384,21 @@ struct gl_dlist_state
    GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
    GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
    
    GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
    GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
 
    struct {
       /* State known to have been set by the currently-compiling display
        * list.  Used to eliminate some redundant state changes.
        */
-      GLenum ShadeModel;
+      GLenum16 ShadeModel;
    } Current;
 };
 
 /** @{
  *
  * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums
  * to small enums suitable for use as an array index.
  */
 
 enum mesa_debug_source {
@@ -4612,28 +4612,28 @@ struct gl_image_unit
    /**
     * Layer of the texture object bound to this unit, or zero if the
     * whole level is bound.
     */
    GLuint _Layer;
 
    /**
     * Access allowed to this texture image.  Either \c GL_READ_ONLY,
     * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
     */
-   GLenum Access;
+   GLenum16 Access;
 
    /**
     * GL internal format that determines the interpretation of the
     * image memory when shader image operations are performed through
     * this unit.
     */
-   GLenum Format;
+   GLenum16 Format;
 
    /**
     * Mesa format corresponding to \c Format.
     */
    mesa_format _ActualFormat;
 
 };
 
 /**
  * Shader subroutines storage
@@ -4921,33 +4921,33 @@ struct gl_context
    struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
 
    struct gl_subroutine_index_binding SubroutineIndex[MESA_SHADER_STAGES];
    /*@}*/
 
    struct gl_meta_state *Meta;  /**< for "meta" operations */
 
    /* GL_EXT_framebuffer_object */
    struct gl_renderbuffer *CurrentRenderbuffer;
 
-   GLenum ErrorValue;        /**< Last error code */
+   GLenum16 ErrorValue;      /**< Last error code */
 
    /**
     * Recognize and silence repeated error debug messages in buggy apps.
     */
    const char *ErrorDebugFmtString;
    GLuint ErrorDebugCount;
 
    /* GL_ARB_debug_output/GL_KHR_debug */
    simple_mtx_t DebugMutex;
    struct gl_debug_state *Debug;
 
-   GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
+   GLenum16 RenderMode;      /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
    GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */
    uint64_t NewDriverState;  /**< bitwise-or of flags from DriverFlags */
 
    struct gl_driver_flags DriverFlags;
 
    GLboolean ViewportInitialized;  /**< has viewport size been initialized? */
 
    GLbitfield64 varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
 
    /** \name Derived state */
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index f1e3881..9942f69 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -96,21 +96,21 @@ struct vbo_exec_context
       fi_type *buffer_ptr;              /* cursor, points into buffer */
       GLuint   buffer_used;             /* in bytes */
       fi_type vertex[VBO_ATTRIB_MAX*4]; /* current vertex */
 
       GLuint vert_count;   /**< Number of vertices currently in buffer */
       GLuint max_vert;     /**< Max number of vertices allowed in buffer */
       struct vbo_exec_copied_vtx copied;
 
       GLbitfield64 enabled;             /**< mask of enabled vbo arrays. */
       GLubyte attrsz[VBO_ATTRIB_MAX];   /**< nr. of attrib components (1..4) */
-      GLenum attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */
+      GLenum16 attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc */
       GLubyte active_sz[VBO_ATTRIB_MAX];  /**< attrib size (nr. 32-bit words) */
 
       /** pointers into the current 'vertex' array, declared above */
       fi_type *attrptr[VBO_ATTRIB_MAX];
 
       struct gl_vertex_array arrays[VERT_ATTRIB_MAX];
 
       /* According to program mode, the values above plus current
        * values are squashed down to the 32 attributes passed to the
        * vertex program below:
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 485b7b1..97909d2 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -56,21 +56,21 @@ struct vbo_save_copied_vtx {
  * On executing this list, the 'current' values may be updated with
  * the values of the final vertex, and often no fixup of the start of
  * the vertex list is required.
  *
  * Eval and other commands that don't fit into these vertex lists are
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
    GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
    GLubyte attrsz[VBO_ATTRIB_MAX];
-   GLenum attrtype[VBO_ATTRIB_MAX];
+   GLenum16 attrtype[VBO_ATTRIB_MAX];
    GLuint vertex_size;  /**< size in GLfloats */
 
    /* Copy of the final vertex from node->vertex_store->bufferobj.
     * Keep this in regular (non-VBO) memory to avoid repeated
     * map/unmap of the VBO when updating GL current data.
     */
    fi_type *current_data;
    GLuint current_size;
 
    GLuint buffer_offset;
@@ -122,21 +122,21 @@ struct vbo_save_primitive_store {
 
 struct vbo_save_context {
    struct gl_context *ctx;
    GLvertexformat vtxfmt;
    GLvertexformat vtxfmt_noop;  /**< Used if out_of_memory is true */
    struct gl_vertex_array arrays[VBO_ATTRIB_MAX];
    const struct gl_vertex_array *inputs[VBO_ATTRIB_MAX];
 
    GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
    GLubyte attrsz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
-   GLenum attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_INT, etc */
+   GLenum16 attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_INT, etc */
    GLubyte active_sz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
    GLuint vertex_size;  /**< size in GLfloats */
 
    GLboolean out_of_memory;  /**< True if last VBO allocation failed */
 
    fi_type *buffer;
    GLuint count;
    GLuint wrap_count;
    GLuint replay_flags;
 
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 8a4b659..3fad4c7 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -133,21 +133,21 @@ _playback_copy_to_current(struct gl_context *ctx,
 static void vbo_bind_vertex_list(struct gl_context *ctx,
                                  const struct vbo_save_vertex_list *node)
 {
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_save_context *save = &vbo->save;
    struct gl_vertex_array *arrays = save->arrays;
    GLuint buffer_offset = node->buffer_offset;
    const GLuint *map;
    GLuint attr;
    GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
-   GLenum node_attrtype[VBO_ATTRIB_MAX];  /* copy of node->attrtype[] */
+   GLenum16 node_attrtype[VBO_ATTRIB_MAX];  /* copy of node->attrtype[] */
    GLbitfield64 varying_inputs = 0x0;
 
    memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
    memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype));
 
    /* Install the default (ie Current) attributes first, then overlay
     * all active ones.
     */
    switch (get_program_mode(ctx)) {
    case VP_NONE:
-- 
2.7.4



More information about the mesa-dev mailing list