[Mesa-dev] [PATCH] mesa: replace GLenum with GLenum16 in common structures

Marek Olšák maraeo at gmail.com
Tue Nov 14 14:04:33 UTC 2017


On Mon, Nov 13, 2017 at 10:19 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 11/08/2017 07:16 PM, Marek Olšák wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> For lower CPU cache usage. All enums fit within 2 bytes.
>
> Have you benchmarked this on anything?  My recollection is that for many
> things loads and stores of 16-bit values is more expensive than 8- or
> 32-bit values on 64-bit architectures.  More recent CPUs may have
> changed in this respect... I think that was back in the Core2 kind of
> time frame, but I thought it also applied to AMD CPUs.
>
> I've often toyed with the idea of converting a bunch of these to
> zero-based enums that could be stored in uint8_t (like Gallium?), but I
> just never got around to it.

I haven't done any benchmarking. I'd like to decrease the size of
gl_context even more. My target is 80K. In the meantime, people can
ack this.

Marek

>
>> gl_context = 152400 -> 136824 bytes
>> vbo_context = 22696 -> 21520 bytes
>
> Ouch.  Just... ouch.
>
>> ---
>>  src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   4 +-
>>  src/mesa/drivers/dri/nouveau/nv10_state_frag.c |   4 +-
>>  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 +-
>>  7 files changed, 114 insertions(+), 113 deletions(-)
>>
>> 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/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 fd5306c..078cf20 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -375,21 +375,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 */
>> @@ -411,53 +411,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 */
>> +   GLenum 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;
>> @@ -474,29 +474,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
>>  {
>> @@ -520,21 +520,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).
>> @@ -599,71 +599,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? */
>>
>> @@ -743,21 +743,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;
>> @@ -783,37 +783,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 */
>>  };
>>
>>
>>  /**
>> @@ -822,21 +822,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
>> @@ -849,24 +849,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.
>> @@ -909,21 +909,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 */
>> @@ -967,130 +967,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
>>  {
>>     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
>>  {
>>     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
>>  {
>> @@ -1210,36 +1210,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 */
>>
>> @@ -1321,31 +1321,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 */
>> @@ -1388,21 +1388,21 @@ typedef enum {
>>
>>  /**
>>   * GL_ARB_vertex/pixel_buffer_object buffer object
>>   */
>>  struct gl_buffer_object
>>  {
>>     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 */
>> @@ -1444,22 +1444,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 */
>>  };
>> @@ -1474,22 +1474,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 */
>>  };
>> @@ -1631,21 +1631,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
>>   */
>> @@ -1720,21 +1720,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
>> @@ -1853,21 +1853,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;
>>
>> @@ -1921,21 +1921,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
>> @@ -2018,21 +2018,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.
>> @@ -2068,22 +2068,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 */
>> @@ -2152,21 +2152,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];
>>
>>           /**
>> @@ -2425,28 +2425,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 {
>> @@ -2454,26 +2454,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.
>> @@ -2560,21 +2560,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;
>>
>> @@ -2822,21 +2822,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
>>  {
>> @@ -2894,21 +2894,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;
>>
>> @@ -2941,21 +2941,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;
>> @@ -3148,21 +3148,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 */
>>  };
>>
>>
>> @@ -3185,34 +3185,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
>>  {
>> @@ -3312,22 +3312,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;
>> @@ -3342,21 +3342,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
>> @@ -3429,21 +3429,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(),
>> @@ -3468,22 +3468,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;
>>     GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
>>     GLint _ColorReadBufferIndex; /* -1 = None */
>>     struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
>>     struct gl_renderbuffer *_ColorReadBuffer;
>>
>>     /** Delete this framebuffer */
>>     void (*Delete)(struct gl_framebuffer *fb);
>> @@ -3751,21 +3751,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;
>>
>> @@ -3777,21 +3777,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.
>>      *
>> @@ -3966,21 +3966,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 */
>> @@ -4375,21 +4375,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 {
>> @@ -4603,28 +4603,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
>> @@ -4912,33 +4912,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 */
>>     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:
>>
>


More information about the mesa-dev mailing list