mesa: Also track a remapped version of the color logic op
[mesa.git] / src / mesa / main / mtypes.h
index 8ef1183785c3c2ac4650780dfb4b3167dd118e34..0c47be4ec7295ffe718645dd83ef5304d34ec219 100644 (file)
@@ -46,7 +46,7 @@
 #include "compiler/shader_info.h"
 #include "main/formats.h"       /* MESA_FORMAT_COUNT */
 #include "compiler/glsl/list.h"
-#include "util/bitscan.h"
+#include "util/simple_mtx.h"
 #include "util/u_dynarray.h"
 
 
@@ -55,6 +55,16 @@ extern "C" {
 #endif
 
 
+/** Set a single bit */
+#define BITFIELD_BIT(b)      ((GLbitfield)1 << (b))
+/** Set all bits up to excluding bit b */
+#define BITFIELD_MASK(b)      \
+   ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
+/** Set count bits starting from bit b  */
+#define BITFIELD_RANGE(b, count) \
+   (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))
+
+
 /**
  * \name 64-bit extension of GLbitfield.
  */
@@ -87,8 +97,8 @@ struct st_context;
 struct gl_uniform_storage;
 struct prog_instruction;
 struct gl_program_parameter_list;
+struct gl_shader_spirv_data;
 struct set;
-struct set_entry;
 struct vbo_context;
 /*@}*/
 
@@ -232,7 +242,7 @@ struct gl_config
 
    /* ARB_multisample / SGIS_multisample */
    GLint sampleBuffers;
-   GLint samples;
+   GLuint samples;
 
    /* SGIX_pbuffer / GLX 1.3 */
    GLint maxPbufferWidth;
@@ -260,11 +270,11 @@ struct gl_config
  * \name Bit flags used for updating material values.
  */
 /*@{*/
-#define MAT_ATTRIB_FRONT_AMBIENT           0 
+#define MAT_ATTRIB_FRONT_AMBIENT           0
 #define MAT_ATTRIB_BACK_AMBIENT            1
-#define MAT_ATTRIB_FRONT_DIFFUSE           2 
+#define MAT_ATTRIB_FRONT_DIFFUSE           2
 #define MAT_ATTRIB_BACK_DIFFUSE            3
-#define MAT_ATTRIB_FRONT_SPECULAR          4 
+#define MAT_ATTRIB_FRONT_SPECULAR          4
 #define MAT_ATTRIB_BACK_SPECULAR           5
 #define MAT_ATTRIB_FRONT_EMISSION          6
 #define MAT_ATTRIB_BACK_EMISSION           7
@@ -274,16 +284,12 @@ struct gl_config
 #define MAT_ATTRIB_BACK_INDEXES            11
 #define MAT_ATTRIB_MAX                     12
 
-#define MAT_ATTRIB_AMBIENT(f)  (MAT_ATTRIB_FRONT_AMBIENT+(f))  
-#define MAT_ATTRIB_DIFFUSE(f)  (MAT_ATTRIB_FRONT_DIFFUSE+(f))  
-#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) 
-#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) 
+#define MAT_ATTRIB_AMBIENT(f)  (MAT_ATTRIB_FRONT_AMBIENT+(f))
+#define MAT_ATTRIB_DIFFUSE(f)  (MAT_ATTRIB_FRONT_DIFFUSE+(f))
+#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
+#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
-#define MAT_ATTRIB_INDEXES(f)  (MAT_ATTRIB_FRONT_INDEXES+(f))  
-
-#define MAT_INDEX_AMBIENT  0
-#define MAT_INDEX_DIFFUSE  1
-#define MAT_INDEX_SPECULAR 2
+#define MAT_ATTRIB_INDEXES(f)  (MAT_ATTRIB_FRONT_INDEXES+(f))
 
 #define MAT_BIT_FRONT_AMBIENT         (1<<MAT_ATTRIB_FRONT_AMBIENT)
 #define MAT_BIT_BACK_AMBIENT          (1<<MAT_ATTRIB_BACK_AMBIENT)
@@ -299,21 +305,21 @@ struct gl_config
 #define MAT_BIT_BACK_INDEXES          (1<<MAT_ATTRIB_BACK_INDEXES)
 
 
-#define FRONT_MATERIAL_BITS    (MAT_BIT_FRONT_EMISSION |       \
-                                MAT_BIT_FRONT_AMBIENT |        \
-                                MAT_BIT_FRONT_DIFFUSE |        \
-                                MAT_BIT_FRONT_SPECULAR |       \
-                                MAT_BIT_FRONT_SHININESS |      \
-                                MAT_BIT_FRONT_INDEXES)
+#define FRONT_MATERIAL_BITS   (MAT_BIT_FRONT_EMISSION | \
+                               MAT_BIT_FRONT_AMBIENT | \
+                               MAT_BIT_FRONT_DIFFUSE | \
+                               MAT_BIT_FRONT_SPECULAR | \
+                               MAT_BIT_FRONT_SHININESS | \
+                               MAT_BIT_FRONT_INDEXES)
 
-#define BACK_MATERIAL_BITS     (MAT_BIT_BACK_EMISSION |        \
-                                MAT_BIT_BACK_AMBIENT |         \
-                                MAT_BIT_BACK_DIFFUSE |         \
-                                MAT_BIT_BACK_SPECULAR |        \
-                                MAT_BIT_BACK_SHININESS |       \
-                                MAT_BIT_BACK_INDEXES)
+#define BACK_MATERIAL_BITS    (MAT_BIT_BACK_EMISSION | \
+                               MAT_BIT_BACK_AMBIENT | \
+                               MAT_BIT_BACK_DIFFUSE | \
+                               MAT_BIT_BACK_SPECULAR | \
+                               MAT_BIT_BACK_SHININESS | \
+                               MAT_BIT_BACK_INDEXES)
 
-#define ALL_MATERIAL_BITS      (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
+#define ALL_MATERIAL_BITS     (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
 /*@}*/
 
 
@@ -355,7 +361,7 @@ struct gl_light
    GLfloat QuadraticAttenuation;
    GLboolean Enabled;          /**< On/off flag */
 
-   /** 
+   /**
     * \name Derived fields
     */
    /*@{*/
@@ -383,7 +389,7 @@ struct gl_lightmodel
    GLboolean LocalViewer;      /**< Local (or infinite) view point? */
    GLboolean TwoSide;          /**< Two (or one) sided lighting? */
    GLenum ColorControl;                /**< either GL_SINGLE_COLOR
-                                *    or GL_SEPARATE_SPECULAR_COLOR */
+                                     or GL_SEPARATE_SPECULAR_COLOR */
 };
 
 
@@ -407,6 +413,43 @@ union gl_color_union
    GLuint ui[4];
 };
 
+/**
+ * Remapped color logical operations
+ *
+ * With the exception of NVIDIA hardware, which consumes the OpenGL enumerants
+ * directly, everything wants this mapping of color logical operations.
+ *
+ * Fun fact: These values are just the bit-reverse of the low-nibble of the GL
+ * enumerant values (i.e., `GL_NOOP & 0x0f` is `b0101' while
+ * \c COLOR_LOGICOP_NOOP is `b1010`).
+ *
+ * Fun fact #2: These values are just an encoding of the operation as a table
+ * of bit values. The result of the logic op is:
+ *
+ *    result_bit = (logic_op >> (2 * src_bit + dst_bit)) & 1
+ *
+ * For the GL enums, the result is:
+ *
+ *    result_bit = logic_op & (1 << (2 * src_bit + dst_bit))
+ */
+enum PACKED gl_logicop_mode {
+   COLOR_LOGICOP_CLEAR = 0,
+   COLOR_LOGICOP_NOR = 1,
+   COLOR_LOGICOP_AND_INVERTED = 2,
+   COLOR_LOGICOP_COPY_INVERTED = 3,
+   COLOR_LOGICOP_AND_REVERSE = 4,
+   COLOR_LOGICOP_INVERT = 5,
+   COLOR_LOGICOP_XOR = 6,
+   COLOR_LOGICOP_NAND = 7,
+   COLOR_LOGICOP_AND = 8,
+   COLOR_LOGICOP_EQUIV = 9,
+   COLOR_LOGICOP_NOOP = 10,
+   COLOR_LOGICOP_OR_INVERTED = 11,
+   COLOR_LOGICOP_COPY = 12,
+   COLOR_LOGICOP_OR_REVERSE = 13,
+   COLOR_LOGICOP_OR = 14,
+   COLOR_LOGICOP_SET = 15
+};
 
 /**
  * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
@@ -420,7 +463,7 @@ struct gl_colorbuffer_attrib
 
    GLenum DrawBuffer[MAX_DRAW_BUFFERS];        /**< Which buffer to draw into */
 
-   /** 
+   /**
     * \name alpha testing
     */
    /*@{*/
@@ -430,7 +473,7 @@ struct gl_colorbuffer_attrib
    GLclampf AlphaRef;                  /**< Alpha reference value */
    /*@}*/
 
-   /** 
+   /**
     * \name Blending
     */
    /*@{*/
@@ -475,13 +518,14 @@ struct gl_colorbuffer_attrib
    bool BlendCoherent;
    /*@}*/
 
-   /** 
+   /**
     * \name Logic op
     */
    /*@{*/
    GLboolean IndexLogicOpEnabled;      /**< Color index logic op enabled flag */
    GLboolean ColorLogicOpEnabled;      /**< RGBA logic op enabled flag */
    GLenum LogicOp;                     /**< Logic operator */
+   enum gl_logicop_mode _LogicOp;
 
    /*@}*/
 
@@ -503,7 +547,7 @@ struct gl_current_attrib
    /**
     * \name Current vertex attributes (color, texcoords, etc).
     * \note Values are valid only after FLUSH_VERTICES has been called.
-    * \note Index and Edgeflag current values are stored as floats in the 
+    * \note Index and Edgeflag current values are stored as floats in the
     * SIX and SEVEN attribute slots.
     * \note We need double storage for 64-bit vertex attributes
     */
@@ -542,7 +586,7 @@ struct gl_depthbuffer_attrib
 struct gl_eval_attrib
 {
    /**
-    * \name Enable bits 
+    * \name Enable bits
     */
    /*@{*/
    GLboolean Map1Color4;
@@ -565,7 +609,7 @@ struct gl_eval_attrib
    GLboolean Map2Vertex4;
    GLboolean AutoNormal;
    /*@}*/
-   
+
    /**
     * \name Map Grid endpoints and divisions and calculated du values
     */
@@ -613,9 +657,9 @@ struct gl_fog_attrib
 };
 
 
-/** 
+/**
  * Hint attribute group (GL_HINT_BIT).
- * 
+ *
  * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
  */
 struct gl_hint_attrib
@@ -658,13 +702,13 @@ struct gl_light_attrib
    GLboolean _ClampVertexColor;
    GLenum ClampVertexColor;             /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */
 
-   /** 
-    * Derived state for optimizations: 
+   /**
+    * Derived state for optimizations:
     */
    /*@{*/
    GLbitfield _EnabledLights;  /**< bitmask containing enabled lights */
 
-   GLboolean _NeedEyeCoords;           
+   GLboolean _NeedEyeCoords;
    GLboolean _NeedVertices;            /**< Use fast shader? */
 
    GLfloat _BaseColor[2][3];
@@ -824,6 +868,8 @@ 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? */
@@ -969,7 +1015,7 @@ typedef enum
  */
 struct gl_sampler_object
 {
-   mtx_t Mutex;
+   simple_mtx_t Mutex;
    GLuint Name;
    GLint RefCount;
    GLchar *Label;               /**< GL_KHR_debug */
@@ -990,8 +1036,8 @@ struct gl_sampler_object
    GLboolean CubeMapSeamless;   /**< GL_AMD_seamless_cubemap_per_texture */
 
    /** GL_ARB_bindless_texture */
-   struct util_dynarray Handles;
    bool HandleAllocated;
+   struct util_dynarray Handles;
 };
 
 
@@ -1001,7 +1047,7 @@ struct gl_sampler_object
  */
 struct gl_texture_object
 {
-   mtx_t Mutex;      /**< for thread safety */
+   simple_mtx_t Mutex;      /**< for thread safety */
    GLint RefCount;             /**< reference count */
    GLuint Name;                /**< the user-visible texture object ID */
    GLchar *Label;               /**< GL_KHR_debug */
@@ -1012,7 +1058,6 @@ struct gl_texture_object
    struct gl_sampler_object Sampler;
 
    GLenum DepthMode;           /**< GL_ARB_depth_texture */
-   bool StencilSampling;       /**< Should we sample stencil instead of depth? */
 
    GLfloat Priority;           /**< in [0,1] */
    GLint BaseLevel;            /**< min mipmap level, OpenGL 1.2 */
@@ -1033,12 +1078,17 @@ struct gl_texture_object
    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;
+
    /** Actual texture images, indexed by [cube face] and [mipmap level] */
    struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
 
@@ -1060,7 +1110,6 @@ struct gl_texture_object
    /** GL_ARB_bindless_texture */
    struct util_dynarray SamplerHandles;
    struct util_dynarray ImageHandles;
-   bool HandleAllocated;
 };
 
 
@@ -1191,13 +1240,13 @@ struct gl_tex_env_combine_packed
 #define TEXGEN_REFLECTION_MAP_NV 0x8
 #define TEXGEN_NORMAL_MAP_NV     0x10
 
-#define TEXGEN_NEED_NORMALS      (TEXGEN_SPHERE_MAP        | \
-                                 TEXGEN_REFLECTION_MAP_NV | \
-                                 TEXGEN_NORMAL_MAP_NV)
-#define TEXGEN_NEED_EYE_COORD    (TEXGEN_SPHERE_MAP        | \
-                                 TEXGEN_REFLECTION_MAP_NV | \
-                                 TEXGEN_NORMAL_MAP_NV     | \
-                                 TEXGEN_EYE_LINEAR)
+#define TEXGEN_NEED_NORMALS   (TEXGEN_SPHERE_MAP        | \
+                               TEXGEN_REFLECTION_MAP_NV | \
+                               TEXGEN_NORMAL_MAP_NV)
+#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP        | \
+                               TEXGEN_REFLECTION_MAP_NV | \
+                               TEXGEN_NORMAL_MAP_NV     | \
+                               TEXGEN_EYE_LINEAR)
 /*@}*/
 
 
@@ -1248,8 +1297,8 @@ struct gl_texture_unit
    /** Current sampler object (GL_ARB_sampler_objects) */
    struct gl_sampler_object *Sampler;
 
-   /** 
-    * \name GL_EXT_texture_env_combine 
+   /**
+    * \name GL_EXT_texture_env_combine
     */
    struct gl_tex_env_combine_state Combine;
 
@@ -1350,10 +1399,10 @@ struct gl_viewport_attrib
 };
 
 
-typedef enum {
+typedef enum
+{
    MAP_USER,
    MAP_INTERNAL,
-
    MAP_COUNT
 } gl_map_buffer_index;
 
@@ -1361,7 +1410,8 @@ typedef enum {
 /**
  * Fields describing a mapped buffer range.
  */
-struct gl_buffer_mapping {
+struct gl_buffer_mapping
+{
    GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
    GLvoid *Pointer;     /**< User-space address of mapping */
    GLintptr Offset;     /**< Mapped offset */
@@ -1372,7 +1422,8 @@ struct gl_buffer_mapping {
 /**
  * Usages we've seen for a buffer object.
  */
-typedef enum {
+typedef enum
+{
    USAGE_UNIFORM_BUFFER = 0x1,
    USAGE_TEXTURE_BUFFER = 0x2,
    USAGE_ATOMIC_COUNTER_BUFFER = 0x4,
@@ -1388,7 +1439,7 @@ typedef enum {
  */
 struct gl_buffer_object
 {
-   mtx_t Mutex;
+   simple_mtx_t Mutex;
    GLint RefCount;
    GLuint Name;
    GLchar *Label;       /**< GL_KHR_debug */
@@ -1503,7 +1554,7 @@ struct gl_vertex_buffer_binding
    GLsizei Stride;                     /**< User-specified stride */
    GLuint InstanceDivisor;             /**< GL_ARB_instanced_arrays */
    struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
-   GLbitfield64 _BoundArrays;          /**< Arrays bound to this binding point */
+   GLbitfield _BoundArrays;            /**< Arrays bound to this binding point */
 };
 
 
@@ -1528,7 +1579,7 @@ struct gl_vertex_array_object
    /**
     * Derived vertex attribute arrays
     *
-    * This is a legacy data structure created from gl_vertex_attrib_array and
+    * This is a legacy data structure created from gl_array_attributes and
     * gl_vertex_buffer_binding, for compatibility with existing driver code.
     */
    struct gl_vertex_array _VertexAttrib[VERT_ATTRIB_MAX];
@@ -1540,29 +1591,32 @@ struct gl_vertex_array_object
    struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX];
 
    /** Mask indicating which vertex arrays have vertex buffer associated. */
-   GLbitfield64 VertexAttribBufferMask;
+   GLbitfield VertexAttribBufferMask;
 
    /** Mask of VERT_BIT_* values indicating which arrays are enabled */
-   GLbitfield64 _Enabled;
+   GLbitfield _Enabled;
 
    /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
-   GLbitfield64 NewArrays;
+   GLbitfield NewArrays;
 
    /** The index buffer (also known as the element array buffer in OpenGL). */
    struct gl_buffer_object *IndexBufferObj;
 };
 
 
-/** Used to signal when transitioning from one kind of drawing method
+/**
+ * Used to signal when transitioning from one kind of drawing method
  * to another.
  */
-typedef enum {
+typedef enum
+{
    DRAW_NONE,          /**< Initial value only */
    DRAW_BEGIN_END,
    DRAW_DISPLAY_LIST,
    DRAW_ARRAYS
 } gl_draw_method;
 
+
 /**
  * Enum for the OpenGL APIs we know about and may support.
  *
@@ -1578,6 +1632,7 @@ typedef enum
    API_OPENGL_LAST = API_OPENGL_CORE
 } gl_api;
 
+
 /**
  * Vertex array state
  */
@@ -1689,7 +1744,7 @@ struct gl_2d_map
  */
 struct gl_evaluators
 {
-   /** 
+   /**
     * \name 1-D maps
     */
    /*@{*/
@@ -1704,8 +1759,8 @@ struct gl_evaluators
    struct gl_1d_map Map1Texture4;
    /*@}*/
 
-   /** 
-    * \name 2-D maps 
+   /**
+    * \name 2-D maps
     */
    /*@{*/
    struct gl_2d_map Map2Vertex3;
@@ -1776,6 +1831,9 @@ struct gl_transform_feedback_buffer
 /** Post-link transform feedback info. */
 struct gl_transform_feedback_info
 {
+   /* Was xfb enabled via the api or in shader layout qualifiers */
+   bool api_enabled;
+
    unsigned NumOutputs;
 
    /* Bitmask of active buffer indices. */
@@ -1997,16 +2055,17 @@ struct gl_bindless_sampler
    /** Texture unit (set by glUniform1()). */
    GLubyte unit;
 
-   /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
-   gl_texture_index target;
-
    /** Whether this bindless sampler is bound to a unit. */
    GLboolean bound;
 
+   /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
+   gl_texture_index target;
+
    /** Pointer to the base of the data. */
    GLvoid *data;
 };
 
+
 /**
  * A bindless image object.
  */
@@ -2015,16 +2074,17 @@ struct gl_bindless_image
    /** Image unit (set by glUniform1()). */
    GLubyte unit;
 
-   /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
-   GLenum access;
-
    /** Whether this bindless image is bound to a unit. */
    GLboolean bound;
 
+   /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
+   GLenum access;
+
    /** Pointer to the base of the data. */
    GLvoid *data;
 };
 
+
 /**
  * Names of the various vertex/fragment program register files, etc.
  *
@@ -2053,6 +2113,7 @@ typedef enum
    PROGRAM_BUFFER,      /**< for shader buffers, compile-time only */
    PROGRAM_MEMORY,      /**< for shared, global and local memory */
    PROGRAM_IMAGE,       /**< for shader images, compile-time only */
+   PROGRAM_HW_ATOMIC,   /**< for hw atomic counters, compile-time only */
    PROGRAM_FILE_MAX
 } gl_register_file;
 
@@ -2076,6 +2137,10 @@ struct gl_program
 
    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 */
 
    /** Is this program written to on disk shader cache */
@@ -2253,6 +2318,9 @@ struct gl_vertex_program_state
    GLboolean Enabled;            /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
    GLboolean PointSizeEnabled;   /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
    GLboolean TwoSideEnabled;     /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
+   /** Should fixed-function T&L be implemented with a vertex prog? */
+   GLboolean _MaintainTnlProgram;
+
    struct gl_program *Current;  /**< User-bound vertex program */
 
    /** Currently enabled and valid vertex program (including internal
@@ -2263,9 +2331,6 @@ struct gl_vertex_program_state
 
    GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
 
-   /** Should fixed-function T&L be implemented with a vertex prog? */
-   GLboolean _MaintainTnlProgram;
-
    /** Program to emulate fixed-function T&L (see above) */
    struct gl_program *_TnlProgram;
 
@@ -2314,6 +2379,9 @@ struct gl_geometry_program_state
 struct gl_fragment_program_state
 {
    GLboolean Enabled;     /**< User-set fragment program enable flag */
+   /** Should fixed-function texturing be implemented with a fragment prog? */
+   GLboolean _MaintainTexEnvProgram;
+
    struct gl_program *Current;  /**< User-bound fragment program */
 
    /** Currently enabled and valid fragment program (including internal
@@ -2324,9 +2392,6 @@ struct gl_fragment_program_state
 
    GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
 
-   /** Should fixed-function texturing be implemented with a fragment prog? */
-   GLboolean _MaintainTexEnvProgram;
-
    /** Program to emulate fixed-function texture env/combine (see above) */
    struct gl_program *_TexEnvProgram;
 
@@ -2368,10 +2433,14 @@ struct ati_fragment_shader
    GLubyte numArithInstr[2];
    GLubyte regsAssigned[2];
    GLubyte NumPasses;         /**< 1 or 2 */
+   /** Current compile stage: 0 setup pass1, 1 arith pass1, 2 setup pass2, 3 arith pass2 */
    GLubyte cur_pass;
    GLubyte last_optype;
    GLboolean interpinp1;
    GLboolean isValid;
+   /** Array of 2 bit values for each tex unit to remember whether
+    * STR or STQ swizzle was used
+    */
    GLuint swizzlerq;
    struct gl_program *Program;
 };
@@ -2521,19 +2590,6 @@ struct gl_linked_shader
    struct glsl_symbol_table *symbols;
 };
 
-static inline GLbitfield gl_external_samplers(struct gl_program *prog)
-{
-   GLbitfield external_samplers = 0;
-   GLbitfield mask = prog->SamplersUsed;
-
-   while (mask) {
-      int idx = u_bit_scan(&mask);
-      if (prog->sh.SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX)
-         external_samplers |= (1 << idx);
-   }
-
-   return external_samplers;
-}
 
 /**
  * Compile status enum. compile_skipped is used to indicate the compile
@@ -2564,9 +2620,10 @@ struct gl_shader
    GLchar *Label;   /**< GL_KHR_debug */
    unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
    GLboolean DeletePending;
-   enum gl_compile_status CompileStatus;
    bool IsES;              /**< True if this shader uses GLSL ES */
 
+   enum gl_compile_status CompileStatus;
+
 #ifdef DEBUG
    unsigned SourceChecksum;       /**< for debug/logging purposes */
 #endif
@@ -2578,14 +2635,14 @@ struct gl_shader
 
    unsigned Version;       /**< GLSL version used for linking */
 
-   struct exec_list *ir;
-   struct glsl_symbol_table *symbols;
-
    /**
     * A bitmask of gl_advanced_blend_mode values
     */
    GLbitfield BlendSupport;
 
+   struct exec_list *ir;
+   struct glsl_symbol_table *symbols;
+
    /**
     * Whether early fragment tests are enabled as defined by
     * ARB_shader_image_load_store.
@@ -2620,6 +2677,9 @@ struct gl_shader
    GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
 
    struct gl_shader_info info;
+
+   /* ARB_gl_spirv related data */
+   struct gl_shader_spirv_data *spirv_data;
 };
 
 
@@ -2849,9 +2909,9 @@ struct gl_shader_program_data
    struct gl_uniform_storage *UniformStorage;
 
    unsigned NumUniformBlocks;
-   struct gl_uniform_block *UniformBlocks;
-
    unsigned NumShaderStorageBlocks;
+
+   struct gl_uniform_block *UniformBlocks;
    struct gl_uniform_block *ShaderStorageBlocks;
 
    struct gl_active_atomic_buffer *AtomicBuffers;
@@ -2861,21 +2921,24 @@ struct gl_shader_program_data
    unsigned NumUniformDataSlots;
    union gl_constant_value *UniformDataSlots;
 
-   bool cache_fallback;
-
-   /* TODO: This used by Gallium drivers to skip the cache on tgsi fallback.
-    * All structures (gl_program, uniform storage, etc) will get recreated
-    * even though we have already loaded them from cache. Once the i965 cache
-    * lands we should switch to using the cache_fallback support.
+   /* Used to hold initial uniform values for program binary restores.
+    *
+    * From the ARB_get_program_binary spec:
+    *
+    *    "A successful call to ProgramBinary will reset all uniform
+    *    variables to their initial values. The initial value is either
+    *    the value of the variable's initializer as specified in the
+    *    original shader source, or 0 if no initializer was present.
     */
-   bool skip_cache;
+   union gl_constant_value *UniformDataDefaults;
+
+   GLboolean Validated;
 
    /** List of all active resources after linking. */
    struct gl_program_resource *ProgramResourceList;
    unsigned NumProgramResourceList;
 
    enum gl_link_status LinkStatus;   /**< GL_LINK_STATUS */
-   GLboolean Validated;
    GLchar *InfoLog;
 
    unsigned Version;       /**< GLSL version used for linking */
@@ -3021,7 +3084,7 @@ struct gl_shader_program
     * #extension ARB_fragment_coord_conventions: enable
     */
    GLboolean ARB_fragment_coord_conventions_enable;
-};   
+};
 
 
 #define GLSL_DUMP      0x1  /**< Dump shaders to stdout */
@@ -3189,11 +3252,11 @@ struct gl_query_state
 struct gl_sync_object
 {
    GLuint Name;               /**< Fence name */
-   GLchar *Label;             /**< GL_KHR_debug */
    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)
-                              */
+                               * live references (e.g., sync not yet finished)
+                               */
    GLenum SyncCondition;
    GLbitfield Flags;          /**< Flags passed to glFenceSync */
    GLuint StatusFlag:1;       /**< Has the sync object been signaled? */
@@ -3205,7 +3268,7 @@ struct gl_sync_object
  */
 struct gl_shared_state
 {
-   mtx_t Mutex;                   /**< for thread safety */
+   simple_mtx_t Mutex;            /**< for thread safety */
    GLint RefCount;                        /**< Reference count */
    struct _mesa_HashTable *DisplayList;           /**< Display lists hash table */
    struct _mesa_HashTable *BitmapAtlas;    /**< For optimized glBitmap text */
@@ -3219,7 +3282,7 @@ struct gl_shared_state
 
    /**
     * \name Thread safety and statechange notification for texture
-    * objects. 
+    * objects.
     *
     * \todo Improve the granularity of locking.
     */
@@ -3278,6 +3341,14 @@ struct gl_shared_state
    /** EXT_external_objects */
    struct _mesa_HashTable *MemoryObjects;
 
+   /**
+    * Some context in this share group was affected by a disjoint
+    * operation. This operation can be anything that has effects on
+    * values of timer queries in such manner that they become invalid for
+    * performance metrics. As example gpu reset, counter overflow or gpu
+    * frequency changes.
+    */
+   bool DisjointOperation;
 };
 
 
@@ -3289,7 +3360,7 @@ struct gl_shared_state
  */
 struct gl_renderbuffer
 {
-   mtx_t Mutex; /**< for thread safety */
+   simple_mtx_t Mutex; /**< for thread safety */
    GLuint ClassID;        /**< Useful for drivers */
    GLuint Name;
    GLchar *Label;         /**< GL_KHR_debug */
@@ -3367,7 +3438,7 @@ struct gl_renderbuffer_attachment
  */
 struct gl_framebuffer
 {
-   mtx_t Mutex;  /**< for thread safety */
+   simple_mtx_t Mutex;  /**< for thread safety */
    /**
     * If zero, this is a window system framebuffer.  If non-zero, this
     * is a FBO framebuffer; note that for some devices (i.e. those with
@@ -3469,8 +3540,8 @@ struct gl_framebuffer
 
    /** Computed from ColorDraw/ReadBuffer above */
    GLuint _NumColorDrawBuffers;
-   GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
-   GLint _ColorReadBufferIndex; /* -1 = None */
+   gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
+   gl_buffer_index _ColorReadBufferIndex;
    struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
@@ -3561,7 +3632,6 @@ struct gl_program_constants
    GLuint MaxShaderStorageBlocks;
 };
 
-
 /**
  * Constants which may be overridden by device driver during context creation
  * but are never changed after that.
@@ -3699,6 +3769,11 @@ struct gl_constants
     */
    GLboolean AllowGLSLBuiltinVariableRedeclaration;
 
+   /**
+    * Allow GLSL interpolation qualifier mismatch across shader stages.
+    */
+   GLboolean AllowGLSLCrossStageInterpolationMismatch;
+
    /**
     * Allow creating a higher compat profile (version 3.1+) for apps that
     * request it. Be careful when adding that driconf option because some
@@ -3840,6 +3915,15 @@ struct gl_constants
     */
    GLboolean DisableVaryingPacking;
 
+   /**
+    * UBOs and SSBOs can be packed tightly by the OpenGL implementation when
+    * layout is set as shared (the default) or packed. However most Mesa drivers
+    * just use STD140 for these layouts. This flag allows drivers to use STD430
+    * for packed and shared layouts which allows arrays to be packed more
+    * tightly.
+    */
+   bool UseSTD430AsDefaultPacking;
+
    /**
     * Should meaningful names be generated for compiler temporary variables?
     *
@@ -3963,8 +4047,6 @@ struct gl_constants
    GLuint MaxTessPatchComponents;
    GLuint MaxTessControlTotalOutputComponents;
    bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
-   bool LowerTCSPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
-   bool LowerTESPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
    bool PrimitiveRestartForPatches;
    bool LowerCsDerivedVariables;    /**< Lower gl_GlobalInvocationID and
                                      *   gl_LocalInvocationIndex based on
@@ -3981,6 +4063,9 @@ struct gl_constants
 
    /** When drivers are OK with mapped buffers during draw and other calls. */
    bool AllowMappedBuffersDuringExecution;
+
+   /** GL_ARB_get_program_binary */
+   GLuint NumProgramBinaryFormats;
 };
 
 
@@ -4030,6 +4115,7 @@ struct gl_extensions
    GLboolean ARB_enhanced_layouts;
    GLboolean ARB_explicit_attrib_location;
    GLboolean ARB_explicit_uniform_location;
+   GLboolean ARB_gl_spirv;
    GLboolean ARB_gpu_shader5;
    GLboolean ARB_gpu_shader_fp64;
    GLboolean ARB_gpu_shader_int64;
@@ -4043,6 +4129,7 @@ struct gl_extensions
    GLboolean ARB_occlusion_query2;
    GLboolean ARB_pipeline_statistics_query;
    GLboolean ARB_point_sprite;
+   GLboolean ARB_polygon_offset_clamp;
    GLboolean ARB_post_depth_coverage;
    GLboolean ARB_query_buffer_object;
    GLboolean ARB_robust_buffer_access_behavior;
@@ -4081,6 +4168,7 @@ struct gl_extensions
    GLboolean ARB_texture_env_combine;
    GLboolean ARB_texture_env_crossbar;
    GLboolean ARB_texture_env_dot3;
+   GLboolean ARB_texture_filter_anisotropic;
    GLboolean ARB_texture_float;
    GLboolean ARB_texture_gather;
    GLboolean ARB_texture_mirror_clamp_to_edge;
@@ -4109,16 +4197,18 @@ struct gl_extensions
    GLboolean EXT_blend_func_separate;
    GLboolean EXT_blend_minmax;
    GLboolean EXT_depth_bounds_test;
+   GLboolean EXT_disjoint_timer_query;
    GLboolean EXT_draw_buffers2;
    GLboolean EXT_framebuffer_multisample;
    GLboolean EXT_framebuffer_multisample_blit_scaled;
    GLboolean EXT_framebuffer_sRGB;
    GLboolean EXT_gpu_program_parameters;
    GLboolean EXT_gpu_shader4;
+   GLboolean EXT_memory_object;
+   GLboolean EXT_memory_object_fd;
    GLboolean EXT_packed_float;
    GLboolean EXT_pixel_buffer_object;
    GLboolean EXT_point_parameters;
-   GLboolean EXT_polygon_offset_clamp;
    GLboolean EXT_provoking_vertex;
    GLboolean EXT_shader_integer_mix;
    GLboolean EXT_shader_samples_identical;
@@ -4135,6 +4225,7 @@ struct gl_extensions
    GLboolean EXT_texture_sRGB;
    GLboolean EXT_texture_sRGB_decode;
    GLboolean EXT_texture_swizzle;
+   GLboolean EXT_texture_type_2_10_10_10_REV;
    GLboolean EXT_transform_feedback;
    GLboolean EXT_timer_query;
    GLboolean EXT_vertex_array_bgra;
@@ -4169,6 +4260,7 @@ struct gl_extensions
    GLboolean KHR_texture_compression_astc_hdr;
    GLboolean KHR_texture_compression_astc_ldr;
    GLboolean KHR_texture_compression_astc_sliced_3d;
+   GLboolean MESA_tile_raster_order;
    GLboolean MESA_pack_invert;
    GLboolean MESA_shader_framebuffer_fetch;
    GLboolean MESA_shader_framebuffer_fetch_non_coherent;
@@ -4207,6 +4299,12 @@ struct gl_extensions
     * while meta is in progress.
     */
    GLubyte Version;
+   /**
+    * Force-enabled, yet unrecognized, extensions.
+    * See _mesa_one_time_init_extension_overrides()
+    */
+#define MAX_UNRECOGNIZED_EXTENSIONS 16
+   const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
 };
 
 
@@ -4225,7 +4323,7 @@ struct gl_matrix_stack
 
 
 /**
- * \name Bits for image transfer operations 
+ * \name Bits for image transfer operations
  * \sa __struct gl_contextRec::ImageTransferState.
  */
 /*@{*/
@@ -4236,12 +4334,13 @@ struct gl_matrix_stack
 
 
 /** Pixel Transfer ops */
-#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT |                     \
-                   IMAGE_SHIFT_OFFSET_BIT |                    \
-                   IMAGE_MAP_COLOR_BIT)
+#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
+                    IMAGE_SHIFT_OFFSET_BIT | \
+                    IMAGE_MAP_COLOR_BIT)
+
 
 /**
- * \name Bits to indicate what state has changed.  
+ * \name Bits to indicate what state has changed.
  */
 /*@{*/
 #define _NEW_MODELVIEW         (1u << 0)   /**< gl_context::ModelView */
@@ -4306,29 +4405,18 @@ struct gl_matrix_stack
 #include "dd.h"
 
 
-/**
- * Display list flags.
- * Strictly this is a tnl-private concept, but it doesn't seem
- * worthwhile adding a tnl private structure just to hold this one bit
- * of information:
- */
-#define DLIST_DANGLING_REFS     0x1 
-
-
 /** Opaque declaration of display list payload data type */
 union gl_dlist_node;
 
 
 /**
- * Provide a location where information about a display list can be
- * collected.  Could be extended with driverPrivate structures,
- * etc. in the future.
+ * Per-display list information.
  */
 struct gl_display_list
 {
    GLuint Name;
-   GLchar *Label;     /**< GL_KHR_debug */
    GLbitfield Flags;  /**< DLIST_x flags */
+   GLchar *Label;     /**< GL_KHR_debug */
    /** The dlist commands are in a linked list of nodes */
    union gl_dlist_node *Head;
 };
@@ -4339,17 +4427,16 @@ struct gl_display_list
  */
 struct gl_dlist_state
 {
-   GLuint CallDepth;           /**< Current recursion calling depth */
-
    struct gl_display_list *CurrentList; /**< List currently being compiled */
    union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
    GLuint CurrentPos;          /**< Index into current block of nodes */
+   GLuint CallDepth;           /**< Current recursion calling depth */
 
    GLvertexformat ListVtxfmt;
 
    GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
    GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
-   
+
    GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
    GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
 
@@ -4367,7 +4454,8 @@ struct gl_dlist_state
  * to small enums suitable for use as an array index.
  */
 
-enum mesa_debug_source {
+enum mesa_debug_source
+{
    MESA_DEBUG_SOURCE_API,
    MESA_DEBUG_SOURCE_WINDOW_SYSTEM,
    MESA_DEBUG_SOURCE_SHADER_COMPILER,
@@ -4377,7 +4465,8 @@ enum mesa_debug_source {
    MESA_DEBUG_SOURCE_COUNT
 };
 
-enum mesa_debug_type {
+enum mesa_debug_type
+{
    MESA_DEBUG_TYPE_ERROR,
    MESA_DEBUG_TYPE_DEPRECATED,
    MESA_DEBUG_TYPE_UNDEFINED,
@@ -4390,7 +4479,8 @@ enum mesa_debug_type {
    MESA_DEBUG_TYPE_COUNT
 };
 
-enum mesa_debug_severity {
+enum mesa_debug_severity
+{
    MESA_DEBUG_SEVERITY_LOW,
    MESA_DEBUG_SEVERITY_MEDIUM,
    MESA_DEBUG_SEVERITY_HIGH,
@@ -4421,6 +4511,9 @@ struct gl_driver_flags
    /** gl_context::RasterDiscard */
    uint64_t NewRasterizerDiscard;
 
+   /** gl_context::TileRasterOrder* */
+   uint64_t NewTileRasterOrder;
+
    /**
     * gl_context::UniformBufferBindings
     * gl_shader_program::UniformBlocks
@@ -4530,7 +4623,7 @@ struct gl_driver_flags
    uint64_t NewShaderConstants[MESA_SHADER_STAGES];
 };
 
-struct gl_uniform_buffer_binding
+struct gl_buffer_binding
 {
    struct gl_buffer_object *BufferObject;
    /** Start of uniform block data in the buffer */
@@ -4544,20 +4637,6 @@ struct gl_uniform_buffer_binding
    GLboolean AutomaticSize;
 };
 
-struct gl_shader_storage_buffer_binding
-{
-   struct gl_buffer_object *BufferObject;
-   /** Start of shader storage block data in the buffer */
-   GLintptr Offset;
-   /** Size of data allowed to be referenced from the buffer (in bytes) */
-   GLsizeiptr Size;
-   /**
-    * glBindBufferBase() indicates that the Size should be ignored and only
-    * limited by the current size of the BufferObject.
-    */
-   GLboolean AutomaticSize;
-};
-
 /**
  * ARB_shader_image_load_store image unit.
  */
@@ -4612,16 +4691,6 @@ struct gl_image_unit
 
 };
 
-/**
- * Binding point for an atomic counter buffer object.
- */
-struct gl_atomic_buffer_binding
-{
-   struct gl_buffer_object *BufferObject;
-   GLintptr Offset;
-   GLsizeiptr Size;
-};
-
 /**
  * Shader subroutines storage
  */
@@ -4646,7 +4715,9 @@ struct gl_image_handle_object
 
 struct gl_memory_object
 {
-   GLuint Name;          /**< hash table ID/name */
+   GLuint Name;            /**< hash table ID/name */
+   GLboolean Immutable;    /**< denotes mutability state of parameters */
+   GLboolean Dedicated;    /**< import memory from a dedicated allocation */
 };
 
 /**
@@ -4756,7 +4827,7 @@ struct gl_context
    /*@}*/
 
    /** \name Renderer attribute groups
-    * 
+    *
     * We define a struct for each attribute group to make pushing and popping
     * attributes easy.  Also it's a good organization.
     */
@@ -4870,7 +4941,7 @@ struct gl_context
     * associated with uniform blocks by glUniformBlockBinding()'s state in the
     * shader program.
     */
-   struct gl_uniform_buffer_binding
+   struct gl_buffer_binding
       UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
 
    /**
@@ -4879,7 +4950,7 @@ struct gl_context
     * glBindBufferBase().  They are associated with shader storage blocks by
     * glShaderStorageBlockBinding()'s state in the shader program.
     */
-   struct gl_shader_storage_buffer_binding
+   struct gl_buffer_binding
       ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
 
    /**
@@ -4897,7 +4968,7 @@ struct gl_context
    /**
     * Array of atomic counter buffer binding points.
     */
-   struct gl_atomic_buffer_binding
+   struct gl_buffer_binding
       AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
 
    /**
@@ -4922,7 +4993,7 @@ struct gl_context
    GLuint ErrorDebugCount;
 
    /* GL_ARB_debug_output/GL_KHR_debug */
-   mtx_t DebugMutex;
+   simple_mtx_t DebugMutex;
    struct gl_debug_state *Debug;
 
    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
@@ -4933,14 +5004,15 @@ struct gl_context
 
    GLboolean ViewportInitialized;  /**< has viewport size been initialized? */
 
-   GLbitfield64 varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
+   GLbitfield varying_vp_inputs;  /**< mask of VERT_BIT_* flags */
 
    /** \name Derived state */
    GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
    GLfloat _EyeZDir[3];
-   GLfloat _ModelViewInvScale;
+   GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
+   GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
    GLboolean _NeedEyeCoords;
-   GLboolean _ForceEyeCoords; 
+   GLboolean _ForceEyeCoords;
 
    GLuint TextureStateTimestamp; /**< detect changes to shared state */
 
@@ -4957,16 +5029,25 @@ struct gl_context
     */
    GLboolean HasConfig;
 
-   /** software compression/decompression supported or not */
-   GLboolean Mesa_DXTn;
-
    GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
 
    GLboolean RasterDiscard;  /**< GL_RASTERIZER_DISCARD */
    GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
 
+   /** Does glVertexAttrib(0) alias glVertex()? */
+   bool _AttribZeroAliasesVertex;
+
+   /**
+    * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
+    * renderer's tiles should be excecuted, to meet the requirements of
+    * GL_MESA_tile_raster_order.
+    */
+   GLboolean TileRasterOrderFixed;
+   GLboolean TileRasterOrderIncreasingX;
+   GLboolean TileRasterOrderIncreasingY;
+
    /**
-    * \name Hooks for module contexts.  
+    * \name Hooks for module contexts.
     *
     * These will eventually live in the driver or elsewhere.
     */