summaryrefslogtreecommitdiffstats
path: root/third_party/rust/glslopt/glsl-optimizer/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/glslopt/glsl-optimizer/src/mesa')
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/config.h322
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.c1920
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.h460
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/dd.h1503
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/debug_output.h107
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/draw.h227
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/enums.h58
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/errors.h118
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions.h125
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.c50
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.h490
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/formats.h749
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glheader.h164
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glthread.h142
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/hash.h181
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/macros.h800
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/menums.h189
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mesa_private.h56
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mtypes.h5281
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/shaderobj.h265
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/uniforms.h523
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/main/version.h66
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/math/m_matrix.h218
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/dummy_errors.c30
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/ir_to_mesa.h59
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_instruction.h293
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_parameter.h244
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_statevars.h156
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/program.h169
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.c314
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.h62
-rw-r--r--third_party/rust/glslopt/glsl-optimizer/src/mesa/vbo/vbo.h162
32 files changed, 15503 insertions, 0 deletions
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/config.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/config.h
new file mode 100644
index 0000000000..4ea2e645b6
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/config.h
@@ -0,0 +1,322 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file config.h
+ * Tunable configuration parameters.
+ */
+
+#ifndef MESA_CONFIG_H_INCLUDED
+#define MESA_CONFIG_H_INCLUDED
+
+#include "compiler/shader_enums.h"
+
+/**
+ * \name OpenGL implementation limits
+ */
+/*@{*/
+
+/** Maximum modelview matrix stack depth */
+#define MAX_MODELVIEW_STACK_DEPTH 32
+
+/** Maximum projection matrix stack depth */
+#define MAX_PROJECTION_STACK_DEPTH 32
+
+/** Maximum texture matrix stack depth */
+#define MAX_TEXTURE_STACK_DEPTH 10
+
+/** Maximum attribute stack depth */
+#define MAX_ATTRIB_STACK_DEPTH 16
+
+/** Maximum client attribute stack depth */
+#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
+
+/** Maximum recursion depth of display list calls */
+#define MAX_LIST_NESTING 64
+
+/** Maximum number of lights */
+#define MAX_LIGHTS 8
+
+/**
+ * Maximum number of user-defined clipping planes supported by any driver in
+ * Mesa. This is used to size arrays.
+ */
+#define MAX_CLIP_PLANES 8
+
+/** Maximum pixel map lookup table size */
+#define MAX_PIXEL_MAP_TABLE 256
+
+/** Maximum number of auxillary color buffers */
+#define MAX_AUX_BUFFERS 1
+
+/** Maximum order (degree) of curves */
+#define MAX_EVAL_ORDER 30
+
+/** Maximum Name stack depth */
+#define MAX_NAME_STACK_DEPTH 64
+
+/** Minimum point size */
+#define MIN_POINT_SIZE 1.0
+/** Maximum point size */
+#define MAX_POINT_SIZE 60.0
+/** Point size granularity */
+#define POINT_SIZE_GRANULARITY 0.1
+
+/** Minimum line width */
+#define MIN_LINE_WIDTH 1.0
+/** Maximum line width */
+#define MAX_LINE_WIDTH 10.0
+/** Line width granularity */
+#define LINE_WIDTH_GRANULARITY 0.1
+
+/** Max memory to allow for a single texture image (in megabytes) */
+#define MAX_TEXTURE_MBYTES 1024
+
+/** Number of 1D/2D texture mipmap levels */
+#define MAX_TEXTURE_LEVELS 15
+
+/** Number of 3D texture mipmap levels */
+#define MAX_3D_TEXTURE_LEVELS 15
+
+/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
+#define MAX_CUBE_TEXTURE_LEVELS 15
+
+/** Maximum rectangular texture size - GL_NV_texture_rectangle */
+#define MAX_TEXTURE_RECT_SIZE 16384
+
+/**
+ * Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array
+ */
+#define MAX_ARRAY_TEXTURE_LAYERS 64
+
+/**
+ * Max number of texture coordinate units. This mainly just applies to
+ * the fixed-function vertex code. This will be difficult to raise above
+ * eight because of various vertex attribute bitvectors.
+ */
+#define MAX_TEXTURE_COORD_UNITS 8
+
+/**
+ * Max number of texture image units. Also determines number of texture
+ * samplers in shaders.
+ */
+#define MAX_TEXTURE_IMAGE_UNITS 32
+
+/**
+ * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
+ * This value is only used for dimensioning arrays.
+ * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the
+ * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be
+ * used almost everywhere else.
+ */
+#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS)
+
+/** Maximum number of viewports supported with ARB_viewport_array */
+#define MAX_VIEWPORTS 16
+
+/** Maximum number of window rectangles supported with EXT_window_rectangles */
+#define MAX_WINDOW_RECTANGLES 8
+
+/** Maximum size for CVA. May be overridden by the drivers. */
+#define MAX_ARRAY_LOCK_SIZE 3000
+
+/** Subpixel precision for antialiasing, window coordinate snapping */
+#define SUB_PIXEL_BITS 4
+
+/** For GL_ARB_texture_compression */
+#define MAX_COMPRESSED_TEXTURE_FORMATS 25
+
+/** For GL_EXT_texture_filter_anisotropic */
+#define MAX_TEXTURE_MAX_ANISOTROPY 16.0
+
+/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */
+#define MAX_TEXTURE_LOD_BIAS 14.0
+
+/** For any program target/extension */
+/*@{*/
+#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024)
+
+/**
+ * Per-program constants (power of two)
+ *
+ * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader
+ * and GLSL shader names for the same thing. They should \b always have the
+ * same value. Each refers to the number of vec4 values supplied as
+ * per-program parameters.
+ */
+/*@{*/
+#define MAX_PROGRAM_LOCAL_PARAMS 4096
+#define MAX_UNIFORMS 4096
+#define MAX_UNIFORM_BUFFERS 15 /* + 1 default uniform buffer */
+#define MAX_SHADER_STORAGE_BUFFERS 16
+/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
+#define MAX_COMBINED_UNIFORM_BUFFERS (MAX_UNIFORM_BUFFERS * 6)
+#define MAX_COMBINED_SHADER_STORAGE_BUFFERS (MAX_SHADER_STORAGE_BUFFERS * 6)
+#define MAX_ATOMIC_COUNTERS 4096
+/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
+#define MAX_COMBINED_ATOMIC_BUFFERS (MAX_UNIFORM_BUFFERS * 6)
+/* Size of an atomic counter in bytes according to ARB_shader_atomic_counters */
+#define ATOMIC_COUNTER_SIZE 4
+#define MAX_IMAGE_UNIFORMS 32
+/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
+#define MAX_IMAGE_UNITS (MAX_IMAGE_UNIFORMS * 6)
+/*@}*/
+
+/**
+ * Per-context constants (power of two)
+ *
+ * \note
+ * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS
+ * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make
+ * incorrect assumptions.
+ */
+#define MAX_PROGRAM_ENV_PARAMS 256
+
+#define MAX_PROGRAM_MATRICES 8
+#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
+#define MAX_PROGRAM_CALL_DEPTH 8
+#define MAX_PROGRAM_TEMPS 256
+#define MAX_PROGRAM_ADDRESS_REGS 1
+#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
+#define MAX_PROGRAM_INPUTS 32
+#define MAX_PROGRAM_OUTPUTS 64
+/*@}*/
+
+/** For GL_ARB_vertex_program */
+/*@{*/
+#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
+#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS
+/*@}*/
+
+/** For GL_ARB_fragment_program */
+/*@{*/
+#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0
+#define MAX_FRAGMENT_PROGRAM_PARAMS 64
+#define MAX_FRAGMENT_PROGRAM_INPUTS 12
+/*@}*/
+
+/** For GL_ARB_vertex_shader */
+/*@{*/
+#define MAX_VERTEX_GENERIC_ATTRIBS 16
+/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
+#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS * 6)
+/*@}*/
+
+
+/** For GL_EXT_framebuffer_object */
+/*@{*/
+#define MAX_COLOR_ATTACHMENTS 8
+#define MAX_RENDERBUFFER_SIZE 16384
+/*@}*/
+
+/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
+#define SUPPORTED_ATI_BUMP_UNITS 0xff
+
+/** For GL_EXT_transform_feedback */
+#define MAX_FEEDBACK_BUFFERS 4
+#define MAX_FEEDBACK_ATTRIBS 32
+
+/** For geometry shader */
+/*@{*/
+#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512
+#define MAX_GEOMETRY_OUTPUT_VERTICES 256
+#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024
+/*@}*/
+
+/** For GL_ARB_debug_output and GL_KHR_debug */
+/*@{*/
+#define MAX_DEBUG_LOGGED_MESSAGES 10
+#define MAX_DEBUG_MESSAGE_LENGTH 4096
+/*@}*/
+
+/** For GL_KHR_debug */
+/*@{*/
+#define MAX_LABEL_LENGTH 256
+#define MAX_DEBUG_GROUP_STACK_DEPTH 64
+/*@}*/
+
+/** For GL_ARB_gpu_shader5 */
+/*@{*/
+#define MAX_GEOMETRY_SHADER_INVOCATIONS 32
+#define MIN_FRAGMENT_INTERPOLATION_OFFSET -0.5
+#define MAX_FRAGMENT_INTERPOLATION_OFFSET 0.5
+#define FRAGMENT_INTERPOLATION_OFFSET_BITS 4
+#define MAX_VERTEX_STREAMS 4
+/*@}*/
+
+/** For GL_ARB_shader_subroutine */
+/*@{*/
+#define MAX_SUBROUTINES 256
+#define MAX_SUBROUTINE_UNIFORM_LOCATIONS 1024
+/*@}*/
+
+/** For GL_INTEL_performance_query */
+/*@{*/
+#define MAX_PERFQUERY_QUERY_NAME_LENGTH 256
+#define MAX_PERFQUERY_COUNTER_NAME_LENGTH 256
+#define MAX_PERFQUERY_COUNTER_DESC_LENGTH 1024
+#define PERFQUERY_HAVE_GPA_EXTENDED_COUNTERS 0
+/*@}*/
+
+/** For GL_ARB_pipeline_statistics_query */
+#define MAX_PIPELINE_STATISTICS 11
+
+/** For GL_ARB_tessellation_shader */
+/*@{*/
+#define MAX_TESS_GEN_LEVEL 64
+#define MAX_PATCH_VERTICES 32
+#define MAX_TESS_PATCH_COMPONENTS 120
+#define MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 4096
+/*@}*/
+
+/*
+ * Color channel component order
+ *
+ * \note Changes will almost certainly cause problems at this time.
+ */
+#define RCOMP 0
+#define GCOMP 1
+#define BCOMP 2
+#define ACOMP 3
+
+
+/**
+ * Maximum number of temporary vertices required for clipping.
+ *
+ * Used in array_cache and tnl modules.
+ */
+#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
+
+
+/** For GL_ARB_sample_locations - maximum of SAMPLE_LOCATION_PIXEL_GRID_*_ARB */
+#define MAX_SAMPLE_LOCATION_GRID_SIZE 4
+
+/* It is theoretically possible for Consts.MaxSamples to be >32 but
+ * other code seems to assume that is not the case.
+ */
+#define MAX_SAMPLE_LOCATION_TABLE_SIZE \
+ (MAX_SAMPLE_LOCATION_GRID_SIZE * MAX_SAMPLE_LOCATION_GRID_SIZE * 32)
+
+#endif /* MESA_CONFIG_H_INCLUDED */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.c b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.c
new file mode 100644
index 0000000000..2b8becb806
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.c
@@ -0,0 +1,1920 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file context.c
+ * Mesa context/visual/framebuffer management functions.
+ * \author Brian Paul
+ */
+
+/**
+ * \mainpage Mesa Main Module
+ *
+ * \section MainIntroduction Introduction
+ *
+ * The Mesa Main module consists of all the files in the main/ directory.
+ * Among the features of this module are:
+ * <UL>
+ * <LI> Structures to represent most GL state </LI>
+ * <LI> State set/get functions </LI>
+ * <LI> Display lists </LI>
+ * <LI> Texture unit, object and image handling </LI>
+ * <LI> Matrix and attribute stacks </LI>
+ * </UL>
+ *
+ * Other modules are responsible for API dispatch, vertex transformation,
+ * point/line/triangle setup, rasterization, vertex array caching,
+ * vertex/fragment programs/shaders, etc.
+ *
+ *
+ * \section AboutDoxygen About Doxygen
+ *
+ * If you're viewing this information as Doxygen-generated HTML you'll
+ * see the documentation index at the top of this page.
+ *
+ * The first line lists the Mesa source code modules.
+ * The second line lists the indexes available for viewing the documentation
+ * for each module.
+ *
+ * Selecting the <b>Main page</b> link will display a summary of the module
+ * (this page).
+ *
+ * Selecting <b>Data Structures</b> will list all C structures.
+ *
+ * Selecting the <b>File List</b> link will list all the source files in
+ * the module.
+ * Selecting a filename will show a list of all functions defined in that file.
+ *
+ * Selecting the <b>Data Fields</b> link will display a list of all
+ * documented structure members.
+ *
+ * Selecting the <b>Globals</b> link will display a list
+ * of all functions, structures, global variables and macros in the module.
+ *
+ */
+
+
+#include "glheader.h"
+
+#include "accum.h"
+#include "api_exec.h"
+#include "api_loopback.h"
+#include "arrayobj.h"
+#include "attrib.h"
+#include "bbox.h"
+#include "blend.h"
+#include "buffers.h"
+#include "bufferobj.h"
+#include "conservativeraster.h"
+#include "context.h"
+#include "cpuinfo.h"
+#include "debug.h"
+#include "debug_output.h"
+#include "depth.h"
+#include "dlist.h"
+#include "eval.h"
+#include "extensions.h"
+#include "fbobject.h"
+#include "feedback.h"
+#include "fog.h"
+#include "formats.h"
+#include "framebuffer.h"
+#include "glthread.h"
+#include "hint.h"
+#include "hash.h"
+#include "light.h"
+#include "lines.h"
+#include "macros.h"
+#include "matrix.h"
+#include "multisample.h"
+#include "performance_monitor.h"
+#include "performance_query.h"
+#include "pipelineobj.h"
+#include "pixel.h"
+#include "pixelstore.h"
+#include "points.h"
+#include "polygon.h"
+#include "queryobj.h"
+#include "syncobj.h"
+#include "rastpos.h"
+#include "remap.h"
+#include "scissor.h"
+#include "shared.h"
+#include "shaderobj.h"
+#include "shaderimage.h"
+#include "state.h"
+#include "util/debug.h"
+#include "util/disk_cache.h"
+#include "util/strtod.h"
+#include "stencil.h"
+#include "shaderimage.h"
+#include "texcompress_s3tc.h"
+#include "texstate.h"
+#include "transformfeedback.h"
+#include "mtypes.h"
+#include "varray.h"
+#include "version.h"
+#include "viewport.h"
+#include "texturebindless.h"
+#include "program/program.h"
+#include "math/m_matrix.h"
+#include "main/dispatch.h" /* for _gloffset_COUNT */
+#include "macros.h"
+#include "git_sha1.h"
+
+#ifdef USE_SPARC_ASM
+#include "sparc/sparc.h"
+#endif
+
+#include "compiler/glsl_types.h"
+#include "compiler/glsl/builtin_functions.h"
+#include "compiler/glsl/glsl_parser_extras.h"
+#include <stdbool.h>
+#include "util/u_memory.h"
+
+
+#ifndef MESA_VERBOSE
+int MESA_VERBOSE = 0;
+#endif
+
+#ifndef MESA_DEBUG_FLAGS
+int MESA_DEBUG_FLAGS = 0;
+#endif
+
+
+/* ubyte -> float conversion */
+GLfloat _mesa_ubyte_to_float_color_tab[256];
+
+
+
+/**
+ * Swap buffers notification callback.
+ *
+ * \param ctx GL context.
+ *
+ * Called by window system just before swapping buffers.
+ * We have to finish any pending rendering.
+ */
+void
+_mesa_notifySwapBuffers(struct gl_context *ctx)
+{
+ if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS)
+ _mesa_debug(ctx, "SwapBuffers\n");
+ FLUSH_VERTICES(ctx, 0);
+ if (ctx->Driver.Flush) {
+ ctx->Driver.Flush(ctx);
+ }
+}
+
+
+/**********************************************************************/
+/** \name GL Visual allocation/destruction */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * Allocates a struct gl_config structure and initializes it via
+ * _mesa_initialize_visual().
+ *
+ * \param dbFlag double buffering
+ * \param stereoFlag stereo buffer
+ * \param depthBits requested bits per depth buffer value. Any value in [0, 32]
+ * is acceptable but the actual depth type will be GLushort or GLuint as
+ * needed.
+ * \param stencilBits requested minimum bits per stencil buffer value
+ * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number
+ * of bits per color component in accum buffer.
+ * \param redBits number of bits per color component in frame buffer for RGB(A)
+ * mode. We always use 8 in core Mesa though.
+ * \param greenBits same as above.
+ * \param blueBits same as above.
+ * \param alphaBits same as above.
+ * \param numSamples not really used.
+ *
+ * \return pointer to new struct gl_config or NULL if requested parameters
+ * can't be met.
+ *
+ * \note Need to add params for level and numAuxBuffers (at least)
+ */
+struct gl_config *
+_mesa_create_visual( GLboolean dbFlag,
+ GLboolean stereoFlag,
+ GLint redBits,
+ GLint greenBits,
+ GLint blueBits,
+ GLint alphaBits,
+ GLint depthBits,
+ GLint stencilBits,
+ GLint accumRedBits,
+ GLint accumGreenBits,
+ GLint accumBlueBits,
+ GLint accumAlphaBits,
+ GLuint numSamples )
+{
+ struct gl_config *vis = CALLOC_STRUCT(gl_config);
+ if (vis) {
+ if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag,
+ redBits, greenBits, blueBits, alphaBits,
+ depthBits, stencilBits,
+ accumRedBits, accumGreenBits,
+ accumBlueBits, accumAlphaBits,
+ numSamples)) {
+ free(vis);
+ return NULL;
+ }
+ }
+ return vis;
+}
+
+
+/**
+ * Makes some sanity checks and fills in the fields of the struct
+ * gl_config object with the given parameters. If the caller needs to
+ * set additional fields, he should just probably init the whole
+ * gl_config object himself.
+ *
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \sa _mesa_create_visual() above for the parameter description.
+ */
+GLboolean
+_mesa_initialize_visual( struct gl_config *vis,
+ GLboolean dbFlag,
+ GLboolean stereoFlag,
+ GLint redBits,
+ GLint greenBits,
+ GLint blueBits,
+ GLint alphaBits,
+ GLint depthBits,
+ GLint stencilBits,
+ GLint accumRedBits,
+ GLint accumGreenBits,
+ GLint accumBlueBits,
+ GLint accumAlphaBits,
+ GLuint numSamples )
+{
+ assert(vis);
+
+ if (depthBits < 0 || depthBits > 32) {
+ return GL_FALSE;
+ }
+ if (stencilBits < 0 || stencilBits > 8) {
+ return GL_FALSE;
+ }
+ assert(accumRedBits >= 0);
+ assert(accumGreenBits >= 0);
+ assert(accumBlueBits >= 0);
+ assert(accumAlphaBits >= 0);
+
+ vis->doubleBufferMode = dbFlag;
+ vis->stereoMode = stereoFlag;
+
+ vis->redBits = redBits;
+ vis->greenBits = greenBits;
+ vis->blueBits = blueBits;
+ vis->alphaBits = alphaBits;
+ vis->rgbBits = redBits + greenBits + blueBits;
+
+ vis->depthBits = depthBits;
+ vis->stencilBits = stencilBits;
+
+ vis->accumRedBits = accumRedBits;
+ vis->accumGreenBits = accumGreenBits;
+ vis->accumBlueBits = accumBlueBits;
+ vis->accumAlphaBits = accumAlphaBits;
+
+ vis->numAuxBuffers = 0;
+ vis->level = 0;
+ vis->sampleBuffers = numSamples > 0 ? 1 : 0;
+ vis->samples = numSamples;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Destroy a visual and free its memory.
+ *
+ * \param vis visual.
+ *
+ * Frees the visual structure.
+ */
+void
+_mesa_destroy_visual( struct gl_config *vis )
+{
+ free(vis);
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Context allocation, initialization, destroying
+ *
+ * The purpose of the most initialization functions here is to provide the
+ * default state values according to the OpenGL specification.
+ */
+/**********************************************************************/
+/*@{*/
+
+
+/**
+ * One-time initialization mutex lock.
+ *
+ * \sa Used by one_time_init().
+ */
+mtx_t OneTimeLock = _MTX_INITIALIZER_NP;
+
+
+/**
+ * Calls all the various one-time-fini functions in Mesa
+ */
+
+static void
+one_time_fini(void)
+{
+ glsl_type_singleton_decref();
+ _mesa_locale_fini();
+}
+
+/**
+ * Calls all the various one-time-init functions in Mesa.
+ *
+ * While holding a global mutex lock, calls several initialization functions,
+ * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is
+ * defined.
+ *
+ * \sa _math_init().
+ */
+void
+_mesa_initialize(void)
+{
+ static bool initialized;
+
+ mtx_lock(&OneTimeLock);
+
+ /* truly one-time init */
+ if (!initialized) {
+ GLuint i;
+
+ STATIC_ASSERT(sizeof(GLbyte) == 1);
+ STATIC_ASSERT(sizeof(GLubyte) == 1);
+ STATIC_ASSERT(sizeof(GLshort) == 2);
+ STATIC_ASSERT(sizeof(GLushort) == 2);
+ STATIC_ASSERT(sizeof(GLint) == 4);
+ STATIC_ASSERT(sizeof(GLuint) == 4);
+
+ _mesa_locale_init();
+
+ _mesa_one_time_init_extension_overrides();
+
+ _mesa_get_cpu_features();
+
+ for (i = 0; i < 256; i++) {
+ _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
+ }
+
+ atexit(one_time_fini);
+
+#if defined(DEBUG)
+ if (MESA_VERBOSE != 0) {
+ _mesa_debug(NULL, "Mesa " PACKAGE_VERSION " DEBUG build" MESA_GIT_SHA1 "\n");
+ }
+#endif
+
+ /* Take a glsl type reference for the duration of libGL's life to avoid
+ * unecessary creation/destruction of glsl types.
+ */
+ glsl_type_singleton_init_or_ref();
+
+ _mesa_init_remap_table();
+ }
+
+ initialized = true;
+
+ mtx_unlock(&OneTimeLock);
+}
+
+
+/**
+ * Initialize fields of gl_current_attrib (aka ctx->Current.*)
+ */
+static void
+_mesa_init_current(struct gl_context *ctx)
+{
+ GLuint i;
+
+ /* Init all to (0,0,0,1) */
+ for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) {
+ ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
+ }
+
+ /* redo special cases: */
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 );
+}
+
+
+/**
+ * Init vertex/fragment/geometry program limits.
+ * Important: drivers should override these with actual limits.
+ */
+static void
+init_program_limits(struct gl_constants *consts, gl_shader_stage stage,
+ struct gl_program_constants *prog)
+{
+ prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS;
+ prog->MaxAluInstructions = MAX_PROGRAM_INSTRUCTIONS;
+ prog->MaxTexInstructions = MAX_PROGRAM_INSTRUCTIONS;
+ prog->MaxTexIndirections = MAX_PROGRAM_INSTRUCTIONS;
+ prog->MaxTemps = MAX_PROGRAM_TEMPS;
+ prog->MaxEnvParams = MAX_PROGRAM_ENV_PARAMS;
+ prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
+ prog->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS;
+
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
+ prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
+ prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+ prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+ prog->MaxInputComponents = 0; /* value not used */
+ prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
+ break;
+ case MESA_SHADER_FRAGMENT:
+ prog->MaxParameters = MAX_FRAGMENT_PROGRAM_PARAMS;
+ prog->MaxAttribs = MAX_FRAGMENT_PROGRAM_INPUTS;
+ prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
+ prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+ prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
+ prog->MaxOutputComponents = 0; /* value not used */
+ break;
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
+ case MESA_SHADER_GEOMETRY:
+ prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
+ prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
+ prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+ prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+ prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
+ prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
+ break;
+ case MESA_SHADER_COMPUTE:
+ prog->MaxParameters = 0; /* not meaningful for compute shaders */
+ prog->MaxAttribs = 0; /* not meaningful for compute shaders */
+ prog->MaxAddressRegs = 0; /* not meaningful for compute shaders */
+ prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+ prog->MaxInputComponents = 0; /* not meaningful for compute shaders */
+ prog->MaxOutputComponents = 0; /* not meaningful for compute shaders */
+ break;
+ default:
+ assert(0 && "Bad shader stage in init_program_limits()");
+ }
+
+ /* Set the native limits to zero. This implies that there is no native
+ * support for shaders. Let the drivers fill in the actual values.
+ */
+ prog->MaxNativeInstructions = 0;
+ prog->MaxNativeAluInstructions = 0;
+ prog->MaxNativeTexInstructions = 0;
+ prog->MaxNativeTexIndirections = 0;
+ prog->MaxNativeAttribs = 0;
+ prog->MaxNativeTemps = 0;
+ prog->MaxNativeAddressRegs = 0;
+ prog->MaxNativeParameters = 0;
+
+ /* Set GLSL datatype range/precision info assuming IEEE float values.
+ * Drivers should override these defaults as needed.
+ */
+ prog->MediumFloat.RangeMin = 127;
+ prog->MediumFloat.RangeMax = 127;
+ prog->MediumFloat.Precision = 23;
+ prog->LowFloat = prog->HighFloat = prog->MediumFloat;
+
+ /* Assume ints are stored as floats for now, since this is the least-common
+ * denominator. The OpenGL ES spec implies (page 132) that the precision
+ * of integer types should be 0. Practically speaking, IEEE
+ * single-precision floating point values can only store integers in the
+ * range [-0x01000000, 0x01000000] without loss of precision.
+ */
+ prog->MediumInt.RangeMin = 24;
+ prog->MediumInt.RangeMax = 24;
+ prog->MediumInt.Precision = 0;
+ prog->LowInt = prog->HighInt = prog->MediumInt;
+
+ prog->MaxUniformBlocks = 12;
+ prog->MaxCombinedUniformComponents = (prog->MaxUniformComponents +
+ consts->MaxUniformBlockSize / 4 *
+ prog->MaxUniformBlocks);
+
+ prog->MaxAtomicBuffers = 0;
+ prog->MaxAtomicCounters = 0;
+
+ prog->MaxShaderStorageBlocks = 8;
+}
+
+
+/**
+ * Initialize fields of gl_constants (aka ctx->Const.*).
+ * Use defaults from config.h. The device drivers will often override
+ * some of these values (such as number of texture units).
+ */
+void
+_mesa_init_constants(struct gl_constants *consts, gl_api api)
+{
+ int i;
+ assert(consts);
+
+ /* Constants, may be overriden (usually only reduced) by device drivers */
+ consts->MaxTextureMbytes = MAX_TEXTURE_MBYTES;
+ consts->MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1);
+ consts->Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
+ consts->MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
+ consts->MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
+ consts->MaxArrayTextureLayers = MAX_ARRAY_TEXTURE_LAYERS;
+ consts->MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS;
+ consts->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->MaxTextureUnits = MIN2(consts->MaxTextureCoordUnits,
+ consts->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits);
+ consts->MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
+ consts->MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
+ consts->MaxTextureBufferSize = 65536;
+ consts->TextureBufferOffsetAlignment = 1;
+ consts->MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
+ consts->SubPixelBits = SUB_PIXEL_BITS;
+ consts->MinPointSize = MIN_POINT_SIZE;
+ consts->MaxPointSize = MAX_POINT_SIZE;
+ consts->MinPointSizeAA = MIN_POINT_SIZE;
+ consts->MaxPointSizeAA = MAX_POINT_SIZE;
+ consts->PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY;
+ consts->MinLineWidth = MIN_LINE_WIDTH;
+ consts->MaxLineWidth = MAX_LINE_WIDTH;
+ consts->MinLineWidthAA = MIN_LINE_WIDTH;
+ consts->MaxLineWidthAA = MAX_LINE_WIDTH;
+ consts->LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY;
+ consts->MaxClipPlanes = 6;
+ consts->MaxLights = MAX_LIGHTS;
+ consts->MaxShininess = 128.0;
+ consts->MaxSpotExponent = 128.0;
+ consts->MaxViewportWidth = 16384;
+ consts->MaxViewportHeight = 16384;
+ consts->MinMapBufferAlignment = 64;
+
+ /* Driver must override these values if ARB_viewport_array is supported. */
+ consts->MaxViewports = 1;
+ consts->ViewportSubpixelBits = 0;
+ consts->ViewportBounds.Min = 0;
+ consts->ViewportBounds.Max = 0;
+
+ /** GL_ARB_uniform_buffer_object */
+ consts->MaxCombinedUniformBlocks = 36;
+ consts->MaxUniformBufferBindings = 36;
+ consts->MaxUniformBlockSize = 16384;
+ consts->UniformBufferOffsetAlignment = 1;
+
+ /** GL_ARB_shader_storage_buffer_object */
+ consts->MaxCombinedShaderStorageBlocks = 8;
+ consts->MaxShaderStorageBufferBindings = 8;
+ consts->MaxShaderStorageBlockSize = 128 * 1024 * 1024; /* 2^27 */
+ consts->ShaderStorageBufferOffsetAlignment = 256;
+
+ /* GL_ARB_explicit_uniform_location, GL_MAX_UNIFORM_LOCATIONS */
+ consts->MaxUserAssignableUniformLocations =
+ 4 * MESA_SHADER_STAGES * MAX_UNIFORMS;
+
+ for (i = 0; i < MESA_SHADER_STAGES; i++)
+ init_program_limits(consts, i, &consts->Program[i]);
+
+ consts->MaxProgramMatrices = MAX_PROGRAM_MATRICES;
+ consts->MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
+
+ /* Set the absolute minimum possible GLSL version. API_OPENGL_CORE can
+ * mean an OpenGL 3.0 forward-compatible context, so that implies a minimum
+ * possible version of 1.30. Otherwise, the minimum possible version 1.20.
+ * Since Mesa unconditionally advertises GL_ARB_shading_language_100 and
+ * GL_ARB_shader_objects, every driver has GLSL 1.20... even if they don't
+ * advertise any extensions to enable any shader stages (e.g.,
+ * GL_ARB_vertex_shader).
+ */
+ consts->GLSLVersion = api == API_OPENGL_CORE ? 130 : 120;
+ consts->GLSLVersionCompat = consts->GLSLVersion;
+
+ consts->GLSLLowerConstArrays = true;
+
+ /* Assume that if GLSL 1.30+ (or GLSL ES 3.00+) is supported that
+ * gl_VertexID is implemented using a native hardware register with OpenGL
+ * semantics.
+ */
+ consts->VertexID_is_zero_based = false;
+
+ /* GL_ARB_draw_buffers */
+ consts->MaxDrawBuffers = MAX_DRAW_BUFFERS;
+
+ consts->MaxColorAttachments = MAX_COLOR_ATTACHMENTS;
+ consts->MaxRenderbufferSize = MAX_RENDERBUFFER_SIZE;
+
+ consts->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+ consts->MaxVarying = 16; /* old limit not to break tnl and swrast */
+ consts->Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES;
+ consts->MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS;
+ consts->MaxGeometryShaderInvocations = MAX_GEOMETRY_SHADER_INVOCATIONS;
+
+#ifdef DEBUG
+ consts->GenerateTemporaryNames = true;
+#else
+ consts->GenerateTemporaryNames = false;
+#endif
+
+ /* GL_ARB_framebuffer_object */
+ consts->MaxSamples = 0;
+
+ /* GLSL default if NativeIntegers == FALSE */
+ consts->UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u;
+
+ /* GL_ARB_sync */
+ consts->MaxServerWaitTimeout = 0x7fffffff7fffffffULL;
+
+ /* GL_EXT_provoking_vertex */
+ consts->QuadsFollowProvokingVertexConvention = GL_TRUE;
+
+ /** GL_ARB_viewport_array */
+ consts->LayerAndVPIndexProvokingVertex = GL_UNDEFINED_VERTEX;
+
+ /* GL_EXT_transform_feedback */
+ consts->MaxTransformFeedbackBuffers = MAX_FEEDBACK_BUFFERS;
+ consts->MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
+ consts->MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
+ consts->MaxVertexStreams = 1;
+
+ /* GL 3.2 */
+ consts->ProfileMask = api == API_OPENGL_CORE
+ ? GL_CONTEXT_CORE_PROFILE_BIT
+ : GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
+
+ /* GL 4.4 */
+ consts->MaxVertexAttribStride = 2048;
+
+ /** GL_EXT_gpu_shader4 */
+ consts->MinProgramTexelOffset = -8;
+ consts->MaxProgramTexelOffset = 7;
+
+ /* GL_ARB_texture_gather */
+ consts->MinProgramTextureGatherOffset = -8;
+ consts->MaxProgramTextureGatherOffset = 7;
+
+ /* GL_ARB_robustness */
+ consts->ResetStrategy = GL_NO_RESET_NOTIFICATION_ARB;
+
+ /* GL_KHR_robustness */
+ consts->RobustAccess = GL_FALSE;
+
+ /* ES 3.0 or ARB_ES3_compatibility */
+ consts->MaxElementIndex = 0xffffffffu;
+
+ /* GL_ARB_texture_multisample */
+ consts->MaxColorTextureSamples = 1;
+ consts->MaxDepthTextureSamples = 1;
+ consts->MaxIntegerSamples = 1;
+
+ /* GL_ARB_shader_atomic_counters */
+ consts->MaxAtomicBufferBindings = MAX_COMBINED_ATOMIC_BUFFERS;
+ consts->MaxAtomicBufferSize = MAX_ATOMIC_COUNTERS * ATOMIC_COUNTER_SIZE;
+ consts->MaxCombinedAtomicBuffers = MAX_COMBINED_ATOMIC_BUFFERS;
+ consts->MaxCombinedAtomicCounters = MAX_ATOMIC_COUNTERS;
+
+ /* GL_ARB_vertex_attrib_binding */
+ consts->MaxVertexAttribRelativeOffset = 2047;
+ consts->MaxVertexAttribBindings = MAX_VERTEX_GENERIC_ATTRIBS;
+
+ /* GL_ARB_compute_shader */
+ consts->MaxComputeWorkGroupCount[0] = 65535;
+ consts->MaxComputeWorkGroupCount[1] = 65535;
+ consts->MaxComputeWorkGroupCount[2] = 65535;
+ consts->MaxComputeWorkGroupSize[0] = 1024;
+ consts->MaxComputeWorkGroupSize[1] = 1024;
+ consts->MaxComputeWorkGroupSize[2] = 64;
+ /* Enables compute support for GLES 3.1 if >= 128 */
+ consts->MaxComputeWorkGroupInvocations = 0;
+
+ /** GL_ARB_gpu_shader5 */
+ consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET;
+ consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET;
+
+ /** GL_KHR_context_flush_control */
+ consts->ContextReleaseBehavior = GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH;
+
+ /** GL_ARB_tessellation_shader */
+ consts->MaxTessGenLevel = MAX_TESS_GEN_LEVEL;
+ consts->MaxPatchVertices = MAX_PATCH_VERTICES;
+ consts->Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->MaxTessPatchComponents = MAX_TESS_PATCH_COMPONENTS;
+ consts->MaxTessControlTotalOutputComponents = MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS;
+ consts->PrimitiveRestartForPatches = false;
+
+ /** GL_ARB_compute_variable_group_size */
+ consts->MaxComputeVariableGroupSize[0] = 512;
+ consts->MaxComputeVariableGroupSize[1] = 512;
+ consts->MaxComputeVariableGroupSize[2] = 64;
+ consts->MaxComputeVariableGroupInvocations = 512;
+
+ /** GL_NV_conservative_raster */
+ consts->MaxSubpixelPrecisionBiasBits = 0;
+
+ /** GL_NV_conservative_raster_dilate */
+ consts->ConservativeRasterDilateRange[0] = 0.0;
+ consts->ConservativeRasterDilateRange[1] = 0.0;
+ consts->ConservativeRasterDilateGranularity = 0.0;
+
+ consts->glBeginEndBufferSize = 512 * 1024;
+}
+
+
+/**
+ * Do some sanity checks on the limits/constants for the given context.
+ * Only called the first time a context is bound.
+ */
+static void
+check_context_limits(struct gl_context *ctx)
+{
+ (void) ctx;
+
+ /* check that we don't exceed the size of various bitfields */
+ assert(VARYING_SLOT_MAX <=
+ (8 * sizeof(ctx->VertexProgram._Current->info.outputs_written)));
+ assert(VARYING_SLOT_MAX <=
+ (8 * sizeof(ctx->FragmentProgram._Current->info.inputs_read)));
+
+ /* shader-related checks */
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+ assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+
+ /* Texture unit checks */
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits > 0);
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS);
+ assert(ctx->Const.MaxTextureCoordUnits > 0);
+ assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS);
+ assert(ctx->Const.MaxTextureUnits > 0);
+ assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS);
+ assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS);
+ assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
+ ctx->Const.MaxTextureCoordUnits));
+ assert(ctx->Const.MaxCombinedTextureImageUnits > 0);
+ assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+ assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+ /* number of coord units cannot be greater than number of image units */
+ assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits);
+
+
+ /* Texture size checks */
+ assert(ctx->Const.MaxTextureSize <= (1 << (MAX_TEXTURE_LEVELS - 1)));
+ assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS);
+ assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS);
+ assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE);
+
+ /* Texture level checks */
+ assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
+ assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
+
+ /* Max texture size should be <= max viewport size (render to texture) */
+ assert(ctx->Const.MaxTextureSize <= ctx->Const.MaxViewportWidth);
+ assert(ctx->Const.MaxTextureSize <= ctx->Const.MaxViewportHeight);
+
+ assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS);
+
+ /* if this fails, add more enum values to gl_buffer_index */
+ assert(BUFFER_COLOR0 + MAX_DRAW_BUFFERS <= BUFFER_COUNT);
+
+ /* XXX probably add more tests */
+}
+
+
+/**
+ * Initialize the attribute groups in a GL context.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes all the attributes, calling the respective <tt>init*</tt>
+ * functions for the more complex data structures.
+ */
+static GLboolean
+init_attrib_groups(struct gl_context *ctx)
+{
+ assert(ctx);
+
+ /* Constants */
+ _mesa_init_constants(&ctx->Const, ctx->API);
+
+ /* Extensions */
+ _mesa_init_extensions(&ctx->Extensions);
+
+ /* Attribute Groups */
+ _mesa_init_accum( ctx );
+ _mesa_init_attrib( ctx );
+ _mesa_init_bbox( ctx );
+ _mesa_init_buffer_objects( ctx );
+ _mesa_init_color( ctx );
+ _mesa_init_conservative_raster( ctx );
+ _mesa_init_current( ctx );
+ _mesa_init_depth( ctx );
+ _mesa_init_debug( ctx );
+ _mesa_init_debug_output( ctx );
+ _mesa_init_display_list( ctx );
+ _mesa_init_eval( ctx );
+ _mesa_init_fbobjects( ctx );
+ _mesa_init_feedback( ctx );
+ _mesa_init_fog( ctx );
+ _mesa_init_hint( ctx );
+ _mesa_init_image_units( ctx );
+ _mesa_init_line( ctx );
+ _mesa_init_lighting( ctx );
+ _mesa_init_matrix( ctx );
+ _mesa_init_multisample( ctx );
+ _mesa_init_performance_monitors( ctx );
+ _mesa_init_performance_queries( ctx );
+ _mesa_init_pipeline( ctx );
+ _mesa_init_pixel( ctx );
+ _mesa_init_pixelstore( ctx );
+ _mesa_init_point( ctx );
+ _mesa_init_polygon( ctx );
+ _mesa_init_program( ctx );
+ _mesa_init_queryobj( ctx );
+ _mesa_init_sync( ctx );
+ _mesa_init_rastpos( ctx );
+ _mesa_init_scissor( ctx );
+ _mesa_init_shader_state( ctx );
+ _mesa_init_stencil( ctx );
+ _mesa_init_transform( ctx );
+ _mesa_init_transform_feedback( ctx );
+ _mesa_init_varray( ctx );
+ _mesa_init_viewport( ctx );
+ _mesa_init_resident_handles( ctx );
+
+ if (!_mesa_init_texture( ctx ))
+ return GL_FALSE;
+
+ /* Miscellaneous */
+ ctx->TileRasterOrderIncreasingX = GL_TRUE;
+ ctx->TileRasterOrderIncreasingY = GL_TRUE;
+ ctx->NewState = _NEW_ALL;
+ ctx->NewDriverState = ~0;
+ ctx->ErrorValue = GL_NO_ERROR;
+ ctx->ShareGroupReset = false;
+ ctx->varying_vp_inputs = VERT_BIT_ALL;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Update default objects in a GL context with respect to shared state.
+ *
+ * \param ctx GL context.
+ *
+ * Removes references to old default objects, (texture objects, program
+ * objects, etc.) and changes to reference those from the current shared
+ * state.
+ */
+static GLboolean
+update_default_objects(struct gl_context *ctx)
+{
+ assert(ctx);
+
+ _mesa_update_default_objects_program(ctx);
+ _mesa_update_default_objects_texture(ctx);
+ _mesa_update_default_objects_buffer_objects(ctx);
+
+ return GL_TRUE;
+}
+
+
+/* XXX this is temporary and should be removed at some point in the
+ * future when there's a reasonable expectation that the libGL library
+ * contains the _glapi_new_nop_table() and _glapi_set_nop_handler()
+ * functions which were added in Mesa 10.6.
+ */
+#if !defined(_WIN32)
+/* Avoid libGL / driver ABI break */
+#define USE_GLAPI_NOP_FEATURES 0
+#else
+#define USE_GLAPI_NOP_FEATURES 1
+#endif
+
+
+/**
+ * This function is called by the glapi no-op functions. For each OpenGL
+ * function/entrypoint there's a simple no-op function. These "no-op"
+ * functions call this function.
+ *
+ * If there's a current OpenGL context for the calling thread, we record a
+ * GL_INVALID_OPERATION error. This can happen either because the app's
+ * calling an unsupported extension function, or calling an illegal function
+ * (such as glClear between glBegin/glEnd).
+ *
+ * If there's no current OpenGL context for the calling thread, we can
+ * print a message to stderr.
+ *
+ * \param name the name of the OpenGL function
+ */
+#if USE_GLAPI_NOP_FEATURES
+static void
+nop_handler(const char *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid call)", name);
+ }
+#ifndef NDEBUG
+ else if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
+ fprintf(stderr,
+ "GL User Error: gl%s called without a rendering context\n",
+ name);
+ fflush(stderr);
+ }
+#endif
+}
+#endif
+
+
+/**
+ * Special no-op glFlush, see below.
+ */
+#if defined(_WIN32)
+static void GLAPIENTRY
+nop_glFlush(void)
+{
+ /* don't record an error like we do in nop_handler() */
+}
+#endif
+
+
+#if !USE_GLAPI_NOP_FEATURES
+static int
+generic_nop(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function called "
+ "(unsupported extension or deprecated function?)");
+ return 0;
+}
+#endif
+
+
+/**
+ * Create a new API dispatch table in which all entries point to the
+ * generic_nop() function. This will not work on Windows because of
+ * the __stdcall convention which requires the callee to clean up the
+ * call stack. That's impossible with one generic no-op function.
+ */
+struct _glapi_table *
+_mesa_new_nop_table(unsigned numEntries)
+{
+ struct _glapi_table *table;
+
+#if !USE_GLAPI_NOP_FEATURES
+ table = malloc(numEntries * sizeof(_glapi_proc));
+ if (table) {
+ _glapi_proc *entry = (_glapi_proc *) table;
+ unsigned i;
+ for (i = 0; i < numEntries; i++) {
+ entry[i] = (_glapi_proc) generic_nop;
+ }
+ }
+#else
+ table = _glapi_new_nop_table(numEntries);
+#endif
+ return table;
+}
+
+
+/**
+ * Allocate and initialize a new dispatch table. The table will be
+ * populated with pointers to "no-op" functions. In turn, the no-op
+ * functions will call nop_handler() above.
+ */
+struct _glapi_table *
+_mesa_alloc_dispatch_table(void)
+{
+ /* Find the larger of Mesa's dispatch table and libGL's dispatch table.
+ * In practice, this'll be the same for stand-alone Mesa. But for DRI
+ * Mesa we do this to accommodate different versions of libGL and various
+ * DRI drivers.
+ */
+ int numEntries = MAX2(_glapi_get_dispatch_table_size(), _gloffset_COUNT);
+
+ struct _glapi_table *table = _mesa_new_nop_table(numEntries);
+
+#if defined(_WIN32)
+ if (table) {
+ /* This is a special case for Windows in the event that
+ * wglGetProcAddress is called between glBegin/End().
+ *
+ * The MS opengl32.dll library apparently calls glFlush from
+ * wglGetProcAddress(). If we're inside glBegin/End(), glFlush
+ * will dispatch to _mesa_generic_nop() and we'll generate a
+ * GL_INVALID_OPERATION error.
+ *
+ * The specific case which hits this is piglit's primitive-restart
+ * test which calls glPrimitiveRestartNV() inside glBegin/End. The
+ * first time we call glPrimitiveRestartNV() Piglit's API dispatch
+ * code will try to resolve the function by calling wglGetProcAddress.
+ * This raises GL_INVALID_OPERATION and an assert(glGetError()==0)
+ * will fail causing the test to fail. By suppressing the error, the
+ * assertion passes and the test continues.
+ */
+ SET_Flush(table, nop_glFlush);
+ }
+#endif
+
+#if USE_GLAPI_NOP_FEATURES
+ _glapi_set_nop_handler(nop_handler);
+#endif
+
+ return table;
+}
+
+/**
+ * Creates a minimal dispatch table for use within glBegin()/glEnd().
+ *
+ * This ensures that we generate GL_INVALID_OPERATION errors from most
+ * functions, since the set of functions that are valid within Begin/End is
+ * very small.
+ *
+ * From the GL 1.0 specification section 2.6.3, "GL Commands within
+ * Begin/End"
+ *
+ * "The only GL commands that are allowed within any Begin/End pairs are
+ * the commands for specifying vertex coordinates, vertex color, normal
+ * coordinates, and texture coordinates (Vertex, Color, Index, Normal,
+ * TexCoord), EvalCoord and EvalPoint commands (see section 5.1),
+ * commands for specifying lighting material parameters (Material
+ * commands see section 2.12.2), display list invocation commands
+ * (CallList and CallLists see section 5.4), and the EdgeFlag
+ * command. Executing Begin after Begin has already been executed but
+ * before an End is issued generates the INVALID OPERATION error, as does
+ * executing End without a previous corresponding Begin. Executing any
+ * other GL command within Begin/End results in the error INVALID
+ * OPERATION."
+ *
+ * The table entries for specifying vertex attributes are set up by
+ * install_vtxfmt() and _mesa_loopback_init_api_table(), and End() and dlists
+ * are set by install_vtxfmt() as well.
+ */
+static struct _glapi_table *
+create_beginend_table(const struct gl_context *ctx)
+{
+ struct _glapi_table *table;
+
+ table = _mesa_alloc_dispatch_table();
+ if (!table)
+ return NULL;
+
+ /* Fill in functions which return a value, since they should return some
+ * specific value even if they emit a GL_INVALID_OPERATION error from them
+ * being called within glBegin()/glEnd().
+ */
+#define COPY_DISPATCH(func) SET_##func(table, GET_##func(ctx->Exec))
+
+ COPY_DISPATCH(GenLists);
+ COPY_DISPATCH(IsProgram);
+ COPY_DISPATCH(IsVertexArray);
+ COPY_DISPATCH(IsBuffer);
+ COPY_DISPATCH(IsEnabled);
+ COPY_DISPATCH(IsEnabledi);
+ COPY_DISPATCH(IsRenderbuffer);
+ COPY_DISPATCH(IsFramebuffer);
+ COPY_DISPATCH(CheckFramebufferStatus);
+ COPY_DISPATCH(RenderMode);
+ COPY_DISPATCH(GetString);
+ COPY_DISPATCH(GetStringi);
+ COPY_DISPATCH(GetPointerv);
+ COPY_DISPATCH(IsQuery);
+ COPY_DISPATCH(IsSampler);
+ COPY_DISPATCH(IsSync);
+ COPY_DISPATCH(IsTexture);
+ COPY_DISPATCH(IsTransformFeedback);
+ COPY_DISPATCH(DeleteQueries);
+ COPY_DISPATCH(AreTexturesResident);
+ COPY_DISPATCH(FenceSync);
+ COPY_DISPATCH(ClientWaitSync);
+ COPY_DISPATCH(MapBuffer);
+ COPY_DISPATCH(UnmapBuffer);
+ COPY_DISPATCH(MapBufferRange);
+ COPY_DISPATCH(ObjectPurgeableAPPLE);
+ COPY_DISPATCH(ObjectUnpurgeableAPPLE);
+
+ _mesa_loopback_init_api_table(ctx, table);
+
+ return table;
+}
+
+void
+_mesa_initialize_dispatch_tables(struct gl_context *ctx)
+{
+ /* Do the code-generated setup of the exec table in api_exec.c. */
+ _mesa_initialize_exec_table(ctx);
+
+ if (ctx->Save)
+ _mesa_initialize_save_table(ctx);
+}
+
+/**
+ * Initialize a struct gl_context struct (rendering context).
+ *
+ * This includes allocating all the other structs and arrays which hang off of
+ * the context by pointers.
+ * Note that the driver needs to pass in its dd_function_table here since
+ * we need to at least call driverFunctions->NewTextureObject to create the
+ * default texture objects.
+ *
+ * Called by _mesa_create_context().
+ *
+ * Performs the imports and exports callback tables initialization, and
+ * miscellaneous one-time initializations. If no shared context is supplied one
+ * is allocated, and increase its reference count. Setups the GL API dispatch
+ * tables. Initialize the TNL module. Sets the maximum Z buffer depth.
+ * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables
+ * for debug flags.
+ *
+ * \param ctx the context to initialize
+ * \param api the GL API type to create the context for
+ * \param visual describes the visual attributes for this context or NULL to
+ * create a configless context
+ * \param share_list points to context to share textures, display lists,
+ * etc with, or NULL
+ * \param driverFunctions table of device driver functions for this context
+ * to use
+ */
+GLboolean
+_mesa_initialize_context(struct gl_context *ctx,
+ gl_api api,
+ const struct gl_config *visual,
+ struct gl_context *share_list,
+ const struct dd_function_table *driverFunctions)
+{
+ struct gl_shared_state *shared;
+ int i;
+
+ assert(driverFunctions->NewTextureObject);
+ assert(driverFunctions->FreeTextureImageBuffer);
+
+ ctx->API = api;
+ ctx->DrawBuffer = NULL;
+ ctx->ReadBuffer = NULL;
+ ctx->WinSysDrawBuffer = NULL;
+ ctx->WinSysReadBuffer = NULL;
+
+ if (visual) {
+ ctx->Visual = *visual;
+ ctx->HasConfig = GL_TRUE;
+ }
+ else {
+ memset(&ctx->Visual, 0, sizeof ctx->Visual);
+ ctx->HasConfig = GL_FALSE;
+ }
+
+ _mesa_override_gl_version(ctx);
+
+ /* misc one-time initializations */
+ _mesa_initialize();
+
+ /* Plug in driver functions and context pointer here.
+ * This is important because when we call alloc_shared_state() below
+ * we'll call ctx->Driver.NewTextureObject() to create the default
+ * textures.
+ */
+ ctx->Driver = *driverFunctions;
+
+ if (share_list) {
+ /* share state with another context */
+ shared = share_list->Shared;
+ }
+ else {
+ /* allocate new, unshared state */
+ shared = _mesa_alloc_shared_state(ctx);
+ if (!shared)
+ return GL_FALSE;
+ }
+
+ _mesa_reference_shared_state(ctx, &ctx->Shared, shared);
+
+ if (!init_attrib_groups( ctx ))
+ goto fail;
+
+ /* KHR_no_error is likely to crash, overflow memory, etc if an application
+ * has errors so don't enable it for setuid processes.
+ */
+ if (env_var_as_boolean("MESA_NO_ERROR", false)) {
+#if !defined(_WIN32)
+ if (geteuid() == getuid())
+#endif
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
+ }
+
+ /* setup the API dispatch tables with all nop functions */
+ ctx->OutsideBeginEnd = _mesa_alloc_dispatch_table();
+ if (!ctx->OutsideBeginEnd)
+ goto fail;
+ ctx->Exec = ctx->OutsideBeginEnd;
+ ctx->CurrentClientDispatch = ctx->CurrentServerDispatch = ctx->OutsideBeginEnd;
+
+ ctx->FragmentProgram._MaintainTexEnvProgram
+ = (getenv("MESA_TEX_PROG") != NULL);
+
+ ctx->VertexProgram._MaintainTnlProgram
+ = (getenv("MESA_TNL_PROG") != NULL);
+ if (ctx->VertexProgram._MaintainTnlProgram) {
+ /* this is required... */
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+ }
+
+ /* Mesa core handles all the formats that mesa core knows about.
+ * Drivers will want to override this list with just the formats
+ * they can handle, and confirm that appropriate fallbacks exist in
+ * _mesa_choose_tex_format().
+ */
+ memset(&ctx->TextureFormatSupported, GL_TRUE,
+ sizeof(ctx->TextureFormatSupported));
+
+ switch (ctx->API) {
+ case API_OPENGL_COMPAT:
+ ctx->BeginEnd = create_beginend_table(ctx);
+ ctx->Save = _mesa_alloc_dispatch_table();
+ if (!ctx->BeginEnd || !ctx->Save)
+ goto fail;
+
+ /* fall-through */
+ case API_OPENGL_CORE:
+ break;
+ case API_OPENGLES:
+ /**
+ * GL_OES_texture_cube_map says
+ * "Initially all texture generation modes are set to REFLECTION_MAP_OES"
+ */
+ for (i = 0; i < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); i++) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[i];
+
+ texUnit->GenS.Mode = GL_REFLECTION_MAP_NV;
+ texUnit->GenT.Mode = GL_REFLECTION_MAP_NV;
+ texUnit->GenR.Mode = GL_REFLECTION_MAP_NV;
+ texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV;
+ texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV;
+ texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV;
+ }
+ break;
+ case API_OPENGLES2:
+ ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
+ ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+ break;
+ }
+
+ ctx->FirstTimeCurrent = GL_TRUE;
+
+ return GL_TRUE;
+
+fail:
+ _mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
+ free(ctx->BeginEnd);
+ free(ctx->OutsideBeginEnd);
+ free(ctx->Save);
+ return GL_FALSE;
+}
+
+
+/**
+ * Free the data associated with the given context.
+ *
+ * But doesn't free the struct gl_context struct itself.
+ *
+ * \sa _mesa_initialize_context() and init_attrib_groups().
+ */
+void
+_mesa_free_context_data(struct gl_context *ctx)
+{
+ if (!_mesa_get_current_context()){
+ /* No current context, but we may need one in order to delete
+ * texture objs, etc. So temporarily bind the context now.
+ */
+ _mesa_make_current(ctx, NULL, NULL);
+ }
+
+ /* unreference WinSysDraw/Read buffers */
+ _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
+
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram, NULL);
+
+ _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->GeometryProgram._Current, NULL);
+
+ _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, NULL);
+ _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
+
+ _mesa_reference_program(ctx, &ctx->ComputeProgram._Current, NULL);
+
+ _mesa_reference_vao(ctx, &ctx->Array.VAO, NULL);
+ _mesa_reference_vao(ctx, &ctx->Array.DefaultVAO, NULL);
+ _mesa_reference_vao(ctx, &ctx->Array._EmptyVAO, NULL);
+ _mesa_reference_vao(ctx, &ctx->Array._DrawVAO, NULL);
+
+ _mesa_free_attrib_data(ctx);
+ _mesa_free_buffer_objects(ctx);
+ _mesa_free_eval_data( ctx );
+ _mesa_free_texture_data( ctx );
+ _mesa_free_image_textures(ctx);
+ _mesa_free_matrix_data( ctx );
+ _mesa_free_pipeline_data(ctx);
+ _mesa_free_program_data(ctx);
+ _mesa_free_shader_state(ctx);
+ _mesa_free_queryobj_data(ctx);
+ _mesa_free_sync_data(ctx);
+ _mesa_free_varray_data(ctx);
+ _mesa_free_transform_feedback(ctx);
+ _mesa_free_performance_monitors(ctx);
+ _mesa_free_performance_queries(ctx);
+ _mesa_free_resident_handles(ctx);
+
+ _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL);
+ _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, NULL);
+
+ /* free dispatch tables */
+ free(ctx->BeginEnd);
+ free(ctx->OutsideBeginEnd);
+ free(ctx->Save);
+ free(ctx->ContextLost);
+ free(ctx->MarshalExec);
+
+ /* Shared context state (display lists, textures, etc) */
+ _mesa_reference_shared_state(ctx, &ctx->Shared, NULL);
+
+ /* needs to be after freeing shared state */
+ _mesa_free_display_list_data(ctx);
+
+ _mesa_free_errors_data(ctx);
+
+ free((void *)ctx->Extensions.String);
+
+ free(ctx->VersionString);
+
+ ralloc_free(ctx->SoftFP64);
+
+ /* unbind the context if it's currently bound */
+ if (ctx == _mesa_get_current_context()) {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ /* Do this after unbinding context to ensure any thread is finished. */
+ if (ctx->shader_builtin_ref) {
+ _mesa_glsl_builtin_functions_decref();
+ ctx->shader_builtin_ref = false;
+ }
+
+ free(ctx->Const.SpirVExtensions);
+}
+
+
+/**
+ * Destroy a struct gl_context structure.
+ *
+ * \param ctx GL context.
+ *
+ * Calls _mesa_free_context_data() and frees the gl_context object itself.
+ */
+void
+_mesa_destroy_context( struct gl_context *ctx )
+{
+ if (ctx) {
+ _mesa_free_context_data(ctx);
+ free( (void *) ctx );
+ }
+}
+
+
+/**
+ * Copy attribute groups from one context to another.
+ *
+ * \param src source context
+ * \param dst destination context
+ * \param mask bitwise OR of GL_*_BIT flags
+ *
+ * According to the bits specified in \p mask, copies the corresponding
+ * attributes from \p src into \p dst. For many of the attributes a simple \c
+ * memcpy is not enough due to the existence of internal pointers in their data
+ * structures.
+ */
+void
+_mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
+ GLuint mask )
+{
+ if (mask & GL_ACCUM_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Accum = src->Accum;
+ }
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Color = src->Color;
+ }
+ if (mask & GL_CURRENT_BIT) {
+ /* OK to memcpy */
+ dst->Current = src->Current;
+ }
+ if (mask & GL_DEPTH_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Depth = src->Depth;
+ }
+ if (mask & GL_ENABLE_BIT) {
+ /* no op */
+ }
+ if (mask & GL_EVAL_BIT) {
+ /* OK to memcpy */
+ dst->Eval = src->Eval;
+ }
+ if (mask & GL_FOG_BIT) {
+ /* OK to memcpy */
+ dst->Fog = src->Fog;
+ }
+ if (mask & GL_HINT_BIT) {
+ /* OK to memcpy */
+ dst->Hint = src->Hint;
+ }
+ if (mask & GL_LIGHTING_BIT) {
+ /* OK to memcpy */
+ dst->Light = src->Light;
+ }
+ if (mask & GL_LINE_BIT) {
+ /* OK to memcpy */
+ dst->Line = src->Line;
+ }
+ if (mask & GL_LIST_BIT) {
+ /* OK to memcpy */
+ dst->List = src->List;
+ }
+ if (mask & GL_PIXEL_MODE_BIT) {
+ /* OK to memcpy */
+ dst->Pixel = src->Pixel;
+ }
+ if (mask & GL_POINT_BIT) {
+ /* OK to memcpy */
+ dst->Point = src->Point;
+ }
+ if (mask & GL_POLYGON_BIT) {
+ /* OK to memcpy */
+ dst->Polygon = src->Polygon;
+ }
+ if (mask & GL_POLYGON_STIPPLE_BIT) {
+ /* Use loop instead of memcpy due to problem with Portland Group's
+ * C compiler. Reported by John Stone.
+ */
+ GLuint i;
+ for (i = 0; i < 32; i++) {
+ dst->PolygonStipple[i] = src->PolygonStipple[i];
+ }
+ }
+ if (mask & GL_SCISSOR_BIT) {
+ /* OK to memcpy */
+ dst->Scissor = src->Scissor;
+ }
+ if (mask & GL_STENCIL_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Stencil = src->Stencil;
+ }
+ if (mask & GL_TEXTURE_BIT) {
+ /* Cannot memcpy because of pointers */
+ _mesa_copy_texture_state(src, dst);
+ }
+ if (mask & GL_TRANSFORM_BIT) {
+ /* OK to memcpy */
+ dst->Transform = src->Transform;
+ }
+ if (mask & GL_VIEWPORT_BIT) {
+ unsigned i;
+ for (i = 0; i < src->Const.MaxViewports; i++) {
+ /* OK to memcpy */
+ dst->ViewportArray[i] = src->ViewportArray[i];
+ }
+ }
+
+ /* XXX FIXME: Call callbacks?
+ */
+ dst->NewState = _NEW_ALL;
+ dst->NewDriverState = ~0;
+}
+
+
+/**
+ * Check if the given context can render into the given framebuffer
+ * by checking visual attributes.
+ *
+ * \return GL_TRUE if compatible, GL_FALSE otherwise.
+ */
+static GLboolean
+check_compatible(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer)
+{
+ const struct gl_config *ctxvis = &ctx->Visual;
+ const struct gl_config *bufvis = &buffer->Visual;
+
+ if (buffer == _mesa_get_incomplete_framebuffer())
+ return GL_TRUE;
+
+#define check_component(foo) \
+ if (ctxvis->foo && bufvis->foo && \
+ ctxvis->foo != bufvis->foo) \
+ return GL_FALSE
+
+ check_component(redShift);
+ check_component(greenShift);
+ check_component(blueShift);
+ check_component(redBits);
+ check_component(greenBits);
+ check_component(blueBits);
+ check_component(depthBits);
+ check_component(stencilBits);
+
+#undef check_component
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Check if the viewport/scissor size has not yet been initialized.
+ * Initialize the size if the given width and height are non-zero.
+ */
+static void
+check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
+{
+ if (!ctx->ViewportInitialized && width > 0 && height > 0) {
+ unsigned i;
+
+ /* Note: set flag here, before calling _mesa_set_viewport(), to prevent
+ * potential infinite recursion.
+ */
+ ctx->ViewportInitialized = GL_TRUE;
+
+ /* Note: ctx->Const.MaxViewports may not have been set by the driver
+ * yet, so just initialize all of them.
+ */
+ for (i = 0; i < MAX_VIEWPORTS; i++) {
+ _mesa_set_viewport(ctx, i, 0, 0, width, height);
+ _mesa_set_scissor(ctx, i, 0, 0, width, height);
+ }
+ }
+}
+
+
+static void
+handle_first_current(struct gl_context *ctx)
+{
+ if (ctx->Version == 0 || !ctx->DrawBuffer) {
+ /* probably in the process of tearing down the context */
+ return;
+ }
+
+ check_context_limits(ctx);
+
+ _mesa_update_vertex_processing_mode(ctx);
+
+ /* According to GL_MESA_configless_context the default value of
+ * glDrawBuffers depends on the config of the first surface it is bound to.
+ * For GLES it is always GL_BACK which has a magic interpretation.
+ */
+ if (!ctx->HasConfig && _mesa_is_desktop_gl(ctx)) {
+ if (ctx->DrawBuffer != _mesa_get_incomplete_framebuffer()) {
+ GLenum16 buffer;
+
+ if (ctx->DrawBuffer->Visual.doubleBufferMode)
+ buffer = GL_BACK;
+ else
+ buffer = GL_FRONT;
+
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer,
+ NULL /* destMask */);
+ }
+
+ if (ctx->ReadBuffer != _mesa_get_incomplete_framebuffer()) {
+ gl_buffer_index bufferIndex;
+ GLenum buffer;
+
+ if (ctx->ReadBuffer->Visual.doubleBufferMode) {
+ buffer = GL_BACK;
+ bufferIndex = BUFFER_BACK_LEFT;
+ }
+ else {
+ buffer = GL_FRONT;
+ bufferIndex = BUFFER_FRONT_LEFT;
+ }
+
+ _mesa_readbuffer(ctx, ctx->ReadBuffer, buffer, bufferIndex);
+ }
+ }
+
+ /* Determine if generic vertex attribute 0 aliases the conventional
+ * glVertex position.
+ */
+ {
+ const bool is_forward_compatible_context =
+ ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+
+ /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
+ * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
+ * that will erroneously allow this usage in a 3.0 forward-compatible
+ * context too.
+ */
+ ctx->_AttribZeroAliasesVertex = (ctx->API == API_OPENGLES
+ || (ctx->API == API_OPENGL_COMPAT
+ && !is_forward_compatible_context));
+ }
+
+ /* We can use this to help debug user's problems. Tell them to set
+ * the MESA_INFO env variable before running their app. Then the
+ * first time each context is made current we'll print some useful
+ * information.
+ */
+ if (getenv("MESA_INFO")) {
+ _mesa_print_info(ctx);
+ }
+}
+
+/**
+ * Bind the given context to the given drawBuffer and readBuffer and
+ * make it the current context for the calling thread.
+ * We'll render into the drawBuffer and read pixels from the
+ * readBuffer (i.e. glRead/CopyPixels, glCopyTexImage, etc).
+ *
+ * We check that the context's and framebuffer's visuals are compatible
+ * and return immediately if they're not.
+ *
+ * \param newCtx the new GL context. If NULL then there will be no current GL
+ * context.
+ * \param drawBuffer the drawing framebuffer
+ * \param readBuffer the reading framebuffer
+ */
+GLboolean
+_mesa_make_current( struct gl_context *newCtx,
+ struct gl_framebuffer *drawBuffer,
+ struct gl_framebuffer *readBuffer )
+{
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(newCtx, "_mesa_make_current()\n");
+
+ /* Check that the context's and framebuffer's visuals are compatible.
+ */
+ if (newCtx && drawBuffer && newCtx->WinSysDrawBuffer != drawBuffer) {
+ if (!check_compatible(newCtx, drawBuffer)) {
+ _mesa_warning(newCtx,
+ "MakeCurrent: incompatible visuals for context and drawbuffer");
+ return GL_FALSE;
+ }
+ }
+ if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) {
+ if (!check_compatible(newCtx, readBuffer)) {
+ _mesa_warning(newCtx,
+ "MakeCurrent: incompatible visuals for context and readbuffer");
+ return GL_FALSE;
+ }
+ }
+
+ if (curCtx &&
+ (curCtx->WinSysDrawBuffer || curCtx->WinSysReadBuffer) &&
+ /* make sure this context is valid for flushing */
+ curCtx != newCtx &&
+ curCtx->Const.ContextReleaseBehavior ==
+ GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) {
+ _mesa_flush(curCtx);
+ }
+
+ /* Call this periodically to detect when the user has begun using
+ * GL rendering from multiple threads.
+ */
+ _glapi_check_multithread();
+
+ if (!newCtx) {
+ _glapi_set_dispatch(NULL); /* none current */
+ /* We need old ctx to correctly release Draw/ReadBuffer
+ * and avoid a surface leak in st_renderbuffer_delete.
+ * Therefore, first drop buffers then set new ctx to NULL.
+ */
+ if (curCtx) {
+ _mesa_reference_framebuffer(&curCtx->WinSysDrawBuffer, NULL);
+ _mesa_reference_framebuffer(&curCtx->WinSysReadBuffer, NULL);
+ }
+ _glapi_set_context(NULL);
+ assert(_mesa_get_current_context() == NULL);
+ }
+ else {
+ _glapi_set_context((void *) newCtx);
+ assert(_mesa_get_current_context() == newCtx);
+ _glapi_set_dispatch(newCtx->CurrentClientDispatch);
+
+ if (drawBuffer && readBuffer) {
+ assert(_mesa_is_winsys_fbo(drawBuffer));
+ assert(_mesa_is_winsys_fbo(readBuffer));
+ _mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
+ _mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
+
+ /*
+ * Only set the context's Draw/ReadBuffer fields if they're NULL
+ * or not bound to a user-created FBO.
+ */
+ if (!newCtx->DrawBuffer || _mesa_is_winsys_fbo(newCtx->DrawBuffer)) {
+ _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer);
+ /* Update the FBO's list of drawbuffers/renderbuffers.
+ * For winsys FBOs this comes from the GL state (which may have
+ * changed since the last time this FBO was bound).
+ */
+ _mesa_update_draw_buffers(newCtx);
+ _mesa_update_allow_draw_out_of_order(newCtx);
+ }
+ if (!newCtx->ReadBuffer || _mesa_is_winsys_fbo(newCtx->ReadBuffer)) {
+ _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
+ /* In _mesa_initialize_window_framebuffer, for single-buffered
+ * visuals, the ColorReadBuffer is set to be GL_FRONT, even with
+ * GLES contexts. When calling read_buffer, we verify we are reading
+ * from GL_BACK in is_legal_es3_readbuffer_enum. But the default is
+ * incorrect, and certain dEQP tests check this. So fix it here.
+ */
+ if (_mesa_is_gles(newCtx) &&
+ !newCtx->ReadBuffer->Visual.doubleBufferMode)
+ if (newCtx->ReadBuffer->ColorReadBuffer == GL_FRONT)
+ newCtx->ReadBuffer->ColorReadBuffer = GL_BACK;
+ }
+
+ /* XXX only set this flag if we're really changing the draw/read
+ * framebuffer bindings.
+ */
+ newCtx->NewState |= _NEW_BUFFERS;
+
+ check_init_viewport(newCtx, drawBuffer->Width, drawBuffer->Height);
+ }
+
+ if (newCtx->FirstTimeCurrent) {
+ handle_first_current(newCtx);
+ newCtx->FirstTimeCurrent = GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Make context 'ctx' share the display lists, textures and programs
+ * that are associated with 'ctxToShare'.
+ * Any display lists, textures or programs associated with 'ctx' will
+ * be deleted if nobody else is sharing them.
+ */
+GLboolean
+_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare)
+{
+ if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) {
+ struct gl_shared_state *oldShared = NULL;
+
+ /* save ref to old state to prevent it from being deleted immediately */
+ _mesa_reference_shared_state(ctx, &oldShared, ctx->Shared);
+
+ /* update ctx's Shared pointer */
+ _mesa_reference_shared_state(ctx, &ctx->Shared, ctxToShare->Shared);
+
+ update_default_objects(ctx);
+
+ /* release the old shared state */
+ _mesa_reference_shared_state(ctx, &oldShared, NULL);
+
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+
+/**
+ * \return pointer to the current GL context for this thread.
+ *
+ * Calls _glapi_get_context(). This isn't the fastest way to get the current
+ * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in
+ * context.h.
+ */
+struct gl_context *
+_mesa_get_current_context( void )
+{
+ return (struct gl_context *) _glapi_get_context();
+}
+
+
+/**
+ * Get context's current API dispatch table.
+ *
+ * It'll either be the immediate-mode execute dispatcher, the display list
+ * compile dispatcher, or the thread marshalling dispatcher.
+ *
+ * \param ctx GL context.
+ *
+ * \return pointer to dispatch_table.
+ *
+ * Simply returns __struct gl_contextRec::CurrentClientDispatch.
+ */
+struct _glapi_table *
+_mesa_get_dispatch(struct gl_context *ctx)
+{
+ return ctx->CurrentClientDispatch;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Miscellaneous functions */
+/**********************************************************************/
+/*@{*/
+/**
+ * Flush commands.
+ */
+void
+_mesa_flush(struct gl_context *ctx)
+{
+ FLUSH_VERTICES( ctx, 0 );
+ if (ctx->Driver.Flush) {
+ ctx->Driver.Flush(ctx);
+ }
+}
+
+
+
+/**
+ * Flush commands and wait for completion.
+ *
+ * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
+ * dd_function_table::Finish driver callback, if not NULL.
+ */
+void GLAPIENTRY
+_mesa_Finish(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, 0);
+
+ if (ctx->Driver.Finish) {
+ ctx->Driver.Finish(ctx);
+ }
+}
+
+
+/**
+ * Execute glFlush().
+ *
+ * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
+ * dd_function_table::Flush driver callback, if not NULL.
+ */
+void GLAPIENTRY
+_mesa_Flush(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ _mesa_flush(ctx);
+}
+
+
+/*@}*/
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.h
new file mode 100644
index 0000000000..d5b97ac4fc
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/context.h
@@ -0,0 +1,460 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file context.h
+ * Mesa context and visual-related functions.
+ *
+ * There are three large Mesa data types/classes which are meant to be
+ * used by device drivers:
+ * - struct gl_context: this contains the Mesa rendering state
+ * - struct gl_config: this describes the color buffer (RGB vs. ci), whether
+ * or not there's a depth buffer, stencil buffer, etc.
+ * - struct gl_framebuffer: contains pointers to the depth buffer, stencil
+ * buffer, accum buffer and alpha buffers.
+ *
+ * These types should be encapsulated by corresponding device driver
+ * data types. See xmesa.h and xmesaP.h for an example.
+ *
+ * In OOP terms, struct gl_context, struct gl_config, and struct gl_framebuffer
+ * are base classes which the device driver must derive from.
+ *
+ * The following functions create and destroy these data types.
+ */
+
+
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+
+#include "errors.h"
+
+#include "extensions.h"
+#include "mtypes.h"
+#include "vbo/vbo.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct _glapi_table;
+
+
+/** \name Visual-related functions */
+/*@{*/
+
+extern struct gl_config *
+_mesa_create_visual( GLboolean dbFlag,
+ GLboolean stereoFlag,
+ GLint redBits,
+ GLint greenBits,
+ GLint blueBits,
+ GLint alphaBits,
+ GLint depthBits,
+ GLint stencilBits,
+ GLint accumRedBits,
+ GLint accumGreenBits,
+ GLint accumBlueBits,
+ GLint accumAlphaBits,
+ GLuint numSamples );
+
+extern GLboolean
+_mesa_initialize_visual( struct gl_config *v,
+ GLboolean dbFlag,
+ GLboolean stereoFlag,
+ GLint redBits,
+ GLint greenBits,
+ GLint blueBits,
+ GLint alphaBits,
+ GLint depthBits,
+ GLint stencilBits,
+ GLint accumRedBits,
+ GLint accumGreenBits,
+ GLint accumBlueBits,
+ GLint accumAlphaBits,
+ GLuint numSamples );
+
+extern void
+_mesa_destroy_visual( struct gl_config *vis );
+
+/*@}*/
+
+
+/** \name Context-related functions */
+/*@{*/
+
+extern void
+_mesa_initialize(void);
+
+extern GLboolean
+_mesa_initialize_context( struct gl_context *ctx,
+ gl_api api,
+ const struct gl_config *visual,
+ struct gl_context *share_list,
+ const struct dd_function_table *driverFunctions);
+
+extern void
+_mesa_free_context_data(struct gl_context *ctx);
+
+extern void
+_mesa_destroy_context( struct gl_context *ctx );
+
+
+extern void
+_mesa_copy_context(const struct gl_context *src, struct gl_context *dst, GLuint mask);
+
+extern GLboolean
+_mesa_make_current( struct gl_context *ctx, struct gl_framebuffer *drawBuffer,
+ struct gl_framebuffer *readBuffer );
+
+extern GLboolean
+_mesa_share_state(struct gl_context *ctx, struct gl_context *ctxToShare);
+
+extern struct gl_context *
+_mesa_get_current_context(void);
+
+/*@}*/
+
+extern void
+_mesa_init_constants(struct gl_constants *consts, gl_api api);
+
+extern void
+_mesa_notifySwapBuffers(struct gl_context *gc);
+
+
+extern struct _glapi_table *
+_mesa_get_dispatch(struct gl_context *ctx);
+
+extern void
+_mesa_set_context_lost_dispatch(struct gl_context *ctx);
+
+
+
+/** \name Miscellaneous */
+/*@{*/
+
+extern void
+_mesa_flush(struct gl_context *ctx);
+
+extern void GLAPIENTRY
+_mesa_Finish( void );
+
+extern void GLAPIENTRY
+_mesa_Flush( void );
+
+/*@}*/
+
+
+/**
+ * Are we currently between glBegin and glEnd?
+ * During execution, not display list compilation.
+ */
+static inline GLboolean
+_mesa_inside_begin_end(const struct gl_context *ctx)
+{
+ return ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END;
+}
+
+
+/**
+ * Are we currently between glBegin and glEnd in a display list?
+ */
+static inline GLboolean
+_mesa_inside_dlist_begin_end(const struct gl_context *ctx)
+{
+ return ctx->Driver.CurrentSavePrimitive <= PRIM_MAX;
+}
+
+
+
+/**
+ * \name Macros for flushing buffered rendering commands before state changes,
+ * checking if inside glBegin/glEnd, etc.
+ */
+/*@{*/
+
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
+ * and calls dd_function_table::FlushVertices if so. Marks
+ * __struct gl_contextRec::NewState with \p newstate.
+ */
+#define FLUSH_VERTICES(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __func__); \
+ if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
+ vbo_exec_FlushVertices(ctx, FLUSH_STORED_VERTICES); \
+ ctx->NewState |= newstate; \
+} while (0)
+
+/**
+ * Flush current state.
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush current state,
+ * and calls dd_function_table::FlushVertices if so. Marks
+ * __struct gl_contextRec::NewState with \p newstate.
+ */
+#define FLUSH_CURRENT(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __func__); \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
+ vbo_exec_FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
+ ctx->NewState |= newstate; \
+} while (0)
+
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush stored vertices
+ * or current state and calls dd_function_table::FlushVertices if so.
+ */
+#define FLUSH_FOR_DRAW(ctx) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ _mesa_debug(ctx, "FLUSH_FOR_DRAW in %s\n", __func__); \
+ if (ctx->Driver.NeedFlush) { \
+ if (ctx->_AllowDrawOutOfOrder) { \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
+ vbo_exec_FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
+ } else { \
+ vbo_exec_FlushVertices(ctx, ctx->Driver.NeedFlush); \
+ } \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair, with return value.
+ *
+ * \param ctx GL context.
+ * \param retval value to return in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
+do { \
+ if (_mesa_inside_begin_end(ctx)) { \
+ _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \
+ return retval; \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair.
+ *
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END(ctx) \
+do { \
+ if (_mesa_inside_begin_end(ctx)) { \
+ _mesa_error(ctx, GL_INVALID_OPERATION, "Inside glBegin/glEnd"); \
+ return; \
+ } \
+} while (0)
+
+/*@}*/
+
+
+/**
+ * Checks if the context is for Desktop GL (Compatibility or Core)
+ */
+static inline bool
+_mesa_is_desktop_gl(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGL_CORE;
+}
+
+
+/**
+ * Checks if the context is for any GLES version
+ */
+static inline bool
+_mesa_is_gles(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
+}
+
+
+/**
+ * Checks if the context is for GLES 3.0 or later
+ */
+static inline bool
+_mesa_is_gles3(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES2 && ctx->Version >= 30;
+}
+
+
+/**
+ * Checks if the context is for GLES 3.1 or later
+ */
+static inline bool
+_mesa_is_gles31(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES2 && ctx->Version >= 31;
+}
+
+
+/**
+ * Checks if the context is for GLES 3.2 or later
+ */
+static inline bool
+_mesa_is_gles32(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES2 && ctx->Version >= 32;
+}
+
+
+static inline bool
+_mesa_is_no_error_enabled(const struct gl_context *ctx)
+{
+ return ctx->Const.ContextFlags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR;
+}
+
+
+static inline bool
+_mesa_has_integer_textures(const struct gl_context *ctx)
+{
+ return _mesa_has_EXT_texture_integer(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_half_float_textures(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_float(ctx) ||
+ _mesa_has_OES_texture_half_float(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_float_textures(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_float(ctx) ||
+ _mesa_has_OES_texture_float(ctx) || _mesa_is_gles3(ctx);
+ }
+
+static inline bool
+_mesa_has_texture_rgb10_a2ui(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_rgb10_a2ui(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_float_depth_buffer(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_depth_buffer_float(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_packed_float(const struct gl_context *ctx)
+{
+ return _mesa_has_EXT_packed_float(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_rg_textures(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_rg(ctx) || _mesa_has_EXT_texture_rg(ctx) ||
+ _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_texture_shared_exponent(const struct gl_context *ctx)
+{
+ return _mesa_has_EXT_texture_shared_exponent(ctx) || _mesa_is_gles3(ctx);
+}
+
+static inline bool
+_mesa_has_texture_type_2_10_10_10_REV(const struct gl_context *ctx)
+{
+ return _mesa_is_desktop_gl(ctx) ||
+ _mesa_has_EXT_texture_type_2_10_10_10_REV(ctx);
+}
+
+/**
+ * Checks if the context supports geometry shaders.
+ */
+static inline bool
+_mesa_has_geometry_shaders(const struct gl_context *ctx)
+{
+ return _mesa_has_OES_geometry_shader(ctx) ||
+ (_mesa_is_desktop_gl(ctx) && ctx->Version >= 32);
+}
+
+
+/**
+ * Checks if the context supports compute shaders.
+ */
+static inline bool
+_mesa_has_compute_shaders(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_compute_shader(ctx) ||
+ (ctx->API == API_OPENGLES2 && ctx->Version >= 31);
+}
+
+/**
+ * Checks if the context supports tessellation.
+ */
+static inline bool
+_mesa_has_tessellation(const struct gl_context *ctx)
+{
+ /* _mesa_has_EXT_tessellation_shader(ctx) is redundant with the OES
+ * check, so don't bother calling it.
+ */
+ return _mesa_has_OES_tessellation_shader(ctx) ||
+ _mesa_has_ARB_tessellation_shader(ctx);
+}
+
+static inline bool
+_mesa_has_texture_cube_map_array(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_cube_map_array(ctx) ||
+ _mesa_has_OES_texture_cube_map_array(ctx);
+}
+
+static inline bool
+_mesa_has_texture_view(const struct gl_context *ctx)
+{
+ return _mesa_has_ARB_texture_view(ctx) ||
+ _mesa_has_OES_texture_view(ctx);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* CONTEXT_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/dd.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/dd.h
new file mode 100644
index 0000000000..4a7d775db4
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/dd.h
@@ -0,0 +1,1503 @@
+/**
+ * \file dd.h
+ * Device driver interfaces.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DD_INCLUDED
+#define DD_INCLUDED
+
+#include "glheader.h"
+#include "formats.h"
+#include "menums.h"
+#include "compiler/shader_enums.h"
+
+struct gl_bitmap_atlas;
+struct gl_buffer_object;
+struct gl_context;
+struct gl_display_list;
+struct gl_framebuffer;
+struct gl_image_unit;
+struct gl_pixelstore_attrib;
+struct gl_program;
+struct gl_renderbuffer;
+struct gl_renderbuffer_attachment;
+struct gl_shader;
+struct gl_shader_program;
+struct gl_texture_image;
+struct gl_texture_object;
+struct gl_memory_info;
+struct gl_transform_feedback_object;
+struct ati_fragment_shader;
+struct util_queue_monitoring;
+struct _mesa_prim;
+struct _mesa_index_buffer;
+
+/* GL_ARB_vertex_buffer_object */
+/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
+ * NULL) if buffer is unavailable for immediate mapping.
+ *
+ * Does GL_MAP_INVALIDATE_RANGE_BIT do this? It seems so, but it
+ * would require more book-keeping in the driver than seems necessary
+ * at this point.
+ *
+ * Does GL_MAP_INVALDIATE_BUFFER_BIT do this? Not really -- we don't
+ * want to provoke the driver to throw away the old storage, we will
+ * respect the contents of already referenced data.
+ */
+#define MESA_MAP_NOWAIT_BIT 0x4000
+
+/* Mapping a buffer is allowed from any thread. */
+#define MESA_MAP_THREAD_SAFE_BIT 0x8000
+
+
+/**
+ * Device driver function table.
+ * Core Mesa uses these function pointers to call into device drivers.
+ * Most of these functions directly correspond to OpenGL state commands.
+ * Core Mesa will call these functions after error checking has been done
+ * so that the drivers don't have to worry about error testing.
+ *
+ * Vertex transformation/clipping/lighting is patched into the T&L module.
+ * Rasterization functions are patched into the swrast module.
+ *
+ * Note: when new functions are added here, the drivers/common/driverfuncs.c
+ * file should be updated too!!!
+ */
+struct dd_function_table {
+ /**
+ * Return a string as needed by glGetString().
+ * Only the GL_RENDERER query must be implemented. Otherwise, NULL can be
+ * returned.
+ */
+ const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name );
+
+ /**
+ * Notify the driver after Mesa has made some internal state changes.
+ *
+ * This is in addition to any state change callbacks Mesa may already have
+ * made.
+ */
+ void (*UpdateState)(struct gl_context *ctx);
+
+ /**
+ * This is called whenever glFinish() is called.
+ */
+ void (*Finish)( struct gl_context *ctx );
+
+ /**
+ * This is called whenever glFlush() is called.
+ */
+ void (*Flush)( struct gl_context *ctx );
+
+ /**
+ * Clear the color/depth/stencil/accum buffer(s).
+ * \param buffers a bitmask of BUFFER_BIT_* flags indicating which
+ * renderbuffers need to be cleared.
+ */
+ void (*Clear)( struct gl_context *ctx, GLbitfield buffers );
+
+ /**
+ * Execute glRasterPos, updating the ctx->Current.Raster fields
+ */
+ void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] );
+
+ /**
+ * \name Image-related functions
+ */
+ /*@{*/
+
+ /**
+ * Called by glDrawPixels().
+ * \p unpack describes how to unpack the source image data.
+ */
+ void (*DrawPixels)( struct gl_context *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+ /**
+ * Called by glReadPixels().
+ */
+ void (*ReadPixels)( struct gl_context *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ GLvoid *dest );
+
+ /**
+ * Called by glCopyPixels().
+ */
+ void (*CopyPixels)( struct gl_context *ctx, GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint dstx, GLint dsty, GLenum type );
+
+ /**
+ * Called by glBitmap().
+ */
+ void (*Bitmap)( struct gl_context *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+
+ /**
+ * Called by display list code for optimized glCallLists/glBitmap rendering
+ * The driver must support texture rectangles of width 1024 or more.
+ */
+ void (*DrawAtlasBitmaps)(struct gl_context *ctx,
+ const struct gl_bitmap_atlas *atlas,
+ GLuint count, const GLubyte *ids);
+ /*@}*/
+
+
+ /**
+ * \name Texture image functions
+ */
+ /*@{*/
+
+ /**
+ * Choose actual hardware texture format given the texture target, the
+ * user-provided source image format and type and the desired internal
+ * format. In some cases, srcFormat and srcType can be GL_NONE.
+ * Note: target may be GL_TEXTURE_CUBE_MAP, but never
+ * GL_TEXTURE_CUBE_MAP_[POSITIVE/NEGATIVE]_[XYZ].
+ * Called by glTexImage(), etc.
+ */
+ mesa_format (*ChooseTextureFormat)(struct gl_context *ctx,
+ GLenum target, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType );
+
+ /**
+ * Queries different driver parameters for a particular target and format.
+ * Since ARB_internalformat_query2 introduced several new query parameters
+ * over ARB_internalformat_query, having one driver hook for each parameter
+ * is no longer feasible. So this is the generic entry-point for calls
+ * to glGetInternalFormativ and glGetInternalFormati64v, after Mesa has
+ * checked errors and default values.
+ *
+ * \param ctx GL context
+ * \param target GL target enum
+ * \param internalFormat GL format enum
+ * \param pname GL enum that specifies the info to query.
+ * \param params Buffer to hold the result of the query.
+ */
+ void (*QueryInternalFormat)(struct gl_context *ctx,
+ GLenum target,
+ GLenum internalFormat,
+ GLenum pname,
+ GLint *params);
+
+ /**
+ * Called by glTexImage[123]D() and glCopyTexImage[12]D()
+ * Allocate texture memory and copy the user's image to the buffer.
+ * The gl_texture_image fields, etc. will be fully initialized.
+ * The parameters are the same as glTexImage3D(), plus:
+ * \param dims 1, 2, or 3 indicating glTexImage1/2/3D()
+ * \param packing describes how to unpack the source data.
+ * \param texImage is the destination texture image.
+ */
+ void (*TexImage)(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
+
+ /**
+ * Called by glTexSubImage[123]D().
+ * Replace a subset of the target texture with new texel data.
+ */
+ void (*TexSubImage)(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLint depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing);
+
+
+ /**
+ * Called by glGetTexImage(), glGetTextureSubImage().
+ */
+ void (*GetTexSubImage)(struct gl_context *ctx,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLvoid *pixels,
+ struct gl_texture_image *texImage);
+
+ /**
+ * Called by glClearTex[Sub]Image
+ *
+ * Clears a rectangular region of the image to a given value. The
+ * clearValue argument is either NULL or points to a single texel to use as
+ * the clear value in the same internal format as the texture image. If it
+ * is NULL then the texture should be cleared to zeroes.
+ */
+ void (*ClearTexSubImage)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ const GLvoid *clearValue);
+
+ /**
+ * Called by glCopyTex[Sub]Image[123]D().
+ *
+ * This function should copy a rectangular region in the rb to a single
+ * destination slice, specified by @slice. In the case of 1D array
+ * textures (where one GL call can potentially affect multiple destination
+ * slices), core mesa takes care of calling this function multiple times,
+ * once for each scanline to be copied.
+ */
+ void (*CopyTexSubImage)(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint slice,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
+ /**
+ * Called by glCopyImageSubData().
+ *
+ * This function should copy one 2-D slice from src_teximage or
+ * src_renderbuffer to dst_teximage or dst_renderbuffer. Either the
+ * teximage or renderbuffer pointer will be non-null to indicate which
+ * is the real src/dst.
+ *
+ * If one of the textures is 3-D or is a 1-D or 2-D array
+ * texture, this function will be called multiple times: once for each
+ * slice. If one of the textures is a cube map, this function will be
+ * called once for each face to be copied.
+ */
+ void (*CopyImageSubData)(struct gl_context *ctx,
+ struct gl_texture_image *src_teximage,
+ struct gl_renderbuffer *src_renderbuffer,
+ int src_x, int src_y, int src_z,
+ struct gl_texture_image *dst_teximage,
+ struct gl_renderbuffer *dst_renderbuffer,
+ int dst_x, int dst_y, int dst_z,
+ int src_width, int src_height);
+
+ /**
+ * Called by glGenerateMipmap() or when GL_GENERATE_MIPMAP_SGIS is enabled.
+ * Note that if the texture is a cube map, the <target> parameter will
+ * indicate which cube face to generate (GL_POSITIVE/NEGATIVE_X/Y/Z).
+ * texObj->BaseLevel is the level from which to generate the remaining
+ * mipmap levels.
+ */
+ void (*GenerateMipmap)(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj);
+
+ /**
+ * Called by glTexImage, glCompressedTexImage, glCopyTexImage
+ * and glTexStorage to check if the dimensions of the texture image
+ * are too large.
+ * \param target any GL_PROXY_TEXTURE_x target
+ * \return GL_TRUE if the image is OK, GL_FALSE if too large
+ */
+ GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target,
+ GLuint numLevels, GLint level,
+ mesa_format format, GLuint numSamples,
+ GLint width, GLint height,
+ GLint depth);
+ /*@}*/
+
+
+ /**
+ * \name Compressed texture functions
+ */
+ /*@{*/
+
+ /**
+ * Called by glCompressedTexImage[123]D().
+ */
+ void (*CompressedTexImage)(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLsizei imageSize, const GLvoid *data);
+
+ /**
+ * Called by glCompressedTexSubImage[123]D().
+ */
+ void (*CompressedTexSubImage)(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_image *texImage,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data);
+ /*@}*/
+
+ /**
+ * \name Texture object / image functions
+ */
+ /*@{*/
+
+ /**
+ * Called by glBindTexture() and glBindTextures().
+ */
+ void (*BindTexture)( struct gl_context *ctx, GLuint texUnit,
+ GLenum target, struct gl_texture_object *tObj );
+
+ /**
+ * Called to allocate a new texture object. Drivers will usually
+ * allocate/return a subclass of gl_texture_object.
+ */
+ struct gl_texture_object * (*NewTextureObject)(struct gl_context *ctx,
+ GLuint name, GLenum target);
+ /**
+ * Called to delete/free a texture object. Drivers should free the
+ * object and any image data it contains.
+ */
+ void (*DeleteTexture)(struct gl_context *ctx,
+ struct gl_texture_object *texObj);
+
+ /** Called to allocate a new texture image object. */
+ struct gl_texture_image * (*NewTextureImage)(struct gl_context *ctx);
+
+ /** Called to free a texture image object returned by NewTextureImage() */
+ void (*DeleteTextureImage)(struct gl_context *ctx,
+ struct gl_texture_image *);
+
+ /** Called to allocate memory for a single texture image */
+ GLboolean (*AllocTextureImageBuffer)(struct gl_context *ctx,
+ struct gl_texture_image *texImage);
+
+ /** Free the memory for a single texture image */
+ void (*FreeTextureImageBuffer)(struct gl_context *ctx,
+ struct gl_texture_image *texImage);
+
+ /** Map a slice of a texture image into user space.
+ * Note: for GL_TEXTURE_1D_ARRAY, height must be 1, y must be 0 and slice
+ * indicates the 1D array index.
+ * \param texImage the texture image
+ * \param slice the 3D image slice or array texture slice
+ * \param x, y, w, h region of interest
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
+ * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
+ * \param mapOut returns start of mapping of region of interest
+ * \param rowStrideOut returns row stride (in bytes). In the case of a
+ * compressed texture, this is the byte stride between one row of blocks
+ * and another.
+ */
+ void (*MapTextureImage)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLuint slice,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **mapOut, GLint *rowStrideOut);
+
+ void (*UnmapTextureImage)(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLuint slice);
+
+ /** For GL_ARB_texture_storage. Allocate memory for whole mipmap stack.
+ * All the gl_texture_images in the texture object will have their
+ * dimensions, format, etc. initialized already.
+ */
+ GLboolean (*AllocTextureStorage)(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth);
+
+ /** Called as part of glTextureView to add views to origTexObj */
+ GLboolean (*TextureView)(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ struct gl_texture_object *origTexObj);
+
+ /**
+ * Map a renderbuffer into user space.
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
+ * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
+ */
+ void (*MapRenderbuffer)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **mapOut, GLint *rowStrideOut,
+ bool flip_y);
+
+ void (*UnmapRenderbuffer)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb);
+
+ /**
+ * Optional driver entrypoint that binds a non-texture renderbuffer's
+ * contents to a texture image.
+ */
+ GLboolean (*BindRenderbufferTexImage)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ struct gl_texture_image *texImage);
+ /*@}*/
+
+
+ /**
+ * \name Vertex/fragment program functions
+ */
+ /*@{*/
+ /** Allocate a new program */
+ struct gl_program * (*NewProgram)(struct gl_context *ctx,
+ gl_shader_stage stage,
+ GLuint id, bool is_arb_asm);
+ /** Delete a program */
+ void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
+ /**
+ * Allocate a program to associate with the new ATI fragment shader (optional)
+ */
+ struct gl_program * (*NewATIfs)(struct gl_context *ctx,
+ struct ati_fragment_shader *curProg);
+ /**
+ * Notify driver that a program string (and GPU code) has been specified
+ * or modified. Return GL_TRUE or GL_FALSE to indicate if the program is
+ * supported by the driver.
+ */
+ GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target,
+ struct gl_program *prog);
+
+ /**
+ * Notify driver that the sampler uniforms for the current program have
+ * changed. On some drivers, this may require shader recompiles.
+ */
+ void (*SamplerUniformChange)(struct gl_context *ctx, GLenum target,
+ struct gl_program *prog);
+
+ /** Query if program can be loaded onto hardware */
+ GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target,
+ struct gl_program *prog);
+
+ /*@}*/
+
+ /**
+ * \name GLSL shader/program functions.
+ */
+ /*@{*/
+ /**
+ * Called when a shader program is linked.
+ *
+ * This gives drivers an opportunity to clone the IR and make their
+ * own transformations on it for the purposes of code generation.
+ */
+ GLboolean (*LinkShader)(struct gl_context *ctx,
+ struct gl_shader_program *shader);
+ /*@}*/
+
+
+ /**
+ * \name Draw functions.
+ */
+ /*@{*/
+ /**
+ * For indirect array drawing:
+ *
+ * typedef struct {
+ * GLuint count;
+ * GLuint primCount;
+ * GLuint first;
+ * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ * } DrawArraysIndirectCommand;
+ *
+ * For indirect indexed drawing:
+ *
+ * typedef struct {
+ * GLuint count;
+ * GLuint primCount;
+ * GLuint firstIndex;
+ * GLint baseVertex;
+ * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+ * } DrawElementsIndirectCommand;
+ */
+
+ /**
+ * Draw a number of primitives.
+ * \param prims array [nr_prims] describing what to draw (prim type,
+ * vertex count, first index, instance count, etc).
+ * \param ib index buffer for indexed drawing, NULL for array drawing
+ * \param index_bounds_valid are min_index and max_index valid?
+ * \param min_index lowest vertex index used
+ * \param max_index highest vertex index used
+ * \param num_instances instance count from ARB_draw_instanced
+ * \param base_instance base instance from ARB_base_instance
+ * \param tfb_vertcount if non-null, indicates which transform feedback
+ * object has the vertex count.
+ * \param tfb_stream If called via DrawTransformFeedbackStream, specifies
+ * the vertex stream buffer from which to get the vertex
+ * count.
+ * \param indirect If any prims are indirect, this specifies the buffer
+ * to find the "DrawArrays/ElementsIndirectCommand" data.
+ * This may be deprecated in the future
+ */
+ void (*Draw)(struct gl_context *ctx,
+ const struct _mesa_prim *prims, GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid,
+ GLuint min_index, GLuint max_index,
+ GLuint num_instances, GLuint base_instance,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned tfb_stream);
+
+
+ /**
+ * Draw a primitive, getting the vertex count, instance count, start
+ * vertex, etc. from a buffer object.
+ * \param mode GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
+ * \param indirect_data buffer to get "DrawArrays/ElementsIndirectCommand"
+ * data
+ * \param indirect_offset offset of first primitive in indrect_data buffer
+ * \param draw_count number of primitives to draw
+ * \param stride stride, in bytes, between
+ * "DrawArrays/ElementsIndirectCommand" objects
+ * \param indirect_draw_count_buffer if non-NULL specifies a buffer to get
+ * the real draw_count value. Used for
+ * GL_ARB_indirect_parameters.
+ * \param indirect_draw_count_offset offset to the draw_count value in
+ * indirect_draw_count_buffer
+ * \param ib index buffer for indexed drawing, NULL otherwise.
+ */
+ void (*DrawIndirect)(struct gl_context *ctx, GLuint mode,
+ struct gl_buffer_object *indirect_data,
+ GLsizeiptr indirect_offset, unsigned draw_count,
+ unsigned stride,
+ struct gl_buffer_object *indirect_draw_count_buffer,
+ GLsizeiptr indirect_draw_count_offset,
+ const struct _mesa_index_buffer *ib);
+ /*@}*/
+
+
+ /**
+ * \name State-changing functions.
+ *
+ * \note drawing functions are above.
+ *
+ * These functions are called by their corresponding OpenGL API functions.
+ * They are \e also called by the gl_PopAttrib() function!!!
+ * May add more functions like these to the device driver in the future.
+ */
+ /*@{*/
+ /** Specify the alpha test function */
+ void (*AlphaFunc)(struct gl_context *ctx, GLenum func, GLfloat ref);
+ /** Set the blend color */
+ void (*BlendColor)(struct gl_context *ctx, const GLfloat color[4]);
+ /** Set the blend equation */
+ void (*BlendEquationSeparate)(struct gl_context *ctx,
+ GLenum modeRGB, GLenum modeA);
+ /** Specify pixel arithmetic */
+ void (*BlendFuncSeparate)(struct gl_context *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA);
+ /** Specify a plane against which all geometry is clipped */
+ void (*ClipPlane)(struct gl_context *ctx, GLenum plane, const GLfloat *eq);
+ /** Enable and disable writing of frame buffer color components */
+ void (*ColorMask)(struct gl_context *ctx, GLboolean rmask, GLboolean gmask,
+ GLboolean bmask, GLboolean amask );
+ /** Cause a material color to track the current color */
+ void (*ColorMaterial)(struct gl_context *ctx, GLenum face, GLenum mode);
+ /** Specify whether front- or back-facing facets can be culled */
+ void (*CullFace)(struct gl_context *ctx, GLenum mode);
+ /** Define front- and back-facing polygons */
+ void (*FrontFace)(struct gl_context *ctx, GLenum mode);
+ /** Specify the value used for depth buffer comparisons */
+ void (*DepthFunc)(struct gl_context *ctx, GLenum func);
+ /** Enable or disable writing into the depth buffer */
+ void (*DepthMask)(struct gl_context *ctx, GLboolean flag);
+ /** Specify mapping of depth values from NDC to window coordinates */
+ void (*DepthRange)(struct gl_context *ctx);
+ /** Specify the current buffer for writing */
+ void (*DrawBuffer)(struct gl_context *ctx);
+ /** Used to allocated any buffers with on-demand creation */
+ void (*DrawBufferAllocate)(struct gl_context *ctx);
+ /** Enable or disable server-side gl capabilities */
+ void (*Enable)(struct gl_context *ctx, GLenum cap, GLboolean state);
+ /** Specify fog parameters */
+ void (*Fogfv)(struct gl_context *ctx, GLenum pname, const GLfloat *params);
+ /** Set light source parameters.
+ * Note: for GL_POSITION and GL_SPOT_DIRECTION, params will have already
+ * been transformed to eye-space.
+ */
+ void (*Lightfv)(struct gl_context *ctx, GLenum light,
+ GLenum pname, const GLfloat *params );
+ /** Set the lighting model parameters */
+ void (*LightModelfv)(struct gl_context *ctx, GLenum pname,
+ const GLfloat *params);
+ /** Specify the line stipple pattern */
+ void (*LineStipple)(struct gl_context *ctx, GLint factor, GLushort pattern );
+ /** Specify the width of rasterized lines */
+ void (*LineWidth)(struct gl_context *ctx, GLfloat width);
+ /** Specify a logical pixel operation for color index rendering */
+ void (*LogicOpcode)(struct gl_context *ctx, enum gl_logicop_mode opcode);
+ void (*PointParameterfv)(struct gl_context *ctx, GLenum pname,
+ const GLfloat *params);
+ /** Specify the diameter of rasterized points */
+ void (*PointSize)(struct gl_context *ctx, GLfloat size);
+ /** Select a polygon rasterization mode */
+ void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode);
+ /** Set the scale and units used to calculate depth values */
+ void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units, GLfloat clamp);
+ /** Set the polygon stippling pattern */
+ void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask );
+ /* Specifies the current buffer for reading */
+ void (*ReadBuffer)( struct gl_context *ctx, GLenum buffer );
+ /** Set rasterization mode */
+ void (*RenderMode)(struct gl_context *ctx, GLenum mode );
+ /** Define the scissor box */
+ void (*Scissor)(struct gl_context *ctx);
+ /** Select flat or smooth shading */
+ void (*ShadeModel)(struct gl_context *ctx, GLenum mode);
+ /** OpenGL 2.0 two-sided StencilFunc */
+ void (*StencilFuncSeparate)(struct gl_context *ctx, GLenum face, GLenum func,
+ GLint ref, GLuint mask);
+ /** OpenGL 2.0 two-sided StencilMask */
+ void (*StencilMaskSeparate)(struct gl_context *ctx, GLenum face, GLuint mask);
+ /** OpenGL 2.0 two-sided StencilOp */
+ void (*StencilOpSeparate)(struct gl_context *ctx, GLenum face, GLenum fail,
+ GLenum zfail, GLenum zpass);
+ /** Control the generation of texture coordinates */
+ void (*TexGen)(struct gl_context *ctx, GLenum coord, GLenum pname,
+ const GLfloat *params);
+ /** Set texture environment parameters */
+ void (*TexEnv)(struct gl_context *ctx, GLenum target, GLenum pname,
+ const GLfloat *param);
+ /** Set texture parameter (callee gets param value from the texObj) */
+ void (*TexParameter)(struct gl_context *ctx,
+ struct gl_texture_object *texObj, GLenum pname);
+ /** Set the viewport */
+ void (*Viewport)(struct gl_context *ctx);
+ /*@}*/
+
+
+ /**
+ * \name Vertex/pixel buffer object functions
+ */
+ /*@{*/
+ struct gl_buffer_object * (*NewBufferObject)(struct gl_context *ctx,
+ GLuint buffer);
+
+ void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
+
+ GLboolean (*BufferData)(struct gl_context *ctx, GLenum target,
+ GLsizeiptrARB size, const GLvoid *data, GLenum usage,
+ GLenum storageFlags, struct gl_buffer_object *obj);
+
+ void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset,
+ GLsizeiptrARB size, const GLvoid *data,
+ struct gl_buffer_object *obj );
+
+ void (*GetBufferSubData)( struct gl_context *ctx,
+ GLintptrARB offset, GLsizeiptrARB size,
+ GLvoid *data, struct gl_buffer_object *obj );
+
+ void (*ClearBufferSubData)( struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr size,
+ const GLvoid *clearValue,
+ GLsizeiptr clearValueSize,
+ struct gl_buffer_object *obj );
+
+ void (*CopyBufferSubData)( struct gl_context *ctx,
+ struct gl_buffer_object *src,
+ struct gl_buffer_object *dst,
+ GLintptr readOffset, GLintptr writeOffset,
+ GLsizeiptr size );
+
+ void (*InvalidateBufferSubData)( struct gl_context *ctx,
+ struct gl_buffer_object *obj,
+ GLintptr offset,
+ GLsizeiptr length );
+
+ /* Returns pointer to the start of the mapped range.
+ * May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
+ */
+ void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
+ GLsizeiptr length, GLbitfield access,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+
+ void (*FlushMappedBufferRange)(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+
+ GLboolean (*UnmapBuffer)( struct gl_context *ctx,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+ /*@}*/
+
+ /**
+ * \name Functions for GL_APPLE_object_purgeable
+ */
+ /*@{*/
+ /* variations on ObjectPurgeable */
+ GLenum (*BufferObjectPurgeable)(struct gl_context *ctx,
+ struct gl_buffer_object *obj, GLenum option);
+ GLenum (*RenderObjectPurgeable)(struct gl_context *ctx,
+ struct gl_renderbuffer *obj, GLenum option);
+ GLenum (*TextureObjectPurgeable)(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum option);
+
+ /* variations on ObjectUnpurgeable */
+ GLenum (*BufferObjectUnpurgeable)(struct gl_context *ctx,
+ struct gl_buffer_object *obj,
+ GLenum option);
+ GLenum (*RenderObjectUnpurgeable)(struct gl_context *ctx,
+ struct gl_renderbuffer *obj,
+ GLenum option);
+ GLenum (*TextureObjectUnpurgeable)(struct gl_context *ctx,
+ struct gl_texture_object *obj,
+ GLenum option);
+ /*@}*/
+
+ /**
+ * \name Functions for GL_EXT_framebuffer_{object,blit,discard}.
+ */
+ /*@{*/
+ struct gl_framebuffer * (*NewFramebuffer)(struct gl_context *ctx,
+ GLuint name);
+ struct gl_renderbuffer * (*NewRenderbuffer)(struct gl_context *ctx,
+ GLuint name);
+ void (*BindFramebuffer)(struct gl_context *ctx, GLenum target,
+ struct gl_framebuffer *drawFb,
+ struct gl_framebuffer *readFb);
+ void (*FramebufferRenderbuffer)(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb);
+ void (*RenderTexture)(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ struct gl_renderbuffer_attachment *att);
+ void (*FinishRenderTexture)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb);
+ void (*ValidateFramebuffer)(struct gl_context *ctx,
+ struct gl_framebuffer *fb);
+ /*@}*/
+ void (*BlitFramebuffer)(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter);
+ void (*DiscardFramebuffer)(struct gl_context *ctx, struct gl_framebuffer *fb,
+ struct gl_renderbuffer_attachment *att);
+
+ /**
+ * \name Functions for GL_ARB_sample_locations
+ */
+ void (*GetProgrammableSampleCaps)(struct gl_context *ctx,
+ const struct gl_framebuffer *fb,
+ GLuint *bits, GLuint *width, GLuint *height);
+ void (*EvaluateDepthValues)(struct gl_context *ctx);
+
+ /**
+ * \name Query objects
+ */
+ /*@{*/
+ struct gl_query_object * (*NewQueryObject)(struct gl_context *ctx, GLuint id);
+ void (*DeleteQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*BeginQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*QueryCounter)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*EndQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*CheckQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ void (*WaitQuery)(struct gl_context *ctx, struct gl_query_object *q);
+ /*
+ * \pname the value requested to be written (GL_QUERY_RESULT, etc)
+ * \ptype the type of the value requested to be written:
+ * GL_UNSIGNED_INT, GL_UNSIGNED_INT64_ARB,
+ * GL_INT, GL_INT64_ARB
+ */
+ void (*StoreQueryResult)(struct gl_context *ctx, struct gl_query_object *q,
+ struct gl_buffer_object *buf, intptr_t offset,
+ GLenum pname, GLenum ptype);
+ /*@}*/
+
+ /**
+ * \name Performance monitors
+ */
+ /*@{*/
+ void (*InitPerfMonitorGroups)(struct gl_context *ctx);
+ struct gl_perf_monitor_object * (*NewPerfMonitor)(struct gl_context *ctx);
+ void (*DeletePerfMonitor)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m);
+ GLboolean (*BeginPerfMonitor)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m);
+
+ /** Stop an active performance monitor, discarding results. */
+ void (*ResetPerfMonitor)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m);
+ void (*EndPerfMonitor)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m);
+ GLboolean (*IsPerfMonitorResultAvailable)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m);
+ void (*GetPerfMonitorResult)(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m,
+ GLsizei dataSize,
+ GLuint *data,
+ GLint *bytesWritten);
+ /*@}*/
+
+ /**
+ * \name Performance Query objects
+ */
+ /*@{*/
+ unsigned (*InitPerfQueryInfo)(struct gl_context *ctx);
+ void (*GetPerfQueryInfo)(struct gl_context *ctx,
+ unsigned queryIndex,
+ const char **name,
+ GLuint *dataSize,
+ GLuint *numCounters,
+ GLuint *numActive);
+ void (*GetPerfCounterInfo)(struct gl_context *ctx,
+ unsigned queryIndex,
+ unsigned counterIndex,
+ const char **name,
+ const char **desc,
+ GLuint *offset,
+ GLuint *data_size,
+ GLuint *type_enum,
+ GLuint *data_type_enum,
+ GLuint64 *raw_max);
+ struct gl_perf_query_object * (*NewPerfQueryObject)(struct gl_context *ctx,
+ unsigned queryIndex);
+ void (*DeletePerfQuery)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj);
+ bool (*BeginPerfQuery)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj);
+ void (*EndPerfQuery)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj);
+ void (*WaitPerfQuery)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj);
+ bool (*IsPerfQueryReady)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj);
+ void (*GetPerfQueryData)(struct gl_context *ctx,
+ struct gl_perf_query_object *obj,
+ GLsizei dataSize,
+ GLuint *data,
+ GLuint *bytesWritten);
+ /*@}*/
+
+
+ /**
+ * \name GREMEDY debug/marker functions
+ */
+ /*@{*/
+ void (*EmitStringMarker)(struct gl_context *ctx, const GLchar *string, GLsizei len);
+ /*@}*/
+
+ /**
+ * \name Support for multiple T&L engines
+ */
+ /*@{*/
+
+ /**
+ * Set by the driver-supplied T&L engine.
+ *
+ * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
+ */
+ GLuint CurrentExecPrimitive;
+
+ /**
+ * Current glBegin state of an in-progress compilation. May be
+ * GL_POINTS, GL_TRIANGLE_STRIP, etc. or PRIM_OUTSIDE_BEGIN_END
+ * or PRIM_UNKNOWN.
+ */
+ GLuint CurrentSavePrimitive;
+
+
+#define FLUSH_STORED_VERTICES 0x1
+#define FLUSH_UPDATE_CURRENT 0x2
+ /**
+ * Set by the driver-supplied T&L engine whenever vertices are buffered
+ * between glBegin()/glEnd() objects or __struct gl_contextRec::Current
+ * is not updated. A bitmask of the FLUSH_x values above.
+ *
+ * The dd_function_table::FlushVertices call below may be used to resolve
+ * these conditions.
+ */
+ GLbitfield NeedFlush;
+
+ /** Need to call vbo_save_SaveFlushVertices() upon state change? */
+ GLboolean SaveNeedFlush;
+
+ /**
+ * Notify driver that the special derived value _NeedEyeCoords has
+ * changed.
+ */
+ void (*LightingSpaceChange)( struct gl_context *ctx );
+
+ /**@}*/
+
+ /**
+ * \name GL_ARB_sync interfaces
+ */
+ /*@{*/
+ struct gl_sync_object * (*NewSyncObject)(struct gl_context *);
+ void (*FenceSync)(struct gl_context *, struct gl_sync_object *,
+ GLenum, GLbitfield);
+ void (*DeleteSyncObject)(struct gl_context *, struct gl_sync_object *);
+ void (*CheckSync)(struct gl_context *, struct gl_sync_object *);
+ void (*ClientWaitSync)(struct gl_context *, struct gl_sync_object *,
+ GLbitfield, GLuint64);
+ void (*ServerWaitSync)(struct gl_context *, struct gl_sync_object *,
+ GLbitfield, GLuint64);
+ /*@}*/
+
+ /** GL_NV_conditional_render */
+ void (*BeginConditionalRender)(struct gl_context *ctx,
+ struct gl_query_object *q,
+ GLenum mode);
+ void (*EndConditionalRender)(struct gl_context *ctx,
+ struct gl_query_object *q);
+
+ /**
+ * \name GL_OES_draw_texture interface
+ */
+ /*@{*/
+ void (*DrawTex)(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
+ GLfloat width, GLfloat height);
+ /*@}*/
+
+ /**
+ * \name GL_OES_EGL_image interface
+ */
+ void (*EGLImageTargetTexture2D)(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle);
+ void (*EGLImageTargetRenderbufferStorage)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ void *image_handle);
+
+ /**
+ * \name GL_EXT_EGL_image_storage interface
+ */
+ void (*EGLImageTargetTexStorage)(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle);
+ /**
+ * \name GL_EXT_transform_feedback interface
+ */
+ struct gl_transform_feedback_object *
+ (*NewTransformFeedback)(struct gl_context *ctx, GLuint name);
+ void (*DeleteTransformFeedback)(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
+ void (*BeginTransformFeedback)(struct gl_context *ctx, GLenum mode,
+ struct gl_transform_feedback_object *obj);
+ void (*EndTransformFeedback)(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
+ void (*PauseTransformFeedback)(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
+ void (*ResumeTransformFeedback)(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj);
+
+ /**
+ * Return the number of vertices written to a stream during the last
+ * Begin/EndTransformFeedback block.
+ */
+ GLsizei (*GetTransformFeedbackVertexCount)(struct gl_context *ctx,
+ struct gl_transform_feedback_object *obj,
+ GLuint stream);
+
+ /**
+ * \name GL_NV_texture_barrier interface
+ */
+ void (*TextureBarrier)(struct gl_context *ctx);
+
+ /**
+ * \name GL_ARB_sampler_objects
+ */
+ struct gl_sampler_object * (*NewSamplerObject)(struct gl_context *ctx,
+ GLuint name);
+
+ /**
+ * \name Return a timestamp in nanoseconds as defined by GL_ARB_timer_query.
+ * This should be equivalent to glGetInteger64v(GL_TIMESTAMP);
+ */
+ uint64_t (*GetTimestamp)(struct gl_context *ctx);
+
+ /**
+ * \name GL_ARB_texture_multisample
+ */
+ void (*GetSamplePosition)(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLuint index,
+ GLfloat *outValue);
+
+ /**
+ * \name NV_vdpau_interop interface
+ */
+ void (*VDPAUMapSurface)(struct gl_context *ctx, GLenum target,
+ GLenum access, GLboolean output,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ const GLvoid *vdpSurface, GLuint index);
+ void (*VDPAUUnmapSurface)(struct gl_context *ctx, GLenum target,
+ GLenum access, GLboolean output,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ const GLvoid *vdpSurface, GLuint index);
+
+ /**
+ * Query reset status for GL_ARB_robustness
+ *
+ * Per \c glGetGraphicsResetStatusARB, this function should return a
+ * non-zero value once after a reset. If a reset is non-atomic, the
+ * non-zero status should be returned for the duration of the reset.
+ */
+ GLenum (*GetGraphicsResetStatus)(struct gl_context *ctx);
+
+ /**
+ * \name GL_ARB_shader_image_load_store interface.
+ */
+ /** @{ */
+ void (*MemoryBarrier)(struct gl_context *ctx, GLbitfield barriers);
+ /** @} */
+
+ /**
+ * GL_EXT_shader_framebuffer_fetch_non_coherent rendering barrier.
+ *
+ * On return from this function any framebuffer contents written by
+ * previous draw commands are guaranteed to be visible from subsequent
+ * fragment shader invocations using the
+ * EXT_shader_framebuffer_fetch_non_coherent interface.
+ */
+ /** @{ */
+ void (*FramebufferFetchBarrier)(struct gl_context *ctx);
+ /** @} */
+
+ /**
+ * \name GL_ARB_compute_shader interface
+ */
+ /*@{*/
+ void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
+ void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr indirect);
+ /*@}*/
+
+ /**
+ * \name GL_ARB_compute_variable_group_size interface
+ */
+ /*@{*/
+ void (*DispatchComputeGroupSize)(struct gl_context *ctx,
+ const GLuint *num_groups,
+ const GLuint *group_size);
+ /*@}*/
+
+ /**
+ * Query information about memory. Device memory is e.g. VRAM. Staging
+ * memory is e.g. GART. All sizes are in kilobytes.
+ */
+ void (*QueryMemoryInfo)(struct gl_context *ctx,
+ struct gl_memory_info *info);
+
+ /**
+ * Indicate that this thread is being used by Mesa as a background drawing
+ * thread for the given GL context.
+ *
+ * If this function is called more than once from any given thread, each
+ * subsequent call overrides the context that was passed in the previous
+ * call. Mesa takes advantage of this to re-use a background thread to
+ * perform drawing on behalf of multiple contexts.
+ *
+ * Mesa may sometimes call this function from a non-background thread
+ * (i.e. a thread that has already been bound to a context using
+ * __DriverAPIRec::MakeCurrent()); when this happens, ctx will be equal to
+ * the context that is bound to this thread.
+ *
+ * Mesa will only call this function if GL multithreading is enabled.
+ */
+ void (*SetBackgroundContext)(struct gl_context *ctx,
+ struct util_queue_monitoring *queue_info);
+
+ /**
+ * \name GL_ARB_sparse_buffer interface
+ */
+ /*@{*/
+ void (*BufferPageCommitment)(struct gl_context *ctx,
+ struct gl_buffer_object *bufferObj,
+ GLintptr offset, GLsizeiptr size,
+ GLboolean commit);
+ /*@}*/
+
+ /**
+ * \name GL_ARB_bindless_texture interface
+ */
+ /*@{*/
+ GLuint64 (*NewTextureHandle)(struct gl_context *ctx,
+ struct gl_texture_object *texObj,
+ struct gl_sampler_object *sampObj);
+ void (*DeleteTextureHandle)(struct gl_context *ctx, GLuint64 handle);
+ void (*MakeTextureHandleResident)(struct gl_context *ctx, GLuint64 handle,
+ bool resident);
+ GLuint64 (*NewImageHandle)(struct gl_context *ctx,
+ struct gl_image_unit *imgObj);
+ void (*DeleteImageHandle)(struct gl_context *ctx, GLuint64 handle);
+ void (*MakeImageHandleResident)(struct gl_context *ctx, GLuint64 handle,
+ GLenum access, bool resident);
+ /*@}*/
+
+
+ /**
+ * \name GL_EXT_external_objects interface
+ */
+ /*@{*/
+ /**
+ * Called to allocate a new memory object. Drivers will usually
+ * allocate/return a subclass of gl_memory_object.
+ */
+ struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
+ GLuint name);
+ /**
+ * Called to delete/free a memory object. Drivers should free the
+ * object and any image data it contains.
+ */
+ void (*DeleteMemoryObject)(struct gl_context *ctx,
+ struct gl_memory_object *memObj);
+
+ /**
+ * Set the given memory object as the texture's storage.
+ */
+ GLboolean (*SetTextureStorageForMemoryObject)(struct gl_context *ctx,
+ struct gl_texture_object *tex_obj,
+ struct gl_memory_object *mem_obj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLuint64 offset);
+
+ /**
+ * Use a memory object as the backing data for a buffer object
+ */
+ GLboolean (*BufferDataMem)(struct gl_context *ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ struct gl_memory_object *memObj,
+ GLuint64 offset,
+ GLenum usage,
+ struct gl_buffer_object *bufObj);
+
+ /**
+ * Fill uuid with an unique identifier for this driver
+ *
+ * uuid must point to GL_UUID_SIZE_EXT bytes of available memory
+ */
+ void (*GetDriverUuid)(struct gl_context *ctx, char *uuid);
+
+ /**
+ * Fill uuid with an unique identifier for the device associated
+ * to this driver
+ *
+ * uuid must point to GL_UUID_SIZE_EXT bytes of available memory
+ */
+ void (*GetDeviceUuid)(struct gl_context *ctx, char *uuid);
+
+ /*@}*/
+
+ /**
+ * \name GL_EXT_external_objects_fd interface
+ */
+ /*@{*/
+ /**
+ * Called to import a memory object. The caller relinquishes ownership
+ * of fd after the call returns.
+ *
+ * Accessing fd after ImportMemoryObjectFd returns results in undefined
+ * behaviour. This is consistent with EXT_external_object_fd.
+ */
+ void (*ImportMemoryObjectFd)(struct gl_context *ctx,
+ struct gl_memory_object *memObj,
+ GLuint64 size,
+ int fd);
+ /*@}*/
+
+ /**
+ * \name GL_ARB_get_program_binary
+ */
+ /*@{*/
+ /**
+ * Calls to retrieve/store a binary serialized copy of the current program.
+ */
+ void (*GetProgramBinaryDriverSHA1)(struct gl_context *ctx, uint8_t *sha1);
+
+ void (*ProgramBinarySerializeDriverBlob)(struct gl_context *ctx,
+ struct gl_shader_program *shProg,
+ struct gl_program *prog);
+
+ void (*ProgramBinaryDeserializeDriverBlob)(struct gl_context *ctx,
+ struct gl_shader_program *shProg,
+ struct gl_program *prog);
+ /*@}*/
+
+ /**
+ * \name GL_EXT_semaphore interface
+ */
+ /*@{*/
+ /**
+ * Called to allocate a new semaphore object. Drivers will usually
+ * allocate/return a subclass of gl_semaphore_object.
+ */
+ struct gl_semaphore_object * (*NewSemaphoreObject)(struct gl_context *ctx,
+ GLuint name);
+ /**
+ * Called to delete/free a semaphore object. Drivers should free the
+ * object and any associated resources.
+ */
+ void (*DeleteSemaphoreObject)(struct gl_context *ctx,
+ struct gl_semaphore_object *semObj);
+
+ /**
+ * Introduce an operation to wait for the semaphore object in the GL
+ * server's command stream
+ */
+ void (*ServerWaitSemaphoreObject)(struct gl_context *ctx,
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *srcLayouts);
+
+ /**
+ * Introduce an operation to signal the semaphore object in the GL
+ * server's command stream
+ */
+ void (*ServerSignalSemaphoreObject)(struct gl_context *ctx,
+ struct gl_semaphore_object *semObj,
+ GLuint numBufferBarriers,
+ struct gl_buffer_object **bufObjs,
+ GLuint numTextureBarriers,
+ struct gl_texture_object **texObjs,
+ const GLenum *dstLayouts);
+ /*@}*/
+
+ /**
+ * \name GL_EXT_semaphore_fd interface
+ */
+ /*@{*/
+ /**
+ * Called to import a semaphore object. The caller relinquishes ownership
+ * of fd after the call returns.
+ *
+ * Accessing fd after ImportSemaphoreFd returns results in undefined
+ * behaviour. This is consistent with EXT_semaphore_fd.
+ */
+ void (*ImportSemaphoreFd)(struct gl_context *ctx,
+ struct gl_semaphore_object *semObj,
+ int fd);
+ /*@}*/
+
+ /**
+ * \name Disk shader cache functions
+ */
+ /*@{*/
+ /**
+ * Called to initialize gl_program::driver_cache_blob (and size) with a
+ * ralloc allocated buffer.
+ *
+ * This buffer will be saved and restored as part of the gl_program
+ * serialization and deserialization.
+ */
+ void (*ShaderCacheSerializeDriverBlob)(struct gl_context *ctx,
+ struct gl_program *prog);
+ /*@}*/
+
+ /**
+ * \name Set the number of compiler threads for ARB_parallel_shader_compile
+ */
+ void (*SetMaxShaderCompilerThreads)(struct gl_context *ctx, unsigned count);
+ bool (*GetShaderProgramCompletionStatus)(struct gl_context *ctx,
+ struct gl_shader_program *shprog);
+};
+
+
+/**
+ * Per-vertex functions.
+ *
+ * These are the functions which can appear between glBegin and glEnd.
+ * Depending on whether we're inside or outside a glBegin/End pair
+ * and whether we're in immediate mode or building a display list, these
+ * functions behave differently. This structure allows us to switch
+ * between those modes more easily.
+ *
+ * Generally, these pointers point to functions in the VBO module.
+ */
+typedef struct {
+ void (GLAPIENTRYP ArrayElement)( GLint );
+ void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Color3fv)( const GLfloat * );
+ void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Color4fv)( const GLfloat * );
+ void (GLAPIENTRYP EdgeFlag)( GLboolean );
+ void (GLAPIENTRYP EvalCoord1f)( GLfloat );
+ void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * );
+ void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat );
+ void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * );
+ void (GLAPIENTRYP EvalPoint1)( GLint );
+ void (GLAPIENTRYP EvalPoint2)( GLint, GLint );
+ void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
+ void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
+ void (GLAPIENTRYP Indexf)( GLfloat );
+ void (GLAPIENTRYP Indexfv)( const GLfloat * );
+ void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Normal3fv)( const GLfloat * );
+ void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord1f)( GLfloat );
+ void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
+ void (GLAPIENTRYP CallList)( GLuint );
+ void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * );
+ void (GLAPIENTRYP Begin)( GLenum );
+ void (GLAPIENTRYP End)( void );
+ void (GLAPIENTRYP PrimitiveRestartNV)( void );
+ /* Originally for GL_NV_vertex_program, now used only dlist.c and friends */
+ void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
+ void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
+ void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+ void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+ void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
+ /* GL_ARB_vertex_program */
+ void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
+ void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
+ void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+ void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+ void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
+
+ /* GL_EXT_gpu_shader4 / GL 3.0 */
+ void (GLAPIENTRYP VertexAttribI1i)( GLuint index, GLint x);
+ void (GLAPIENTRYP VertexAttribI2i)( GLuint index, GLint x, GLint y);
+ void (GLAPIENTRYP VertexAttribI3i)( GLuint index, GLint x, GLint y, GLint z);
+ void (GLAPIENTRYP VertexAttribI4i)( GLuint index, GLint x, GLint y, GLint z, GLint w);
+ void (GLAPIENTRYP VertexAttribI2iv)( GLuint index, const GLint *v);
+ void (GLAPIENTRYP VertexAttribI3iv)( GLuint index, const GLint *v);
+ void (GLAPIENTRYP VertexAttribI4iv)( GLuint index, const GLint *v);
+
+ void (GLAPIENTRYP VertexAttribI1ui)( GLuint index, GLuint x);
+ void (GLAPIENTRYP VertexAttribI2ui)( GLuint index, GLuint x, GLuint y);
+ void (GLAPIENTRYP VertexAttribI3ui)( GLuint index, GLuint x, GLuint y, GLuint z);
+ void (GLAPIENTRYP VertexAttribI4ui)( GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+ void (GLAPIENTRYP VertexAttribI2uiv)( GLuint index, const GLuint *v);
+ void (GLAPIENTRYP VertexAttribI3uiv)( GLuint index, const GLuint *v);
+ void (GLAPIENTRYP VertexAttribI4uiv)( GLuint index, const GLuint *v);
+
+ /* GL_ARB_vertex_type_10_10_10_2_rev / GL3.3 */
+ void (GLAPIENTRYP VertexP2ui)( GLenum type, GLuint value );
+ void (GLAPIENTRYP VertexP2uiv)( GLenum type, const GLuint *value);
+
+ void (GLAPIENTRYP VertexP3ui)( GLenum type, GLuint value );
+ void (GLAPIENTRYP VertexP3uiv)( GLenum type, const GLuint *value);
+
+ void (GLAPIENTRYP VertexP4ui)( GLenum type, GLuint value );
+ void (GLAPIENTRYP VertexP4uiv)( GLenum type, const GLuint *value);
+
+ void (GLAPIENTRYP TexCoordP1ui)( GLenum type, GLuint coords );
+ void (GLAPIENTRYP TexCoordP1uiv)( GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP TexCoordP2ui)( GLenum type, GLuint coords );
+ void (GLAPIENTRYP TexCoordP2uiv)( GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP TexCoordP3ui)( GLenum type, GLuint coords );
+ void (GLAPIENTRYP TexCoordP3uiv)( GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP TexCoordP4ui)( GLenum type, GLuint coords );
+ void (GLAPIENTRYP TexCoordP4uiv)( GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP MultiTexCoordP1ui)( GLenum texture, GLenum type, GLuint coords );
+ void (GLAPIENTRYP MultiTexCoordP1uiv)( GLenum texture, GLenum type, const GLuint *coords );
+ void (GLAPIENTRYP MultiTexCoordP2ui)( GLenum texture, GLenum type, GLuint coords );
+ void (GLAPIENTRYP MultiTexCoordP2uiv)( GLenum texture, GLenum type, const GLuint *coords );
+ void (GLAPIENTRYP MultiTexCoordP3ui)( GLenum texture, GLenum type, GLuint coords );
+ void (GLAPIENTRYP MultiTexCoordP3uiv)( GLenum texture, GLenum type, const GLuint *coords );
+ void (GLAPIENTRYP MultiTexCoordP4ui)( GLenum texture, GLenum type, GLuint coords );
+ void (GLAPIENTRYP MultiTexCoordP4uiv)( GLenum texture, GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP NormalP3ui)( GLenum type, GLuint coords );
+ void (GLAPIENTRYP NormalP3uiv)( GLenum type, const GLuint *coords );
+
+ void (GLAPIENTRYP ColorP3ui)( GLenum type, GLuint color );
+ void (GLAPIENTRYP ColorP3uiv)( GLenum type, const GLuint *color );
+
+ void (GLAPIENTRYP ColorP4ui)( GLenum type, GLuint color );
+ void (GLAPIENTRYP ColorP4uiv)( GLenum type, const GLuint *color );
+
+ void (GLAPIENTRYP SecondaryColorP3ui)( GLenum type, GLuint color );
+ void (GLAPIENTRYP SecondaryColorP3uiv)( GLenum type, const GLuint *color );
+
+ void (GLAPIENTRYP VertexAttribP1ui)( GLuint index, GLenum type,
+ GLboolean normalized, GLuint value);
+ void (GLAPIENTRYP VertexAttribP2ui)( GLuint index, GLenum type,
+ GLboolean normalized, GLuint value);
+ void (GLAPIENTRYP VertexAttribP3ui)( GLuint index, GLenum type,
+ GLboolean normalized, GLuint value);
+ void (GLAPIENTRYP VertexAttribP4ui)( GLuint index, GLenum type,
+ GLboolean normalized, GLuint value);
+ void (GLAPIENTRYP VertexAttribP1uiv)( GLuint index, GLenum type,
+ GLboolean normalized,
+ const GLuint *value);
+ void (GLAPIENTRYP VertexAttribP2uiv)( GLuint index, GLenum type,
+ GLboolean normalized,
+ const GLuint *value);
+ void (GLAPIENTRYP VertexAttribP3uiv)( GLuint index, GLenum type,
+ GLboolean normalized,
+ const GLuint *value);
+ void (GLAPIENTRYP VertexAttribP4uiv)( GLuint index, GLenum type,
+ GLboolean normalized,
+ const GLuint *value);
+
+ /* GL_ARB_vertex_attrib_64bit / GL 4.1 */
+ void (GLAPIENTRYP VertexAttribL1d)( GLuint index, GLdouble x);
+ void (GLAPIENTRYP VertexAttribL2d)( GLuint index, GLdouble x, GLdouble y);
+ void (GLAPIENTRYP VertexAttribL3d)( GLuint index, GLdouble x, GLdouble y, GLdouble z);
+ void (GLAPIENTRYP VertexAttribL4d)( GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+
+ void (GLAPIENTRYP VertexAttribL1dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL2dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL3dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL4dv)( GLuint index, const GLdouble *v);
+
+ void (GLAPIENTRYP VertexAttribL1ui64ARB)( GLuint index, GLuint64EXT x);
+ void (GLAPIENTRYP VertexAttribL1ui64vARB)( GLuint index, const GLuint64EXT *v);
+} GLvertexformat;
+
+
+#endif /* DD_INCLUDED */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/debug_output.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/debug_output.h
new file mode 100644
index 0000000000..8a5eedc21f
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/debug_output.h
@@ -0,0 +1,107 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2016 Brian Paul, et al All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DEBUG_OUTPUT_H
+#define DEBUG_OUTPUT_H
+
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "glheader.h"
+#include "menums.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+
+void
+_mesa_init_debug_output(struct gl_context *ctx);
+
+void
+_mesa_free_errors_data(struct gl_context *ctx);
+
+void
+_mesa_debug_get_id(GLuint *id);
+
+bool
+_mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val);
+
+GLint
+_mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname);
+
+void *
+_mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname);
+
+void
+_mesa_log_msg(struct gl_context *ctx, enum mesa_debug_source source,
+ enum mesa_debug_type type, GLuint id,
+ enum mesa_debug_severity severity, GLint len, const char *buf);
+
+bool
+_mesa_debug_is_message_enabled(const struct gl_debug_state *debug,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ GLuint id,
+ enum mesa_debug_severity severity);
+
+void GLAPIENTRY
+_mesa_DebugMessageInsert(GLenum source, GLenum type, GLuint id,
+ GLenum severity, GLint length,
+ const GLchar* buf);
+
+GLuint GLAPIENTRY
+_mesa_GetDebugMessageLog(GLuint count, GLsizei logSize, GLenum* sources,
+ GLenum* types, GLenum* ids, GLenum* severities,
+ GLsizei* lengths, GLchar* messageLog);
+
+void GLAPIENTRY
+_mesa_DebugMessageControl(GLenum source, GLenum type, GLenum severity,
+ GLsizei count, const GLuint *ids,
+ GLboolean enabled);
+
+void GLAPIENTRY
+_mesa_DebugMessageCallback(GLDEBUGPROC callback,
+ const void *userParam);
+
+void GLAPIENTRY
+_mesa_PushDebugGroup(GLenum source, GLuint id, GLsizei length,
+ const GLchar *message);
+
+void GLAPIENTRY
+_mesa_PopDebugGroup(void);
+
+void GLAPIENTRY
+_mesa_StringMarkerGREMEDY(GLsizei len, const GLvoid *string);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* DEBUG_OUTPUT_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/draw.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/draw.h
new file mode 100644
index 0000000000..212e70a3fd
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/draw.h
@@ -0,0 +1,227 @@
+/*
+ * mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \brief Array type draw functions, the main workhorse of any OpenGL API
+ * \author Keith Whitwell
+ */
+
+
+#ifndef DRAW_H
+#define DRAW_H
+
+#include <stdbool.h>
+#include "main/glheader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+
+struct _mesa_prim
+{
+ GLubyte mode; /**< GL_POINTS, GL_LINES, GL_QUAD_STRIP, etc */
+
+ /**
+ * tnl: If true, line stipple emulation will reset the pattern walker.
+ * vbo: If false and the primitive is a line loop, the first vertex is
+ * the beginning of the line loop and it won't be drawn.
+ * Instead, it will be moved to the end.
+ */
+ bool begin;
+
+ /**
+ * tnl: If true and the primitive is a line loop, it will be closed.
+ * vbo: Same as tnl.
+ */
+ bool end;
+
+ GLuint start;
+ GLuint count;
+ GLint basevertex;
+ GLuint draw_id;
+};
+
+/* Would like to call this a "vbo_index_buffer", but this would be
+ * confusing as the indices are not neccessarily yet in a non-null
+ * buffer object.
+ */
+struct _mesa_index_buffer
+{
+ GLuint count;
+ uint8_t index_size_shift; /* logbase2(index_size) */
+ struct gl_buffer_object *obj;
+ const void *ptr;
+};
+
+
+void
+_mesa_initialize_exec_dispatch(const struct gl_context *ctx,
+ struct _glapi_table *exec);
+
+void GLAPIENTRY
+_mesa_EvalMesh1(GLenum mode, GLint i1, GLint i2);
+
+void GLAPIENTRY
+_mesa_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
+
+void GLAPIENTRY
+_mesa_DrawElementsInstancedARB(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices, GLsizei numInstances);
+
+void GLAPIENTRY
+_mesa_DrawArraysInstancedBaseInstance(GLenum mode, GLint first,
+ GLsizei count, GLsizei numInstances,
+ GLuint baseInstance);
+
+void GLAPIENTRY
+_mesa_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count,
+ GLenum type, const GLvoid * indices,
+ GLsizei numInstances,
+ GLint basevertex);
+
+void GLAPIENTRY
+_mesa_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count,
+ GLenum type,
+ const GLvoid *indices,
+ GLsizei numInstances,
+ GLuint baseInstance);
+
+void GLAPIENTRY
+_mesa_DrawTransformFeedbackStream(GLenum mode, GLuint name, GLuint stream);
+
+void GLAPIENTRY
+_mesa_DrawTransformFeedbackInstanced(GLenum mode, GLuint name,
+ GLsizei primcount);
+
+void GLAPIENTRY
+_mesa_DrawTransformFeedbackStreamInstanced(GLenum mode, GLuint name,
+ GLuint stream,
+ GLsizei primcount);
+
+void GLAPIENTRY
+_mesa_DrawArraysIndirect(GLenum mode, const GLvoid *indirect);
+
+void GLAPIENTRY
+_mesa_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect);
+
+void GLAPIENTRY
+_mesa_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect,
+ GLsizei primcount, GLsizei stride);
+
+void GLAPIENTRY
+_mesa_MultiDrawElementsIndirect(GLenum mode, GLenum type,
+ const GLvoid *indirect,
+ GLsizei primcount, GLsizei stride);
+
+void GLAPIENTRY
+_mesa_MultiDrawArraysIndirectCountARB(GLenum mode, GLintptr indirect,
+ GLintptr drawcount_offset,
+ GLsizei maxdrawcount, GLsizei stride);
+
+void GLAPIENTRY
+_mesa_MultiDrawElementsIndirectCountARB(GLenum mode, GLenum type,
+ GLintptr indirect,
+ GLintptr drawcount_offset,
+ GLsizei maxdrawcount, GLsizei stride);
+
+void GLAPIENTRY
+_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
+
+
+void GLAPIENTRY
+_mesa_DrawArraysInstancedARB(GLenum mode, GLint first, GLsizei count,
+ GLsizei primcount);
+
+void GLAPIENTRY
+_mesa_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
+ GLsizei count,
+ GLenum type,
+ const GLvoid *indices,
+ GLsizei numInstances,
+ GLint basevertex,
+ GLuint baseInstance);
+
+void GLAPIENTRY
+_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+
+void GLAPIENTRY
+_mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
+ GLenum type, const GLvoid *indices);
+
+
+void GLAPIENTRY
+_mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices, GLint basevertex);
+
+
+void GLAPIENTRY
+_mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices,
+ GLint basevertex);
+
+
+void GLAPIENTRY
+_mesa_DrawTransformFeedback(GLenum mode, GLuint name);
+
+
+
+void GLAPIENTRY
+_mesa_MultiDrawArrays(GLenum mode, const GLint *first,
+ const GLsizei *count, GLsizei primcount);
+
+
+void GLAPIENTRY
+_mesa_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
+ const GLvoid *const *indices, GLsizei primcount);
+
+
+void GLAPIENTRY
+_mesa_MultiDrawElementsBaseVertex(GLenum mode,
+ const GLsizei *count, GLenum type,
+ const GLvoid * const * indices, GLsizei primcount,
+ const GLint *basevertex);
+
+
+void GLAPIENTRY
+_mesa_MultiModeDrawArraysIBM(const GLenum * mode, const GLint * first,
+ const GLsizei * count,
+ GLsizei primcount, GLint modestride);
+
+
+void GLAPIENTRY
+_mesa_MultiModeDrawElementsIBM(const GLenum * mode, const GLsizei * count,
+ GLenum type, const GLvoid * const * indices,
+ GLsizei primcount, GLint modestride);
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/enums.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/enums.h
new file mode 100644
index 0000000000..0e18cd407e
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/enums.h
@@ -0,0 +1,58 @@
+/**
+ * \file enums.h
+ * Enumeration name/number lookup functions.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _ENUMS_H_
+#define _ENUMS_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern const char *_mesa_enum_to_string( int nr );
+
+/* Get the name of an enum given that it is a primitive type. Avoids
+ * GL_FALSE/GL_POINTS ambiguity and others.
+ */
+const char *_mesa_lookup_prim_by_nr( unsigned nr );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/errors.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/errors.h
new file mode 100644
index 0000000000..17fe380f26
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/errors.h
@@ -0,0 +1,118 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file errors.h
+ * Mesa debugging and error handling functions.
+ *
+ * This file provides functions to record errors, warnings, and miscellaneous
+ * debug information.
+ */
+
+
+#ifndef ERRORS_H
+#define ERRORS_H
+
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "glheader.h"
+#include "menums.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+
+extern void
+_mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
+
+extern void
+_mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
+
+extern void
+_mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4);
+
+extern void
+_mesa_error_no_memory(const char *caller);
+
+extern void
+_mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
+
+extern void
+_mesa_log(const char *fmtString, ...) PRINTFLIKE(1, 2);
+
+extern FILE *
+_mesa_get_log_file(void);
+
+void
+_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
+ const char *msg);
+
+extern void
+_mesa_gl_vdebugf(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *fmtString,
+ va_list args);
+
+extern void
+_mesa_gl_debugf(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *fmtString, ...) PRINTFLIKE(6, 7);
+
+extern size_t
+_mesa_gl_debug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *msg);
+
+#define _mesa_perf_debug(ctx, sev, ...) do { \
+ static GLuint msg_id = 0; \
+ if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) { \
+ _mesa_gl_debugf(ctx, &msg_id, \
+ MESA_DEBUG_SOURCE_API, \
+ MESA_DEBUG_TYPE_PERFORMANCE, \
+ sev, \
+ __VA_ARGS__); \
+ } \
+} while (0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* ERRORS_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions.h
new file mode 100644
index 0000000000..303929baab
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions.h
@@ -0,0 +1,125 @@
+/**
+ * \file extensions.h
+ * Extension handling.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _EXTENSIONS_H_
+#define _EXTENSIONS_H_
+
+#include "mtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+struct gl_extensions;
+
+extern void _mesa_enable_sw_extensions(struct gl_context *ctx);
+
+extern void _mesa_one_time_init_extension_overrides(void);
+
+extern void _mesa_init_extensions(struct gl_extensions *extentions);
+
+extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx);
+
+extern void _mesa_override_extensions(struct gl_context *ctx);
+
+extern GLuint
+_mesa_get_extension_count(struct gl_context *ctx);
+
+extern const GLubyte *
+_mesa_get_enabled_extension(struct gl_context *ctx, GLuint index);
+
+
+/**
+ * \brief An element of the \c extension_table.
+ */
+struct mesa_extension {
+ /** Name of extension, such as "GL_ARB_depth_clamp". */
+ const char *name;
+
+ /** Offset (in bytes) of the corresponding member in struct gl_extensions. */
+ size_t offset;
+
+ /** Minimum version the extension requires for the given API
+ * (see gl_api defined in mtypes.h). The value is equal to:
+ * 10 * major_version + minor_version
+ */
+ uint8_t version[API_OPENGL_LAST + 1];
+
+ /** Year the extension was proposed or approved. Used to sort the
+ * extension string chronologically. */
+ uint16_t year;
+};
+
+extern const struct mesa_extension _mesa_extension_table[];
+
+
+/* Generate enums for the functions below */
+enum {
+#define EXT(name_str, ...) MESA_EXTENSION_##name_str,
+#include "extensions_table.h"
+#undef EXT
+MESA_EXTENSION_COUNT
+};
+
+
+/** Checks if the context supports a user-facing extension */
+#define EXT(name_str, driver_cap, ...) \
+static inline bool \
+_mesa_has_##name_str(const struct gl_context *ctx) \
+{ \
+ return ctx->Extensions.driver_cap && (ctx->Extensions.Version >= \
+ _mesa_extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \
+}
+#include "extensions_table.h"
+#undef EXT
+
+/* Sometimes the driver wants to query the extension override status before
+ * a context is created. These variables are filled with extension override
+ * information before context creation.
+ *
+ * This can be useful during extension bring-up when an extension is
+ * partially implemented, but cannot yet be advertised as supported.
+ *
+ * Use it with care and keep access read-only.
+ */
+extern struct gl_extensions _mesa_extension_override_enables;
+extern struct gl_extensions _mesa_extension_override_disables;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.c b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.c
new file mode 100644
index 0000000000..6241705de1
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.c
@@ -0,0 +1,50 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "main/extensions.h"
+
+/**
+ * Given a member \c x of struct gl_extensions, return offset of
+ * \c x in bytes.
+ */
+#define o(x) offsetof(struct gl_extensions, x)
+
+/**
+ * \brief Table of supported OpenGL extensions for all API's.
+ */
+const struct mesa_extension _mesa_extension_table[] = {
+#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, yyyy) \
+ { .name = "GL_" #name_str, .offset = o(driver_cap), \
+ .version = { \
+ [API_OPENGL_COMPAT] = gll_ver, \
+ [API_OPENGL_CORE] = glc_ver, \
+ [API_OPENGLES] = gles_ver, \
+ [API_OPENGLES2] = gles2_ver, \
+ }, \
+ .year = yyyy \
+ },
+#include "extensions_table.h"
+#undef EXT
+};
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.h
new file mode 100644
index 0000000000..18d5f8073b
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/extensions_table.h
@@ -0,0 +1,490 @@
+/* The extension table is alphabetically sorted by the extension name string column. */
+
+#define GLL 0
+#define GLC 0
+#define ES1 0
+#define ES2 0
+#define x ~0
+
+EXT(3DFX_texture_compression_FXT1 , TDFX_texture_compression_FXT1 , GLL, GLC, x , x , 1999)
+
+EXT(AMD_compressed_ATC_texture , AMD_compressed_ATC_texture , x , x , ES1, ES2, 2008)
+EXT(AMD_conservative_depth , ARB_conservative_depth , GLL, GLC, x , x , 2009)
+EXT(AMD_depth_clamp_separate , AMD_depth_clamp_separate , GLL, GLC, x , x , 2009)
+EXT(AMD_draw_buffers_blend , ARB_draw_buffers_blend , GLL, GLC, x , x , 2009)
+EXT(AMD_framebuffer_multisample_advanced , AMD_framebuffer_multisample_advanced , GLL, GLC, x , ES2, 2018)
+EXT(AMD_gpu_shader_int64 , ARB_gpu_shader_int64 , x , GLC, x , x , 2015)
+EXT(AMD_multi_draw_indirect , ARB_draw_indirect , GLL, GLC, x , x , 2011)
+EXT(AMD_performance_monitor , AMD_performance_monitor , GLL, GLC, x , ES2, 2007)
+EXT(AMD_pinned_memory , AMD_pinned_memory , GLL, GLC, x , x , 2013)
+EXT(AMD_query_buffer_object , ARB_query_buffer_object , GLL, GLC, x , x , 2012)
+EXT(AMD_seamless_cubemap_per_texture , AMD_seamless_cubemap_per_texture , GLL, GLC, x , x , 2009)
+EXT(AMD_shader_stencil_export , ARB_shader_stencil_export , GLL, GLC, x , x , 2009)
+EXT(AMD_shader_trinary_minmax , dummy_true , GLL, GLC, x , x , 2012)
+EXT(AMD_texture_texture4 , ARB_texture_gather , GLL, GLC, x , x , 2008)
+EXT(AMD_vertex_shader_layer , AMD_vertex_shader_layer , GLL, GLC, x , x , 2012)
+EXT(AMD_vertex_shader_viewport_index , AMD_vertex_shader_viewport_index , GLL, GLC, x , x , 2012)
+
+EXT(ANDROID_extension_pack_es31a , ANDROID_extension_pack_es31a , x , x , x , 31, 2014)
+
+EXT(ANGLE_texture_compression_dxt3 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2011)
+EXT(ANGLE_texture_compression_dxt5 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2011)
+
+EXT(APPLE_object_purgeable , APPLE_object_purgeable , GLL, GLC, x , x , 2006)
+EXT(APPLE_packed_pixels , dummy_true , GLL, x , x , x , 2002)
+EXT(APPLE_texture_max_level , dummy_true , x , x , ES1, ES2, 2009)
+
+EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GLL, GLC, x , x , 2009)
+EXT(ARB_ES3_1_compatibility , ARB_ES3_1_compatibility , GLL, GLC, x , x , 2014)
+EXT(ARB_ES3_2_compatibility , ARB_ES3_2_compatibility , x , GLC, x , x , 2015)
+EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GLL, GLC, x , x , 2012)
+EXT(ARB_arrays_of_arrays , ARB_arrays_of_arrays , GLL, GLC, x , x , 2012)
+EXT(ARB_base_instance , ARB_base_instance , GLL, GLC, x , x , 2011)
+EXT(ARB_bindless_texture , ARB_bindless_texture , GLL, GLC, x , x , 2013)
+EXT(ARB_blend_func_extended , ARB_blend_func_extended , GLL, GLC, x , x , 2009)
+EXT(ARB_buffer_storage , ARB_buffer_storage , GLL, GLC, x , x , 2013)
+EXT(ARB_clear_buffer_object , dummy_true , GLL, GLC, x , x , 2012)
+EXT(ARB_clear_texture , ARB_clear_texture , GLL, GLC, x , x , 2013)
+EXT(ARB_clip_control , ARB_clip_control , GLL, GLC, x , x , 2014)
+EXT(ARB_color_buffer_float , ARB_color_buffer_float , GLL, GLC, x , x , 2004)
+EXT(ARB_compatibility , ARB_compatibility , GLL, x , x , x , 2009)
+EXT(ARB_compressed_texture_pixel_storage , dummy_true , GLL, GLC, x , x , 2011)
+EXT(ARB_compute_shader , ARB_compute_shader , GLL, GLC, x , x , 2012)
+EXT(ARB_compute_variable_group_size , ARB_compute_variable_group_size , GLL, GLC, x , x , 2013)
+EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GLL, GLC, x , x , 2014)
+EXT(ARB_conservative_depth , ARB_conservative_depth , GLL, GLC, x , x , 2011)
+EXT(ARB_copy_buffer , dummy_true , GLL, GLC, x , x , 2008)
+EXT(ARB_copy_image , ARB_copy_image , GLL, GLC, x , x , 2012)
+EXT(ARB_cull_distance , ARB_cull_distance , GLL, GLC, x , x , 2014)
+EXT(ARB_debug_output , dummy_true , GLL, GLC, x , x , 2009)
+EXT(ARB_depth_buffer_float , ARB_depth_buffer_float , GLL, GLC, x , x , 2008)
+EXT(ARB_depth_clamp , ARB_depth_clamp , GLL, GLC, x , x , 2003)
+EXT(ARB_depth_texture , ARB_depth_texture , GLL, x , x , x , 2001)
+EXT(ARB_derivative_control , ARB_derivative_control , GLL, GLC, x , x , 2014)
+EXT(ARB_direct_state_access , dummy_true , 31, GLC, x , x , 2014)
+EXT(ARB_draw_buffers , dummy_true , GLL, GLC, x , x , 2002)
+EXT(ARB_draw_buffers_blend , ARB_draw_buffers_blend , GLL, GLC, x , x , 2009)
+EXT(ARB_draw_elements_base_vertex , ARB_draw_elements_base_vertex , GLL, GLC, x , x , 2009)
+EXT(ARB_draw_indirect , ARB_draw_indirect , GLL, GLC, x , x , 2010)
+EXT(ARB_draw_instanced , ARB_draw_instanced , GLL, GLC, x , x , 2008)
+EXT(ARB_enhanced_layouts , ARB_enhanced_layouts , GLL, GLC, x , x , 2013)
+EXT(ARB_explicit_attrib_location , ARB_explicit_attrib_location , GLL, GLC, x , x , 2009)
+EXT(ARB_explicit_uniform_location , ARB_explicit_uniform_location , GLL, GLC, x , x , 2012)
+EXT(ARB_fragment_coord_conventions , ARB_fragment_coord_conventions , GLL, GLC, x , x , 2009)
+EXT(ARB_fragment_layer_viewport , ARB_fragment_layer_viewport , GLL, GLC, x , x , 2012)
+EXT(ARB_fragment_program , ARB_fragment_program , GLL, x , x , x , 2002)
+EXT(ARB_fragment_program_shadow , ARB_fragment_program_shadow , GLL, x , x , x , 2003)
+EXT(ARB_fragment_shader , ARB_fragment_shader , GLL, GLC, x , x , 2002)
+EXT(ARB_fragment_shader_interlock , ARB_fragment_shader_interlock , GLL, GLC, x , x , 2015)
+EXT(ARB_framebuffer_no_attachments , ARB_framebuffer_no_attachments , GLL, GLC, x , x , 2012)
+EXT(ARB_framebuffer_object , ARB_framebuffer_object , GLL, GLC, x , x , 2005)
+EXT(ARB_framebuffer_sRGB , EXT_framebuffer_sRGB , GLL, GLC, x , x , 1998)
+EXT(ARB_get_program_binary , dummy_true , GLL, GLC, x , x , 2010)
+EXT(ARB_get_texture_sub_image , dummy_true , GLL, GLC, x , x , 2014)
+EXT(ARB_gl_spirv , ARB_gl_spirv , GLL, GLC, x , x , 2016)
+EXT(ARB_gpu_shader5 , ARB_gpu_shader5 , GLL, GLC, x , x , 2010)
+EXT(ARB_gpu_shader_fp64 , ARB_gpu_shader_fp64 , 32, GLC, x , x , 2010)
+EXT(ARB_gpu_shader_int64 , ARB_gpu_shader_int64 , 40, GLC, x , x , 2015)
+EXT(ARB_half_float_pixel , dummy_true , GLL, GLC, x , x , 2003)
+EXT(ARB_half_float_vertex , ARB_half_float_vertex , GLL, GLC, x , x , 2008)
+EXT(ARB_indirect_parameters , ARB_indirect_parameters , GLL, GLC, x , x , 2013)
+EXT(ARB_instanced_arrays , ARB_instanced_arrays , GLL, GLC, x , x , 2008)
+EXT(ARB_internalformat_query , ARB_internalformat_query , GLL, GLC, x , x , 2011)
+EXT(ARB_internalformat_query2 , ARB_internalformat_query2 , GLL, GLC, x , x , 2013)
+EXT(ARB_invalidate_subdata , dummy_true , GLL, GLC, x , x , 2012)
+EXT(ARB_map_buffer_alignment , dummy_true , GLL, GLC, x , x , 2011)
+EXT(ARB_map_buffer_range , ARB_map_buffer_range , GLL, GLC, x , x , 2008)
+EXT(ARB_multi_bind , dummy_true , GLL, GLC, x , x , 2013)
+EXT(ARB_multi_draw_indirect , ARB_draw_indirect , GLL, GLC, x , x , 2012)
+EXT(ARB_multisample , dummy_true , GLL, x , x , x , 1994)
+EXT(ARB_multitexture , dummy_true , GLL, x , x , x , 1998)
+EXT(ARB_occlusion_query , ARB_occlusion_query , GLL, x , x , x , 2001)
+EXT(ARB_occlusion_query2 , ARB_occlusion_query2 , GLL, GLC, x , x , 2003)
+EXT(ARB_parallel_shader_compile , dummy_true , GLL, GLC, x , x , 2015)
+EXT(ARB_pipeline_statistics_query , ARB_pipeline_statistics_query , GLL, GLC, x , x , 2014)
+EXT(ARB_pixel_buffer_object , EXT_pixel_buffer_object , GLL, GLC, x , x , 2004)
+EXT(ARB_point_parameters , EXT_point_parameters , GLL, x , x , x , 1997)
+EXT(ARB_point_sprite , ARB_point_sprite , GLL, GLC, x , x , 2003)
+EXT(ARB_polygon_offset_clamp , ARB_polygon_offset_clamp , GLL, GLC, x , x , 2017)
+EXT(ARB_post_depth_coverage , ARB_post_depth_coverage , GLL, GLC, x , x, 2015)
+EXT(ARB_program_interface_query , dummy_true , GLL, GLC, x , x , 2012)
+EXT(ARB_provoking_vertex , EXT_provoking_vertex , GLL, GLC, x , x , 2009)
+EXT(ARB_query_buffer_object , ARB_query_buffer_object , GLL, GLC, x , x , 2013)
+EXT(ARB_robust_buffer_access_behavior , ARB_robust_buffer_access_behavior , GLL, GLC, x , x , 2012)
+EXT(ARB_robustness , dummy_true , GLL, GLC, x , x , 2010)
+EXT(ARB_sample_locations , ARB_sample_locations , GLL, GLC, x , x , 2015)
+EXT(ARB_sample_shading , ARB_sample_shading , GLL, GLC, x , x , 2009)
+EXT(ARB_sampler_objects , dummy_true , GLL, GLC, x , x , 2009)
+EXT(ARB_seamless_cube_map , ARB_seamless_cube_map , GLL, GLC, x , x , 2009)
+EXT(ARB_seamless_cubemap_per_texture , AMD_seamless_cubemap_per_texture , GLL, GLC, x , x , 2013)
+EXT(ARB_separate_shader_objects , dummy_true , GLL, GLC, x , x , 2010)
+EXT(ARB_shader_atomic_counter_ops , ARB_shader_atomic_counter_ops , GLL, GLC, x , x , 2015)
+EXT(ARB_shader_atomic_counters , ARB_shader_atomic_counters , GLL, GLC, x , x , 2011)
+EXT(ARB_shader_ballot , ARB_shader_ballot , GLL, GLC, x , x , 2015)
+EXT(ARB_shader_bit_encoding , ARB_shader_bit_encoding , GLL, GLC, x , x , 2010)
+EXT(ARB_shader_clock , ARB_shader_clock , GLL, GLC, x , x , 2015)
+EXT(ARB_shader_draw_parameters , ARB_shader_draw_parameters , GLL, GLC, x , x , 2013)
+EXT(ARB_shader_group_vote , ARB_shader_group_vote , GLL, GLC, x , x , 2013)
+EXT(ARB_shader_image_load_store , ARB_shader_image_load_store , GLL, GLC, x , x , 2011)
+EXT(ARB_shader_image_size , ARB_shader_image_size , GLL, GLC, x , x , 2012)
+EXT(ARB_shader_objects , dummy_true , GLL, GLC, x , x , 2002)
+EXT(ARB_shader_precision , ARB_shader_precision , GLL, GLC, x , x , 2010)
+EXT(ARB_shader_stencil_export , ARB_shader_stencil_export , GLL, GLC, x , x , 2009)
+EXT(ARB_shader_storage_buffer_object , ARB_shader_storage_buffer_object , GLL, GLC, x , x , 2012)
+EXT(ARB_shader_subroutine , dummy_true , 31, GLC, x , x , 2010)
+EXT(ARB_shader_texture_image_samples , ARB_shader_texture_image_samples , GLL, GLC, x , x , 2014)
+EXT(ARB_shader_texture_lod , ARB_shader_texture_lod , GLL, GLC, x , x , 2009)
+EXT(ARB_shader_viewport_layer_array , ARB_shader_viewport_layer_array , GLL, GLC, x , x , 2015)
+EXT(ARB_shading_language_100 , dummy_true , GLL, x , x , x , 2003)
+EXT(ARB_shading_language_420pack , ARB_shading_language_420pack , GLL, GLC, x , x , 2011)
+EXT(ARB_shading_language_include , dummy_true , GLL, GLC, x , x , 2013)
+EXT(ARB_shading_language_packing , ARB_shading_language_packing , GLL, GLC, x , x , 2011)
+EXT(ARB_shadow , ARB_shadow , GLL, x , x , x , 2001)
+EXT(ARB_sparse_buffer , ARB_sparse_buffer , GLL, GLC, x , x , 2014)
+EXT(ARB_spirv_extensions , ARB_spirv_extensions , GLL, GLC, x , x , 2016)
+EXT(ARB_stencil_texturing , ARB_stencil_texturing , GLL, GLC, x , x , 2012)
+EXT(ARB_sync , ARB_sync , GLL, GLC, x , x , 2003)
+EXT(ARB_tessellation_shader , ARB_tessellation_shader , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_barrier , NV_texture_barrier , GLL, GLC, x , x , 2014)
+EXT(ARB_texture_border_clamp , ARB_texture_border_clamp , GLL, x , x , x , 2000)
+EXT(ARB_texture_buffer_object , ARB_texture_buffer_object , GLL, GLC, x , x , 2008)
+EXT(ARB_texture_buffer_object_rgb32 , ARB_texture_buffer_object_rgb32 , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_buffer_range , ARB_texture_buffer_range , GLL, GLC, x , x , 2012)
+EXT(ARB_texture_compression , dummy_true , GLL, x , x , x , 2000)
+EXT(ARB_texture_compression_bptc , ARB_texture_compression_bptc , GLL, GLC, x , x , 2010)
+EXT(ARB_texture_compression_rgtc , ARB_texture_compression_rgtc , GLL, GLC, x , x , 2004)
+EXT(ARB_texture_cube_map , ARB_texture_cube_map , GLL, x , x , x , 1999)
+EXT(ARB_texture_cube_map_array , ARB_texture_cube_map_array , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_env_add , dummy_true , GLL, x , x , x , 1999)
+EXT(ARB_texture_env_combine , ARB_texture_env_combine , GLL, x , x , x , 2001)
+EXT(ARB_texture_env_crossbar , ARB_texture_env_crossbar , GLL, x , x , x , 2001)
+EXT(ARB_texture_env_dot3 , ARB_texture_env_dot3 , GLL, x , x , x , 2001)
+EXT(ARB_texture_filter_anisotropic , ARB_texture_filter_anisotropic , GLL, GLC, x , x , 2017)
+EXT(ARB_texture_float , ARB_texture_float , GLL, GLC, x , x , 2004)
+EXT(ARB_texture_gather , ARB_texture_gather , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_mirror_clamp_to_edge , ARB_texture_mirror_clamp_to_edge , GLL, GLC, x , x , 2013)
+EXT(ARB_texture_mirrored_repeat , dummy_true , GLL, x , x , x , 2001)
+EXT(ARB_texture_multisample , ARB_texture_multisample , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_non_power_of_two , ARB_texture_non_power_of_two , GLL, GLC, x , x , 2003)
+EXT(ARB_texture_query_levels , ARB_texture_query_levels , GLL, GLC, x , x , 2012)
+EXT(ARB_texture_query_lod , ARB_texture_query_lod , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_rectangle , NV_texture_rectangle , GLL, GLC, x , x , 2004)
+EXT(ARB_texture_rg , ARB_texture_rg , GLL, GLC, x , x , 2008)
+EXT(ARB_texture_rgb10_a2ui , ARB_texture_rgb10_a2ui , GLL, GLC, x , x , 2009)
+EXT(ARB_texture_stencil8 , ARB_texture_stencil8 , GLL, GLC, x , x , 2013)
+EXT(ARB_texture_storage , dummy_true , GLL, GLC, x , x , 2011)
+EXT(ARB_texture_storage_multisample , ARB_texture_multisample , GLL, GLC, x , x , 2012)
+EXT(ARB_texture_swizzle , EXT_texture_swizzle , GLL, GLC, x , x , 2008)
+EXT(ARB_texture_view , ARB_texture_view , GLL, GLC, x , x , 2012)
+EXT(ARB_timer_query , ARB_timer_query , GLL, GLC, x , x , 2010)
+EXT(ARB_transform_feedback2 , ARB_transform_feedback2 , GLL, GLC, x , x , 2010)
+EXT(ARB_transform_feedback3 , ARB_transform_feedback3 , GLL, GLC, x , x , 2010)
+EXT(ARB_transform_feedback_instanced , ARB_transform_feedback_instanced , GLL, GLC, x , x , 2011)
+EXT(ARB_transform_feedback_overflow_query , ARB_transform_feedback_overflow_query , GLL, GLC, x , x , 2014)
+EXT(ARB_transpose_matrix , dummy_true , GLL, x , x , x , 1999)
+EXT(ARB_uniform_buffer_object , ARB_uniform_buffer_object , GLL, GLC, x , x , 2009)
+EXT(ARB_vertex_array_bgra , EXT_vertex_array_bgra , GLL, GLC, x , x , 2008)
+EXT(ARB_vertex_array_object , dummy_true , GLL, GLC, x , x , 2006)
+EXT(ARB_vertex_attrib_64bit , ARB_vertex_attrib_64bit , 32, GLC, x , x , 2010)
+EXT(ARB_vertex_attrib_binding , dummy_true , GLL, GLC, x , x , 2012)
+EXT(ARB_vertex_buffer_object , dummy_true , GLL, GLC, x , x , 2003)
+EXT(ARB_vertex_program , ARB_vertex_program , GLL, x , x , x , 2002)
+EXT(ARB_vertex_shader , ARB_vertex_shader , GLL, GLC, x , x , 2002)
+EXT(ARB_vertex_type_10f_11f_11f_rev , ARB_vertex_type_10f_11f_11f_rev , GLL, GLC, x , x , 2013)
+EXT(ARB_vertex_type_2_10_10_10_rev , ARB_vertex_type_2_10_10_10_rev , GLL, GLC, x , x , 2009)
+EXT(ARB_viewport_array , ARB_viewport_array , GLL, GLC, x , x , 2010)
+EXT(ARB_window_pos , dummy_true , GLL, x , x , x , 2001)
+
+EXT(ATI_blend_equation_separate , EXT_blend_equation_separate , GLL, GLC, x , x , 2003)
+EXT(ATI_draw_buffers , dummy_true , GLL, x , x , x , 2002)
+EXT(ATI_fragment_shader , ATI_fragment_shader , GLL, x , x , x , 2001)
+EXT(ATI_meminfo , ATI_meminfo , GLL, GLC, x , x , 2009)
+EXT(ATI_separate_stencil , EXT_stencil_two_side , GLL, x , x , x , 2006)
+EXT(ATI_texture_compression_3dc , ATI_texture_compression_3dc , GLL, x , x , x , 2004)
+EXT(ATI_texture_env_combine3 , ATI_texture_env_combine3 , GLL, x , x , x , 2002)
+EXT(ATI_texture_float , ARB_texture_float , GLL, GLC, x , x , 2002)
+EXT(ATI_texture_mirror_once , ATI_texture_mirror_once , GLL, GLC, x , x , 2006)
+
+EXT(EXT_EGL_image_storage , EXT_EGL_image_storage , GLL, GLC , x , 30, 2018)
+EXT(EXT_EGL_sync , dummy_true , GLL, GLC, x , x , 2019)
+EXT(EXT_abgr , dummy_true , GLL, GLC, x , x , 1995)
+EXT(EXT_base_instance , ARB_base_instance , x , x , x , 30, 2014)
+EXT(EXT_bgra , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_blend_color , EXT_blend_color , GLL, x , x , x , 1995)
+EXT(EXT_blend_equation_separate , EXT_blend_equation_separate , GLL, GLC, x , x , 2003)
+EXT(EXT_blend_func_extended , ARB_blend_func_extended , x , x , x , ES2, 2015)
+EXT(EXT_blend_func_separate , EXT_blend_func_separate , GLL, x , x , x , 1999)
+EXT(EXT_blend_minmax , EXT_blend_minmax , GLL, x , ES1, ES2, 1995)
+EXT(EXT_blend_subtract , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_buffer_storage , ARB_buffer_storage , x , x , x , 31, 2015)
+EXT(EXT_clip_control , ARB_clip_control , x , x , x , ES2, 2017)
+EXT(EXT_clip_cull_distance , ARB_cull_distance , x , x , x , 30, 2016)
+EXT(EXT_color_buffer_float , dummy_true , x , x , x , 30, 2013)
+EXT(EXT_compiled_vertex_array , dummy_true , GLL, x , x , x , 1996)
+EXT(EXT_compressed_ETC1_RGB8_sub_texture , OES_compressed_ETC1_RGB8_texture , x , x , ES1, ES2, 2014)
+EXT(EXT_copy_image , OES_copy_image , x , x , x , 30, 2014)
+EXT(EXT_copy_texture , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_demote_to_helper_invocation , EXT_demote_to_helper_invocation , GLL, GLC, ES1, ES2, 2019)
+EXT(EXT_depth_bounds_test , EXT_depth_bounds_test , GLL, GLC, x , x , 2002)
+EXT(EXT_depth_clamp , ARB_depth_clamp , x , x , x , ES2, 2019)
+EXT(EXT_direct_state_access , dummy_true , GLL, x , x , x , 2010)
+EXT(EXT_discard_framebuffer , dummy_true , x , x , ES1, ES2, 2009)
+EXT(EXT_disjoint_timer_query , EXT_disjoint_timer_query , x , x , x , ES2, 2016)
+EXT(EXT_draw_buffers , dummy_true , x , x , x , ES2, 2012)
+EXT(EXT_draw_buffers2 , EXT_draw_buffers2 , GLL, GLC, x , x , 2006)
+EXT(EXT_draw_buffers_indexed , ARB_draw_buffers_blend , x , x , x , 30, 2014)
+EXT(EXT_draw_elements_base_vertex , ARB_draw_elements_base_vertex , x , x , x , ES2, 2014)
+EXT(EXT_draw_instanced , ARB_draw_instanced , GLL, GLC, x , ES2 , 2006)
+EXT(EXT_draw_range_elements , dummy_true , GLL, x , x , x , 1997)
+EXT(EXT_float_blend , EXT_float_blend , x , x , x , 30, 2015)
+EXT(EXT_fog_coord , dummy_true , GLL, x , x , x , 1999)
+EXT(EXT_frag_depth , dummy_true , x , x , x , ES2, 2010)
+EXT(EXT_framebuffer_blit , dummy_true , GLL, GLC, x , x , 2005)
+EXT(EXT_framebuffer_multisample , EXT_framebuffer_multisample , GLL, GLC, x , x , 2005)
+EXT(EXT_framebuffer_multisample_blit_scaled , EXT_framebuffer_multisample_blit_scaled, GLL, GLC, x , x , 2011)
+EXT(EXT_framebuffer_object , dummy_true , GLL, GLC, x , x , 2000)
+EXT(EXT_framebuffer_sRGB , EXT_framebuffer_sRGB , GLL, GLC, x , x , 1998)
+EXT(EXT_geometry_point_size , OES_geometry_shader , x , x , x , 31, 2015)
+EXT(EXT_geometry_shader , OES_geometry_shader , x , x , x , 31, 2015)
+EXT(EXT_gpu_program_parameters , EXT_gpu_program_parameters , GLL, x , x , x , 2006)
+/* Since all of EXT_gpu_shader4 features were rolled into GLSL 1.40, it shouldn't be exposed in a core context.
+ * Additionally, EXT_gpu_shader4 would reintroduce functions that were removed in GLSL 1.40. */
+EXT(EXT_gpu_shader4 , EXT_gpu_shader4 , GLL, x , x , x , 2006)
+EXT(EXT_gpu_shader5 , ARB_gpu_shader5 , x , x , x , 31, 2014)
+EXT(EXT_map_buffer_range , ARB_map_buffer_range , x , x , ES1, ES2, 2012)
+EXT(EXT_memory_object , EXT_memory_object , GLL, GLC, x , ES2, 2017)
+EXT(EXT_memory_object_fd , EXT_memory_object_fd , GLL, GLC, x , ES2, 2017)
+EXT(EXT_multi_draw_arrays , dummy_true , GLL, x , ES1, ES2, 1999)
+EXT(EXT_multisampled_render_to_texture , EXT_multisampled_render_to_texture , x , x , x , ES2, 2016)
+EXT(EXT_multisampled_render_to_texture2 , EXT_multisampled_render_to_texture , x , x , x , ES2, 2016)
+EXT(EXT_occlusion_query_boolean , ARB_occlusion_query2 , x , x , x , ES2, 2011)
+EXT(EXT_packed_depth_stencil , dummy_true , GLL, GLC, x , x , 2005)
+EXT(EXT_packed_float , EXT_packed_float , GLL, GLC, x , x , 2004)
+EXT(EXT_packed_pixels , dummy_true , GLL, x , x , x , 1997)
+EXT(EXT_pixel_buffer_object , EXT_pixel_buffer_object , GLL, GLC, x , x , 2004)
+EXT(EXT_point_parameters , EXT_point_parameters , GLL, x , x , x , 1997)
+EXT(EXT_polygon_offset_clamp , ARB_polygon_offset_clamp , GLL, GLC, ES1, ES2, 2014)
+EXT(EXT_primitive_bounding_box , OES_primitive_bounding_box , x , x , x , 31, 2014)
+EXT(EXT_provoking_vertex , EXT_provoking_vertex , GLL, GLC, x , x , 2009)
+EXT(EXT_read_format_bgra , dummy_true , x , x , ES1, ES2, 2009)
+EXT(EXT_render_snorm , EXT_render_snorm , x , x , x, 31, 2014)
+EXT(EXT_rescale_normal , dummy_true , GLL, x , x , x , 1997)
+EXT(EXT_robustness , KHR_robustness , x, x, x , ES2, 2011)
+EXT(EXT_sRGB_write_control , EXT_framebuffer_sRGB , x, x , x , 30, 2013)
+EXT(EXT_secondary_color , dummy_true , GLL, x , x , x , 1999)
+EXT(EXT_semaphore , EXT_semaphore , GLL, GLC, x , ES2, 2017)
+EXT(EXT_semaphore_fd , EXT_semaphore_fd , GLL, GLC, x , ES2, 2017)
+EXT(EXT_separate_shader_objects , dummy_true , x , x , x , ES2, 2013)
+EXT(EXT_separate_specular_color , dummy_true , GLL, x , x , x , 1997)
+EXT(EXT_shader_framebuffer_fetch , EXT_shader_framebuffer_fetch , GLL, GLC, x , ES2, 2013)
+EXT(EXT_shader_framebuffer_fetch_non_coherent, EXT_shader_framebuffer_fetch_non_coherent, GLL, GLC, x, ES2, 2018)
+EXT(EXT_shader_image_load_formatted , EXT_shader_image_load_formatted , GLL, GLC, x , x , 2014)
+EXT(EXT_shader_image_load_store , EXT_shader_image_load_store , GLL, GLC, x , x , 2010)
+EXT(EXT_shader_implicit_conversions , dummy_true , x , x , x , 31, 2013)
+EXT(EXT_shader_integer_mix , EXT_shader_integer_mix , GLL, GLC, x , 30, 2013)
+EXT(EXT_shader_io_blocks , dummy_true , x , x , x , 31, 2014)
+EXT(EXT_shader_samples_identical , EXT_shader_samples_identical , GLL, GLC, x , 31, 2015)
+EXT(EXT_shadow_funcs , ARB_shadow , GLL, x , x , x , 2002)
+EXT(EXT_stencil_two_side , EXT_stencil_two_side , GLL, x , x , x , 2001)
+EXT(EXT_stencil_wrap , dummy_true , GLL, x , x , x , 2002)
+EXT(EXT_subtexture , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_tessellation_point_size , ARB_tessellation_shader , x , x , x , 31, 2013)
+EXT(EXT_tessellation_shader , ARB_tessellation_shader , x , x , x , 31, 2013)
+EXT(EXT_texture , dummy_true , GLL, x , x , x , 1996)
+EXT(EXT_texture3D , dummy_true , GLL, x , x , x , 1996)
+EXT(EXT_texture_array , EXT_texture_array , GLL, GLC, x , x , 2006)
+EXT(EXT_texture_border_clamp , ARB_texture_border_clamp , x , x , x , ES2, 2014)
+EXT(EXT_texture_buffer , OES_texture_buffer , x , x , x , 31, 2014)
+EXT(EXT_texture_buffer_object , EXT_texture_buffer_object , GLL, x , x , x , 2007)
+EXT(EXT_texture_compression_bptc , ARB_texture_compression_bptc , x , x , x , 30, 2017)
+EXT(EXT_texture_compression_dxt1 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2004)
+EXT(EXT_texture_compression_latc , EXT_texture_compression_latc , GLL, x , x , x , 2006)
+EXT(EXT_texture_compression_rgtc , ARB_texture_compression_rgtc , GLL, GLC, x , 30, 2004)
+EXT(EXT_texture_compression_s3tc , EXT_texture_compression_s3tc , GLL, GLC, x , ES2, 2000)
+EXT(EXT_texture_compression_s3tc_srgb , EXT_texture_compression_s3tc_srgb , x , x, x , ES2, 2016)
+EXT(EXT_texture_cube_map , ARB_texture_cube_map , GLL, x , x , x , 2001)
+EXT(EXT_texture_cube_map_array , OES_texture_cube_map_array , x , x , x , 31, 2014)
+EXT(EXT_texture_edge_clamp , dummy_true , GLL, x , x , x , 1997)
+EXT(EXT_texture_env_add , dummy_true , GLL, x , x , x , 1999)
+EXT(EXT_texture_env_combine , dummy_true , GLL, x , x , x , 2000)
+EXT(EXT_texture_env_dot3 , EXT_texture_env_dot3 , GLL, x , x , x , 2000)
+EXT(EXT_texture_filter_anisotropic , EXT_texture_filter_anisotropic , GLL, GLC, ES1, ES2, 1999)
+EXT(EXT_texture_format_BGRA8888 , dummy_true , x , x , ES1, ES2, 2005)
+EXT(EXT_texture_integer , EXT_texture_integer , GLL, GLC, x , x , 2006)
+EXT(EXT_texture_lod_bias , dummy_true , GLL, x , ES1, x , 1999)
+EXT(EXT_texture_mirror_clamp , EXT_texture_mirror_clamp , GLL, GLC, x , x , 2004)
+EXT(EXT_texture_norm16 , EXT_texture_norm16 , x , x , x , 31, 2014)
+EXT(EXT_texture_object , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_texture_query_lod , ARB_texture_query_lod , x , x , x , 30, 2019)
+EXT(EXT_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2004)
+EXT(EXT_texture_rg , ARB_texture_rg , x , x , x , ES2, 2011)
+EXT(EXT_texture_sRGB , EXT_texture_sRGB , GLL, GLC, x , x , 2004)
+EXT(EXT_texture_sRGB_R8 , EXT_texture_sRGB_R8 , GLL ,GLC, x , 30, 2018)
+EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode , GLL, GLC, x , 30, 2006)
+EXT(EXT_texture_shadow_lod , EXT_texture_shadow_lod , GLL, GLC, x , 30, 2018)
+EXT(EXT_texture_shared_exponent , EXT_texture_shared_exponent , GLL, GLC, x , x , 2004)
+EXT(EXT_texture_snorm , EXT_texture_snorm , GLL, GLC, x , x , 2009)
+EXT(EXT_texture_swizzle , EXT_texture_swizzle , GLL, GLC, x , x , 2008)
+EXT(EXT_texture_type_2_10_10_10_REV , EXT_texture_type_2_10_10_10_REV , x , x , x , ES2, 2008)
+EXT(EXT_texture_view , OES_texture_view , x , x , x , 31, 2014)
+EXT(EXT_timer_query , EXT_timer_query , GLL, GLC, x , x , 2006)
+EXT(EXT_transform_feedback , EXT_transform_feedback , GLL, GLC, x , x , 2011)
+EXT(EXT_unpack_subimage , dummy_true , x , x , x , ES2, 2011)
+EXT(EXT_vertex_array , dummy_true , GLL, x , x , x , 1995)
+EXT(EXT_vertex_array_bgra , EXT_vertex_array_bgra , GLL, GLC, x , x , 2008)
+EXT(EXT_vertex_attrib_64bit , ARB_vertex_attrib_64bit , 32, GLC, x , x , 2010)
+EXT(EXT_window_rectangles , EXT_window_rectangles , GLL, GLC, x , 30, 2016)
+
+EXT(GREMEDY_string_marker , GREMEDY_string_marker , GLL, GLC, x , x , 2007)
+
+EXT(IBM_multimode_draw_arrays , dummy_true , GLL, GLC, x , x , 1998)
+EXT(IBM_rasterpos_clip , dummy_true , GLL, x , x , x , 1996)
+EXT(IBM_texture_mirrored_repeat , dummy_true , GLL, x , x , x , 1998)
+
+EXT(INGR_blend_func_separate , EXT_blend_func_separate , GLL, x , x , x , 1999)
+
+EXT(INTEL_blackhole_render , INTEL_blackhole_render , 30, 30, x , ES2, 2018)
+EXT(INTEL_conservative_rasterization , INTEL_conservative_rasterization , x , GLC, x , 31, 2013)
+EXT(INTEL_performance_query , INTEL_performance_query , GLL, GLC, x , ES2, 2013)
+EXT(INTEL_shader_atomic_float_minmax , INTEL_shader_atomic_float_minmax , GLL, GLC, x , x , 2018)
+EXT(INTEL_shader_integer_functions2 , INTEL_shader_integer_functions2 , GLL, GLC, x , x , 2018)
+
+EXT(KHR_blend_equation_advanced , KHR_blend_equation_advanced , GLL, GLC, x , ES2, 2014)
+EXT(KHR_blend_equation_advanced_coherent , KHR_blend_equation_advanced_coherent , GLL, GLC, x , ES2, 2014)
+EXT(KHR_context_flush_control , dummy_true , GLL, GLC, x , ES2, 2014)
+EXT(KHR_debug , dummy_true , GLL, GLC, 11, ES2, 2012)
+EXT(KHR_no_error , dummy_true , GLL, GLC, ES1, ES2, 2015)
+EXT(KHR_parallel_shader_compile , dummy_true , GLL, GLC, x , ES2, 2017)
+EXT(KHR_robust_buffer_access_behavior , ARB_robust_buffer_access_behavior , GLL, GLC, x , ES2, 2014)
+EXT(KHR_robustness , KHR_robustness , GLL, GLC, x , ES2, 2012)
+EXT(KHR_texture_compression_astc_hdr , KHR_texture_compression_astc_hdr , GLL, GLC, x , ES2, 2012)
+EXT(KHR_texture_compression_astc_ldr , KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012)
+EXT(KHR_texture_compression_astc_sliced_3d , KHR_texture_compression_astc_sliced_3d , GLL, GLC, x , ES2, 2015)
+
+EXT(MESA_framebuffer_flip_y , MESA_framebuffer_flip_y , 43, 43, x , 30, 2018)
+EXT(MESA_pack_invert , MESA_pack_invert , GLL, GLC, x , x , 2002)
+EXT(MESA_shader_integer_functions , MESA_shader_integer_functions , GLL, GLC, x , 30, 2016)
+EXT(MESA_texture_signed_rgba , EXT_texture_snorm , GLL, GLC, x , x , 2009)
+EXT(MESA_tile_raster_order , MESA_tile_raster_order , GLL, GLC, x , ES2, 2017)
+EXT(MESA_window_pos , dummy_true , GLL, x , x , x , 2000)
+EXT(MESA_ycbcr_texture , MESA_ycbcr_texture , GLL, GLC, x , x , 2002)
+
+EXT(NVX_gpu_memory_info , NVX_gpu_memory_info , GLL, GLC, x , x , 2013)
+
+EXT(NV_alpha_to_coverage_dither_control , NV_alpha_to_coverage_dither_control , GLL, GLC, x , ES2, 2017)
+EXT(NV_blend_square , dummy_true , GLL, x , x , x , 1999)
+EXT(NV_compute_shader_derivatives , NV_compute_shader_derivatives , GLL, GLC, x , 32, 2018)
+EXT(NV_conditional_render , NV_conditional_render , GLL, GLC, x , ES2, 2008)
+EXT(NV_conservative_raster , NV_conservative_raster , GLL, GLC, ES1, ES2, 2015)
+EXT(NV_conservative_raster_dilate , NV_conservative_raster_dilate , GLL, GLC, ES1, ES2, 2015)
+EXT(NV_conservative_raster_pre_snap , NV_conservative_raster_pre_snap , GLL, GLC, ES1, ES2, 2017)
+EXT(NV_conservative_raster_pre_snap_triangles, NV_conservative_raster_pre_snap_triangles, GLL, GLC, ES1, ES2, 2015)
+EXT(NV_copy_image , NV_copy_image , GLL, GLC, x , x, 2009)
+EXT(NV_depth_clamp , ARB_depth_clamp , GLL, GLC, x , x , 2001)
+EXT(NV_draw_buffers , dummy_true , x , x , x , ES2, 2011)
+EXT(NV_fbo_color_attachments , dummy_true , x , x , x , ES2, 2010)
+EXT(NV_fill_rectangle , NV_fill_rectangle , GLL, GLC, x , x , 2015)
+EXT(NV_fog_distance , NV_fog_distance , GLL, x , x , x , 2001)
+EXT(NV_fragment_shader_interlock , ARB_fragment_shader_interlock , GLL, GLC, x , 31, 2015)
+EXT(NV_image_formats , ARB_shader_image_load_store , x , x , x , 31, 2014)
+EXT(NV_light_max_exponent , dummy_true , GLL, x , x , x , 1999)
+EXT(NV_packed_depth_stencil , dummy_true , GLL, GLC, x , x , 2000)
+EXT(NV_pixel_buffer_object , EXT_pixel_buffer_object , x , x , x , ES2, 2012)
+EXT(NV_point_sprite , NV_point_sprite , GLL, GLC, x , x , 2001)
+EXT(NV_primitive_restart , NV_primitive_restart , GLL, x , x , x , 2002)
+EXT(NV_read_buffer , dummy_true , x , x , x , ES2, 2011)
+EXT(NV_read_depth , dummy_true , x , x , x , ES2, 2011)
+EXT(NV_read_depth_stencil , dummy_true , x , x , x , ES2, 2011)
+EXT(NV_read_stencil , dummy_true , x , x , x , ES2, 2011)
+EXT(NV_sample_locations , ARB_sample_locations , GLL, GLC, x , ES2, 2015)
+EXT(NV_shader_atomic_float , NV_shader_atomic_float , GLL, GLC, x , x , 2012)
+EXT(NV_texgen_reflection , dummy_true , GLL, x , x , x , 1999)
+EXT(NV_texture_barrier , NV_texture_barrier , GLL, GLC, x , x , 2009)
+EXT(NV_texture_env_combine4 , NV_texture_env_combine4 , GLL, x , x , x , 1999)
+EXT(NV_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2000)
+EXT(NV_vdpau_interop , NV_vdpau_interop , GLL, GLC, x , x , 2010)
+EXT(NV_viewport_array2 , NV_viewport_array2 , GLL, GLC, x , 31, 2015)
+EXT(NV_viewport_swizzle , NV_viewport_swizzle , GLL, GLC, x , 31, 2015)
+
+EXT(OES_EGL_image , OES_EGL_image , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */
+EXT(OES_EGL_image_external , OES_EGL_image_external , x , x , ES1, ES2, 2010)
+EXT(OES_EGL_image_external_essl3 , OES_EGL_image_external , x , x , x , 30, 2015)
+EXT(OES_EGL_sync , dummy_true , x , x , ES1, ES2, 2010)
+EXT(OES_blend_equation_separate , EXT_blend_equation_separate , x , x , ES1, x , 2009)
+EXT(OES_blend_func_separate , EXT_blend_func_separate , x , x , ES1, x , 2009)
+EXT(OES_blend_subtract , dummy_true , x , x , ES1, x , 2009)
+EXT(OES_byte_coordinates , dummy_true , x , x , ES1, x , 2002)
+EXT(OES_compressed_ETC1_RGB8_texture , OES_compressed_ETC1_RGB8_texture , x , x , ES1, ES2, 2005)
+EXT(OES_compressed_paletted_texture , dummy_true , x , x , ES1, x , 2003)
+EXT(OES_copy_image , OES_copy_image , x , x , x , 30, 2014)
+EXT(OES_depth24 , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_depth32 , dummy_false , x , x , x , x , 2005)
+EXT(OES_depth_texture , ARB_depth_texture , x , x , x , ES2, 2006)
+EXT(OES_depth_texture_cube_map , OES_depth_texture_cube_map , x , x , x , ES2, 2012)
+EXT(OES_draw_buffers_indexed , ARB_draw_buffers_blend , x , x , x , 30, 2014)
+EXT(OES_draw_elements_base_vertex , ARB_draw_elements_base_vertex , x , x , x , ES2, 2014)
+EXT(OES_draw_texture , OES_draw_texture , x , x , ES1, x , 2004)
+EXT(OES_element_index_uint , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_fbo_render_mipmap , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_fixed_point , dummy_true , x , x , ES1, x , 2002)
+EXT(OES_framebuffer_object , dummy_true , x , x , ES1, x , 2005)
+EXT(OES_geometry_point_size , OES_geometry_shader , x , x , x , 31, 2015)
+EXT(OES_geometry_shader , OES_geometry_shader , x , x , x , 31, 2015)
+EXT(OES_get_program_binary , dummy_true , x , x , x , ES2, 2008)
+EXT(OES_gpu_shader5 , ARB_gpu_shader5 , x , x , x , 31, 2014)
+EXT(OES_mapbuffer , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_packed_depth_stencil , dummy_true , x , x , ES1, ES2, 2007)
+EXT(OES_point_size_array , dummy_true , x , x , ES1, x , 2004)
+EXT(OES_point_sprite , ARB_point_sprite , x , x , ES1, x , 2004)
+EXT(OES_primitive_bounding_box , OES_primitive_bounding_box , x , x , x , 31, 2014)
+EXT(OES_query_matrix , dummy_true , x , x , ES1, x , 2003)
+EXT(OES_read_format , dummy_true , GLL, x , ES1, x , 2003)
+EXT(OES_required_internalformat , dummy_true , x , x , ES1, ES2, 2012)
+EXT(OES_rgb8_rgba8 , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_sample_shading , OES_sample_variables , x , x , x , 30, 2014)
+EXT(OES_sample_variables , OES_sample_variables , x , x , x , 30, 2014)
+EXT(OES_shader_image_atomic , ARB_shader_image_load_store , x , x , x , 31, 2015)
+EXT(OES_shader_io_blocks , dummy_true , x , x , x , 31, 2014)
+EXT(OES_shader_multisample_interpolation , OES_sample_variables , x , x , x , 30, 2014)
+EXT(OES_single_precision , dummy_true , x , x , ES1, x , 2003)
+EXT(OES_standard_derivatives , OES_standard_derivatives , x , x , x , ES2, 2005)
+EXT(OES_stencil1 , dummy_false , x , x , x , x , 2005)
+EXT(OES_stencil4 , dummy_false , x , x , x , x , 2005)
+EXT(OES_stencil8 , dummy_true , x , x , ES1, ES2, 2005)
+EXT(OES_stencil_wrap , dummy_true , x , x , ES1, x , 2002)
+EXT(OES_surfaceless_context , dummy_true , x , x , ES1, ES2, 2012)
+EXT(OES_tessellation_point_size , ARB_tessellation_shader , x , x , x , 31, 2014)
+EXT(OES_tessellation_shader , ARB_tessellation_shader , x , x , x , 31, 2014)
+EXT(OES_texture_3D , dummy_true , x , x , x , ES2, 2005)
+EXT(OES_texture_border_clamp , ARB_texture_border_clamp , x , x , x , ES2, 2014)
+EXT(OES_texture_buffer , OES_texture_buffer , x , x , x , 31, 2014)
+EXT(OES_texture_compression_astc , OES_texture_compression_astc , x , x , ES1, ES2, 2015)
+EXT(OES_texture_cube_map , ARB_texture_cube_map , x , x , ES1, x , 2007)
+EXT(OES_texture_cube_map_array , OES_texture_cube_map_array , x , x , x , 31, 2014)
+EXT(OES_texture_env_crossbar , ARB_texture_env_crossbar , x , x , ES1, x , 2005)
+EXT(OES_texture_float , OES_texture_float , x , x , x , ES2, 2005)
+EXT(OES_texture_float_linear , OES_texture_float_linear , x , x , x , ES2, 2005)
+EXT(OES_texture_half_float , OES_texture_half_float , x , x , x , ES2, 2005)
+EXT(OES_texture_half_float_linear , OES_texture_half_float_linear , x , x , x , ES2, 2005)
+EXT(OES_texture_mirrored_repeat , dummy_true , x , x , ES1, x , 2005)
+EXT(OES_texture_npot , ARB_texture_non_power_of_two , x , x , ES1, ES2, 2005)
+EXT(OES_texture_stencil8 , ARB_texture_stencil8 , x , x , x , 30, 2014)
+EXT(OES_texture_storage_multisample_2d_array, ARB_texture_multisample , x , x , x , 31, 2014)
+EXT(OES_texture_view , OES_texture_view , x , x , x , 31, 2014)
+EXT(OES_vertex_array_object , dummy_true , x , x , ES1, ES2, 2010)
+EXT(OES_vertex_half_float , ARB_half_float_vertex , x , x , x , ES2, 2005)
+EXT(OES_viewport_array , OES_viewport_array , x , x , x , 31, 2010)
+
+EXT(S3_s3tc , ANGLE_texture_compression_dxt , GLL, GLC, x , x , 1999)
+
+EXT(SGIS_generate_mipmap , dummy_true , GLL, x , x , x , 1997)
+EXT(SGIS_texture_border_clamp , ARB_texture_border_clamp , GLL, x , x , x , 1997)
+EXT(SGIS_texture_edge_clamp , dummy_true , GLL, x , x , x , 1997)
+EXT(SGIS_texture_lod , dummy_true , GLL, x , x , x , 1997)
+
+EXT(SUN_multi_draw_arrays , dummy_true , GLL, x , x , x , 1999)
+#undef GLL
+#undef GLC
+#undef ES1
+#undef ES2
+#undef x
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/formats.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/formats.h
new file mode 100644
index 0000000000..f0e58b327e
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/formats.h
@@ -0,0 +1,749 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Brian Paul
+ */
+
+
+#ifndef FORMATS_H
+#define FORMATS_H
+
+
+#include <GL/gl.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include "gallium/include/pipe/p_format.h"
+#include "util/u_endian.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type
+ * for GL_LUMINANCE4_ALPHA4.
+ */
+#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1)
+
+
+/**
+ * Max number of bytes for any non-compressed pixel format below, or for
+ * intermediate pixel storage in Mesa. This should never be less than
+ * 16. Maybe 32 someday?
+ */
+#define MAX_PIXEL_BYTES 16
+
+/**
+ * Specifies the layout of a pixel format. See the MESA_FORMAT
+ * documentation below.
+ */
+enum mesa_format_layout {
+ MESA_FORMAT_LAYOUT_ARRAY,
+ MESA_FORMAT_LAYOUT_PACKED,
+ MESA_FORMAT_LAYOUT_S3TC,
+ MESA_FORMAT_LAYOUT_RGTC,
+ MESA_FORMAT_LAYOUT_LATC,
+ MESA_FORMAT_LAYOUT_FXT1,
+ MESA_FORMAT_LAYOUT_ETC1,
+ MESA_FORMAT_LAYOUT_ETC2,
+ MESA_FORMAT_LAYOUT_BPTC,
+ MESA_FORMAT_LAYOUT_ASTC,
+ MESA_FORMAT_LAYOUT_ATC,
+ MESA_FORMAT_LAYOUT_OTHER,
+};
+
+/**
+ * An enum representing different possible swizzling values. This is used
+ * to interpret the output of _mesa_get_format_swizzle
+ */
+enum {
+ MESA_FORMAT_SWIZZLE_X = 0,
+ MESA_FORMAT_SWIZZLE_Y = 1,
+ MESA_FORMAT_SWIZZLE_Z = 2,
+ MESA_FORMAT_SWIZZLE_W = 3,
+ MESA_FORMAT_SWIZZLE_ZERO = 4,
+ MESA_FORMAT_SWIZZLE_ONE = 5,
+ MESA_FORMAT_SWIZZLE_NONE = 6,
+};
+
+/**
+ * An uint32_t that encodes the information necessary to represent an
+ * array format
+ */
+typedef uint32_t mesa_array_format;
+
+/**
+ * Encoding for valid array format data types
+ */
+enum mesa_array_format_datatype {
+ MESA_ARRAY_FORMAT_TYPE_UBYTE = 0x0,
+ MESA_ARRAY_FORMAT_TYPE_USHORT = 0x1,
+ MESA_ARRAY_FORMAT_TYPE_UINT = 0x2,
+ MESA_ARRAY_FORMAT_TYPE_BYTE = 0x4,
+ MESA_ARRAY_FORMAT_TYPE_SHORT = 0x5,
+ MESA_ARRAY_FORMAT_TYPE_INT = 0x6,
+ MESA_ARRAY_FORMAT_TYPE_HALF = 0xd,
+ MESA_ARRAY_FORMAT_TYPE_FLOAT = 0xe,
+};
+
+enum mesa_array_format_base_format {
+ MESA_ARRAY_FORMAT_BASE_FORMAT_RGBA_VARIANTS = 0x0,
+ MESA_ARRAY_FORMAT_BASE_FORMAT_DEPTH = 0x1,
+ MESA_ARRAY_FORMAT_BASE_FORMAT_STENCIL = 0x2,
+};
+
+/**
+ * An enum useful to encode/decode information stored in a mesa_array_format
+ */
+enum {
+ MESA_ARRAY_FORMAT_TYPE_IS_SIGNED = 0x4,
+ MESA_ARRAY_FORMAT_TYPE_IS_FLOAT = 0x8,
+ MESA_ARRAY_FORMAT_TYPE_NORMALIZED = 0x10,
+ MESA_ARRAY_FORMAT_DATATYPE_MASK = 0xf,
+ MESA_ARRAY_FORMAT_TYPE_MASK = 0x1f,
+ MESA_ARRAY_FORMAT_TYPE_SIZE_MASK = 0x3,
+ MESA_ARRAY_FORMAT_NUM_CHANS_MASK = 0xe0,
+ MESA_ARRAY_FORMAT_SWIZZLE_X_MASK = 0x00700,
+ MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK = 0x03800,
+ MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK = 0x1c000,
+ MESA_ARRAY_FORMAT_SWIZZLE_W_MASK = 0xe0000,
+ MESA_ARRAY_FORMAT_BASE_FORMAT_MASK = 0x300000,
+ MESA_ARRAY_FORMAT_BIT = 0x80000000
+};
+
+#define MESA_ARRAY_FORMAT(BASE_FORMAT, SIZE, SIGNED, IS_FLOAT, NORM, NUM_CHANS, \
+ SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) ( \
+ (((SIZE >> 1) ) & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK) | \
+ (((SIGNED) << 2 ) & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) | \
+ (((IS_FLOAT) << 3 ) & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) | \
+ (((NORM) << 4 ) & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) | \
+ (((NUM_CHANS) << 5 ) & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) | \
+ (((SWIZZLE_X) << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) | \
+ (((SWIZZLE_Y) << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) | \
+ (((SWIZZLE_Z) << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) | \
+ (((SWIZZLE_W) << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) | \
+ (((BASE_FORMAT) << 20) & MESA_ARRAY_FORMAT_BASE_FORMAT_MASK) | \
+ MESA_ARRAY_FORMAT_BIT)
+
+/**
+ * Various helpers to access the data encoded in a mesa_array_format
+ */
+static inline bool
+_mesa_array_format_is_signed(mesa_array_format f)
+{
+ return (f & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) != 0;
+}
+
+static inline bool
+_mesa_array_format_is_float(mesa_array_format f)
+{
+ return (f & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) != 0;
+}
+
+static inline bool
+_mesa_array_format_is_normalized(mesa_array_format f)
+{
+ return (f & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) !=0;
+}
+
+static inline enum mesa_array_format_base_format
+_mesa_array_format_get_base_format(mesa_array_format f)
+{
+ return (enum mesa_array_format_base_format)
+ ((f & MESA_ARRAY_FORMAT_BASE_FORMAT_MASK) >> 20);
+}
+
+static inline enum mesa_array_format_datatype
+_mesa_array_format_get_datatype(mesa_array_format f)
+{
+ return (enum mesa_array_format_datatype)
+ (f & MESA_ARRAY_FORMAT_DATATYPE_MASK);
+}
+
+static inline int
+_mesa_array_format_datatype_get_size(enum mesa_array_format_datatype type)
+{
+ return 1 << (type & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
+}
+
+static inline int
+_mesa_array_format_get_type_size(mesa_array_format f)
+{
+ return 1 << (f & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
+}
+
+static inline int
+_mesa_array_format_get_num_channels(mesa_array_format f)
+{
+ return (f & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) >> 5;
+}
+
+static inline void
+_mesa_array_format_get_swizzle(mesa_array_format f, uint8_t *swizzle)
+{
+ swizzle[0] = (f & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) >> 8;
+ swizzle[1] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) >> 11;
+ swizzle[2] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) >> 14;
+ swizzle[3] = (f & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) >> 17;
+}
+
+static inline void
+_mesa_array_format_set_swizzle(mesa_array_format *f,
+ int32_t x, int32_t y, int32_t z, int32_t w)
+{
+ *f &= ~(MESA_ARRAY_FORMAT_SWIZZLE_X_MASK |
+ MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK |
+ MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK |
+ MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
+
+ *f |= ((x << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) |
+ ((y << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) |
+ ((z << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) |
+ ((w << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
+}
+
+/**
+ * A helper to know if the format stored in a uint32_t is a mesa_format
+ * or a mesa_array_format
+ */
+static inline bool
+_mesa_format_is_mesa_array_format(uint32_t f)
+{
+ return (f & MESA_ARRAY_FORMAT_BIT) != 0;
+}
+
+/**
+ * Mesa texture/renderbuffer image formats. These are just other names of the
+ * gallium p_format.h formats.
+ */
+typedef enum pipe_format mesa_format;
+
+ /**
+ * \name Basic hardware formats
+ *
+ * The mesa format name specification is as follows:
+ *
+ * There shall be 3 naming format base types: those for component array
+ * formats (type A); those for compressed formats (type C); and those for
+ * packed component formats (type P). With type A formats, color component
+ * order does not change with endianess. Each format name shall begin with
+ * MESA_FORMAT_, followed by a component label (from the Component Label
+ * list below) for each component in the order that the component(s) occur
+ * in the format, except for non-linear color formats where the first
+ * letter shall be 'S'. For type P formats, each component label is
+ * followed by the number of bits that represent it in the fundamental
+ * data type used by the format.
+ *
+ * Following the listing of the component labels shall be an underscore; a
+ * compression type followed by an underscore for Type C formats only; a
+ * storage type from the list below; and a bit with for type A formats,
+ * which is the bit width for each array element.
+ *
+ *
+ * ---------- Format Base Type A: Array ----------
+ * MESA_FORMAT_[component list]_[storage type][array element bit width]
+ *
+ * examples:
+ * MESA_FORMAT_A_SNORM8 - uchar[i] = A
+ * MESA_FORMAT_RGBA_16 - ushort[i * 4 + 0] = R, ushort[i * 4 + 1] = G,
+ * ushort[i * 4 + 2] = B, ushort[i * 4 + 3] = A
+ * MESA_FORMAT_Z_UNORM32 - float[i] = Z
+ *
+ *
+ *
+ * ---------- Format Base Type C: Compressed ----------
+ * MESA_FORMAT_[component list*][_*][compression type][storage type*]
+ * * where required
+ *
+ * examples:
+ * MESA_FORMAT_RGB_ETC1
+ * MESA_FORMAT_RGBA_ETC2
+ * MESA_FORMAT_LATC1_UNORM
+ * MESA_FORMAT_RGBA_FXT1
+ *
+ *
+ *
+ * ---------- Format Base Type P: Packed ----------
+ * MESA_FORMAT_[[component list,bit width][storage type*][_]][_][storage type**]
+ * * when type differs between component
+ * ** when type applies to all components
+ *
+ * examples: msb <------ TEXEL BITS -----------> lsb
+ * MESA_FORMAT_A8B8G8R8_UNORM, RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA
+ * MESA_FORMAT_R5G6B5_UNORM BBBB BGGG GGGR RRRR
+ * MESA_FORMAT_B4G4R4X4_UNORM XXXX RRRR GGGG BBBB
+ * MESA_FORMAT_Z32_FLOAT_S8X24_UINT
+ * MESA_FORMAT_R10G10B10A2_UINT
+ * MESA_FORMAT_R9G9B9E5_FLOAT
+ *
+ *
+ *
+ * ---------- Component Labels: ----------
+ * A - Alpha
+ * B - Blue
+ * DU - Delta U
+ * DV - Delta V
+ * E - Shared Exponent
+ * G - Green
+ * I - Intensity
+ * L - Luminance
+ * R - Red
+ * S - Stencil (when not followed by RGB or RGBA)
+ * U - Chrominance
+ * V - Chrominance
+ * Y - Luma
+ * X - Packing bits
+ * Z - Depth
+ *
+ *
+ *
+ * ---------- Type C Compression Types: ----------
+ * DXT1 - Color component labels shall be given
+ * DXT3 - Color component labels shall be given
+ * DXT5 - Color component labels shall be given
+ * ETC1 - No other information required
+ * ETC2 - No other information required
+ * FXT1 - Color component labels shall be given
+ * FXT3 - Color component labels shall be given
+ * LATC1 - Fundamental data type shall be given
+ * LATC2 - Fundamental data type shall be given
+ * RGTC1 - Color component labels and data type shall be given
+ * RGTC2 - Color component labels and data type shall be given
+ *
+ *
+ *
+ * ---------- Storage Types: ----------
+ * FLOAT
+ * SINT
+ * UINT
+ * SNORM
+ * UNORM
+ * SRGB - RGB components, or L are UNORMs in sRGB color space.
+ * Alpha, if present is linear.
+ *
+ */
+
+#define MESA_FORMAT_NONE PIPE_FORMAT_NONE
+#define MESA_FORMAT_A8B8G8R8_UNORM PIPE_FORMAT_ABGR8888_UNORM
+#define MESA_FORMAT_X8B8G8R8_UNORM PIPE_FORMAT_XBGR8888_UNORM
+#define MESA_FORMAT_R8G8B8A8_UNORM PIPE_FORMAT_RGBA8888_UNORM
+#define MESA_FORMAT_R8G8B8X8_UNORM PIPE_FORMAT_RGBX8888_UNORM
+#define MESA_FORMAT_B8G8R8A8_UNORM PIPE_FORMAT_BGRA8888_UNORM
+#define MESA_FORMAT_B8G8R8X8_UNORM PIPE_FORMAT_BGRX8888_UNORM
+#define MESA_FORMAT_A8R8G8B8_UNORM PIPE_FORMAT_ARGB8888_UNORM
+#define MESA_FORMAT_X8R8G8B8_UNORM PIPE_FORMAT_XRGB8888_UNORM
+#define MESA_FORMAT_B5G6R5_UNORM PIPE_FORMAT_B5G6R5_UNORM
+#define MESA_FORMAT_R5G6B5_UNORM PIPE_FORMAT_R5G6B5_UNORM
+#define MESA_FORMAT_B4G4R4A4_UNORM PIPE_FORMAT_B4G4R4A4_UNORM
+#define MESA_FORMAT_B4G4R4X4_UNORM PIPE_FORMAT_B4G4R4X4_UNORM
+#define MESA_FORMAT_A4R4G4B4_UNORM PIPE_FORMAT_A4R4G4B4_UNORM
+#define MESA_FORMAT_A1B5G5R5_UNORM PIPE_FORMAT_A1B5G5R5_UNORM
+#define MESA_FORMAT_X1B5G5R5_UNORM PIPE_FORMAT_X1B5G5R5_UNORM
+#define MESA_FORMAT_B5G5R5A1_UNORM PIPE_FORMAT_B5G5R5A1_UNORM
+#define MESA_FORMAT_B5G5R5X1_UNORM PIPE_FORMAT_B5G5R5X1_UNORM
+#define MESA_FORMAT_A1R5G5B5_UNORM PIPE_FORMAT_A1R5G5B5_UNORM
+#define MESA_FORMAT_L4A4_UNORM PIPE_FORMAT_L4A4_UNORM
+#define MESA_FORMAT_B2G3R3_UNORM PIPE_FORMAT_B2G3R3_UNORM
+#define MESA_FORMAT_B10G10R10A2_UNORM PIPE_FORMAT_B10G10R10A2_UNORM
+#define MESA_FORMAT_B10G10R10X2_UNORM PIPE_FORMAT_B10G10R10X2_UNORM
+#define MESA_FORMAT_R10G10B10A2_UNORM PIPE_FORMAT_R10G10B10A2_UNORM
+#define MESA_FORMAT_R10G10B10X2_UNORM PIPE_FORMAT_R10G10B10X2_UNORM
+#define MESA_FORMAT_S8_UINT_Z24_UNORM PIPE_FORMAT_S8_UINT_Z24_UNORM
+#define MESA_FORMAT_X8_UINT_Z24_UNORM PIPE_FORMAT_X8Z24_UNORM
+#define MESA_FORMAT_Z24_UNORM_S8_UINT PIPE_FORMAT_Z24_UNORM_S8_UINT
+#define MESA_FORMAT_Z24_UNORM_X8_UINT PIPE_FORMAT_Z24X8_UNORM
+#define MESA_FORMAT_R3G3B2_UNORM PIPE_FORMAT_R3G3B2_UNORM
+#define MESA_FORMAT_A4B4G4R4_UNORM PIPE_FORMAT_A4B4G4R4_UNORM
+#define MESA_FORMAT_R4G4B4A4_UNORM PIPE_FORMAT_R4G4B4A4_UNORM
+#define MESA_FORMAT_R5G5B5A1_UNORM PIPE_FORMAT_R5G5B5A1_UNORM
+#define MESA_FORMAT_A2B10G10R10_UNORM PIPE_FORMAT_A2B10G10R10_UNORM
+#define MESA_FORMAT_A2R10G10B10_UNORM PIPE_FORMAT_A2R10G10B10_UNORM
+#define MESA_FORMAT_YCBCR PIPE_FORMAT_UYVY
+#define MESA_FORMAT_YCBCR_REV PIPE_FORMAT_YUYV
+#define MESA_FORMAT_A_UNORM8 PIPE_FORMAT_A8_UNORM
+#define MESA_FORMAT_A_UNORM16 PIPE_FORMAT_A16_UNORM
+#define MESA_FORMAT_L_UNORM8 PIPE_FORMAT_L8_UNORM
+#define MESA_FORMAT_L_UNORM16 PIPE_FORMAT_L16_UNORM
+#define MESA_FORMAT_LA_UNORM8 PIPE_FORMAT_L8A8_UNORM
+#define MESA_FORMAT_LA_UNORM16 PIPE_FORMAT_L16A16_UNORM
+#define MESA_FORMAT_I_UNORM8 PIPE_FORMAT_I8_UNORM
+#define MESA_FORMAT_I_UNORM16 PIPE_FORMAT_I16_UNORM
+#define MESA_FORMAT_R_UNORM8 PIPE_FORMAT_R8_UNORM
+#define MESA_FORMAT_R_UNORM16 PIPE_FORMAT_R16_UNORM
+#define MESA_FORMAT_RG_UNORM8 PIPE_FORMAT_R8G8_UNORM
+#define MESA_FORMAT_RG_UNORM16 PIPE_FORMAT_R16G16_UNORM
+#define MESA_FORMAT_BGR_UNORM8 PIPE_FORMAT_B8G8R8_UNORM
+#define MESA_FORMAT_RGB_UNORM8 PIPE_FORMAT_R8G8B8_UNORM
+#define MESA_FORMAT_RGBA_UNORM16 PIPE_FORMAT_R16G16B16A16_UNORM
+#define MESA_FORMAT_RGBX_UNORM16 PIPE_FORMAT_R16G16B16X16_UNORM
+#define MESA_FORMAT_Z_UNORM16 PIPE_FORMAT_Z16_UNORM
+#define MESA_FORMAT_Z_UNORM32 PIPE_FORMAT_Z32_UNORM
+#define MESA_FORMAT_S_UINT8 PIPE_FORMAT_S8_UINT
+#define MESA_FORMAT_A8B8G8R8_SNORM PIPE_FORMAT_ABGR8888_SNORM
+#define MESA_FORMAT_X8B8G8R8_SNORM PIPE_FORMAT_XBGR8888_SNORM
+#define MESA_FORMAT_R8G8B8A8_SNORM PIPE_FORMAT_RGBA8888_SNORM
+#define MESA_FORMAT_R8G8B8X8_SNORM PIPE_FORMAT_RGBX8888_SNORM
+#define MESA_FORMAT_A_SNORM8 PIPE_FORMAT_A8_SNORM
+#define MESA_FORMAT_A_SNORM16 PIPE_FORMAT_A16_SNORM
+#define MESA_FORMAT_L_SNORM8 PIPE_FORMAT_L8_SNORM
+#define MESA_FORMAT_L_SNORM16 PIPE_FORMAT_L16_SNORM
+#define MESA_FORMAT_I_SNORM8 PIPE_FORMAT_I8_SNORM
+#define MESA_FORMAT_I_SNORM16 PIPE_FORMAT_I16_SNORM
+#define MESA_FORMAT_R_SNORM8 PIPE_FORMAT_R8_SNORM
+#define MESA_FORMAT_R_SNORM16 PIPE_FORMAT_R16_SNORM
+#define MESA_FORMAT_LA_SNORM8 PIPE_FORMAT_L8A8_SNORM
+#define MESA_FORMAT_LA_SNORM16 PIPE_FORMAT_L16A16_SNORM
+#define MESA_FORMAT_RG_SNORM8 PIPE_FORMAT_R8G8_SNORM
+#define MESA_FORMAT_RG_SNORM16 PIPE_FORMAT_R16G16_SNORM
+#define MESA_FORMAT_RGB_SNORM16 PIPE_FORMAT_R16G16B16_SNORM
+#define MESA_FORMAT_RGBA_SNORM16 PIPE_FORMAT_R16G16B16A16_SNORM
+#define MESA_FORMAT_RGBX_SNORM16 PIPE_FORMAT_R16G16B16X16_SNORM
+#define MESA_FORMAT_A8B8G8R8_SRGB PIPE_FORMAT_ABGR8888_SRGB
+#define MESA_FORMAT_B8G8R8A8_SRGB PIPE_FORMAT_BGRA8888_SRGB
+#define MESA_FORMAT_A8R8G8B8_SRGB PIPE_FORMAT_ARGB8888_SRGB
+#define MESA_FORMAT_B8G8R8X8_SRGB PIPE_FORMAT_BGRX8888_SRGB
+#define MESA_FORMAT_X8R8G8B8_SRGB PIPE_FORMAT_XRGB8888_SRGB
+#define MESA_FORMAT_R8G8B8A8_SRGB PIPE_FORMAT_RGBA8888_SRGB
+#define MESA_FORMAT_R8G8B8X8_SRGB PIPE_FORMAT_RGBX8888_SRGB
+#define MESA_FORMAT_X8B8G8R8_SRGB PIPE_FORMAT_XBGR8888_SRGB
+#define MESA_FORMAT_R_SRGB8 PIPE_FORMAT_R8_SRGB
+#define MESA_FORMAT_L_SRGB8 PIPE_FORMAT_L8_SRGB
+#define MESA_FORMAT_LA_SRGB8 PIPE_FORMAT_L8A8_SRGB
+#define MESA_FORMAT_BGR_SRGB8 PIPE_FORMAT_R8G8B8_SRGB
+#define MESA_FORMAT_R9G9B9E5_FLOAT PIPE_FORMAT_R9G9B9E5_FLOAT
+#define MESA_FORMAT_R11G11B10_FLOAT PIPE_FORMAT_R11G11B10_FLOAT
+#define MESA_FORMAT_Z32_FLOAT_S8X24_UINT PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
+#define MESA_FORMAT_A_FLOAT16 PIPE_FORMAT_A16_FLOAT
+#define MESA_FORMAT_A_FLOAT32 PIPE_FORMAT_A32_FLOAT
+#define MESA_FORMAT_L_FLOAT16 PIPE_FORMAT_L16_FLOAT
+#define MESA_FORMAT_L_FLOAT32 PIPE_FORMAT_L32_FLOAT
+#define MESA_FORMAT_LA_FLOAT16 PIPE_FORMAT_L16A16_FLOAT
+#define MESA_FORMAT_LA_FLOAT32 PIPE_FORMAT_L32A32_FLOAT
+#define MESA_FORMAT_I_FLOAT16 PIPE_FORMAT_I16_FLOAT
+#define MESA_FORMAT_I_FLOAT32 PIPE_FORMAT_I32_FLOAT
+#define MESA_FORMAT_R_FLOAT16 PIPE_FORMAT_R16_FLOAT
+#define MESA_FORMAT_R_FLOAT32 PIPE_FORMAT_R32_FLOAT
+#define MESA_FORMAT_RG_FLOAT16 PIPE_FORMAT_R16G16_FLOAT
+#define MESA_FORMAT_RG_FLOAT32 PIPE_FORMAT_R32G32_FLOAT
+#define MESA_FORMAT_RGB_FLOAT16 PIPE_FORMAT_R16G16B16_FLOAT
+#define MESA_FORMAT_RGB_FLOAT32 PIPE_FORMAT_R32G32B32_FLOAT
+#define MESA_FORMAT_RGBA_FLOAT16 PIPE_FORMAT_R16G16B16A16_FLOAT
+#define MESA_FORMAT_RGBA_FLOAT32 PIPE_FORMAT_R32G32B32A32_FLOAT
+#define MESA_FORMAT_RGBX_FLOAT16 PIPE_FORMAT_R16G16B16X16_FLOAT
+#define MESA_FORMAT_RGBX_FLOAT32 PIPE_FORMAT_R32G32B32X32_FLOAT
+#define MESA_FORMAT_Z_FLOAT32 PIPE_FORMAT_Z32_FLOAT
+#define MESA_FORMAT_A8B8G8R8_UINT PIPE_FORMAT_ABGR8888_UINT
+#define MESA_FORMAT_A8R8G8B8_UINT PIPE_FORMAT_ARGB8888_UINT
+#define MESA_FORMAT_R8G8B8A8_UINT PIPE_FORMAT_RGBA8888_UINT
+#define MESA_FORMAT_B8G8R8A8_UINT PIPE_FORMAT_BGRA8888_UINT
+#define MESA_FORMAT_B10G10R10A2_UINT PIPE_FORMAT_B10G10R10A2_UINT
+#define MESA_FORMAT_R10G10B10A2_UINT PIPE_FORMAT_R10G10B10A2_UINT
+#define MESA_FORMAT_A2B10G10R10_UINT PIPE_FORMAT_A2B10G10R10_UINT
+#define MESA_FORMAT_A2R10G10B10_UINT PIPE_FORMAT_A2R10G10B10_UINT
+#define MESA_FORMAT_B5G6R5_UINT PIPE_FORMAT_B5G6R5_UINT
+#define MESA_FORMAT_R5G6B5_UINT PIPE_FORMAT_R5G6B5_UINT
+#define MESA_FORMAT_B2G3R3_UINT PIPE_FORMAT_B2G3R3_UINT
+#define MESA_FORMAT_R3G3B2_UINT PIPE_FORMAT_R3G3B2_UINT
+#define MESA_FORMAT_A4B4G4R4_UINT PIPE_FORMAT_A4B4G4R4_UINT
+#define MESA_FORMAT_R4G4B4A4_UINT PIPE_FORMAT_R4G4B4A4_UINT
+#define MESA_FORMAT_B4G4R4A4_UINT PIPE_FORMAT_B4G4R4A4_UINT
+#define MESA_FORMAT_A4R4G4B4_UINT PIPE_FORMAT_A4R4G4B4_UINT
+#define MESA_FORMAT_A1B5G5R5_UINT PIPE_FORMAT_A1B5G5R5_UINT
+#define MESA_FORMAT_B5G5R5A1_UINT PIPE_FORMAT_B5G5R5A1_UINT
+#define MESA_FORMAT_A1R5G5B5_UINT PIPE_FORMAT_A1R5G5B5_UINT
+#define MESA_FORMAT_R5G5B5A1_UINT PIPE_FORMAT_R5G5B5A1_UINT
+#define MESA_FORMAT_A_UINT8 PIPE_FORMAT_A8_UINT
+#define MESA_FORMAT_A_UINT16 PIPE_FORMAT_A16_UINT
+#define MESA_FORMAT_A_UINT32 PIPE_FORMAT_A32_UINT
+#define MESA_FORMAT_A_SINT8 PIPE_FORMAT_A8_SINT
+#define MESA_FORMAT_A_SINT16 PIPE_FORMAT_A16_SINT
+#define MESA_FORMAT_A_SINT32 PIPE_FORMAT_A32_SINT
+#define MESA_FORMAT_I_UINT8 PIPE_FORMAT_I8_UINT
+#define MESA_FORMAT_I_UINT16 PIPE_FORMAT_I16_UINT
+#define MESA_FORMAT_I_UINT32 PIPE_FORMAT_I32_UINT
+#define MESA_FORMAT_I_SINT8 PIPE_FORMAT_I8_SINT
+#define MESA_FORMAT_I_SINT16 PIPE_FORMAT_I16_SINT
+#define MESA_FORMAT_I_SINT32 PIPE_FORMAT_I32_SINT
+#define MESA_FORMAT_L_UINT8 PIPE_FORMAT_L8_UINT
+#define MESA_FORMAT_L_UINT16 PIPE_FORMAT_L16_UINT
+#define MESA_FORMAT_L_UINT32 PIPE_FORMAT_L32_UINT
+#define MESA_FORMAT_L_SINT8 PIPE_FORMAT_L8_SINT
+#define MESA_FORMAT_L_SINT16 PIPE_FORMAT_L16_SINT
+#define MESA_FORMAT_L_SINT32 PIPE_FORMAT_L32_SINT
+#define MESA_FORMAT_LA_UINT8 PIPE_FORMAT_L8A8_UINT
+#define MESA_FORMAT_LA_UINT16 PIPE_FORMAT_L16A16_UINT
+#define MESA_FORMAT_LA_UINT32 PIPE_FORMAT_L32A32_UINT
+#define MESA_FORMAT_LA_SINT8 PIPE_FORMAT_L8A8_SINT
+#define MESA_FORMAT_LA_SINT16 PIPE_FORMAT_L16A16_SINT
+#define MESA_FORMAT_LA_SINT32 PIPE_FORMAT_L32A32_SINT
+#define MESA_FORMAT_R_UINT8 PIPE_FORMAT_R8_UINT
+#define MESA_FORMAT_R_UINT16 PIPE_FORMAT_R16_UINT
+#define MESA_FORMAT_R_UINT32 PIPE_FORMAT_R32_UINT
+#define MESA_FORMAT_R_SINT8 PIPE_FORMAT_R8_SINT
+#define MESA_FORMAT_R_SINT16 PIPE_FORMAT_R16_SINT
+#define MESA_FORMAT_R_SINT32 PIPE_FORMAT_R32_SINT
+#define MESA_FORMAT_RG_UINT8 PIPE_FORMAT_R8G8_UINT
+#define MESA_FORMAT_RG_UINT16 PIPE_FORMAT_R16G16_UINT
+#define MESA_FORMAT_RG_UINT32 PIPE_FORMAT_R32G32_UINT
+#define MESA_FORMAT_RG_SINT8 PIPE_FORMAT_R8G8_SINT
+#define MESA_FORMAT_RG_SINT16 PIPE_FORMAT_R16G16_SINT
+#define MESA_FORMAT_RG_SINT32 PIPE_FORMAT_R32G32_SINT
+#define MESA_FORMAT_RGB_UINT8 PIPE_FORMAT_R8G8B8_UINT
+#define MESA_FORMAT_RGB_UINT16 PIPE_FORMAT_R16G16B16_UINT
+#define MESA_FORMAT_RGB_UINT32 PIPE_FORMAT_R32G32B32_UINT
+#define MESA_FORMAT_RGB_SINT8 PIPE_FORMAT_R8G8B8_SINT
+#define MESA_FORMAT_RGB_SINT16 PIPE_FORMAT_R16G16B16_SINT
+#define MESA_FORMAT_RGB_SINT32 PIPE_FORMAT_R32G32B32_SINT
+#define MESA_FORMAT_RGBA_UINT16 PIPE_FORMAT_R16G16B16A16_UINT
+#define MESA_FORMAT_RGBA_UINT32 PIPE_FORMAT_R32G32B32A32_UINT
+#define MESA_FORMAT_RGBA_SINT8 PIPE_FORMAT_R8G8B8A8_SINT
+#define MESA_FORMAT_RGBA_SINT16 PIPE_FORMAT_R16G16B16A16_SINT
+#define MESA_FORMAT_RGBA_SINT32 PIPE_FORMAT_R32G32B32A32_SINT
+#define MESA_FORMAT_RGBX_UINT8 PIPE_FORMAT_R8G8B8X8_UINT
+#define MESA_FORMAT_RGBX_UINT16 PIPE_FORMAT_R16G16B16X16_UINT
+#define MESA_FORMAT_RGBX_UINT32 PIPE_FORMAT_R32G32B32X32_UINT
+#define MESA_FORMAT_RGBX_SINT8 PIPE_FORMAT_R8G8B8X8_SINT
+#define MESA_FORMAT_RGBX_SINT16 PIPE_FORMAT_R16G16B16X16_SINT
+#define MESA_FORMAT_RGBX_SINT32 PIPE_FORMAT_R32G32B32X32_SINT
+#define MESA_FORMAT_RGB_DXT1 PIPE_FORMAT_DXT1_RGB
+#define MESA_FORMAT_RGBA_DXT1 PIPE_FORMAT_DXT1_RGBA
+#define MESA_FORMAT_RGBA_DXT3 PIPE_FORMAT_DXT3_RGBA
+#define MESA_FORMAT_RGBA_DXT5 PIPE_FORMAT_DXT5_RGBA
+#define MESA_FORMAT_SRGB_DXT1 PIPE_FORMAT_DXT1_SRGB
+#define MESA_FORMAT_SRGBA_DXT1 PIPE_FORMAT_DXT1_SRGBA
+#define MESA_FORMAT_SRGBA_DXT3 PIPE_FORMAT_DXT3_SRGBA
+#define MESA_FORMAT_SRGBA_DXT5 PIPE_FORMAT_DXT5_SRGBA
+#define MESA_FORMAT_RGB_FXT1 PIPE_FORMAT_FXT1_RGB
+#define MESA_FORMAT_RGBA_FXT1 PIPE_FORMAT_FXT1_RGBA
+#define MESA_FORMAT_R_RGTC1_UNORM PIPE_FORMAT_RGTC1_UNORM
+#define MESA_FORMAT_R_RGTC1_SNORM PIPE_FORMAT_RGTC1_SNORM
+#define MESA_FORMAT_RG_RGTC2_UNORM PIPE_FORMAT_RGTC2_UNORM
+#define MESA_FORMAT_RG_RGTC2_SNORM PIPE_FORMAT_RGTC2_SNORM
+#define MESA_FORMAT_L_LATC1_UNORM PIPE_FORMAT_LATC1_UNORM
+#define MESA_FORMAT_L_LATC1_SNORM PIPE_FORMAT_LATC1_SNORM
+#define MESA_FORMAT_LA_LATC2_UNORM PIPE_FORMAT_LATC2_UNORM
+#define MESA_FORMAT_LA_LATC2_SNORM PIPE_FORMAT_LATC2_SNORM
+#define MESA_FORMAT_ETC1_RGB8 PIPE_FORMAT_ETC1_RGB8
+#define MESA_FORMAT_ETC2_RGB8 PIPE_FORMAT_ETC2_RGB8
+#define MESA_FORMAT_ETC2_SRGB8 PIPE_FORMAT_ETC2_SRGB8
+#define MESA_FORMAT_ETC2_RGBA8_EAC PIPE_FORMAT_ETC2_RGBA8
+#define MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC PIPE_FORMAT_ETC2_SRGBA8
+#define MESA_FORMAT_ETC2_R11_EAC PIPE_FORMAT_ETC2_R11_UNORM
+#define MESA_FORMAT_ETC2_RG11_EAC PIPE_FORMAT_ETC2_RG11_UNORM
+#define MESA_FORMAT_ETC2_SIGNED_R11_EAC PIPE_FORMAT_ETC2_R11_SNORM
+#define MESA_FORMAT_ETC2_SIGNED_RG11_EAC PIPE_FORMAT_ETC2_RG11_SNORM
+#define MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1 PIPE_FORMAT_ETC2_RGB8A1
+#define MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1 PIPE_FORMAT_ETC2_SRGB8A1
+#define MESA_FORMAT_BPTC_RGBA_UNORM PIPE_FORMAT_BPTC_RGBA_UNORM
+#define MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM PIPE_FORMAT_BPTC_SRGBA
+#define MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT PIPE_FORMAT_BPTC_RGB_FLOAT
+#define MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT PIPE_FORMAT_BPTC_RGB_UFLOAT
+#define MESA_FORMAT_RGBA_ASTC_4x4 PIPE_FORMAT_ASTC_4x4
+#define MESA_FORMAT_RGBA_ASTC_5x4 PIPE_FORMAT_ASTC_5x4
+#define MESA_FORMAT_RGBA_ASTC_5x5 PIPE_FORMAT_ASTC_5x5
+#define MESA_FORMAT_RGBA_ASTC_6x5 PIPE_FORMAT_ASTC_6x5
+#define MESA_FORMAT_RGBA_ASTC_6x6 PIPE_FORMAT_ASTC_6x6
+#define MESA_FORMAT_RGBA_ASTC_8x5 PIPE_FORMAT_ASTC_8x5
+#define MESA_FORMAT_RGBA_ASTC_8x6 PIPE_FORMAT_ASTC_8x6
+#define MESA_FORMAT_RGBA_ASTC_8x8 PIPE_FORMAT_ASTC_8x8
+#define MESA_FORMAT_RGBA_ASTC_10x5 PIPE_FORMAT_ASTC_10x5
+#define MESA_FORMAT_RGBA_ASTC_10x6 PIPE_FORMAT_ASTC_10x6
+#define MESA_FORMAT_RGBA_ASTC_10x8 PIPE_FORMAT_ASTC_10x8
+#define MESA_FORMAT_RGBA_ASTC_10x10 PIPE_FORMAT_ASTC_10x10
+#define MESA_FORMAT_RGBA_ASTC_12x10 PIPE_FORMAT_ASTC_12x10
+#define MESA_FORMAT_RGBA_ASTC_12x12 PIPE_FORMAT_ASTC_12x12
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4 PIPE_FORMAT_ASTC_4x4_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4 PIPE_FORMAT_ASTC_5x4_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5 PIPE_FORMAT_ASTC_5x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5 PIPE_FORMAT_ASTC_6x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6 PIPE_FORMAT_ASTC_6x6_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5 PIPE_FORMAT_ASTC_8x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6 PIPE_FORMAT_ASTC_8x6_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8 PIPE_FORMAT_ASTC_8x8_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5 PIPE_FORMAT_ASTC_10x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6 PIPE_FORMAT_ASTC_10x6_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8 PIPE_FORMAT_ASTC_10x8_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10 PIPE_FORMAT_ASTC_10x10_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10 PIPE_FORMAT_ASTC_12x10_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12 PIPE_FORMAT_ASTC_12x12_SRGB
+#define MESA_FORMAT_RGBA_ASTC_3x3x3 PIPE_FORMAT_ASTC_3x3x3
+#define MESA_FORMAT_RGBA_ASTC_4x3x3 PIPE_FORMAT_ASTC_4x3x3
+#define MESA_FORMAT_RGBA_ASTC_4x4x3 PIPE_FORMAT_ASTC_4x4x3
+#define MESA_FORMAT_RGBA_ASTC_4x4x4 PIPE_FORMAT_ASTC_4x4x4
+#define MESA_FORMAT_RGBA_ASTC_5x4x4 PIPE_FORMAT_ASTC_5x4x4
+#define MESA_FORMAT_RGBA_ASTC_5x5x4 PIPE_FORMAT_ASTC_5x5x4
+#define MESA_FORMAT_RGBA_ASTC_5x5x5 PIPE_FORMAT_ASTC_5x5x5
+#define MESA_FORMAT_RGBA_ASTC_6x5x5 PIPE_FORMAT_ASTC_6x5x5
+#define MESA_FORMAT_RGBA_ASTC_6x6x5 PIPE_FORMAT_ASTC_6x6x5
+#define MESA_FORMAT_RGBA_ASTC_6x6x6 PIPE_FORMAT_ASTC_6x6x6
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_3x3x3 PIPE_FORMAT_ASTC_3x3x3_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x3x3 PIPE_FORMAT_ASTC_4x3x3_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x3 PIPE_FORMAT_ASTC_4x4x3_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x4 PIPE_FORMAT_ASTC_4x4x4_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4x4 PIPE_FORMAT_ASTC_5x4x4_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x4 PIPE_FORMAT_ASTC_5x5x4_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x5 PIPE_FORMAT_ASTC_5x5x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5 PIPE_FORMAT_ASTC_6x5x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5 PIPE_FORMAT_ASTC_6x6x5_SRGB
+#define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6 PIPE_FORMAT_ASTC_6x6x6_SRGB
+#define MESA_FORMAT_ATC_RGB PIPE_FORMAT_ATC_RGB
+#define MESA_FORMAT_ATC_RGBA_EXPLICIT PIPE_FORMAT_ATC_RGBA_EXPLICIT
+#define MESA_FORMAT_ATC_RGBA_INTERPOLATED PIPE_FORMAT_ATC_RGBA_INTERPOLATED
+#define MESA_FORMAT_COUNT PIPE_FORMAT_COUNT
+
+/* Packed to array format adapters */
+#if UTIL_ARCH_LITTLE_ENDIAN
+#define MESA_FORMAT_RGBA_UINT8 MESA_FORMAT_R8G8B8A8_UINT
+#define MESA_FORMAT_RGBA_UNORM8 MESA_FORMAT_R8G8B8A8_UNORM
+#define MESA_FORMAT_RGBA_SNORM8 MESA_FORMAT_R8G8B8A8_SNORM
+#else
+#define MESA_FORMAT_RGBA_UINT8 MESA_FORMAT_A8B8G8R8_UINT
+#define MESA_FORMAT_RGBA_UNORM8 MESA_FORMAT_A8B8G8R8_UNORM
+#define MESA_FORMAT_RGBA_SNORM8 MESA_FORMAT_A8B8G8R8_SNORM
+#endif
+
+extern const char *
+_mesa_get_format_name(mesa_format format);
+
+extern int
+_mesa_get_format_bytes(mesa_format format);
+
+extern GLint
+_mesa_get_format_bits(mesa_format format, GLenum pname);
+
+extern unsigned int
+_mesa_get_format_max_bits(mesa_format format);
+
+extern enum mesa_format_layout
+_mesa_get_format_layout(mesa_format format);
+
+extern GLenum
+_mesa_get_format_datatype(mesa_format format);
+
+extern GLenum
+_mesa_get_format_base_format(uint32_t format);
+
+extern void
+_mesa_get_format_block_size(mesa_format format,
+ unsigned int *bw, unsigned int *bh);
+
+extern void
+_mesa_get_format_block_size_3d(mesa_format format, unsigned int *bw,
+ unsigned int *bh, unsigned int *bd);
+
+extern mesa_array_format
+_mesa_array_format_flip_channels(mesa_array_format format);
+
+extern void
+_mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4]);
+
+extern uint32_t
+_mesa_format_to_array_format(mesa_format format);
+
+extern mesa_format
+_mesa_format_from_array_format(uint32_t array_format);
+
+extern bool
+_mesa_is_format_compressed(mesa_format format);
+
+extern bool
+_mesa_is_format_packed_depth_stencil(mesa_format format);
+
+extern bool
+_mesa_is_format_integer_color(mesa_format format);
+
+extern bool
+_mesa_is_format_unsigned(mesa_format format);
+
+extern bool
+_mesa_is_format_signed(mesa_format format);
+
+extern bool
+_mesa_is_format_integer(mesa_format format);
+
+extern bool
+_mesa_is_format_etc2(mesa_format format);
+
+bool
+_mesa_is_format_astc_2d(mesa_format format);
+
+bool
+_mesa_is_format_color_format(mesa_format format);
+
+bool
+_mesa_is_format_srgb(mesa_format format);
+
+extern uint32_t
+_mesa_format_image_size(mesa_format format, int width,
+ int height, int depth);
+
+extern uint64_t
+_mesa_format_image_size64(mesa_format format, int width,
+ int height, int depth);
+
+extern int32_t
+_mesa_format_row_stride(mesa_format format, int width);
+
+extern void
+_mesa_uncompressed_format_to_type_and_comps(mesa_format format,
+ GLenum *datatype, GLuint *comps);
+
+extern void
+_mesa_test_formats(void);
+
+extern mesa_format
+_mesa_get_srgb_format_linear(mesa_format format);
+
+extern mesa_format
+_mesa_get_linear_format_srgb(mesa_format format);
+
+extern mesa_format
+_mesa_get_intensity_format_red(mesa_format format);
+
+extern mesa_format
+_mesa_get_uncompressed_format(mesa_format format);
+
+extern unsigned int
+_mesa_format_num_components(mesa_format format);
+
+extern bool
+_mesa_format_has_color_component(mesa_format format, int component);
+
+bool
+_mesa_format_matches_format_and_type(mesa_format mesa_format,
+ GLenum format, GLenum type,
+ bool swapBytes, GLenum *error);
+
+mesa_format
+_mesa_format_fallback_rgbx_to_rgba(mesa_format format);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FORMATS_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glheader.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glheader.h
new file mode 100644
index 0000000000..59ca1cbadf
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glheader.h
@@ -0,0 +1,164 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file glheader.h
+ * Wrapper for GL/gl.h and GL/glext.h
+ */
+
+
+#ifndef GLHEADER_H
+#define GLHEADER_H
+
+
+#define GL_GLEXT_PROTOTYPES
+#include "GL/gl.h"
+#include "GL/glext.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Custom Mesa types to save space. */
+typedef unsigned short GLenum16;
+typedef unsigned char GLbitfield8;
+typedef unsigned short GLbitfield16;
+typedef GLuint64 GLbitfield64;
+
+/* Common GLES 1.0 and 2.0 tokens */
+
+#ifndef GL_OES_EGL_image_external
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#endif
+
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_ETC1_RGB8_OES 0x8D64
+#endif
+
+
+/* GLES 1.0 only tokens */
+
+typedef int GLclampx;
+
+#ifndef GL_OES_point_size_array
+#define GL_POINT_SIZE_ARRAY_OES 0x8B9C
+#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A
+#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B
+#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C
+#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F
+#endif
+
+
+#ifndef GL_OES_draw_texture
+#define GL_TEXTURE_CROP_RECT_OES 0x8B9D
+#endif
+
+#ifndef GL_TEXTURE_GEN_STR_OES
+#define GL_TEXTURE_GEN_STR_OES 0x8D60
+#endif
+
+
+/* GLES 2.0 only tokens */
+
+#ifndef GL_PROGRAM_BINARY_LENGTH_OES
+#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
+#endif
+
+#ifndef GL_OES_texture_compression_astc
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#endif
+
+#ifndef GL_EXT_shader_framebuffer_fetch
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#endif
+
+#ifndef GL_EXT_disjoint_timer_query
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+#endif
+
+/* Inexplicably, GL_HALF_FLOAT_OES has a different value than GL_HALF_FLOAT.
+ */
+#ifndef GL_HALF_FLOAT_OES
+#define GL_HALF_FLOAT_OES 0x8D61
+#endif
+
+/* There is no formal spec for the following extension. */
+#ifndef GL_ATI_texture_compression_3dc
+#define GL_ATI_texture_compression_3dc 1
+#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837
+#endif
+
+#ifndef GL_EXT_texture_sRGB_R8
+#define GL_SR8_EXT 0x8FBD
+#endif
+
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_ATC_RGB_AMD 0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
+#endif
+
+/**
+ * Internal token to represent a GLSL shader program (a collection of
+ * one or more shaders that get linked together). Note that GLSL
+ * shaders and shader programs share one name space (one hash table)
+ * so we need a value that's different from any of the
+ * GL_VERTEX/FRAGMENT/GEOMETRY_PROGRAM tokens.
+ */
+#define GL_SHADER_PROGRAM_MESA 0x9999
+
+#ifndef GL_EXT_multisampled_render_to_texture
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GLHEADER_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glthread.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glthread.h
new file mode 100644
index 0000000000..a50b2f87ce
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/glthread.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _GLTHREAD_H
+#define _GLTHREAD_H
+
+/* The size of one batch and the maximum size of one call.
+ *
+ * This should be as low as possible, so that:
+ * - multiple synchronizations within a frame don't slow us down much
+ * - a smaller number of calls per frame can still get decent parallelism
+ * - the memory footprint of the queue is low, and with that comes a lower
+ * chance of experiencing CPU cache thrashing
+ * but it should be high enough so that u_queue overhead remains negligible.
+ */
+#define MARSHAL_MAX_CMD_SIZE (8 * 1024)
+
+/* The number of batch slots in memory.
+ *
+ * One batch is being executed, one batch is being filled, the rest are
+ * waiting batches. There must be at least 1 slot for a waiting batch,
+ * so the minimum number of batches is 3.
+ */
+#define MARSHAL_MAX_BATCHES 8
+
+#include <inttypes.h>
+#include <stdbool.h>
+#include "util/u_queue.h"
+#include "GL/gl.h"
+#include "compiler/shader_enums.h"
+
+struct gl_context;
+struct _mesa_HashTable;
+
+struct glthread_vao {
+ GLuint Name;
+ GLuint CurrentElementBufferName;
+ GLbitfield Enabled;
+ GLbitfield UserPointerMask;
+};
+
+/** A single batch of commands queued up for execution. */
+struct glthread_batch
+{
+ /** Batch fence for waiting for the execution to finish. */
+ struct util_queue_fence fence;
+
+ /** The worker thread will access the context with this. */
+ struct gl_context *ctx;
+
+ /** Amount of data used by batch commands, in bytes. */
+ int used;
+
+ /** Data contained in the command buffer. */
+#ifdef _MSC_VER
+ __declspec(align(8))
+#else
+ __attribute__((aligned(8)))
+#endif
+ uint8_t buffer[MARSHAL_MAX_CMD_SIZE];
+};
+
+struct glthread_state
+{
+ /** Multithreaded queue. */
+ struct util_queue queue;
+
+ /** This is sent to the driver for framebuffer overlay / HUD. */
+ struct util_queue_monitoring stats;
+
+ /** Whether GLThread is enabled. */
+ bool enabled;
+
+ /** The ring of batches in memory. */
+ struct glthread_batch batches[MARSHAL_MAX_BATCHES];
+
+ /** Pointer to the batch currently being filled. */
+ struct glthread_batch *next_batch;
+
+ /** Index of the last submitted batch. */
+ unsigned last;
+
+ /** Index of the batch being filled and about to be submitted. */
+ unsigned next;
+
+ /** Vertex Array objects tracked by glthread independently of Mesa. */
+ struct _mesa_HashTable *VAOs;
+ struct glthread_vao *CurrentVAO;
+ struct glthread_vao *LastLookedUpVAO;
+ struct glthread_vao DefaultVAO;
+ int ClientActiveTexture;
+
+ /** Currently-bound buffer object IDs. */
+ GLuint CurrentArrayBufferName;
+ GLuint CurrentDrawIndirectBufferName;
+};
+
+void _mesa_glthread_init(struct gl_context *ctx);
+void _mesa_glthread_destroy(struct gl_context *ctx);
+
+void _mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func);
+void _mesa_glthread_disable(struct gl_context *ctx, const char *func);
+void _mesa_glthread_flush_batch(struct gl_context *ctx);
+void _mesa_glthread_finish(struct gl_context *ctx);
+void _mesa_glthread_finish_before(struct gl_context *ctx, const char *func);
+
+void _mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target,
+ GLuint buffer);
+void _mesa_glthread_DeleteBuffers(struct gl_context *ctx, GLsizei n,
+ const GLuint *buffers);
+
+void _mesa_glthread_BindVertexArray(struct gl_context *ctx, GLuint id);
+void _mesa_glthread_DeleteVertexArrays(struct gl_context *ctx,
+ GLsizei n, const GLuint *ids);
+void _mesa_glthread_GenVertexArrays(struct gl_context *ctx,
+ GLsizei n, GLuint *arrays);
+void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj,
+ gl_vert_attrib attrib, bool enable);
+void _mesa_glthread_AttribPointer(struct gl_context *ctx,
+ gl_vert_attrib attrib);
+
+#endif /* _GLTHREAD_H*/
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/hash.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/hash.h
new file mode 100644
index 0000000000..0a3996a7d0
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/hash.h
@@ -0,0 +1,181 @@
+/**
+ * \file hash.h
+ * Generic hash table.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef HASH_H
+#define HASH_H
+
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "glheader.h"
+
+#include "c11/threads.h"
+
+/**
+ * Magic GLuint object name that gets stored outside of the struct hash_table.
+ *
+ * The hash table needs a particular pointer to be the marker for a key that
+ * was deleted from the table, along with NULL for the "never allocated in the
+ * table" marker. Legacy GL allows any GLuint to be used as a GL object name,
+ * and we use a 1:1 mapping from GLuints to key pointers, so we need to be
+ * able to track a GLuint that happens to match the deleted key outside of
+ * struct hash_table. We tell the hash table to use "1" as the deleted key
+ * value, so that we test the deleted-key-in-the-table path as best we can.
+ */
+#define DELETED_KEY_VALUE 1
+
+/** @{
+ * Mapping from our use of GLuint as both the key and the hash value to the
+ * hash_table.h API
+ *
+ * There exist many integer hash functions, designed to avoid collisions when
+ * the integers are spread across key space with some patterns. In GL, the
+ * pattern (in the case of glGen*()ed object IDs) is that the keys are unique
+ * contiguous integers starting from 1. Because of that, we just use the key
+ * as the hash value, to minimize the cost of the hash function. If objects
+ * are never deleted, we will never see a collision in the table, because the
+ * table resizes itself when it approaches full, and thus key % table_size ==
+ * key.
+ *
+ * The case where we could have collisions for genned objects would be
+ * something like: glGenBuffers(&a, 100); glDeleteBuffers(&a + 50, 50);
+ * glGenBuffers(&b, 100), because objects 1-50 and 101-200 are allocated at
+ * the end of that sequence, instead of 1-150. So far it doesn't appear to be
+ * a problem.
+ */
+static inline bool
+uint_key_compare(const void *a, const void *b)
+{
+ return a == b;
+}
+
+static inline uint32_t
+uint_hash(GLuint id)
+{
+ return id;
+}
+
+static inline uint32_t
+uint_key_hash(const void *key)
+{
+ return uint_hash((uintptr_t)key);
+}
+
+static inline void *
+uint_key(GLuint id)
+{
+ return (void *)(uintptr_t) id;
+}
+/** @} */
+
+/**
+ * The hash table data structure.
+ */
+struct _mesa_HashTable {
+ struct hash_table *ht;
+ GLuint MaxKey; /**< highest key inserted so far */
+ mtx_t Mutex; /**< mutual exclusion lock */
+ GLboolean InDeleteAll; /**< Debug check */
+ /** Value that would be in the table for DELETED_KEY_VALUE. */
+ void *deleted_key_data;
+};
+
+extern struct _mesa_HashTable *_mesa_NewHashTable(void);
+
+extern void _mesa_DeleteHashTable(struct _mesa_HashTable *table);
+
+extern void *_mesa_HashLookup(struct _mesa_HashTable *table, GLuint key);
+
+extern void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data);
+
+extern void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key);
+
+/**
+ * Lock the hash table mutex.
+ *
+ * This function should be used when multiple objects need
+ * to be looked up in the hash table, to avoid having to lock
+ * and unlock the mutex each time.
+ *
+ * \param table the hash table.
+ */
+static inline void
+_mesa_HashLockMutex(struct _mesa_HashTable *table)
+{
+ assert(table);
+ mtx_lock(&table->Mutex);
+}
+
+
+/**
+ * Unlock the hash table mutex.
+ *
+ * \param table the hash table.
+ */
+static inline void
+_mesa_HashUnlockMutex(struct _mesa_HashTable *table)
+{
+ assert(table);
+ mtx_unlock(&table->Mutex);
+}
+
+extern void *_mesa_HashLookupLocked(struct _mesa_HashTable *table, GLuint key);
+
+extern void _mesa_HashInsertLocked(struct _mesa_HashTable *table,
+ GLuint key, void *data);
+
+extern void _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key);
+
+extern void
+_mesa_HashDeleteAll(struct _mesa_HashTable *table,
+ void (*callback)(GLuint key, void *data, void *userData),
+ void *userData);
+
+extern void
+_mesa_HashWalk(const struct _mesa_HashTable *table,
+ void (*callback)(GLuint key, void *data, void *userData),
+ void *userData);
+
+extern void
+_mesa_HashWalkLocked(const struct _mesa_HashTable *table,
+ void (*callback)(GLuint key, void *data, void *userData),
+ void *userData);
+
+extern void _mesa_HashPrint(const struct _mesa_HashTable *table);
+
+extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys);
+
+extern GLuint
+_mesa_HashNumEntries(const struct _mesa_HashTable *table);
+
+extern void _mesa_test_hash_functions(void);
+
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/macros.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/macros.h
new file mode 100644
index 0000000000..caa310fd02
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/macros.h
@@ -0,0 +1,800 @@
+/**
+ * \file macros.h
+ * A collection of useful macros.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef MACROS_H
+#define MACROS_H
+
+#include "util/macros.h"
+#include "util/u_math.h"
+#include "util/rounding.h"
+#include "util/compiler.h"
+#include "main/glheader.h"
+#include "mesa_private.h"
+
+
+/**
+ * \name Integer / float conversion for colors, normals, etc.
+ */
+/*@{*/
+
+/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */
+extern GLfloat _mesa_ubyte_to_float_color_tab[256];
+#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)]
+
+/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */
+#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F))
+
+
+/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */
+#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */
+#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 )
+
+
+/** Convert GLbyte to GLfloat while preserving zero */
+#define BYTE_TO_FLOATZ(B) ((B) == 0 ? 0.0F : BYTE_TO_FLOAT(B))
+
+
+/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */
+#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */
+#define FLOAT_TO_BYTE_TEX(X) CLAMP( (GLint) (127.0F * (X)), -128, 127 )
+
+/** Convert GLushort in [0,65535] to GLfloat in [0.0,1.0] */
+#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F))
+
+/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */
+#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F))
+
+
+/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */
+#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767] */
+#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 )
+
+/** Convert GLshort to GLfloat while preserving zero */
+#define SHORT_TO_FLOATZ(S) ((S) == 0 ? 0.0F : SHORT_TO_FLOAT(S))
+
+
+/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */
+#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */
+#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) )
+
+
+/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
+#define UINT_TO_FLOAT(U) ((GLfloat) ((U) * (1.0F / 4294967295.0)))
+
+/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
+#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
+
+
+/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
+#define INT_TO_FLOAT(I) ((GLfloat) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0)))
+
+/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
+/* causes overflow:
+#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 )
+*/
+/* a close approximation: */
+#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
+
+/** Convert GLfloat in [-1.0,1.0] to GLint64 in [-(1<<63),(1 << 63) -1] */
+#define FLOAT_TO_INT64(X) ( (GLint64) (9223372036854775807.0 * (double)(X)) )
+
+
+/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */
+#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0))
+
+/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */
+#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) )
+
+
+#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b)))
+#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7)))
+#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8))
+#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23)))
+#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24))
+
+
+#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255)))
+#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b))
+#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767))))
+#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
+#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
+#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) _mesa_lroundevenf( CLAMP((f), 0.0F, 1.0F) * 65535.0F) )
+#define CLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) _mesa_lroundevenf( (f) * 65535.0F) )
+
+#define UNCLAMPED_FLOAT_TO_SHORT(s, f) \
+ s = ( (GLshort) _mesa_lroundevenf( CLAMP((f), -1.0F, 1.0F) * 32767.0F) )
+
+/***
+ *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
+ *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
+ ***/
+#ifndef DEBUG
+/* This function/macro is sensitive to precision. Test very carefully
+ * if you change it!
+ */
+#define UNCLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (FLT); \
+ if (__tmp.i < 0) \
+ UB = (GLubyte) 0; \
+ else if (__tmp.i >= IEEE_ONE) \
+ UB = (GLubyte) 255; \
+ else { \
+ __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
+ } \
+ } while (0)
+#define CLAMPED_FLOAT_TO_UBYTE(UB, FLT) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (FLT) * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
+ } while (0)
+#else
+#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) _mesa_lroundevenf(CLAMP((f), 0.0F, 1.0F) * 255.0F))
+#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) _mesa_lroundevenf((f) * 255.0F))
+#endif
+
+static fi_type UINT_AS_UNION(GLuint u)
+{
+ fi_type tmp;
+ tmp.u = u;
+ return tmp;
+}
+
+static inline fi_type INT_AS_UNION(GLint i)
+{
+ fi_type tmp;
+ tmp.i = i;
+ return tmp;
+}
+
+static inline fi_type FLOAT_AS_UNION(GLfloat f)
+{
+ fi_type tmp;
+ tmp.f = f;
+ return tmp;
+}
+
+static inline uint64_t DOUBLE_AS_UINT64(double d)
+{
+ union {
+ double d;
+ uint64_t u64;
+ } tmp;
+ tmp.d = d;
+ return tmp.u64;
+}
+
+static inline double UINT64_AS_DOUBLE(uint64_t u)
+{
+ union {
+ double d;
+ uint64_t u64;
+ } tmp;
+ tmp.u64 = u;
+ return tmp.d;
+}
+
+/* First sign-extend x, then return uint32_t. */
+#define INT_AS_UINT(x) ((uint32_t)((int32_t)(x)))
+#define FLOAT_AS_UINT(x) (FLOAT_AS_UNION(x).u)
+
+/**
+ * Convert a floating point value to an unsigned fixed point value.
+ *
+ * \param frac_bits The number of bits used to store the fractional part.
+ */
+static inline uint32_t
+U_FIXED(float value, uint32_t frac_bits)
+{
+ value *= (1 << frac_bits);
+ return value < 0.0f ? 0 : (uint32_t) value;
+}
+
+/**
+ * Convert a floating point value to an signed fixed point value.
+ *
+ * \param frac_bits The number of bits used to store the fractional part.
+ */
+static inline int32_t
+S_FIXED(float value, uint32_t frac_bits)
+{
+ return (int32_t) (value * (1 << frac_bits));
+}
+/*@}*/
+
+
+/** Stepping a GLfloat pointer by a byte stride */
+#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i))
+/** Stepping a GLuint pointer by a byte stride */
+#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i))
+/** Stepping a GLubyte[4] pointer by a byte stride */
+#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i))
+/** Stepping a GLfloat[4] pointer by a byte stride */
+#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i))
+/** Stepping a \p t pointer by a byte stride */
+#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i))
+
+
+/**********************************************************************/
+/** \name 4-element vector operations */
+/*@{*/
+
+/** Zero */
+#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0
+
+/** Test for equality */
+#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2] && \
+ (a)[3] == (b)[3])
+
+/** Test for equality (unsigned bytes) */
+static inline GLboolean
+TEST_EQ_4UBV(const GLubyte a[4], const GLubyte b[4])
+{
+#if defined(__i386__)
+ return *((const GLuint *) a) == *((const GLuint *) b);
+#else
+ return TEST_EQ_4V(a, b);
+#endif
+}
+
+
+/** Copy a 4-element vector */
+#define COPY_4V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+
+/** Copy a 4-element unsigned byte vector */
+static inline void
+COPY_4UBV(GLubyte dst[4], const GLubyte src[4])
+{
+#if defined(__i386__)
+ *((GLuint *) dst) = *((GLuint *) src);
+#else
+ /* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */
+ COPY_4V(dst, src);
+#endif
+}
+
+/** Copy \p SZ elements into a 4-element vector */
+#define COPY_SZ_4V(DST, SZ, SRC) \
+do { \
+ switch (SZ) { \
+ case 4: (DST)[3] = (SRC)[3]; \
+ case 3: (DST)[2] = (SRC)[2]; \
+ case 2: (DST)[1] = (SRC)[1]; \
+ case 1: (DST)[0] = (SRC)[0]; \
+ } \
+} while(0)
+
+/** Copy \p SZ elements into a homegeneous (4-element) vector, giving
+ * default values to the remaining */
+#define COPY_CLEAN_4V(DST, SZ, SRC) \
+do { \
+ ASSIGN_4V( DST, 0, 0, 0, 1 ); \
+ COPY_SZ_4V( DST, SZ, SRC ); \
+} while (0)
+
+/** Subtraction */
+#define SUB_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] - (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] - (SRCB)[3]; \
+} while (0)
+
+/** Addition */
+#define ADD_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] + (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] + (SRCB)[3]; \
+} while (0)
+
+/** Element-wise multiplication */
+#define SCALE_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] * (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] * (SRCB)[3]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_4V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+ (DST)[2] += (SRC)[2]; \
+ (DST)[3] += (SRC)[3]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] += (SRCA)[2] * (SRCB)[2]; \
+ (DST)[3] += (SRCA)[3] * (SRCB)[3]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+ (DST)[2] += S * (SRCB)[2]; \
+ (DST)[3] += S * (SRCB)[3]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_4V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+ (DST)[2] = S * (SRCB)[2]; \
+ (DST)[3] = S * (SRCB)[3]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_4V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+ (DST)[2] *= S; \
+ (DST)[3] *= S; \
+} while (0)
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name 3-element vector operations*/
+/*@{*/
+
+/** Zero */
+#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0
+
+/** Test for equality */
+#define TEST_EQ_3V(a,b) \
+ ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2])
+
+/** Copy a 3-element vector */
+#define COPY_3V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+} while (0)
+
+/** Copy a 3-element vector with cast */
+#define COPY_3V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+ (DST)[2] = (CAST)(SRC)[2]; \
+} while (0)
+
+/** Copy a 3-element float vector */
+#define COPY_3FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+ (DST)[2] = _tmp[2]; \
+} while (0)
+
+/** Subtraction */
+#define SUB_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] - (SRCB)[2]; \
+} while (0)
+
+/** Addition */
+#define ADD_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] + (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SCALE_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] * (SRCB)[2]; \
+} while (0)
+
+/** In-place element-wise multiplication */
+#define SELF_SCALE_3V( DST, SRC ) \
+do { \
+ (DST)[0] *= (SRC)[0]; \
+ (DST)[1] *= (SRC)[1]; \
+ (DST)[2] *= (SRC)[2]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_3V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+ (DST)[2] += (SRC)[2]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] += (SRCA)[2] * (SRCB)[2]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_3V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+ (DST)[2] = S * (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+ (DST)[2] += S * (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_3V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+ (DST)[2] *= S; \
+} while (0)
+
+/** In-place scalar addition */
+#define ACC_SCALAR_3V( DST, S ) \
+do { \
+ (DST)[0] += S; \
+ (DST)[1] += S; \
+ (DST)[2] += S; \
+} while (0)
+
+/** Assignment */
+#define ASSIGN_3V( V, V0, V1, V2 ) \
+do { \
+ V[0] = V0; \
+ V[1] = V1; \
+ V[2] = V2; \
+} while(0)
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name 2-element vector operations*/
+/*@{*/
+
+/** Zero */
+#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0
+
+/** Copy a 2-element vector */
+#define COPY_2V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+} while (0)
+
+/** Copy a 2-element vector with cast */
+#define COPY_2V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+} while (0)
+
+/** Copy a 2-element float vector */
+#define COPY_2FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+} while (0)
+
+/** Subtraction */
+#define SUB_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+} while (0)
+
+/** Addition */
+#define ADD_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SCALE_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_2V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_2V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_2V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+} while (0)
+
+/** In-place scalar addition */
+#define ACC_SCALAR_2V( DST, S ) \
+do { \
+ (DST)[0] += S; \
+ (DST)[1] += S; \
+} while (0)
+
+/** Assign scalers to short vectors */
+#define ASSIGN_2V( V, V0, V1 ) \
+do { \
+ V[0] = V0; \
+ V[1] = V1; \
+} while(0)
+
+/*@}*/
+
+/** Copy \p sz elements into a homegeneous (4-element) vector, giving
+ * default values to the remaining components.
+ * The default values are chosen based on \p type.
+ */
+static inline void
+COPY_CLEAN_4V_TYPE_AS_UNION(fi_type dst[4], int sz, const fi_type src[4],
+ GLenum type)
+{
+ switch (type) {
+ case GL_FLOAT:
+ ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1));
+ break;
+ case GL_INT:
+ ASSIGN_4V(dst, INT_AS_UNION(0), INT_AS_UNION(0),
+ INT_AS_UNION(0), INT_AS_UNION(1));
+ break;
+ case GL_UNSIGNED_INT:
+ ASSIGN_4V(dst, UINT_AS_UNION(0), UINT_AS_UNION(0),
+ UINT_AS_UNION(0), UINT_AS_UNION(1));
+ break;
+ default:
+ ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); /* silence warnings */
+ assert(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_UNION macro");
+ }
+ COPY_SZ_4V(dst, sz, src);
+}
+
+/** \name Linear interpolation functions */
+/*@{*/
+
+static inline GLfloat
+LINTERP(GLfloat t, GLfloat out, GLfloat in)
+{
+ return out + t * (in - out);
+}
+
+static inline void
+INTERP_3F(GLfloat t, GLfloat dst[3], const GLfloat out[3], const GLfloat in[3])
+{
+ dst[0] = LINTERP( t, out[0], in[0] );
+ dst[1] = LINTERP( t, out[1], in[1] );
+ dst[2] = LINTERP( t, out[2], in[2] );
+}
+
+static inline void
+INTERP_4F(GLfloat t, GLfloat dst[4], const GLfloat out[4], const GLfloat in[4])
+{
+ dst[0] = LINTERP( t, out[0], in[0] );
+ dst[1] = LINTERP( t, out[1], in[1] );
+ dst[2] = LINTERP( t, out[2], in[2] );
+ dst[3] = LINTERP( t, out[3], in[3] );
+}
+
+/*@}*/
+
+
+
+static inline unsigned
+minify(unsigned value, unsigned levels)
+{
+ return MAX2(1, value >> levels);
+}
+
+
+/** Cross product of two 3-element vectors */
+static inline void
+CROSS3(GLfloat n[3], const GLfloat u[3], const GLfloat v[3])
+{
+ n[0] = u[1] * v[2] - u[2] * v[1];
+ n[1] = u[2] * v[0] - u[0] * v[2];
+ n[2] = u[0] * v[1] - u[1] * v[0];
+}
+
+
+/** Dot product of two 2-element vectors */
+static inline GLfloat
+DOT2(const GLfloat a[2], const GLfloat b[2])
+{
+ return a[0] * b[0] + a[1] * b[1];
+}
+
+static inline GLfloat
+DOT3(const GLfloat a[3], const GLfloat b[3])
+{
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+}
+
+static inline GLfloat
+DOT4(const GLfloat a[4], const GLfloat b[4])
+{
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
+}
+
+
+static inline GLfloat
+LEN_SQUARED_3FV(const GLfloat v[3])
+{
+ return DOT3(v, v);
+}
+
+static inline GLfloat
+LEN_SQUARED_2FV(const GLfloat v[2])
+{
+ return DOT2(v, v);
+}
+
+
+static inline GLfloat
+LEN_3FV(const GLfloat v[3])
+{
+ return sqrtf(LEN_SQUARED_3FV(v));
+}
+
+static inline GLfloat
+LEN_2FV(const GLfloat v[2])
+{
+ return sqrtf(LEN_SQUARED_2FV(v));
+}
+
+
+/* Normalize a 3-element vector to unit length. */
+static inline void
+NORMALIZE_3FV(GLfloat v[3])
+{
+ GLfloat len = (GLfloat) LEN_SQUARED_3FV(v);
+ if (len) {
+ len = 1.0f / sqrtf(len);
+ v[0] *= len;
+ v[1] *= len;
+ v[2] *= len;
+ }
+}
+
+
+/** Test two floats have opposite signs */
+static inline GLboolean
+DIFFERENT_SIGNS(GLfloat x, GLfloat y)
+{
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 6334 ) /* sizeof operator applied to an expression with an operator may yield unexpected results */
+#endif
+ return signbit(x) != signbit(y);
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+}
+
+
+/** casts to silence warnings with some compilers */
+#define ENUM_TO_INT(E) ((GLint)(E))
+#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E))
+#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E))
+#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
+
+
+/* Stringify */
+#define STRINGIFY(x) #x
+
+/*
+ * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers
+ * as offsets into buffer stores. Since the vertex array pointer and
+ * buffer store pointer are both pointers and we need to add them, we use
+ * this macro.
+ * Both pointers/offsets are expressed in bytes.
+ */
+#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) )
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/menums.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/menums.h
new file mode 100644
index 0000000000..79c14da5ea
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/menums.h
@@ -0,0 +1,189 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2018 Advanced Micro Devices, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file menums.h
+ * Often used definitions and enums.
+ */
+
+#ifndef MENUMS_H
+#define MENUMS_H
+
+#include "util/macros.h"
+
+/**
+ * Enum for the OpenGL APIs we know about and may support.
+ *
+ * NOTE: This must match the api_enum table in
+ * src/mesa/main/get_hash_generator.py
+ */
+typedef enum
+{
+ API_OPENGL_COMPAT, /* legacy / compatibility contexts */
+ API_OPENGLES,
+ API_OPENGLES2,
+ API_OPENGL_CORE,
+ API_OPENGL_LAST = API_OPENGL_CORE
+} gl_api;
+
+/**
+ * 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.
+ * Note: the order is from highest priority to lowest priority.
+ */
+typedef enum
+{
+ TEXTURE_2D_MULTISAMPLE_INDEX,
+ TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX,
+ TEXTURE_CUBE_ARRAY_INDEX,
+ TEXTURE_BUFFER_INDEX,
+ TEXTURE_2D_ARRAY_INDEX,
+ TEXTURE_1D_ARRAY_INDEX,
+ TEXTURE_EXTERNAL_INDEX,
+ TEXTURE_CUBE_INDEX,
+ TEXTURE_3D_INDEX,
+ TEXTURE_RECT_INDEX,
+ TEXTURE_2D_INDEX,
+ TEXTURE_1D_INDEX,
+ NUM_TEXTURE_TARGETS
+} gl_texture_index;
+
+/**
+ * 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
+};
+
+/**
+ * Indexes for all renderbuffers
+ */
+typedef enum
+{
+ /* the four standard color buffers */
+ BUFFER_FRONT_LEFT,
+ BUFFER_BACK_LEFT,
+ BUFFER_FRONT_RIGHT,
+ BUFFER_BACK_RIGHT,
+ BUFFER_DEPTH,
+ BUFFER_STENCIL,
+ BUFFER_ACCUM,
+ /* optional aux buffer */
+ BUFFER_AUX0,
+ /* generic renderbuffers */
+ BUFFER_COLOR0,
+ BUFFER_COLOR1,
+ BUFFER_COLOR2,
+ BUFFER_COLOR3,
+ BUFFER_COLOR4,
+ BUFFER_COLOR5,
+ BUFFER_COLOR6,
+ BUFFER_COLOR7,
+ BUFFER_COUNT,
+ BUFFER_NONE = -1,
+} gl_buffer_index;
+
+typedef enum
+{
+ MAP_USER,
+ MAP_INTERNAL,
+ MAP_COUNT
+} gl_map_buffer_index;
+
+/** @{
+ *
+ * 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
+{
+ MESA_DEBUG_SOURCE_API,
+ MESA_DEBUG_SOURCE_WINDOW_SYSTEM,
+ MESA_DEBUG_SOURCE_SHADER_COMPILER,
+ MESA_DEBUG_SOURCE_THIRD_PARTY,
+ MESA_DEBUG_SOURCE_APPLICATION,
+ MESA_DEBUG_SOURCE_OTHER,
+ MESA_DEBUG_SOURCE_COUNT
+};
+
+enum mesa_debug_type
+{
+ MESA_DEBUG_TYPE_ERROR,
+ MESA_DEBUG_TYPE_DEPRECATED,
+ MESA_DEBUG_TYPE_UNDEFINED,
+ MESA_DEBUG_TYPE_PORTABILITY,
+ MESA_DEBUG_TYPE_PERFORMANCE,
+ MESA_DEBUG_TYPE_OTHER,
+ MESA_DEBUG_TYPE_MARKER,
+ MESA_DEBUG_TYPE_PUSH_GROUP,
+ MESA_DEBUG_TYPE_POP_GROUP,
+ MESA_DEBUG_TYPE_COUNT
+};
+
+enum mesa_debug_severity
+{
+ MESA_DEBUG_SEVERITY_LOW,
+ MESA_DEBUG_SEVERITY_MEDIUM,
+ MESA_DEBUG_SEVERITY_HIGH,
+ MESA_DEBUG_SEVERITY_NOTIFICATION,
+ MESA_DEBUG_SEVERITY_COUNT
+};
+
+/** @} */
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mesa_private.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mesa_private.h
new file mode 100644
index 0000000000..229a746a80
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mesa_private.h
@@ -0,0 +1,56 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file mesa_private.h
+ * Contains mesa internal values
+ *
+ */
+
+#ifndef MESA_PRIVATE_H
+#define MESA_PRIVATE_H
+
+#include "glheader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Sometimes we treat floats as ints. On x86 systems, moving a float
+ * as an int (thereby using integer registers instead of FP registers) is
+ * a performance win. Typically, this can be done with ordinary casts.
+ * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
+ * these casts generate warnings.
+ * The following union typedef is used to solve that.
+ */
+typedef union { float f; int i; unsigned u; } fi_type;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MESA_PRIVATE_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mtypes.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mtypes.h
new file mode 100644
index 0000000000..4f1e8e52ab
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/mtypes.h
@@ -0,0 +1,5281 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file mtypes.h
+ * Main Mesa data structures.
+ *
+ * Please try to mark derived values with a leading underscore ('_').
+ */
+
+#ifndef MTYPES_H
+#define MTYPES_H
+
+
+#include <stdint.h> /* uint32_t */
+#include <stdbool.h>
+#include "c11/threads.h"
+
+#include "main/glheader.h"
+#include "main/glthread.h"
+#include "main/menums.h"
+#include "main/config.h"
+#include "glapi/glapi.h"
+#include "math/m_matrix.h" /* GLmatrix */
+#include "compiler/shader_enums.h"
+#include "compiler/shader_info.h"
+#include "main/formats.h" /* MESA_FORMAT_COUNT */
+#include "compiler/glsl/list.h"
+#include "util/simple_mtx.h"
+#include "util/u_dynarray.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1)
+#define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf)
+
+
+/**
+ * \name Some forward type declarations
+ */
+/*@{*/
+struct _mesa_HashTable;
+struct gl_attrib_node;
+struct gl_list_extensions;
+struct gl_meta_state;
+struct gl_program_cache;
+struct gl_texture_object;
+struct gl_debug_state;
+struct gl_context;
+struct st_context;
+struct gl_uniform_storage;
+struct prog_instruction;
+struct gl_program_parameter_list;
+struct gl_shader_spirv_data;
+struct set;
+struct shader_includes;
+struct vbo_context;
+/*@}*/
+
+
+/** Extra draw modes beyond GL_POINTS, GL_TRIANGLE_FAN, etc */
+#define PRIM_MAX GL_PATCHES
+#define PRIM_OUTSIDE_BEGIN_END (PRIM_MAX + 1)
+#define PRIM_UNKNOWN (PRIM_MAX + 2)
+
+/**
+ * Determine if the given gl_varying_slot appears in the fragment shader.
+ */
+static inline GLboolean
+_mesa_varying_slot_in_fs(gl_varying_slot slot)
+{
+ switch (slot) {
+ case VARYING_SLOT_PSIZ:
+ case VARYING_SLOT_BFC0:
+ case VARYING_SLOT_BFC1:
+ case VARYING_SLOT_EDGE:
+ case VARYING_SLOT_CLIP_VERTEX:
+ case VARYING_SLOT_LAYER:
+ case VARYING_SLOT_TESS_LEVEL_OUTER:
+ case VARYING_SLOT_TESS_LEVEL_INNER:
+ case VARYING_SLOT_BOUNDING_BOX0:
+ case VARYING_SLOT_BOUNDING_BOX1:
+ case VARYING_SLOT_VIEWPORT_MASK:
+ return GL_FALSE;
+ default:
+ return GL_TRUE;
+ }
+}
+
+/**
+ * Bit flags for all renderbuffers
+ */
+#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
+#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
+#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
+#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
+#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
+#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
+#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
+#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
+#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
+#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
+#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
+#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
+#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
+#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
+#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
+#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
+#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
+#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
+#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
+
+/**
+ * Mask of all the color buffer bits (but not accum).
+ */
+#define BUFFER_BITS_COLOR (BUFFER_BIT_FRONT_LEFT | \
+ BUFFER_BIT_BACK_LEFT | \
+ BUFFER_BIT_FRONT_RIGHT | \
+ BUFFER_BIT_BACK_RIGHT | \
+ BUFFER_BIT_AUX0 | \
+ BUFFER_BIT_COLOR0 | \
+ BUFFER_BIT_COLOR1 | \
+ BUFFER_BIT_COLOR2 | \
+ BUFFER_BIT_COLOR3 | \
+ BUFFER_BIT_COLOR4 | \
+ BUFFER_BIT_COLOR5 | \
+ BUFFER_BIT_COLOR6 | \
+ BUFFER_BIT_COLOR7)
+
+/* Mask of bits for depth+stencil buffers */
+#define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
+
+/**
+ * Framebuffer configuration (aka visual / pixelformat)
+ * Note: some of these fields should be boolean, but it appears that
+ * code in drivers/dri/common/util.c requires int-sized fields.
+ */
+struct gl_config
+{
+ GLboolean floatMode;
+ GLuint doubleBufferMode;
+ GLuint stereoMode;
+
+ GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
+ GLuint redMask, greenMask, blueMask, alphaMask;
+ GLint redShift, greenShift, blueShift, alphaShift;
+ GLint rgbBits; /* total bits for rgb */
+
+ GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
+ GLint depthBits;
+ GLint stencilBits;
+
+ GLint numAuxBuffers;
+
+ GLint level;
+
+ /* EXT_visual_rating / GLX 1.2 */
+ GLint visualRating;
+
+ /* EXT_visual_info / GLX 1.2 */
+ GLint transparentPixel;
+ /* colors are floats scaled to ints */
+ GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
+ GLint transparentIndex;
+
+ /* ARB_multisample / SGIS_multisample */
+ GLint sampleBuffers;
+ GLuint samples;
+
+ /* SGIX_pbuffer / GLX 1.3 */
+ GLint maxPbufferWidth;
+ GLint maxPbufferHeight;
+ GLint maxPbufferPixels;
+ GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
+ GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
+
+ /* OML_swap_method */
+ GLint swapMethod;
+
+ /* EXT_texture_from_pixmap */
+ GLint bindToTextureRgb;
+ GLint bindToTextureRgba;
+ GLint bindToMipmapTexture;
+ GLint bindToTextureTargets;
+ GLint yInverted;
+
+ /* EXT_framebuffer_sRGB */
+ GLint sRGBCapable;
+
+ /* EGL_KHR_mutable_render_buffer */
+ GLuint mutableRenderBuffer; /* bool */
+};
+
+
+/**
+ * \name Bit flags used for updating material values.
+ */
+/*@{*/
+#define MAT_ATTRIB_FRONT_AMBIENT 0
+#define MAT_ATTRIB_BACK_AMBIENT 1
+#define MAT_ATTRIB_FRONT_DIFFUSE 2
+#define MAT_ATTRIB_BACK_DIFFUSE 3
+#define MAT_ATTRIB_FRONT_SPECULAR 4
+#define MAT_ATTRIB_BACK_SPECULAR 5
+#define MAT_ATTRIB_FRONT_EMISSION 6
+#define MAT_ATTRIB_BACK_EMISSION 7
+#define MAT_ATTRIB_FRONT_SHININESS 8
+#define MAT_ATTRIB_BACK_SHININESS 9
+#define MAT_ATTRIB_FRONT_INDEXES 10
+#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_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
+#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)
+#define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
+#define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
+#define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
+#define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
+#define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
+#define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
+#define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
+#define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
+#define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
+#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 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)
+/*@}*/
+
+
+/**
+ * Material state.
+ */
+struct gl_material
+{
+ GLfloat Attrib[MAT_ATTRIB_MAX][4];
+};
+
+
+/**
+ * Light state flags.
+ */
+/*@{*/
+#define LIGHT_SPOT 0x1
+#define LIGHT_LOCAL_VIEWER 0x2
+#define LIGHT_POSITIONAL 0x4
+#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
+/*@}*/
+
+
+/**
+ * Light source state.
+ */
+struct gl_light
+{
+ GLfloat Ambient[4]; /**< ambient color */
+ GLfloat Diffuse[4]; /**< diffuse color */
+ GLfloat Specular[4]; /**< specular color */
+ GLfloat EyePosition[4]; /**< position in eye coordinates */
+ GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */
+ GLfloat SpotExponent;
+ GLfloat SpotCutoff; /**< in degrees */
+ GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
+ GLfloat ConstantAttenuation;
+ GLfloat LinearAttenuation;
+ GLfloat QuadraticAttenuation;
+ GLboolean Enabled; /**< On/off flag */
+
+ /**
+ * \name Derived fields
+ */
+ /*@{*/
+ GLbitfield _Flags; /**< Mask of LIGHT_x bits defined above */
+
+ GLfloat _Position[4]; /**< position in eye/obj coordinates */
+ GLfloat _VP_inf_norm[3]; /**< Norm direction to infinite light */
+ GLfloat _h_inf_norm[3]; /**< Norm( _VP_inf_norm + <0,0,1> ) */
+ GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */
+ GLfloat _VP_inf_spot_attenuation;
+
+ GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */
+ GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */
+ GLfloat _MatSpecular[2][3]; /**< material spec * light specular */
+ /*@}*/
+};
+
+
+/**
+ * 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? */
+ 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 */
+};
+
+
+/**
+ * Used for storing clear color, texture border color, etc.
+ * The float values are typically unclamped.
+ */
+union gl_color_union
+{
+ GLfloat f[4];
+ GLint i[4];
+ GLuint ui[4];
+};
+
+
+/**
+ * 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 */
+
+ /** 4 colormask bits per draw buffer, max 8 draw buffers. 4*8 = 32 bits */
+ GLbitfield ColorMask;
+
+ GLenum16 DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
+
+ /**
+ * \name alpha testing
+ */
+ /*@{*/
+ GLboolean AlphaEnabled; /**< Alpha test enabled flag */
+ 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
+ {
+ 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;
+
+ /**
+ * Which advanced blending mode is in use (or BLEND_NONE).
+ *
+ * KHR_blend_equation_advanced only allows advanced blending with a single
+ * draw buffer, and NVX_blend_equation_advanced_multi_draw_buffer still
+ * requires all draw buffers to match, so we only need a single value.
+ */
+ enum gl_advanced_blend_mode _AdvancedBlendMode;
+
+ /** 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 */
+ GLenum16 LogicOp; /**< Logic operator */
+ enum gl_logicop_mode _LogicOp;
+ /*@}*/
+
+ GLboolean DitherFlag; /**< Dither enable flag */
+
+ GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
+ 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 */
+};
+
+
+/**
+ * Vertex format to describe a vertex element.
+ */
+struct gl_vertex_format
+{
+ GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
+ GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
+ enum pipe_format _PipeFormat:16; /**< pipe_format for Gallium */
+ GLubyte Size:5; /**< components per element (1,2,3,4) */
+ GLubyte Normalized:1; /**< GL_ARB_vertex_program */
+ GLubyte Integer:1; /**< Integer-valued? */
+ GLubyte Doubles:1; /**< double values are not converted to floats */
+ GLubyte _ElementSize; /**< Size of each element in bytes */
+};
+
+
+/**
+ * Current attribute group (GL_CURRENT_BIT).
+ */
+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
+ * SIX and SEVEN attribute slots.
+ * \note We need double storage for 64-bit vertex attributes
+ */
+ GLfloat Attrib[VERT_ATTRIB_MAX][4*2];
+
+ /**
+ * \name Current raster position attributes (always up to date after a
+ * glRasterPos call).
+ */
+ GLfloat RasterPos[4];
+ GLfloat RasterDistance;
+ GLfloat RasterColor[4];
+ GLfloat RasterSecondaryColor[4];
+ GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
+ GLboolean RasterPosValid;
+};
+
+
+/**
+ * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
+ */
+struct gl_depthbuffer_attrib
+{
+ 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).
+ */
+struct gl_eval_attrib
+{
+ /**
+ * \name Enable bits
+ */
+ /*@{*/
+ GLboolean Map1Color4;
+ GLboolean Map1Index;
+ GLboolean Map1Normal;
+ GLboolean Map1TextureCoord1;
+ GLboolean Map1TextureCoord2;
+ GLboolean Map1TextureCoord3;
+ GLboolean Map1TextureCoord4;
+ GLboolean Map1Vertex3;
+ GLboolean Map1Vertex4;
+ GLboolean Map2Color4;
+ GLboolean Map2Index;
+ GLboolean Map2Normal;
+ GLboolean Map2TextureCoord1;
+ GLboolean Map2TextureCoord2;
+ GLboolean Map2TextureCoord3;
+ GLboolean Map2TextureCoord4;
+ GLboolean Map2Vertex3;
+ GLboolean Map2Vertex4;
+ GLboolean AutoNormal;
+ /*@}*/
+
+ /**
+ * \name Map Grid endpoints and divisions and calculated du values
+ */
+ /*@{*/
+ GLint MapGrid1un;
+ GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du;
+ GLint MapGrid2un, MapGrid2vn;
+ GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du;
+ GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv;
+ /*@}*/
+};
+
+
+/**
+ * Compressed fog mode.
+ */
+enum gl_fog_mode
+{
+ FOG_NONE,
+ FOG_LINEAR,
+ FOG_EXP,
+ FOG_EXP2,
+};
+
+
+/**
+ * Fog attribute group (GL_FOG_BIT).
+ */
+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 */
+ GLenum16 Mode; /**< Fog mode */
+ GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */
+ 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
+{
+ 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 */
+ GLuint MaxShaderCompilerThreads; /**< GL_ARB_parallel_shader_compile */
+};
+
+
+/**
+ * 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;
+
+ 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;
+ 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? */
+
+ GLfloat _BaseColor[2][3];
+ /*@}*/
+};
+
+
+/**
+ * Line attribute group (GL_LINE_BIT).
+ */
+struct gl_line_attrib
+{
+ GLboolean SmoothFlag; /**< GL_LINE_SMOOTH enabled? */
+ GLboolean StippleFlag; /**< GL_LINE_STIPPLE enabled? */
+ GLushort StipplePattern; /**< Stipple pattern */
+ GLint StippleFactor; /**< Stipple repeat factor */
+ GLfloat Width; /**< Line width */
+};
+
+
+/**
+ * Display list attribute group (GL_LIST_BIT).
+ */
+struct gl_list_attrib
+{
+ GLuint ListBase;
+};
+
+
+/**
+ * Multisample attribute group (GL_MULTISAMPLE_BIT).
+ */
+struct gl_multisample_attrib
+{
+ GLboolean Enabled;
+ GLboolean SampleAlphaToCoverage;
+ GLboolean SampleAlphaToOne;
+ GLboolean SampleCoverage;
+ GLboolean SampleCoverageInvert;
+ GLboolean SampleShading;
+
+ /* ARB_texture_multisample / GL3.2 additions */
+ GLboolean SampleMask;
+
+ GLfloat SampleCoverageValue; /**< In range [0, 1] */
+ GLfloat MinSampleShadingValue; /**< In range [0, 1] */
+
+ /** The GL spec defines this as an array but >32x MSAA is madness */
+ GLbitfield SampleMaskValue;
+
+ /* NV_alpha_to_coverage_dither_control */
+ GLenum SampleAlphaToCoverageDitherControl;
+};
+
+
+/**
+ * A pixelmap (see glPixelMap)
+ */
+struct gl_pixelmap
+{
+ GLint Size;
+ GLfloat Map[MAX_PIXEL_MAP_TABLE];
+};
+
+
+/**
+ * Collection of all pixelmaps
+ */
+struct gl_pixelmaps
+{
+ struct gl_pixelmap RtoR; /**< i.e. GL_PIXEL_MAP_R_TO_R */
+ struct gl_pixelmap GtoG;
+ struct gl_pixelmap BtoB;
+ struct gl_pixelmap AtoA;
+ struct gl_pixelmap ItoR;
+ struct gl_pixelmap ItoG;
+ struct gl_pixelmap ItoB;
+ struct gl_pixelmap ItoA;
+ struct gl_pixelmap ItoI;
+ struct gl_pixelmap StoS;
+};
+
+
+/**
+ * Pixel attribute group (GL_PIXEL_MODE_BIT).
+ */
+struct gl_pixel_attrib
+{
+ 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;
+ GLfloat DepthBias, DepthScale;
+ GLint IndexShift, IndexOffset;
+ /*@}*/
+
+ /* Pixel Maps */
+ /* Note: actual pixel maps are not part of this attrib group */
+ GLboolean MapColorFlag;
+ GLboolean MapStencilFlag;
+
+ /*--- End Pixel Transfer State ---*/
+
+ /** glPixelZoom */
+ GLfloat ZoomX, ZoomY;
+};
+
+
+/**
+ * Point attribute group (GL_POINT_BIT).
+ */
+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*/
+ GLenum16 SpriteRMode; /**< GL_NV_point_sprite (only!) */
+ GLenum16 SpriteOrigin; /**< GL_ARB_point_sprite */
+};
+
+
+/**
+ * Polygon attribute group (GL_POLYGON_BIT).
+ */
+struct gl_polygon_attrib
+{
+ GLenum16 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 */
+ GLboolean CullFlag; /**< Culling on/off flag */
+ GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
+ GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
+ 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 */
+};
+
+
+/**
+ * Scissor attributes (GL_SCISSOR_BIT).
+ */
+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 */
+ 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
+ * to GL_FRONT. Element 1 corresponds to the OpenGL 2.0 /
+ * GL_ATI_separate_stencil GL_BACK state. Element 2 corresponds to the
+ * GL_EXT_stencil_two_side GL_BACK state.
+ *
+ * The derived value \c _BackFace is either 1 or 2 depending on whether or
+ * not GL_STENCIL_TEST_TWO_SIDE_EXT is enabled.
+ *
+ * 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) */
+ 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 */
+};
+
+
+/**
+ * Bit flags for each type of texture object
+ */
+/*@{*/
+#define TEXTURE_2D_MULTISAMPLE_BIT (1 << TEXTURE_2D_MULTISAMPLE_INDEX)
+#define TEXTURE_2D_MULTISAMPLE_ARRAY_BIT (1 << TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX)
+#define TEXTURE_CUBE_ARRAY_BIT (1 << TEXTURE_CUBE_ARRAY_INDEX)
+#define TEXTURE_BUFFER_BIT (1 << TEXTURE_BUFFER_INDEX)
+#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX)
+#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX)
+#define TEXTURE_EXTERNAL_BIT (1 << TEXTURE_EXTERNAL_INDEX)
+#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
+#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
+#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
+#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
+#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
+/*@}*/
+
+
+/**
+ * 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 */
+ 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 */
+ GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
+ GLuint Width2; /**< = Width - 2*Border */
+ GLuint Height2; /**< = Height - 2*Border */
+ GLuint Depth2; /**< = Depth - 2*Border */
+ GLuint WidthLog2; /**< = log2(Width2) */
+ GLuint HeightLog2; /**< = log2(Height2) */
+ GLuint DepthLog2; /**< = log2(Depth2) */
+ GLuint MaxNumLevels; /**< = maximum possible number of mipmap
+ levels, computed from the dimensions */
+
+ struct gl_texture_object *TexObject; /**< Pointer back to parent object */
+ GLuint Level; /**< Which mipmap level am I? */
+ /** Cube map face: index into gl_texture_object::Image[] array */
+ GLuint Face;
+
+ /** GL_ARB_texture_multisample */
+ GLuint NumSamples; /**< Sample count, or 0 for non-multisample */
+ GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */
+};
+
+
+/**
+ * Indexes for cube map faces.
+ */
+typedef enum
+{
+ FACE_POS_X = 0,
+ FACE_NEG_X = 1,
+ FACE_POS_Y = 2,
+ FACE_NEG_Y = 3,
+ FACE_POS_Z = 4,
+ FACE_NEG_Z = 5,
+ MAX_FACES = 6
+} gl_face_index;
+
+
+/**
+ * Sampler object state. These objects are new with GL_ARB_sampler_objects
+ * and OpenGL 3.3. Legacy texture objects also contain a sampler object.
+ */
+struct gl_sampler_object
+{
+ simple_mtx_t Mutex;
+ GLuint Name;
+ GLchar *Label; /**< GL_KHR_debug */
+ GLint RefCount;
+
+ 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 */
+ GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
+ 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 */
+ GLenum16 CompareMode; /**< GL_ARB_shadow */
+ GLenum16 CompareFunc; /**< GL_ARB_shadow */
+ GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
+
+ /** GL_ARB_bindless_texture */
+ bool HandleAllocated;
+ struct util_dynarray Handles;
+};
+
+
+/**
+ * Texture object state. Contains the array of mipmap images, border color,
+ * wrap modes, filter modes, and shadow/texcompare state.
+ */
+struct gl_texture_object
+{
+ simple_mtx_t Mutex; /**< for thread safety */
+ GLint RefCount; /**< reference count */
+ GLuint Name; /**< the user-visible texture object ID */
+ GLenum16 Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
+ GLenum16 DepthMode; /**< GL_ARB_depth_texture */
+ GLchar *Label; /**< GL_KHR_debug */
+
+ struct gl_sampler_object Sampler;
+
+ gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
+ Only valid when Target is valid. */
+ GLfloat Priority; /**< in [0,1] */
+ GLint MaxLevel; /**< max mipmap level (max=1000), OpenGL 1.2 */
+ GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
+ GLbyte _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 */
+ GLushort _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
+ GLbyte ImmutableLevels; /**< ES 3.0 / ARB_texture_view */
+ 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 */
+
+ /** GL_OES_EGL_image_external */
+ GLubyte RequiredTextureImageUnits;
+
+ GLubyte MinLevel; /**< GL_ARB_texture_view */
+ GLubyte NumLevels; /**< GL_ARB_texture_view */
+ GLushort MinLayer; /**< GL_ARB_texture_view */
+ GLushort NumLayers; /**< GL_ARB_texture_view */
+
+ /** GL_EXT_memory_object */
+ GLenum16 TextureTiling;
+
+ /** GL_ARB_shader_image_load_store */
+ GLenum16 ImageFormatCompatibilityType;
+
+ /** GL_ARB_texture_buffer_object */
+ GLenum16 BufferObjectFormat;
+ /** Equivalent Mesa format for BufferObjectFormat. */
+ mesa_format _BufferObjectFormat;
+ struct gl_buffer_object *BufferObject;
+
+ /** GL_ARB_texture_buffer_range */
+ GLintptr BufferOffset;
+ GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
+
+ /** Actual texture images, indexed by [cube face] and [mipmap level] */
+ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
+
+ /** 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
+{
+ 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 */
+ GLenum16 SourceRGB[MAX_COMBINER_TERMS];
+ GLenum16 SourceA[MAX_COMBINER_TERMS];
+ /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
+ GLenum16 OperandRGB[MAX_COMBINER_TERMS];
+ GLenum16 OperandA[MAX_COMBINER_TERMS];
+ GLubyte ScaleShiftRGB; /**< 0, 1 or 2 */
+ GLubyte ScaleShiftA; /**< 0, 1 or 2 */
+ GLubyte _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
+ GLubyte _NumArgsA; /**< Number of inputs used for the A combiner */
+};
+
+
+/** Compressed TexEnv effective Combine mode */
+enum gl_tex_env_mode
+{
+ TEXENV_MODE_REPLACE, /* r = a0 */
+ TEXENV_MODE_MODULATE, /* r = a0 * a1 */
+ TEXENV_MODE_ADD, /* r = a0 + a1 */
+ TEXENV_MODE_ADD_SIGNED, /* r = a0 + a1 - 0.5 */
+ TEXENV_MODE_INTERPOLATE, /* r = a0 * a2 + a1 * (1 - a2) */
+ TEXENV_MODE_SUBTRACT, /* r = a0 - a1 */
+ TEXENV_MODE_DOT3_RGB, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGB_EXT, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGBA, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGBA_EXT, /* r = a0 . a1 */
+ TEXENV_MODE_MODULATE_ADD_ATI, /* r = a0 * a2 + a1 */
+ TEXENV_MODE_MODULATE_SIGNED_ADD_ATI, /* r = a0 * a2 + a1 - 0.5 */
+ TEXENV_MODE_MODULATE_SUBTRACT_ATI, /* r = a0 * a2 - a1 */
+ TEXENV_MODE_ADD_PRODUCTS_NV, /* r = a0 * a1 + a2 * a3 */
+ TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV, /* r = a0 * a1 + a2 * a3 - 0.5 */
+};
+
+
+/** Compressed TexEnv Combine source */
+enum gl_tex_env_source
+{
+ TEXENV_SRC_TEXTURE0,
+ TEXENV_SRC_TEXTURE1,
+ TEXENV_SRC_TEXTURE2,
+ TEXENV_SRC_TEXTURE3,
+ TEXENV_SRC_TEXTURE4,
+ TEXENV_SRC_TEXTURE5,
+ TEXENV_SRC_TEXTURE6,
+ TEXENV_SRC_TEXTURE7,
+ TEXENV_SRC_TEXTURE,
+ TEXENV_SRC_PREVIOUS,
+ TEXENV_SRC_PRIMARY_COLOR,
+ TEXENV_SRC_CONSTANT,
+ TEXENV_SRC_ZERO,
+ TEXENV_SRC_ONE,
+};
+
+
+/** Compressed TexEnv Combine operand */
+enum gl_tex_env_operand
+{
+ TEXENV_OPR_COLOR,
+ TEXENV_OPR_ONE_MINUS_COLOR,
+ TEXENV_OPR_ALPHA,
+ TEXENV_OPR_ONE_MINUS_ALPHA,
+};
+
+
+/** Compressed TexEnv Combine argument */
+struct gl_tex_env_argument
+{
+#ifdef __GNUC__
+ __extension__ uint8_t Source:4; /**< TEXENV_SRC_x */
+ __extension__ uint8_t Operand:2; /**< TEXENV_OPR_x */
+#else
+ uint8_t Source; /**< SRC_x */
+ uint8_t Operand; /**< OPR_x */
+#endif
+};
+
+
+/***
+ * Compressed TexEnv Combine state.
+ */
+struct gl_tex_env_combine_packed
+{
+ uint32_t ModeRGB:4; /**< Effective mode for RGB as 4 bits */
+ uint32_t ModeA:4; /**< Effective mode for RGB as 4 bits */
+ uint32_t ScaleShiftRGB:2; /**< 0, 1 or 2 */
+ uint32_t ScaleShiftA:2; /**< 0, 1 or 2 */
+ uint32_t NumArgsRGB:3; /**< Number of inputs used for the RGB combiner */
+ uint32_t NumArgsA:3; /**< Number of inputs used for the A combiner */
+ /** Source arguments in a packed manner */
+ struct gl_tex_env_argument ArgsRGB[MAX_COMBINER_TERMS];
+ struct gl_tex_env_argument ArgsA[MAX_COMBINER_TERMS];
+};
+
+
+/**
+ * TexGenEnabled flags.
+ */
+/*@{*/
+#define S_BIT 1
+#define T_BIT 2
+#define R_BIT 4
+#define Q_BIT 8
+#define STR_BITS (S_BIT | T_BIT | R_BIT)
+/*@}*/
+
+
+/**
+ * Bit flag versions of the corresponding GL_ constants.
+ */
+/*@{*/
+#define TEXGEN_SPHERE_MAP 0x1
+#define TEXGEN_OBJ_LINEAR 0x2
+#define TEXGEN_EYE_LINEAR 0x4
+#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)
+/*@}*/
+
+
+
+/** Tex-gen enabled for texture unit? */
+#define ENABLE_TEXGEN(unit) (1 << (unit))
+
+/** Non-identity texture matrix for texture unit? */
+#define ENABLE_TEXMAT(unit) (1 << (unit))
+
+
+/**
+ * Texture coord generation state.
+ */
+struct gl_texgen
+{
+ GLenum16 Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
+ GLbitfield8 _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
+ GLfloat ObjectPlane[4];
+ GLfloat EyePlane[4];
+};
+
+
+/**
+ * Sampler-related subset of a texture unit, like current texture objects.
+ */
+struct gl_texture_unit
+{
+ GLfloat LodBias; /**< for biasing mipmap levels */
+
+ /** Texture targets that have a non-default texture bound */
+ GLbitfield _BoundTextures;
+
+ /** Current sampler object (GL_ARB_sampler_objects) */
+ struct gl_sampler_object *Sampler;
+
+ /** Current texture object pointers */
+ struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
+
+ /** Points to highest priority, complete and enabled texture object */
+ struct gl_texture_object *_Current;
+};
+
+
+/**
+ * Fixed-function-related subset of a texture unit, like enable flags,
+ * texture environment/function/combiners, and texgen state.
+ */
+struct gl_fixedfunc_texture_unit
+{
+ GLbitfield16 Enabled; /**< bitmask of TEXTURE_*_BIT flags */
+
+ 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;
+ GLbitfield8 TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
+ GLbitfield8 _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
+
+ /**
+ * \name GL_EXT_texture_env_combine
+ */
+ struct gl_tex_env_combine_state Combine;
+
+ /**
+ * Derived state based on \c EnvMode and the \c BaseFormat of the
+ * currently enabled texture.
+ */
+ struct gl_tex_env_combine_state _EnvMode;
+
+ /** Current compressed TexEnv & Combine state */
+ struct gl_tex_env_combine_packed _CurrentCombinePacked;
+
+ /**
+ * Currently enabled combiner state. This will point to either
+ * \c Combine or \c _EnvMode.
+ */
+ struct gl_tex_env_combine_state *_CurrentCombine;
+};
+
+
+/**
+ * Texture attribute group (GL_TEXTURE_BIT).
+ */
+struct gl_texture_attrib
+{
+ struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
+
+ /** GL_ARB_texture_buffer_object */
+ struct gl_buffer_object *BufferObject;
+
+ GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */
+
+ /** Texture coord units/sets used for fragment texturing */
+ GLbitfield8 _EnabledCoordUnits;
+
+ /** Texture coord units that have texgen enabled */
+ GLbitfield8 _TexGenEnabled;
+
+ /** Texture coord units that have non-identity matrices */
+ GLbitfield8 _TexMatEnabled;
+
+ /** Bitwise-OR of all Texture.Unit[i]._GenFlags */
+ GLbitfield8 _GenFlags;
+
+ /** Largest index of a texture unit with _Current != NULL. */
+ GLshort _MaxEnabledTexImageUnit;
+
+ /** Largest index + 1 of texture units that have had any CurrentTex set. */
+ GLubyte NumCurrentTexUsed;
+
+ /** GL_ARB_seamless_cubemap */
+ GLboolean CubeMapSeamless;
+
+ struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+ struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS];
+};
+
+
+/**
+ * Data structure representing a single clip plane (e.g. one of the elements
+ * 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
+{
+ 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 DepthClampNear; /**< GL_AMD_depth_clamp_separate */
+ GLboolean DepthClampFar; /**< GL_AMD_depth_clamp_separate */
+ /** GL_ARB_clip_control */
+ 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 */
+ GLfloat Near, Far; /**< Depth buffer range */
+
+ /**< GL_NV_viewport_swizzle */
+ GLenum16 SwizzleX, SwizzleY, SwizzleZ, SwizzleW;
+};
+
+
+/**
+ * Fields describing a mapped buffer range.
+ */
+struct gl_buffer_mapping
+{
+ GLbitfield AccessFlags; /**< Mask of GL_MAP_x_BIT flags */
+ GLvoid *Pointer; /**< User-space address of mapping */
+ GLintptr Offset; /**< Mapped offset */
+ GLsizeiptr Length; /**< Mapped length */
+};
+
+
+/**
+ * Usages we've seen for a buffer object.
+ */
+typedef enum
+{
+ USAGE_UNIFORM_BUFFER = 0x1,
+ USAGE_TEXTURE_BUFFER = 0x2,
+ USAGE_ATOMIC_COUNTER_BUFFER = 0x4,
+ USAGE_SHADER_STORAGE_BUFFER = 0x8,
+ USAGE_TRANSFORM_FEEDBACK_BUFFER = 0x10,
+ USAGE_PIXEL_PACK_BUFFER = 0x20,
+ USAGE_ARRAY_BUFFER = 0x40,
+ USAGE_ELEMENT_ARRAY_BUFFER = 0x80,
+ USAGE_DISABLE_MINMAX_CACHE = 0x100,
+} gl_buffer_usage;
+
+
+/**
+ * GL_ARB_vertex/pixel_buffer_object buffer object
+ */
+struct gl_buffer_object
+{
+ GLint RefCount;
+ GLuint Name;
+ GLchar *Label; /**< GL_KHR_debug */
+ 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 */
+ GLuint NumSubDataCalls;
+ GLuint NumMapBufferWriteCalls;
+
+ struct gl_buffer_mapping Mappings[MAP_COUNT];
+
+ /** Memoization of min/max index computations for static index buffers */
+ simple_mtx_t MinMaxCacheMutex;
+ struct hash_table *MinMaxCache;
+ unsigned MinMaxCacheHitIndices;
+ unsigned MinMaxCacheMissIndices;
+ bool MinMaxCacheDirty;
+
+ bool HandleAllocated; /**< GL_ARB_bindless_texture */
+};
+
+
+/**
+ * Client pixel packing/unpacking attributes
+ */
+struct gl_pixelstore_attrib
+{
+ GLint Alignment;
+ GLint RowLength;
+ GLint SkipPixels;
+ GLint SkipRows;
+ GLint ImageHeight;
+ GLint SkipImages;
+ GLboolean SwapBytes;
+ GLboolean LsbFirst;
+ GLboolean Invert; /**< GL_MESA_pack_invert */
+ GLint CompressedBlockWidth; /**< GL_ARB_compressed_texture_pixel_storage */
+ GLint CompressedBlockHeight;
+ GLint CompressedBlockDepth;
+ GLint CompressedBlockSize;
+ struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
+};
+
+
+/**
+ * Enum for defining the mapping for the position/generic0 attribute.
+ *
+ * Do not change the order of the values as these are used as
+ * array indices.
+ */
+typedef enum
+{
+ ATTRIBUTE_MAP_MODE_IDENTITY, /**< 1:1 mapping */
+ ATTRIBUTE_MAP_MODE_POSITION, /**< get position and generic0 from position */
+ ATTRIBUTE_MAP_MODE_GENERIC0, /**< get position and generic0 from generic0 */
+ ATTRIBUTE_MAP_MODE_MAX /**< for sizing arrays */
+} gl_attribute_map_mode;
+
+
+/**
+ * Attributes to describe a vertex array.
+ *
+ * Contains the size, type, format and normalization flag,
+ * along with the index of a vertex buffer binding point.
+ *
+ * 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
+{
+ /** Points to client array data. Not used when a VBO is bound */
+ const GLubyte *Ptr;
+ /** Offset of the first element relative to the binding offset */
+ GLuint RelativeOffset;
+ /** Vertex format */
+ struct gl_vertex_format Format;
+ /** Stride as specified with gl*Pointer() */
+ GLshort Stride;
+ /** Index into gl_vertex_array_object::BufferBinding[] array */
+ GLubyte BufferBindingIndex;
+
+ /**
+ * Derived effective buffer binding index
+ *
+ * Index into the gl_vertex_buffer_binding array of the vao.
+ * Similar to BufferBindingIndex, but with the mapping of the
+ * position/generic0 attributes applied and with identical
+ * gl_vertex_buffer_binding entries collapsed to a single
+ * entry within the vao.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLubyte _EffBufferBindingIndex;
+ /**
+ * Derived effective relative offset.
+ *
+ * Relative offset to the effective buffers offset in
+ * gl_vertex_buffer_binding::_EffOffset.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLushort _EffRelativeOffset;
+};
+
+
+/**
+ * This describes the buffer object used for a vertex array (or
+ * multiple vertex arrays). If BufferObj points to the default/null
+ * buffer object, then the vertex array lives in user memory and not a VBO.
+ */
+struct gl_vertex_buffer_binding
+{
+ GLintptr Offset; /**< User-specified offset */
+ GLsizei Stride; /**< User-specified stride */
+ GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
+ struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
+ GLbitfield _BoundArrays; /**< Arrays bound to this binding point */
+
+ /**
+ * Derived effective bound arrays.
+ *
+ * The effective binding handles enabled arrays past the
+ * position/generic0 attribute mapping and reduces the refered
+ * gl_vertex_buffer_binding entries to a unique subset.
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLbitfield _EffBoundArrays;
+ /**
+ * Derived offset.
+ *
+ * The absolute offset to that we can collapse some attributes
+ * to this unique effective binding.
+ * For user space array bindings this contains the smallest pointer value
+ * in the bound and interleaved arrays.
+ * For VBO bindings this contains an offset that lets the attributes
+ * _EffRelativeOffset stay positive and in bounds with
+ * Const.MaxVertexAttribRelativeOffset
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLintptr _EffOffset;
+};
+
+
+/**
+ * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
+ * the GL_ARB_vertex_array_object extension.
+ */
+struct gl_vertex_array_object
+{
+ /** Name of the VAO as received from glGenVertexArray. */
+ GLuint Name;
+
+ GLint RefCount;
+
+ GLchar *Label; /**< GL_KHR_debug */
+
+ /**
+ * Has this array object been bound?
+ */
+ GLboolean EverBound;
+
+ /**
+ * Marked to true if the object is shared between contexts and immutable.
+ * Then reference counting is done using atomics and thread safe.
+ * Is used for dlist VAOs.
+ */
+ bool SharedAndImmutable;
+
+ /** Vertex attribute arrays */
+ struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX];
+
+ /** Vertex buffer bindings */
+ struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX];
+
+ /** Mask indicating which vertex arrays have vertex buffer associated. */
+ GLbitfield VertexAttribBufferMask;
+
+ /** Mask indicating which vertex arrays have a non-zero instance divisor. */
+ GLbitfield NonZeroDivisorMask;
+
+ /** Mask of VERT_BIT_* values indicating which arrays are enabled */
+ GLbitfield Enabled;
+
+ /**
+ * Mask of VERT_BIT_* enabled arrays past position/generic0 mapping
+ *
+ * The value is valid past calling _mesa_update_vao_derived_arrays.
+ * Note that _mesa_update_vao_derived_arrays is called when binding
+ * the VAO to Array._DrawVAO.
+ */
+ GLbitfield _EffEnabledVBO;
+
+ /** Same as _EffEnabledVBO, but for instance divisors. */
+ GLbitfield _EffEnabledNonZeroDivisor;
+
+ /** Denotes the way the position/generic0 attribute is mapped */
+ gl_attribute_map_mode _AttributeMapMode;
+
+ /** Mask of VERT_BIT_* values indicating changed/dirty arrays */
+ GLbitfield NewArrays;
+
+ /** The index buffer (also known as the element array buffer in OpenGL). */
+ struct gl_buffer_object *IndexBufferObj;
+};
+
+
+/**
+ * Vertex array state
+ */
+struct gl_array_attrib
+{
+ /** Currently bound array object. */
+ struct gl_vertex_array_object *VAO;
+
+ /** The default vertex array object */
+ struct gl_vertex_array_object *DefaultVAO;
+
+ /** The last VAO accessed by a DSA function */
+ struct gl_vertex_array_object *LastLookedUpVAO;
+
+ /** These contents are copied to newly created VAOs. */
+ struct gl_vertex_array_object DefaultVAOState;
+
+ /** Array objects (GL_ARB_vertex_array_object) */
+ struct _mesa_HashTable *Objects;
+
+ GLint ActiveTexture; /**< Client Active Texture */
+ GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
+ GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
+
+ /**
+ * \name Primitive restart controls
+ *
+ * Primitive restart is enabled if either \c PrimitiveRestart or
+ * \c PrimitiveRestartFixedIndex is set.
+ */
+ /*@{*/
+ GLboolean PrimitiveRestart;
+ GLboolean PrimitiveRestartFixedIndex;
+ GLboolean _PrimitiveRestart;
+ GLuint RestartIndex;
+ GLuint _RestartIndex[4]; /**< Restart indices for index_size - 1. */
+ /*@}*/
+
+ /* GL_ARB_vertex_buffer_object */
+ struct gl_buffer_object *ArrayBufferObj;
+
+ /**
+ * Vertex array object that is used with the currently active draw command.
+ * The _DrawVAO is either set to the currently bound VAO for array type
+ * draws or to internal VAO's set up by the vbo module to execute immediate
+ * mode or display list draws.
+ */
+ struct gl_vertex_array_object *_DrawVAO;
+ /**
+ * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
+ * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
+ * but may omit those arrays that shall not be referenced by the current
+ * gl_vertex_program_state::_VPMode. For example the generic attributes are
+ * maked out form the _DrawVAO's enabled arrays when a fixed function
+ * array draw is executed.
+ */
+ GLbitfield _DrawVAOEnabledAttribs;
+ /**
+ * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
+ * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
+ */
+ struct gl_vertex_array_object *_EmptyVAO;
+
+ /** Legal array datatypes and the API for which they have been computed */
+ GLbitfield LegalTypesMask;
+ gl_api LegalTypesMaskAPI;
+};
+
+
+/**
+ * Feedback buffer state
+ */
+struct gl_feedback
+{
+ GLenum16 Type;
+ GLbitfield _Mask; /**< FB_* bits */
+ GLfloat *Buffer;
+ GLuint BufferSize;
+ GLuint Count;
+};
+
+
+/**
+ * Selection buffer state
+ */
+struct gl_selection
+{
+ GLuint *Buffer; /**< selection buffer */
+ GLuint BufferSize; /**< size of the selection buffer */
+ GLuint BufferCount; /**< number of values in the selection buffer */
+ GLuint Hits; /**< number of records in the selection buffer */
+ GLuint NameStackDepth; /**< name stack depth */
+ GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
+ GLboolean HitFlag; /**< hit flag */
+ GLfloat HitMinZ; /**< minimum hit depth */
+ GLfloat HitMaxZ; /**< maximum hit depth */
+};
+
+
+/**
+ * 1-D Evaluator control points
+ */
+struct gl_1d_map
+{
+ GLuint Order; /**< Number of control points */
+ GLfloat u1, u2, du; /**< u1, u2, 1.0/(u2-u1) */
+ GLfloat *Points; /**< Points to contiguous control points */
+};
+
+
+/**
+ * 2-D Evaluator control points
+ */
+struct gl_2d_map
+{
+ GLuint Uorder; /**< Number of control points in U dimension */
+ GLuint Vorder; /**< Number of control points in V dimension */
+ GLfloat u1, u2, du;
+ GLfloat v1, v2, dv;
+ GLfloat *Points; /**< Points to contiguous control points */
+};
+
+
+/**
+ * All evaluator control point state
+ */
+struct gl_evaluators
+{
+ /**
+ * \name 1-D maps
+ */
+ /*@{*/
+ struct gl_1d_map Map1Vertex3;
+ struct gl_1d_map Map1Vertex4;
+ struct gl_1d_map Map1Index;
+ struct gl_1d_map Map1Color4;
+ struct gl_1d_map Map1Normal;
+ struct gl_1d_map Map1Texture1;
+ struct gl_1d_map Map1Texture2;
+ struct gl_1d_map Map1Texture3;
+ struct gl_1d_map Map1Texture4;
+ /*@}*/
+
+ /**
+ * \name 2-D maps
+ */
+ /*@{*/
+ struct gl_2d_map Map2Vertex3;
+ struct gl_2d_map Map2Vertex4;
+ struct gl_2d_map Map2Index;
+ struct gl_2d_map Map2Color4;
+ struct gl_2d_map Map2Normal;
+ struct gl_2d_map Map2Texture1;
+ struct gl_2d_map Map2Texture2;
+ struct gl_2d_map Map2Texture3;
+ struct gl_2d_map Map2Texture4;
+ /*@}*/
+};
+
+
+struct gl_transform_feedback_varying_info
+{
+ char *Name;
+ GLenum16 Type;
+ GLint BufferIndex;
+ GLint Size;
+ GLint Offset;
+};
+
+
+/**
+ * Per-output info vertex shaders for transform feedback.
+ */
+struct gl_transform_feedback_output
+{
+ uint32_t OutputRegister;
+ uint32_t OutputBuffer;
+ uint32_t NumComponents;
+ uint32_t StreamId;
+
+ /** offset (in DWORDs) of this output within the interleaved structure */
+ uint32_t DstOffset;
+
+ /**
+ * Offset into the output register of the data to output. For example,
+ * if NumComponents is 2 and ComponentOffset is 1, then the data to
+ * offset is in the y and z components of the output register.
+ */
+ uint32_t ComponentOffset;
+};
+
+
+struct gl_transform_feedback_buffer
+{
+ uint32_t Binding;
+
+ uint32_t NumVaryings;
+
+ /**
+ * Total number of components stored in each buffer. This may be used by
+ * hardware back-ends to determine the correct stride when interleaving
+ * multiple transform feedback outputs in the same buffer.
+ */
+ uint32_t Stride;
+
+ /**
+ * Which transform feedback stream this buffer binding is associated with.
+ */
+ uint32_t Stream;
+};
+
+
+/** Post-link transform feedback info. */
+struct gl_transform_feedback_info
+{
+ unsigned NumOutputs;
+
+ /* Bitmask of active buffer indices. */
+ unsigned ActiveBuffers;
+
+ struct gl_transform_feedback_output *Outputs;
+
+ /** Transform feedback varyings used for the linking of this shader program.
+ *
+ * Use for glGetTransformFeedbackVarying().
+ */
+ struct gl_transform_feedback_varying_info *Varyings;
+ GLint NumVarying;
+
+ struct gl_transform_feedback_buffer Buffers[MAX_FEEDBACK_BUFFERS];
+};
+
+
+/**
+ * Transform feedback object state
+ */
+struct gl_transform_feedback_object
+{
+ GLuint Name; /**< AKA the object ID */
+ GLint RefCount;
+ GLchar *Label; /**< GL_KHR_debug */
+ GLboolean Active; /**< Is transform feedback enabled? */
+ GLboolean Paused; /**< Is transform feedback paused? */
+ GLboolean EndedAnytime; /**< Has EndTransformFeedback been called
+ at least once? */
+ GLboolean EverBound; /**< Has this object been bound? */
+
+ /**
+ * GLES: if Active is true, remaining number of primitives which can be
+ * rendered without overflow. This is necessary to track because GLES
+ * requires us to generate INVALID_OPERATION if a call to glDrawArrays or
+ * glDrawArraysInstanced would overflow transform feedback buffers.
+ * Undefined if Active is false.
+ *
+ * Not tracked for desktop GL since it's unnecessary.
+ */
+ unsigned GlesRemainingPrims;
+
+ /**
+ * The program active when BeginTransformFeedback() was called.
+ * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
+ * where stage is the pipeline stage that is the source of data for
+ * transform feedback.
+ */
+ struct gl_program *program;
+
+ /** The feedback buffers */
+ GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
+ struct gl_buffer_object *Buffers[MAX_FEEDBACK_BUFFERS];
+
+ /** Start of feedback data in dest buffer */
+ GLintptr Offset[MAX_FEEDBACK_BUFFERS];
+
+ /**
+ * Max data to put into dest buffer (in bytes). Computed based on
+ * RequestedSize and the actual size of the buffer.
+ */
+ GLsizeiptr Size[MAX_FEEDBACK_BUFFERS];
+
+ /**
+ * Size that was specified when the buffer was bound. If the buffer was
+ * bound with glBindBufferBase() or glBindBufferOffsetEXT(), this value is
+ * zero.
+ */
+ GLsizeiptr RequestedSize[MAX_FEEDBACK_BUFFERS];
+};
+
+
+/**
+ * Context state for transform feedback.
+ */
+struct gl_transform_feedback_state
+{
+ 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;
+
+ /** The default xform-fb object (Name==0) */
+ struct gl_transform_feedback_object *DefaultObject;
+};
+
+
+/**
+ * A "performance monitor" as described in AMD_performance_monitor.
+ */
+struct gl_perf_monitor_object
+{
+ GLuint Name;
+
+ /** True if the monitor is currently active (Begin called but not End). */
+ GLboolean Active;
+
+ /**
+ * True if the monitor has ended.
+ *
+ * This is distinct from !Active because it may never have began.
+ */
+ GLboolean Ended;
+
+ /**
+ * A list of groups with currently active counters.
+ *
+ * ActiveGroups[g] == n if there are n counters active from group 'g'.
+ */
+ unsigned *ActiveGroups;
+
+ /**
+ * An array of bitsets, subscripted by group ID, then indexed by counter ID.
+ *
+ * Checking whether counter 'c' in group 'g' is active can be done via:
+ *
+ * BITSET_TEST(ActiveCounters[g], c)
+ */
+ GLuint **ActiveCounters;
+};
+
+
+union gl_perf_monitor_counter_value
+{
+ float f;
+ uint64_t u64;
+ uint32_t u32;
+};
+
+
+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.
+ */
+ 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
+{
+ /** Human readable name for the group. */
+ const char *Name;
+
+ /**
+ * Maximum number of counters in this group which can be active at the
+ * same time.
+ */
+ GLuint MaxActiveCounters;
+
+ /** Array of counters within this group. */
+ const struct gl_perf_monitor_counter *Counters;
+ GLuint NumCounters;
+};
+
+
+/**
+ * A query object instance as described in INTEL_performance_query.
+ *
+ * NB: We want to keep this and the corresponding backend structure
+ * relatively lean considering that applications may expect to
+ * allocate enough objects to be able to query around all draw calls
+ * in a frame.
+ */
+struct gl_perf_query_object
+{
+ GLuint Id; /**< hash table ID/name */
+ unsigned Used:1; /**< has been used for 1 or more queries */
+ unsigned Active:1; /**< inside Begin/EndPerfQuery */
+ unsigned Ready:1; /**< result is ready? */
+};
+
+
+/**
+ * Context state for AMD_performance_monitor.
+ */
+struct gl_perf_monitor_state
+{
+ /** Array of performance monitor groups (indexed by group ID) */
+ const struct gl_perf_monitor_group *Groups;
+ GLuint NumGroups;
+
+ /** The table of all performance monitors. */
+ struct _mesa_HashTable *Monitors;
+};
+
+
+/**
+ * Context state for INTEL_performance_query.
+ */
+struct gl_perf_query_state
+{
+ struct _mesa_HashTable *Objects; /**< The table of all performance query objects */
+};
+
+
+/**
+ * A bindless sampler object.
+ */
+struct gl_bindless_sampler
+{
+ /** Texture unit (set by glUniform1()). */
+ GLubyte unit;
+
+ /** 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.
+ */
+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, or
+ * GL_NONE to indicate both read-only and write-only)
+ */
+ GLenum16 access;
+
+ /** Pointer to the base of the data. */
+ GLvoid *data;
+};
+
+
+/**
+ * Current vertex processing mode: fixed function vs. shader.
+ * In reality, fixed function is probably implemented by a shader but that's
+ * not what we care about here.
+ */
+typedef enum
+{
+ VP_MODE_FF, /**< legacy / fixed function */
+ VP_MODE_SHADER, /**< ARB vertex program or GLSL vertex shader */
+ VP_MODE_MAX /**< for sizing arrays */
+} gl_vertex_processing_mode;
+
+
+/**
+ * Base class for any kind of program object
+ */
+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 */
+
+ /** GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
+ GLenum16 Target;
+ 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 */
+
+ /** Is this program written to on disk shader cache */
+ bool program_written_to_cache;
+
+ /** A bitfield indicating which vertex shader inputs consume two slots
+ *
+ * This is used for mapping from single-slot input locations in the GL API
+ * to dual-slot double input locations in the shader. This field is set
+ * once as part of linking and never updated again to ensure the mapping
+ * remains consistent.
+ *
+ * Note: There may be dual-slot variables in the original shader source
+ * which do not appear in this bitfield due to having been eliminated by
+ * the compiler prior to DualSlotInputs being calculated. There may also
+ * be bits set in this bitfield which are set but which the shader never
+ * reads due to compiler optimizations eliminating such variables after
+ * DualSlotInputs is calculated.
+ */
+ GLbitfield64 DualSlotInputs;
+ /** Subset of OutputsWritten outputs written with non-zero index. */
+ GLbitfield64 SecondaryOutputsWritten;
+ /** TEXTURE_x_BIT bitmask */
+ GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+ /** Bitfield of which samplers are used */
+ GLbitfield SamplersUsed;
+ /** Texture units used for shadow sampling. */
+ GLbitfield ShadowSamplers;
+ /** Texture units used for samplerExternalOES */
+ GLbitfield ExternalSamplersUsed;
+
+ /** Named parameters, constants, etc. from program text */
+ struct gl_program_parameter_list *Parameters;
+
+ /** Map from sampler unit to texture unit (set by glUniform1i()) */
+ GLubyte SamplerUnits[MAX_SAMPLERS];
+
+ /* FIXME: We should be able to make this struct a union. However some
+ * drivers (i915/fragment_programs, swrast/prog_execute) mix the use of
+ * these fields, we should fix this.
+ */
+ struct {
+ /** Fields used by GLSL programs */
+ struct {
+ /** Data shared by gl_program and gl_shader_program */
+ struct gl_shader_program_data *data;
+
+ struct gl_active_atomic_buffer **AtomicBuffers;
+
+ /** Post-link transform feedback info. */
+ struct gl_transform_feedback_info *LinkedTransformFeedback;
+
+ /**
+ * Number of types for subroutine uniforms.
+ */
+ GLuint NumSubroutineUniformTypes;
+
+ /**
+ * Subroutine uniform remap table
+ * based on the program level uniform remap table.
+ */
+ GLuint NumSubroutineUniforms; /* non-sparse total */
+ GLuint NumSubroutineUniformRemapTable;
+ struct gl_uniform_storage **SubroutineUniformRemapTable;
+
+ /**
+ * Num of subroutine functions for this stage and storage for them.
+ */
+ GLuint NumSubroutineFunctions;
+ GLuint MaxSubroutineFunctionIndex;
+ struct gl_subroutine_function *SubroutineFunctions;
+
+ /**
+ * Map from image uniform index to image unit (set by glUniform1i())
+ *
+ * An image uniform index is associated with each image uniform by
+ * the linker. The image index associated with each uniform is
+ * stored in the \c gl_uniform_storage::image field.
+ */
+ 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, \c
+ * GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
+ * write-only.
+ *
+ * It may be different, though only more strict than the value of
+ * \c gl_image_unit::Access for the corresponding image unit.
+ */
+ GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
+
+ struct gl_uniform_block **UniformBlocks;
+ struct gl_uniform_block **ShaderStorageBlocks;
+
+ /**
+ * Bitmask of shader storage blocks not declared as read-only.
+ */
+ unsigned ShaderStorageBlocksWriteAccess;
+
+ /** Which texture target is being sampled
+ * (TEXTURE_1D/2D/3D/etc_INDEX)
+ */
+ GLubyte SamplerTargets[MAX_SAMPLERS];
+
+ /**
+ * Number of samplers declared with the bindless_sampler layout
+ * qualifier as specified by ARB_bindless_texture.
+ */
+ GLuint NumBindlessSamplers;
+ GLboolean HasBoundBindlessSampler;
+ struct gl_bindless_sampler *BindlessSamplers;
+
+ /**
+ * Number of images declared with the bindless_image layout qualifier
+ * as specified by ARB_bindless_texture.
+ */
+ GLuint NumBindlessImages;
+ GLboolean HasBoundBindlessImage;
+ struct gl_bindless_image *BindlessImages;
+
+ union {
+ struct {
+ /**
+ * A bitmask of gl_advanced_blend_mode values
+ */
+ GLbitfield BlendSupport;
+ } fs;
+ };
+ } sh;
+
+ /** ARB assembly-style program fields */
+ struct {
+ struct prog_instruction *Instructions;
+
+ /**
+ * Local parameters used by the program.
+ *
+ * It's dynamically allocated because it is rarely used (just
+ * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
+ * once it's allocated.
+ */
+ GLfloat (*LocalParams)[4];
+
+ /** Bitmask of which register files are read/written with indirect
+ * addressing. Mask of (1 << PROGRAM_x) bits.
+ */
+ GLbitfield IndirectRegisterFiles;
+
+ /** Logical counts */
+ /*@{*/
+ GLuint NumInstructions;
+ GLuint NumTemporaries;
+ GLuint NumParameters;
+ GLuint NumAttributes;
+ GLuint NumAddressRegs;
+ GLuint NumAluInstructions;
+ GLuint NumTexInstructions;
+ GLuint NumTexIndirections;
+ /*@}*/
+ /** Native, actual h/w counts */
+ /*@{*/
+ GLuint NumNativeInstructions;
+ GLuint NumNativeTemporaries;
+ GLuint NumNativeParameters;
+ GLuint NumNativeAttributes;
+ GLuint NumNativeAddressRegs;
+ GLuint NumNativeAluInstructions;
+ GLuint NumNativeTexInstructions;
+ GLuint NumNativeTexIndirections;
+ /*@}*/
+
+ /** Used by ARB assembly-style programs. Can only be true for vertex
+ * programs.
+ */
+ GLboolean IsPositionInvariant;
+ } arb;
+ };
+};
+
+
+/**
+ * State common to vertex and fragment programs.
+ */
+struct gl_program_state
+{
+ GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_ARB/NV */
+ const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
+};
+
+
+/**
+ * Context state for vertex programs.
+ */
+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
+ * programs, user-defined vertex programs and GLSL vertex shaders).
+ * This is the program we must use when rendering.
+ */
+ struct gl_program *_Current;
+
+ GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
+
+ /** Program to emulate fixed-function T&L (see above) */
+ struct gl_program *_TnlProgram;
+
+ /** Cache of fixed-function programs */
+ struct gl_program_cache *Cache;
+
+ GLboolean _Overriden;
+
+ /**
+ * If we have a vertex program, a TNL program or no program at all.
+ * Note that this value should be kept up to date all the time,
+ * nevertheless its correctness is asserted in _mesa_update_state.
+ * The reason is to avoid calling _mesa_update_state twice we need
+ * this value on draw *before* actually calling _mesa_update_state.
+ * Also it should need to get recomputed only on changes to the
+ * vertex program which are heavyweight already.
+ */
+ gl_vertex_processing_mode _VPMode;
+};
+
+/**
+ * Context state for tessellation control programs.
+ */
+struct gl_tess_ctrl_program_state
+{
+ /** Currently bound and valid shader. */
+ struct gl_program *_Current;
+
+ GLint patch_vertices;
+ GLfloat patch_default_outer_level[4];
+ GLfloat patch_default_inner_level[2];
+};
+
+/**
+ * Context state for tessellation evaluation programs.
+ */
+struct gl_tess_eval_program_state
+{
+ /** Currently bound and valid shader. */
+ struct gl_program *_Current;
+};
+
+/**
+ * Context state for geometry programs.
+ */
+struct gl_geometry_program_state
+{
+ /**
+ * Currently enabled and valid program (including internal programs
+ * and compiled shader programs).
+ */
+ struct gl_program *_Current;
+};
+
+/**
+ * Context state for fragment programs.
+ */
+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
+ * programs, user-defined fragment programs and GLSL fragment shaders).
+ * This is the program we must use when rendering.
+ */
+ struct gl_program *_Current;
+
+ GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
+
+ /** Program to emulate fixed-function texture env/combine (see above) */
+ struct gl_program *_TexEnvProgram;
+
+ /** Cache of fixed-function programs */
+ struct gl_program_cache *Cache;
+};
+
+
+/**
+ * Context state for compute programs.
+ */
+struct gl_compute_program_state
+{
+ /** Currently enabled and valid program (including internal programs
+ * and compiled shader programs).
+ */
+ struct gl_program *_Current;
+};
+
+
+/**
+ * ATI_fragment_shader runtime state
+ */
+
+struct atifs_instruction;
+struct atifs_setupinst;
+
+/**
+ * ATI fragment shader
+ */
+struct ati_fragment_shader
+{
+ GLuint Id;
+ GLint RefCount;
+ struct atifs_instruction *Instructions[2];
+ struct atifs_setupinst *SetupInst[2];
+ GLfloat Constants[8][4];
+ GLbitfield LocalConstDef; /**< Indicates which constants have been set */
+ 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;
+};
+
+/**
+ * Context state for GL_ATI_fragment_shader
+ */
+struct gl_ati_fragment_shader_state
+{
+ GLboolean Enabled;
+ GLboolean Compiling;
+ GLfloat GlobalConstants[8][4];
+ struct ati_fragment_shader *Current;
+};
+
+/**
+ * Shader subroutine function definition
+ */
+struct gl_subroutine_function
+{
+ char *name;
+ int index;
+ int num_compat_types;
+ const struct glsl_type **types;
+};
+
+/**
+ * Shader information needed by both gl_shader and gl_linked shader.
+ */
+struct gl_shader_info
+{
+ /**
+ * Tessellation Control shader state from layout qualifiers.
+ */
+ struct {
+ /**
+ * 0 - vertices not declared in shader, or
+ * 1 .. GL_MAX_PATCH_VERTICES
+ */
+ GLint VerticesOut;
+ } 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.
+ */
+ GLenum16 PrimitiveMode;
+
+ enum gl_tess_spacing Spacing;
+
+ /**
+ * GL_CW, GL_CCW, or 0 if it's not set in this shader.
+ */
+ 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 {
+ GLint VerticesOut;
+ /**
+ * 0 - Invocations count not declared in shader, or
+ * 1 .. Const.MaxGeometryShaderInvocations
+ */
+ 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.
+ */
+ GLenum16 InputType;
+ /**
+ * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
+ * it's not set in this shader.
+ */
+ 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.
+ */
+ unsigned LocalSize[3];
+
+ /**
+ * Whether a variable work group size has been specified as defined by
+ * ARB_compute_variable_group_size.
+ */
+ bool LocalSizeVariable;
+
+ /*
+ * Arrangement of invocations used to calculate derivatives in a compute
+ * shader. From NV_compute_shader_derivatives.
+ */
+ enum gl_derivative_group DerivativeGroup;
+ } Comp;
+};
+
+/**
+ * A linked GLSL shader object.
+ */
+struct gl_linked_shader
+{
+ gl_shader_stage Stage;
+
+#ifdef DEBUG
+ unsigned SourceChecksum;
+#endif
+
+ struct gl_program *Program; /**< Post-compile assembly code */
+
+ /**
+ * \name Sampler tracking
+ *
+ * \note Each of these fields is only set post-linking.
+ */
+ /*@{*/
+ GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
+ /*@}*/
+
+ /**
+ * Number of default uniform block components used by this shader.
+ *
+ * This field is only set post-linking.
+ */
+ unsigned num_uniform_components;
+
+ /**
+ * Number of combined uniform components used by this shader.
+ *
+ * This field is only set post-linking. It is the sum of the uniform block
+ * sizes divided by sizeof(float), and num_uniform_compoennts.
+ */
+ unsigned num_combined_uniform_components;
+
+ struct exec_list *ir;
+ struct exec_list *packed_varyings;
+ struct exec_list *fragdata_arrays;
+ struct glsl_symbol_table *symbols;
+
+ /**
+ * ARB_gl_spirv related data.
+ *
+ * This is actually a reference to the gl_shader::spirv_data, which
+ * stores information that is also needed during linking.
+ */
+ struct gl_shader_spirv_data *spirv_data;
+};
+
+
+/**
+ * Compile status enum. COMPILE_SKIPPED is used to indicate the compile
+ * was skipped due to the shader matching one that's been seen before by
+ * the on-disk cache.
+ */
+enum gl_compile_status
+{
+ COMPILE_FAILURE = 0,
+ COMPILE_SUCCESS,
+ COMPILE_SKIPPED
+};
+
+/**
+ * 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.
+ */
+ 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;
+
+#ifdef DEBUG
+ unsigned SourceChecksum; /**< for debug/logging purposes */
+#endif
+ const GLchar *Source; /**< Source code string */
+
+ const GLchar *FallbackSource; /**< Fallback string used by on-disk cache*/
+
+ GLchar *InfoLog;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ /**
+ * 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.
+ */
+ bool EarlyFragmentTests;
+
+ bool ARB_fragment_coord_conventions_enable;
+
+ bool redeclares_gl_fragcoord;
+ bool uses_gl_fragcoord;
+
+ bool PostDepthCoverage;
+ bool PixelInterlockOrdered;
+ bool PixelInterlockUnordered;
+ bool SampleInterlockOrdered;
+ bool SampleInterlockUnordered;
+ bool InnerCoverage;
+
+ /**
+ * Fragment shader state from GLSL 1.50 layout qualifiers.
+ */
+ bool origin_upper_left;
+ bool pixel_center_integer;
+
+ /**
+ * Whether bindless_sampler/bindless_image, and respectively
+ * bound_sampler/bound_image are declared at global scope as defined by
+ * ARB_bindless_texture.
+ */
+ bool bindless_sampler;
+ bool bindless_image;
+ bool bound_sampler;
+ bool bound_image;
+
+ /**
+ * Whether layer output is viewport-relative.
+ */
+ bool redeclares_gl_layer;
+ bool layer_viewport_relative;
+
+ /** Global xfb_stride out qualifier if any */
+ GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
+
+ struct gl_shader_info info;
+
+ /* ARB_gl_spirv related data */
+ struct gl_shader_spirv_data *spirv_data;
+};
+
+
+struct gl_uniform_buffer_variable
+{
+ char *Name;
+
+ /**
+ * Name of the uniform as seen by glGetUniformIndices.
+ *
+ * glGetUniformIndices requires that the block instance index \b not be
+ * present in the name of queried uniforms.
+ *
+ * \note
+ * \c gl_uniform_buffer_variable::IndexName and
+ * \c gl_uniform_buffer_variable::Name may point to identical storage.
+ */
+ char *IndexName;
+
+ const struct glsl_type *Type;
+ unsigned int Offset;
+ GLboolean RowMajor;
+};
+
+
+struct gl_uniform_block
+{
+ /** Declared name of the uniform block */
+ char *Name;
+
+ /** Array of supplemental information about UBO ir_variables. */
+ struct gl_uniform_buffer_variable *Uniforms;
+ GLuint NumUniforms;
+
+ /**
+ * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
+ * with glBindBufferBase to bind a buffer object to this uniform block.
+ */
+ GLuint Binding;
+
+ /**
+ * Minimum size (in bytes) of a buffer object to back this uniform buffer
+ * (GL_UNIFORM_BLOCK_DATA_SIZE).
+ */
+ GLuint UniformBufferSize;
+
+ /** Stages that reference this block */
+ uint8_t stageref;
+
+ /**
+ * Linearized array index for uniform block instance arrays
+ *
+ * Given a uniform block instance array declared with size
+ * blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
+ * have the linearized array index
+ *
+ * m-1 m
+ * i_m + ∑ i_j * ∏ s_k
+ * j=0 k=j+1
+ *
+ * For a uniform block instance that is not an array, this is always 0.
+ */
+ uint8_t linearized_array_index;
+
+ /**
+ * Layout specified in the shader
+ *
+ * This isn't accessible through the API, but it is used while
+ * cross-validating uniform blocks.
+ */
+ enum glsl_interface_packing _Packing;
+ GLboolean _RowMajor;
+};
+
+/**
+ * Structure that represents a reference to an atomic buffer from some
+ * shader program.
+ */
+struct gl_active_atomic_buffer
+{
+ /** Uniform indices of the atomic counters declared within it. */
+ GLuint *Uniforms;
+ GLuint NumUniforms;
+
+ /** Binding point index associated with it. */
+ GLuint Binding;
+
+ /** Minimum reasonable size it is expected to have. */
+ GLuint MinimumSize;
+
+ /** Shader stages making use of it. */
+ GLboolean StageReferences[MESA_SHADER_STAGES];
+};
+
+/**
+ * Data container for shader queries. This holds only the minimal
+ * amount of required information for resource queries to work.
+ */
+struct gl_shader_variable
+{
+ /**
+ * Declared type of the variable
+ */
+ const struct glsl_type *type;
+
+ /**
+ * If the variable is in an interface block, this is the type of the block.
+ */
+ const struct glsl_type *interface_type;
+
+ /**
+ * For variables inside structs (possibly recursively), this is the
+ * outermost struct type.
+ */
+ const struct glsl_type *outermost_struct_type;
+
+ /**
+ * Declared name of the variable
+ */
+ char *name;
+
+ /**
+ * Storage location of the base of this variable
+ *
+ * The precise meaning of this field depends on the nature of the variable.
+ *
+ * - Vertex shader input: one of the values from \c gl_vert_attrib.
+ * - Vertex shader output: one of the values from \c gl_varying_slot.
+ * - Geometry shader input: one of the values from \c gl_varying_slot.
+ * - Geometry shader output: one of the values from \c gl_varying_slot.
+ * - Fragment shader input: one of the values from \c gl_varying_slot.
+ * - Fragment shader output: one of the values from \c gl_frag_result.
+ * - Uniforms: Per-stage uniform slot number for default uniform block.
+ * - Uniforms: Index within the uniform block definition for UBO members.
+ * - Non-UBO Uniforms: explicit location until linking then reused to
+ * store uniform slot number.
+ * - Other: This field is not currently used.
+ *
+ * If the variable is a uniform, shader input, or shader output, and the
+ * slot has not been assigned, the value will be -1.
+ */
+ int location;
+
+ /**
+ * Specifies the first component the variable is stored in as per
+ * ARB_enhanced_layouts.
+ */
+ unsigned component:2;
+
+ /**
+ * Output index for dual source blending.
+ *
+ * \note
+ * The GLSL spec only allows the values 0 or 1 for the index in \b dual
+ * source blending.
+ */
+ unsigned index:1;
+
+ /**
+ * Specifies whether a shader input/output is per-patch in tessellation
+ * shader stages.
+ */
+ unsigned patch:1;
+
+ /**
+ * Storage class of the variable.
+ *
+ * \sa (n)ir_variable_mode
+ */
+ unsigned mode:4;
+
+ /**
+ * Interpolation mode for shader inputs / outputs
+ *
+ * \sa glsl_interp_mode
+ */
+ unsigned interpolation:2;
+
+ /**
+ * Was the location explicitly set in the shader?
+ *
+ * If the location is explicitly set in the shader, it \b cannot be changed
+ * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
+ * no effect).
+ */
+ unsigned explicit_location:1;
+
+ /**
+ * Precision qualifier.
+ */
+ unsigned precision:2;
+};
+
+/**
+ * Active resource in a gl_shader_program
+ */
+struct gl_program_resource
+{
+ 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
+{
+ LINKING_FAILURE = 0,
+ LINKING_SUCCESS,
+ LINKING_SKIPPED
+};
+
+/**
+ * A data structure to be shared by gl_shader_program and gl_program.
+ */
+struct gl_shader_program_data
+{
+ GLint RefCount; /**< Reference count */
+
+ /** SHA1 hash of linked shader program */
+ unsigned char sha1[20];
+
+ unsigned NumUniformStorage;
+ unsigned NumHiddenUniforms;
+ struct gl_uniform_storage *UniformStorage;
+
+ unsigned NumUniformBlocks;
+ unsigned NumShaderStorageBlocks;
+
+ struct gl_uniform_block *UniformBlocks;
+ struct gl_uniform_block *ShaderStorageBlocks;
+
+ struct gl_active_atomic_buffer *AtomicBuffers;
+ unsigned NumAtomicBuffers;
+
+ /* Shader cache variables used during restore */
+ unsigned NumUniformDataSlots;
+ union gl_constant_value *UniformDataSlots;
+
+ /* 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.
+ */
+ union gl_constant_value *UniformDataDefaults;
+
+ /** Hash for quick search by name. */
+ struct hash_table_u64 *ProgramResourceHash;
+
+ GLboolean Validated;
+
+ /** List of all active resources after linking. */
+ struct gl_program_resource *ProgramResourceList;
+ unsigned NumProgramResourceList;
+
+ enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
+ GLchar *InfoLog;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ /* Mask of stages this program was linked against */
+ unsigned linked_stages;
+
+ /* Whether the shaders of this program are loaded from SPIR-V binaries
+ * (all have the SPIR_V_BINARY_ARB state). This was introduced by the
+ * ARB_gl_spirv extension.
+ */
+ bool spirv;
+};
+
+/**
+ * A GLSL program object.
+ * Basically a linked collection of vertex and fragment shaders.
+ */
+struct gl_shader_program
+{
+ 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?
+ *
+ * BinaryRetrievableHint is the currently active hint that gets set
+ * during initialization and after linking and BinaryRetrievableHintPending
+ * is the hint set by the user to be active when program is linked next time.
+ */
+ GLboolean BinaryRetrievableHint;
+ GLboolean BinaryRetrievableHintPending;
+
+ /**
+ * Indicates whether program can be bound for individual pipeline stages
+ * using UseProgramStages after it is next linked.
+ */
+ GLboolean SeparateShader;
+
+ GLuint NumShaders; /**< number of attached shaders */
+ struct gl_shader **Shaders; /**< List of attached the shaders */
+
+ /**
+ * User-defined attribute bindings
+ *
+ * These are set via \c glBindAttribLocation and are used to direct the
+ * GLSL linker. These are \b not the values used in the compiled shader,
+ * and they are \b not the values returned by \c glGetAttribLocation.
+ */
+ struct string_to_uint_map *AttributeBindings;
+
+ /**
+ * User-defined fragment data bindings
+ *
+ * These are set via \c glBindFragDataLocation and are used to direct the
+ * GLSL linker. These are \b not the values used in the compiled shader,
+ * and they are \b not the values returned by \c glGetFragDataLocation.
+ */
+ struct string_to_uint_map *FragDataBindings;
+ 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 {
+ 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;
+
+ /**
+ * Geometry shader state - copied into gl_program by
+ * _mesa_copy_linked_program_data().
+ */
+ struct {
+ GLint VerticesIn;
+
+ bool UsesEndPrimitive;
+ bool UsesStreams;
+ } Geom;
+
+ /**
+ * Compute shader state - copied into gl_program by
+ * _mesa_copy_linked_program_data().
+ */
+ struct {
+ /**
+ * Size of shared variables accessed by the compute shader.
+ */
+ unsigned SharedSize;
+ } Comp;
+
+ /** Data shared by gl_program and gl_shader_program */
+ struct gl_shader_program_data *data;
+
+ /**
+ * Mapping from GL uniform locations returned by \c glUniformLocation to
+ * UniformStorage entries. Arrays will have multiple contiguous slots
+ * in the UniformRemapTable, all pointing to the same UniformStorage entry.
+ */
+ unsigned NumUniformRemapTable;
+ struct gl_uniform_storage **UniformRemapTable;
+
+ /**
+ * Sometimes there are empty slots left over in UniformRemapTable after we
+ * allocate slots to explicit locations. This list stores the blocks of
+ * continuous empty slots inside UniformRemapTable.
+ */
+ struct exec_list EmptyUniformLocations;
+
+ /**
+ * Total number of explicit uniform location including inactive uniforms.
+ */
+ unsigned NumExplicitUniformLocations;
+
+ /**
+ * Map of active uniform names to locations
+ *
+ * Maps any active uniform that is not an array element to a location.
+ * Each active uniform, including individual structure members will appear
+ * in this map. This roughly corresponds to the set of names that would be
+ * enumerated by \c glGetActiveUniform.
+ */
+ struct string_to_uint_map *UniformHash;
+
+ GLboolean SamplersValidated; /**< Samplers validated against texture units? */
+
+ bool IsES; /**< True if this program uses GLSL ES */
+
+ /**
+ * Per-stage shaders resulting from the first stage of linking.
+ *
+ * Set of linked shaders for this program. The array is accessed using the
+ * \c MESA_SHADER_* defines. Entries for non-existent stages will be
+ * \c NULL.
+ */
+ struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
+
+ /**
+ * True if any of the fragment shaders attached to this program use:
+ * #extension ARB_fragment_coord_conventions: enable
+ */
+ GLboolean ARB_fragment_coord_conventions_enable;
+};
+
+
+#define GLSL_DUMP 0x1 /**< Dump shaders to stdout */
+#define GLSL_LOG 0x2 /**< Write shaders to files */
+#define GLSL_UNIFORMS 0x4 /**< Print glUniform calls */
+#define GLSL_NOP_VERT 0x8 /**< Force no-op vertex shaders */
+#define GLSL_NOP_FRAG 0x10 /**< Force no-op fragment shaders */
+#define GLSL_USE_PROG 0x20 /**< Log glUseProgram calls */
+#define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
+#define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
+#define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
+#define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
+
+
+/**
+ * Context state for GLSL vertex/fragment shaders.
+ * Extended to support pipeline object
+ */
+struct gl_pipeline_object
+{
+ /** Name of the pipeline object as received from glGenProgramPipelines.
+ * It would be 0 for shaders without separate shader objects.
+ */
+ GLuint Name;
+
+ GLint RefCount;
+
+ GLchar *Label; /**< GL_KHR_debug */
+
+ /**
+ * Programs used for rendering
+ *
+ * There is a separate program set for each shader stage.
+ */
+ struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
+
+ struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
+
+ /**
+ * Program used by glUniform calls.
+ *
+ * Explicitly set by \c glUseProgram and \c glActiveProgramEXT.
+ */
+ struct gl_shader_program *ActiveProgram;
+
+ GLbitfield Flags; /**< Mask of GLSL_x flags */
+ GLboolean EverBound; /**< Has the pipeline object been created */
+ GLboolean Validated; /**< Pipeline Validation status */
+
+ GLchar *InfoLog;
+};
+
+/**
+ * Context state for GLSL pipeline shaders.
+ */
+struct gl_pipeline_shader_state
+{
+ /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
+ struct gl_pipeline_object *Current;
+
+ /** Default Object to ensure that _Shader is never NULL */
+ struct gl_pipeline_object *Default;
+
+ /** Pipeline objects */
+ struct _mesa_HashTable *Objects;
+};
+
+/**
+ * Compiler options for a single GLSL shaders type
+ */
+struct gl_shader_compiler_options
+{
+ /** Driver-selectable options: */
+ GLboolean EmitNoLoops;
+ GLboolean EmitNoCont; /**< Emit CONT opcode? */
+ GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
+ GLboolean EmitNoPow; /**< Emit POW opcodes? */
+ GLboolean EmitNoSat; /**< Emit SAT opcodes? */
+ GLboolean LowerCombinedClipCullDistance; /** Lower gl_ClipDistance and
+ * gl_CullDistance together from
+ * float[8] to vec4[2]
+ **/
+ GLbitfield LowerBuiltinVariablesXfb; /**< Which builtin variables should
+ * be lowered for transform feedback
+ **/
+
+ /**
+ * If we can lower the precision of variables based on precision
+ * qualifiers
+ */
+ GLboolean LowerPrecision;
+
+ /**
+ * \name Forms of indirect addressing the driver cannot do.
+ */
+ /*@{*/
+ GLboolean EmitNoIndirectInput; /**< No indirect addressing of inputs */
+ GLboolean EmitNoIndirectOutput; /**< No indirect addressing of outputs */
+ GLboolean EmitNoIndirectTemp; /**< No indirect addressing of temps */
+ GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
+ GLboolean EmitNoIndirectSampler; /**< No indirect addressing of samplers */
+ /*@}*/
+
+ GLuint MaxIfDepth; /**< Maximum nested IF blocks */
+ GLuint MaxUnrollIterations;
+
+ /**
+ * Optimize code for array of structures backends.
+ *
+ * This is a proxy for:
+ * - preferring DP4 instructions (rather than MUL/MAD) for
+ * matrix * vector operations, such as position transformation.
+ */
+ GLboolean OptimizeForAOS;
+
+ /** Lower UBO and SSBO access to intrinsics. */
+ GLboolean LowerBufferInterfaceBlocks;
+
+ /** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
+ GLboolean ClampBlockIndicesToArrayBounds;
+
+ /** (driconf) Force gl_Position to be considered invariant */
+ GLboolean PositionAlwaysInvariant;
+
+ const struct nir_shader_compiler_options *NirOptions;
+};
+
+
+/**
+ * Occlusion/timer query object.
+ */
+struct gl_query_object
+{
+ 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 */
+};
+
+
+/**
+ * Context state for query objects.
+ */
+struct gl_query_state
+{
+ struct _mesa_HashTable *QueryObjects;
+ struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */
+ struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */
+
+ /** GL_NV_conditional_render */
+ struct gl_query_object *CondRenderQuery;
+
+ /** GL_EXT_transform_feedback */
+ struct gl_query_object *PrimitivesGenerated[MAX_VERTEX_STREAMS];
+ struct gl_query_object *PrimitivesWritten[MAX_VERTEX_STREAMS];
+
+ /** 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];
+
+ 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)
+ */
+ 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
+{
+ 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 */
+ struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
+
+ /** Default texture objects (shared by all texture units) */
+ struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
+
+ /** Fallback texture used when a bound texture is incomplete */
+ struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
+
+ /**
+ * \name Thread safety and statechange notification for texture
+ * objects.
+ *
+ * \todo Improve the granularity of locking.
+ */
+ /*@{*/
+ mtx_t TexMutex; /**< texobj thread safety */
+ GLuint TextureStateStamp; /**< state notification for shared tex */
+ /*@}*/
+
+ /**
+ * \name Vertex/geometry/fragment programs
+ */
+ /*@{*/
+ struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
+ struct gl_program *DefaultVertexProgram;
+ struct gl_program *DefaultFragmentProgram;
+ /*@}*/
+
+ /* GL_ATI_fragment_shader */
+ struct _mesa_HashTable *ATIShaders;
+ struct ati_fragment_shader *DefaultFragmentShader;
+
+ struct _mesa_HashTable *BufferObjects;
+
+ /** Table of both gl_shader and gl_shader_program objects */
+ struct _mesa_HashTable *ShaderObjects;
+
+ /* GL_EXT_framebuffer_object */
+ struct _mesa_HashTable *RenderBuffers;
+ struct _mesa_HashTable *FrameBuffers;
+
+ /* GL_ARB_sync */
+ struct set *SyncObjects;
+
+ /** GL_ARB_sampler_objects */
+ struct _mesa_HashTable *SamplerObjects;
+
+ /* GL_ARB_bindless_texture */
+ struct hash_table_u64 *TextureHandles;
+ struct hash_table_u64 *ImageHandles;
+ mtx_t HandlesMutex; /**< For texture/image handles safety */
+
+ /* GL_ARB_shading_language_include */
+ struct shader_includes *ShaderIncludes;
+ /* glCompileShaderInclude expects ShaderIncludes not to change while it is
+ * in progress.
+ */
+ mtx_t ShaderIncludeMutex;
+
+ /**
+ * Some context in this share group was affected by a GPU reset
+ *
+ * On the next call to \c glGetGraphicsResetStatus, contexts that have not
+ * been affected by a GPU reset must also return
+ * \c GL_INNOCENT_CONTEXT_RESET_ARB.
+ *
+ * Once this field becomes true, it is never reset to false.
+ */
+ bool ShareGroupReset;
+
+ /** EXT_external_objects */
+ struct _mesa_HashTable *MemoryObjects;
+
+ /** EXT_semaphore */
+ struct _mesa_HashTable *SemaphoreObjects;
+
+ /**
+ * 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;
+};
+
+
+
+/**
+ * Renderbuffers represent drawing surfaces such as color, depth and/or
+ * stencil. A framebuffer object has a set of renderbuffers.
+ * Drivers will typically derive subclasses of this type.
+ */
+struct gl_renderbuffer
+{
+ simple_mtx_t Mutex; /**< for thread safety */
+ GLuint ClassID; /**< Useful for drivers */
+ GLuint Name;
+ GLchar *Label; /**< GL_KHR_debug */
+ GLint RefCount;
+ GLuint Width, Height;
+ GLuint Depth;
+ GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
+ GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
+ /**
+ * 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 */
+ GLubyte NumStorageSamples; /**< for AMD_framebuffer_multisample_advanced */
+ 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;
+
+ /** Delete this renderbuffer */
+ void (*Delete)(struct gl_context *ctx, struct gl_renderbuffer *rb);
+
+ /** Allocate new storage for this renderbuffer */
+ GLboolean (*AllocStorage)(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ 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
+{
+ 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
+ * supplied texture object.
+ */
+ struct gl_texture_object *Texture;
+ GLuint TextureLevel; /**< Attached mipmap level. */
+ GLsizei NumSamples; /**< from FramebufferTexture2DMultisampleEXT */
+ GLuint CubeMapFace; /**< 0 .. 5, for cube map textures. */
+ GLuint Zoffset; /**< Slice for 3D textures, or layer for both 1D
+ * and 2D array textures */
+ GLboolean Layered;
+};
+
+
+/**
+ * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
+ * In C++ terms, think of this as a base class from which device drivers
+ * will make derived classes.
+ */
+struct gl_framebuffer
+{
+ 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
+ * a natural pixel coordinate system for FBOs that differs from the
+ * OpenGL/Mesa coordinate system), this means that the viewport,
+ * polygon face orientation, and polygon stipple will have to be inverted.
+ */
+ GLuint Name;
+ GLint RefCount;
+
+ GLchar *Label; /**< GL_KHR_debug */
+
+ GLboolean DeletePending;
+
+ /**
+ * The framebuffer's visual. Immutable if this is a window system buffer.
+ * Computed from attachments if user-made FBO.
+ */
+ struct gl_config Visual;
+
+ /**
+ * Size of frame buffer in pixels. If there are no attachments, then both
+ * of these are 0.
+ */
+ GLuint Width, Height;
+
+ /**
+ * In the case that the framebuffer has no attachment (i.e.
+ * GL_ARB_framebuffer_no_attachments) then the geometry of
+ * the framebuffer is specified by the default values.
+ */
+ struct {
+ GLuint Width, Height, Layers, NumSamples;
+ GLboolean FixedSampleLocations;
+ /* Derived from NumSamples by the driver so that it can choose a valid
+ * value for the hardware.
+ */
+ GLuint _NumSamples;
+ } DefaultGeometry;
+
+ /** \name Drawing bounds (Intersection of buffer size and scissor box)
+ * The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
+ * (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
+ */
+ /*@{*/
+ GLint _Xmin, _Xmax;
+ GLint _Ymin, _Ymax;
+ /*@}*/
+
+ /** \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 */
+ 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(),
+ * _mesa_geometric_height(),
+ * _mesa_geometric_samples() and
+ * _mesa_geometric_layers()
+ * are available that check _HasAttachments.
+ */
+ bool _HasAttachments;
+
+ GLbitfield _IntegerBuffers; /**< Which color buffers are integer valued */
+ GLbitfield _RGBBuffers; /**< Which color buffers have baseformat == RGB */
+ GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */
+
+ /* ARB_color_buffer_float */
+ GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */
+ GLboolean _HasSNormOrFloatColorBuffer;
+
+ /**
+ * The maximum number of layers in the framebuffer, or 0 if the framebuffer
+ * is not layered. For cube maps and cube map arrays, each cube face
+ * counts as a layer. As the case for Width, Height a backend driver
+ * supporting GL_ARB_framebuffer_no_attachments must use DefaultGeometry
+ * 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.
+ */
+ GLenum16 ColorDrawBuffer[MAX_DRAW_BUFFERS];
+ GLenum16 ColorReadBuffer;
+
+ /* GL_ARB_sample_locations */
+ GLfloat *SampleLocationTable; /**< If NULL, no table has been specified */
+ GLboolean ProgrammableSampleLocations;
+ GLboolean SampleLocationPixelGrid;
+
+ /** Computed from ColorDraw/ReadBuffer above */
+ GLuint _NumColorDrawBuffers;
+ gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
+ gl_buffer_index _ColorReadBufferIndex;
+ struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
+ struct gl_renderbuffer *_ColorReadBuffer;
+
+ /* GL_MESA_framebuffer_flip_y */
+ bool FlipY;
+
+ /** Delete this framebuffer */
+ void (*Delete)(struct gl_framebuffer *fb);
+};
+
+
+/**
+ * Precision info for shader datatypes. See glGetShaderPrecisionFormat().
+ */
+struct gl_precision
+{
+ GLushort RangeMin; /**< min value exponent */
+ GLushort RangeMax; /**< max value exponent */
+ GLushort Precision; /**< number of mantissa bits */
+};
+
+
+/**
+ * Limits for vertex, geometry and fragment programs/shaders.
+ */
+struct gl_program_constants
+{
+ /* logical limits */
+ GLuint MaxInstructions;
+ GLuint MaxAluInstructions;
+ GLuint MaxTexInstructions;
+ GLuint MaxTexIndirections;
+ GLuint MaxAttribs;
+ GLuint MaxTemps;
+ GLuint MaxAddressRegs;
+ GLuint MaxAddressOffset; /**< [-MaxAddressOffset, MaxAddressOffset-1] */
+ GLuint MaxParameters;
+ GLuint MaxLocalParams;
+ GLuint MaxEnvParams;
+ /* native/hardware limits */
+ GLuint MaxNativeInstructions;
+ GLuint MaxNativeAluInstructions;
+ GLuint MaxNativeTexInstructions;
+ GLuint MaxNativeTexIndirections;
+ GLuint MaxNativeAttribs;
+ GLuint MaxNativeTemps;
+ GLuint MaxNativeAddressRegs;
+ GLuint MaxNativeParameters;
+ /* For shaders */
+ GLuint MaxUniformComponents; /**< Usually == MaxParameters * 4 */
+
+ /**
+ * \name Per-stage input / output limits
+ *
+ * Previous to OpenGL 3.2, the intrastage data limits were advertised with
+ * a single value: GL_MAX_VARYING_COMPONENTS (GL_MAX_VARYING_VECTORS in
+ * ES). This is stored as \c gl_constants::MaxVarying.
+ *
+ * Starting with OpenGL 3.2, the limits are advertised with per-stage
+ * variables. Each stage as a certain number of outputs that it can feed
+ * to the next stage and a certain number inputs that it can consume from
+ * the previous stage.
+ *
+ * Vertex shader inputs do not participate this in this accounting.
+ * These are tracked exclusively by \c gl_program_constants::MaxAttribs.
+ *
+ * Fragment shader outputs do not participate this in this accounting.
+ * These are tracked exclusively by \c gl_constants::MaxDrawBuffers.
+ */
+ /*@{*/
+ GLuint MaxInputComponents;
+ GLuint MaxOutputComponents;
+ /*@}*/
+
+ /* ES 2.0 and GL_ARB_ES2_compatibility */
+ struct gl_precision LowFloat, MediumFloat, HighFloat;
+ struct gl_precision LowInt, MediumInt, HighInt;
+ /* GL_ARB_uniform_buffer_object */
+ GLuint MaxUniformBlocks;
+ uint64_t MaxCombinedUniformComponents;
+ GLuint MaxTextureImageUnits;
+
+ /* GL_ARB_shader_atomic_counters */
+ GLuint MaxAtomicBuffers;
+ GLuint MaxAtomicCounters;
+
+ /* GL_ARB_shader_image_load_store */
+ GLuint MaxImageUniforms;
+
+ /* GL_ARB_shader_storage_buffer_object */
+ GLuint MaxShaderStorageBlocks;
+};
+
+/**
+ * Constants which may be overridden by device driver during context creation
+ * but are never changed after that.
+ */
+struct gl_constants
+{
+ GLuint MaxTextureMbytes; /**< Max memory per image, in MB */
+ GLuint MaxTextureSize; /**< Max 1D/2D texture size, in pixels*/
+ GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */
+ GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */
+ GLuint MaxArrayTextureLayers; /**< Max layers in array textures */
+ GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */
+ GLuint MaxTextureCoordUnits;
+ GLuint MaxCombinedTextureImageUnits;
+ GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */
+ GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
+ GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
+ GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
+
+ GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
+
+ GLuint MaxArrayLockSize;
+
+ GLint SubPixelBits;
+
+ GLfloat MinPointSize, MaxPointSize; /**< aliased */
+ GLfloat MinPointSizeAA, MaxPointSizeAA; /**< antialiased */
+ GLfloat PointSizeGranularity;
+ GLfloat MinLineWidth, MaxLineWidth; /**< aliased */
+ GLfloat MinLineWidthAA, MaxLineWidthAA; /**< antialiased */
+ GLfloat LineWidthGranularity;
+
+ GLuint MaxClipPlanes;
+ GLuint MaxLights;
+ GLfloat MaxShininess; /**< GL_NV_light_max_exponent */
+ GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
+
+ GLuint MaxViewportWidth, MaxViewportHeight;
+ GLuint MaxViewports; /**< GL_ARB_viewport_array */
+ GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
+ struct {
+ GLfloat Min;
+ GLfloat Max;
+ } ViewportBounds; /**< GL_ARB_viewport_array */
+ GLuint MaxWindowRectangles; /**< GL_EXT_window_rectangles */
+
+ struct gl_program_constants Program[MESA_SHADER_STAGES];
+ GLuint MaxProgramMatrices;
+ GLuint MaxProgramMatrixStackDepth;
+
+ struct {
+ GLuint SamplesPassed;
+ GLuint TimeElapsed;
+ GLuint Timestamp;
+ GLuint PrimitivesGenerated;
+ GLuint PrimitivesWritten;
+ GLuint VerticesSubmitted;
+ GLuint PrimitivesSubmitted;
+ GLuint VsInvocations;
+ GLuint TessPatches;
+ GLuint TessInvocations;
+ GLuint GsInvocations;
+ GLuint GsPrimitives;
+ GLuint FsInvocations;
+ GLuint ComputeInvocations;
+ GLuint ClInPrimitives;
+ GLuint ClOutPrimitives;
+ } QueryCounterBits;
+
+ GLuint MaxDrawBuffers; /**< GL_ARB_draw_buffers */
+
+ GLuint MaxColorAttachments; /**< GL_EXT_framebuffer_object */
+ GLuint MaxRenderbufferSize; /**< GL_EXT_framebuffer_object */
+ GLuint MaxSamples; /**< GL_ARB_framebuffer_object */
+
+ /**
+ * GL_ARB_framebuffer_no_attachments
+ */
+ GLuint MaxFramebufferWidth;
+ GLuint MaxFramebufferHeight;
+ GLuint MaxFramebufferLayers;
+ GLuint MaxFramebufferSamples;
+
+ /** Number of varying vectors between any two shader stages. */
+ GLuint MaxVarying;
+
+ /** @{
+ * GL_ARB_uniform_buffer_object
+ */
+ GLuint MaxCombinedUniformBlocks;
+ GLuint MaxUniformBufferBindings;
+ GLuint MaxUniformBlockSize;
+ GLuint UniformBufferOffsetAlignment;
+ /** @} */
+
+ /** @{
+ * GL_ARB_shader_storage_buffer_object
+ */
+ GLuint MaxCombinedShaderStorageBlocks;
+ GLuint MaxShaderStorageBufferBindings;
+ GLuint MaxShaderStorageBlockSize;
+ GLuint ShaderStorageBufferOffsetAlignment;
+ /** @} */
+
+ /**
+ * GL_ARB_explicit_uniform_location
+ */
+ GLuint MaxUserAssignableUniformLocations;
+
+ /** geometry shader */
+ GLuint MaxGeometryOutputVertices;
+ GLuint MaxGeometryTotalOutputComponents;
+ GLuint MaxGeometryShaderInvocations;
+
+ GLuint GLSLVersion; /**< Desktop GLSL version supported (ex: 120 = 1.20) */
+ GLuint GLSLVersionCompat; /**< Desktop compat GLSL version supported */
+
+ /**
+ * Changes default GLSL extension behavior from "error" to "warn". It's out
+ * of spec, but it can make some apps work that otherwise wouldn't.
+ */
+ GLboolean ForceGLSLExtensionsWarn;
+
+ /**
+ * If non-zero, forces GLSL shaders to behave as if they began
+ * with "#version ForceGLSLVersion".
+ */
+ GLuint ForceGLSLVersion;
+
+ /**
+ * Allow GLSL #extension directives in the middle of shaders.
+ */
+ GLboolean AllowGLSLExtensionDirectiveMidShader;
+
+ /**
+ * Allow builtins as part of constant expressions. This was not allowed
+ * until GLSL 1.20 this allows it everywhere.
+ */
+ GLboolean AllowGLSLBuiltinConstantExpression;
+
+ /**
+ * Allow some relaxation of GLSL ES shader restrictions. This encompasses
+ * a number of relaxations to the ES shader rules.
+ */
+ GLboolean AllowGLSLRelaxedES;
+
+ /**
+ * Allow GLSL built-in variables to be redeclared verbatim
+ */
+ 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
+ * features are unimplemented and might not work correctly.
+ */
+ GLboolean AllowHigherCompatVersion;
+
+ /**
+ * Allow layout qualifiers on function parameters.
+ */
+ GLboolean AllowLayoutQualifiersOnFunctionParameters;
+
+ /**
+ * Force computing the absolute value for sqrt() and inversesqrt() to follow
+ * D3D9 when apps rely on this behaviour.
+ */
+ GLboolean ForceGLSLAbsSqrt;
+
+ /**
+ * Force uninitialized variables to default to zero.
+ */
+ GLboolean GLSLZeroInit;
+
+ /**
+ * Treat integer textures using GL_LINEAR filters as GL_NEAREST.
+ */
+ GLboolean ForceIntegerTexNearest;
+
+ /**
+ * Does the driver support real 32-bit integers? (Otherwise, integers are
+ * simulated via floats.)
+ */
+ GLboolean NativeIntegers;
+
+ /**
+ * Does VertexID count from zero or from base vertex?
+ *
+ * \note
+ * If desktop GLSL 1.30 or GLSL ES 3.00 are not supported, this field is
+ * ignored and need not be set.
+ */
+ bool VertexID_is_zero_based;
+
+ /**
+ * If the driver supports real 32-bit integers, what integer value should be
+ * used for boolean true in uniform uploads? (Usually 1 or ~0.)
+ */
+ GLuint UniformBooleanTrue;
+
+ /**
+ * Maximum amount of time, measured in nanseconds, that the server can wait.
+ */
+ GLuint64 MaxServerWaitTimeout;
+
+ /** GL_EXT_provoking_vertex */
+ GLboolean QuadsFollowProvokingVertexConvention;
+
+ /** GL_ARB_viewport_array */
+ 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;
+
+ /** GL_EXT_transform_feedback */
+ GLuint MaxTransformFeedbackBuffers;
+ GLuint MaxTransformFeedbackSeparateComponents;
+ GLuint MaxTransformFeedbackInterleavedComponents;
+ GLuint MaxVertexStreams;
+
+ /** GL_EXT_gpu_shader4 */
+ GLint MinProgramTexelOffset, MaxProgramTexelOffset;
+
+ /** GL_ARB_texture_gather */
+ GLuint MinProgramTextureGatherOffset;
+ GLuint MaxProgramTextureGatherOffset;
+ GLuint MaxProgramTextureGatherComponents;
+
+ /* GL_ARB_robustness */
+ GLenum16 ResetStrategy;
+
+ /* GL_KHR_robustness */
+ GLboolean RobustAccess;
+
+ /* GL_ARB_blend_func_extended */
+ GLuint MaxDualSourceDrawBuffers;
+
+ /**
+ * Whether the implementation strips out and ignores texture borders.
+ *
+ * Many GPU hardware implementations don't support rendering with texture
+ * borders and mipmapped textures. (Note: not static border color, but the
+ * old 1-pixel border around each edge). Implementations then have to do
+ * slow fallbacks to be correct, or just ignore the border and be fast but
+ * wrong. Setting the flag strips the border off of TexImage calls,
+ * providing "fast but wrong" at significantly reduced driver complexity.
+ *
+ * Texture borders are deprecated in GL 3.0.
+ **/
+ GLboolean StripTextureBorder;
+
+ /**
+ * For drivers which can do a better job at eliminating unused uniforms
+ * than the GLSL compiler.
+ *
+ * XXX Remove these as soon as a better solution is available.
+ */
+ GLboolean GLSLSkipStrictMaxUniformLimitCheck;
+
+ /**
+ * Whether gl_FragCoord, gl_PointCoord and gl_FrontFacing
+ * are system values.
+ **/
+ bool GLSLFragCoordIsSysVal;
+ bool GLSLPointCoordIsSysVal;
+ bool GLSLFrontFacingIsSysVal;
+
+ /**
+ * Run the minimum amount of GLSL optimizations to be able to link
+ * shaders optimally (eliminate dead varyings and uniforms) and just do
+ * all the necessary lowering.
+ */
+ bool GLSLOptimizeConservatively;
+
+ /**
+ * Whether to call lower_const_arrays_to_uniforms() during linking.
+ */
+ bool GLSLLowerConstArrays;
+
+ /**
+ * True if gl_TessLevelInner/Outer[] in the TES should be inputs
+ * (otherwise, they're system values).
+ */
+ bool GLSLTessLevelsAsInputs;
+
+ /**
+ * Always use the GetTransformFeedbackVertexCount() driver hook, rather
+ * than passing the transform feedback object to the drawing function.
+ */
+ GLboolean AlwaysUseGetTransformFeedbackVertexCount;
+
+ /** GL_ARB_map_buffer_alignment */
+ GLuint MinMapBufferAlignment;
+
+ /**
+ * Disable varying packing. This is out of spec, but potentially useful
+ * for older platforms that supports a limited number of texture
+ * indirections--on these platforms, unpacking the varyings in the fragment
+ * shader increases the number of texture indirections by 1, which might
+ * make some shaders not executable at all.
+ *
+ * Drivers that support transform feedback must set this value to GL_FALSE.
+ */
+ GLboolean DisableVaryingPacking;
+
+ /**
+ * Disable varying packing if used for transform feedback. This is needed
+ * for some drivers (e.g. Panfrost) where transform feedback requires
+ * unpacked varyings.
+ *
+ * This variable is mutually exlusive with DisableVaryingPacking.
+ */
+ GLboolean DisableTransformFeedbackPacking;
+
+ /**
+ * 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?
+ *
+ * Generally, it is not useful to have the compiler generate "meaningful"
+ * names for temporary variables that it creates. This can, however, be a
+ * useful debugging aid. In Mesa debug builds or release builds when
+ * MESA_GLSL is set at run-time, meaningful names will be generated.
+ * Drivers can also force names to be generated by setting this field.
+ * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
+ * vertex shader assembly) is set at run-time.
+ */
+ bool GenerateTemporaryNames;
+
+ /*
+ * Maximum value supported for an index in DrawElements and friends.
+ *
+ * This must be at least (1ull<<24)-1. The default value is
+ * (1ull<<32)-1.
+ *
+ * \since ES 3.0 or GL_ARB_ES3_compatibility
+ * \sa _mesa_init_constants
+ */
+ GLuint64 MaxElementIndex;
+
+ /**
+ * Disable interpretation of line continuations (lines ending with a
+ * backslash character ('\') in GLSL source.
+ */
+ GLboolean DisableGLSLLineContinuations;
+
+ /** GL_ARB_texture_multisample */
+ GLint MaxColorTextureSamples;
+ GLint MaxDepthTextureSamples;
+ GLint MaxIntegerSamples;
+
+ /** GL_AMD_framebuffer_multisample_advanced */
+ GLint MaxColorFramebufferSamples;
+ GLint MaxColorFramebufferStorageSamples;
+ GLint MaxDepthStencilFramebufferSamples;
+
+ /* An array of supported MSAA modes allowing different sample
+ * counts per attachment type.
+ */
+ struct {
+ GLint NumColorSamples;
+ GLint NumColorStorageSamples;
+ GLint NumDepthStencilSamples;
+ } SupportedMultisampleModes[40];
+ GLint NumSupportedMultisampleModes;
+
+ /** GL_ARB_shader_atomic_counters */
+ GLuint MaxAtomicBufferBindings;
+ GLuint MaxAtomicBufferSize;
+ GLuint MaxCombinedAtomicBuffers;
+ GLuint MaxCombinedAtomicCounters;
+
+ /** GL_ARB_vertex_attrib_binding */
+ GLint MaxVertexAttribRelativeOffset;
+ GLint MaxVertexAttribBindings;
+
+ /* GL_ARB_shader_image_load_store */
+ GLuint MaxImageUnits;
+ GLuint MaxCombinedShaderOutputResources;
+ GLuint MaxImageSamples;
+ GLuint MaxCombinedImageUniforms;
+
+ /** GL_ARB_compute_shader */
+ GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
+ GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
+ GLuint MaxComputeWorkGroupInvocations;
+ GLuint MaxComputeSharedMemorySize;
+
+ /** GL_ARB_compute_variable_group_size */
+ 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 */
+ 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 PrimitiveRestartForPatches;
+ bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
+ * gl_LocalInvocationIndex based on
+ * other builtin variables. */
+
+ /** GL_OES_primitive_bounding_box */
+ bool NoPrimitiveBoundingBoxOutput;
+
+ /** GL_ARB_sparse_buffer */
+ GLuint SparseBufferPageSize;
+
+ /** Used as an input for sha1 generation in the on-disk shader cache */
+ unsigned char *dri_config_options_sha1;
+
+ /** When drivers are OK with mapped buffers during draw and other calls. */
+ bool AllowMappedBuffersDuringExecution;
+
+ /**
+ * Whether buffer creation, unsynchronized mapping, unmapping, and
+ * deletion is thread-safe.
+ */
+ bool BufferCreateMapUnsynchronizedThreadSafe;
+
+ /** GL_ARB_get_program_binary */
+ GLuint NumProgramBinaryFormats;
+
+ /** GL_NV_conservative_raster */
+ GLuint MaxSubpixelPrecisionBiasBits;
+
+ /** GL_NV_conservative_raster_dilate */
+ GLfloat ConservativeRasterDilateRange[2];
+ GLfloat ConservativeRasterDilateGranularity;
+
+ /** Is the drivers uniform storage packed or padded to 16 bytes. */
+ bool PackedDriverUniformStorage;
+
+ /** Does the driver make use of the NIR based GLSL linker */
+ bool UseNIRGLSLLinker;
+
+ /** Wether or not glBitmap uses red textures rather than alpha */
+ bool BitmapUsesRed;
+
+ /** Whether the vertex buffer offset is a signed 32-bit integer. */
+ bool VertexBufferOffsetIsInt32;
+
+ /** Whether the driver can handle MultiDrawElements with non-VBO indices. */
+ bool MultiDrawWithUserIndices;
+
+ /** Whether out-of-order draw (Begin/End) optimizations are allowed. */
+ bool AllowDrawOutOfOrder;
+
+ /** GL_ARB_gl_spirv */
+ struct spirv_supported_capabilities SpirVCapabilities;
+
+ /** GL_ARB_spirv_extensions */
+ struct spirv_supported_extensions *SpirVExtensions;
+
+ char *VendorOverride;
+
+ /** Buffer size used to upload vertices from glBegin/glEnd. */
+ unsigned glBeginEndBufferSize;
+};
+
+
+/**
+ * Enable flag for each OpenGL extension. Different device drivers will
+ * enable different extensions at runtime.
+ */
+struct gl_extensions
+{
+ GLboolean dummy; /* don't remove this! */
+ GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */
+ GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */
+ GLboolean ANGLE_texture_compression_dxt;
+ GLboolean ARB_ES2_compatibility;
+ GLboolean ARB_ES3_compatibility;
+ GLboolean ARB_ES3_1_compatibility;
+ GLboolean ARB_ES3_2_compatibility;
+ GLboolean ARB_arrays_of_arrays;
+ GLboolean ARB_base_instance;
+ GLboolean ARB_bindless_texture;
+ GLboolean ARB_blend_func_extended;
+ GLboolean ARB_buffer_storage;
+ GLboolean ARB_clear_texture;
+ GLboolean ARB_clip_control;
+ GLboolean ARB_color_buffer_float;
+ GLboolean ARB_compatibility;
+ GLboolean ARB_compute_shader;
+ GLboolean ARB_compute_variable_group_size;
+ GLboolean ARB_conditional_render_inverted;
+ GLboolean ARB_conservative_depth;
+ GLboolean ARB_copy_image;
+ GLboolean ARB_cull_distance;
+ GLboolean ARB_depth_buffer_float;
+ GLboolean ARB_depth_clamp;
+ GLboolean ARB_depth_texture;
+ GLboolean ARB_derivative_control;
+ GLboolean ARB_draw_buffers_blend;
+ GLboolean ARB_draw_elements_base_vertex;
+ GLboolean ARB_draw_indirect;
+ GLboolean ARB_draw_instanced;
+ GLboolean ARB_fragment_coord_conventions;
+ GLboolean ARB_fragment_layer_viewport;
+ GLboolean ARB_fragment_program;
+ GLboolean ARB_fragment_program_shadow;
+ GLboolean ARB_fragment_shader;
+ GLboolean ARB_framebuffer_no_attachments;
+ GLboolean ARB_framebuffer_object;
+ GLboolean ARB_fragment_shader_interlock;
+ 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;
+ GLboolean ARB_half_float_vertex;
+ GLboolean ARB_indirect_parameters;
+ GLboolean ARB_instanced_arrays;
+ GLboolean ARB_internalformat_query;
+ GLboolean ARB_internalformat_query2;
+ GLboolean ARB_map_buffer_range;
+ GLboolean ARB_occlusion_query;
+ 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;
+ GLboolean ARB_sample_locations;
+ GLboolean ARB_sample_shading;
+ GLboolean ARB_seamless_cube_map;
+ GLboolean ARB_shader_atomic_counter_ops;
+ GLboolean ARB_shader_atomic_counters;
+ GLboolean ARB_shader_ballot;
+ GLboolean ARB_shader_bit_encoding;
+ GLboolean ARB_shader_clock;
+ GLboolean ARB_shader_draw_parameters;
+ GLboolean ARB_shader_group_vote;
+ GLboolean ARB_shader_image_load_store;
+ GLboolean ARB_shader_image_size;
+ GLboolean ARB_shader_precision;
+ GLboolean ARB_shader_stencil_export;
+ GLboolean ARB_shader_storage_buffer_object;
+ GLboolean ARB_shader_texture_image_samples;
+ GLboolean ARB_shader_texture_lod;
+ GLboolean ARB_shader_viewport_layer_array;
+ GLboolean ARB_shading_language_packing;
+ GLboolean ARB_shading_language_420pack;
+ GLboolean ARB_shadow;
+ GLboolean ARB_sparse_buffer;
+ GLboolean ARB_stencil_texturing;
+ GLboolean ARB_spirv_extensions;
+ GLboolean ARB_sync;
+ GLboolean ARB_tessellation_shader;
+ GLboolean ARB_texture_border_clamp;
+ GLboolean ARB_texture_buffer_object;
+ GLboolean ARB_texture_buffer_object_rgb32;
+ GLboolean ARB_texture_buffer_range;
+ GLboolean ARB_texture_compression_bptc;
+ GLboolean ARB_texture_compression_rgtc;
+ GLboolean ARB_texture_cube_map;
+ GLboolean ARB_texture_cube_map_array;
+ 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;
+ GLboolean ARB_texture_multisample;
+ GLboolean ARB_texture_non_power_of_two;
+ GLboolean ARB_texture_stencil8;
+ GLboolean ARB_texture_query_levels;
+ GLboolean ARB_texture_query_lod;
+ GLboolean ARB_texture_rg;
+ GLboolean ARB_texture_rgb10_a2ui;
+ GLboolean ARB_texture_view;
+ GLboolean ARB_timer_query;
+ GLboolean ARB_transform_feedback2;
+ GLboolean ARB_transform_feedback3;
+ GLboolean ARB_transform_feedback_instanced;
+ GLboolean ARB_transform_feedback_overflow_query;
+ GLboolean ARB_uniform_buffer_object;
+ GLboolean ARB_vertex_attrib_64bit;
+ GLboolean ARB_vertex_program;
+ GLboolean ARB_vertex_shader;
+ GLboolean ARB_vertex_type_10f_11f_11f_rev;
+ GLboolean ARB_vertex_type_2_10_10_10_rev;
+ GLboolean ARB_viewport_array;
+ GLboolean EXT_blend_color;
+ GLboolean EXT_blend_equation_separate;
+ GLboolean EXT_blend_func_separate;
+ GLboolean EXT_blend_minmax;
+ GLboolean EXT_demote_to_helper_invocation;
+ GLboolean EXT_depth_bounds_test;
+ GLboolean EXT_disjoint_timer_query;
+ GLboolean EXT_draw_buffers2;
+ GLboolean EXT_EGL_image_storage;
+ GLboolean EXT_float_blend;
+ 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_multisampled_render_to_texture;
+ GLboolean EXT_packed_float;
+ GLboolean EXT_pixel_buffer_object;
+ GLboolean EXT_point_parameters;
+ GLboolean EXT_provoking_vertex;
+ GLboolean EXT_render_snorm;
+ GLboolean EXT_semaphore;
+ GLboolean EXT_semaphore_fd;
+ GLboolean EXT_shader_image_load_formatted;
+ GLboolean EXT_shader_image_load_store;
+ GLboolean EXT_shader_integer_mix;
+ GLboolean EXT_shader_samples_identical;
+ GLboolean EXT_sRGB;
+ GLboolean EXT_stencil_two_side;
+ GLboolean EXT_texture_array;
+ GLboolean EXT_texture_buffer_object;
+ GLboolean EXT_texture_compression_latc;
+ GLboolean EXT_texture_compression_s3tc;
+ GLboolean EXT_texture_compression_s3tc_srgb;
+ GLboolean EXT_texture_env_dot3;
+ GLboolean EXT_texture_filter_anisotropic;
+ GLboolean EXT_texture_integer;
+ GLboolean EXT_texture_mirror_clamp;
+ GLboolean EXT_texture_norm16;
+ GLboolean EXT_texture_shadow_lod;
+ GLboolean EXT_texture_shared_exponent;
+ GLboolean EXT_texture_snorm;
+ GLboolean EXT_texture_sRGB;
+ GLboolean EXT_texture_sRGB_R8;
+ 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;
+ GLboolean EXT_window_rectangles;
+ GLboolean OES_copy_image;
+ GLboolean OES_primitive_bounding_box;
+ GLboolean OES_sample_variables;
+ GLboolean OES_standard_derivatives;
+ GLboolean OES_texture_buffer;
+ GLboolean OES_texture_cube_map_array;
+ GLboolean OES_texture_view;
+ GLboolean OES_viewport_array;
+ /* vendor extensions */
+ GLboolean AMD_compressed_ATC_texture;
+ GLboolean AMD_framebuffer_multisample_advanced;
+ GLboolean AMD_depth_clamp_separate;
+ GLboolean AMD_performance_monitor;
+ GLboolean AMD_pinned_memory;
+ GLboolean AMD_seamless_cubemap_per_texture;
+ GLboolean AMD_vertex_shader_layer;
+ GLboolean AMD_vertex_shader_viewport_index;
+ GLboolean ANDROID_extension_pack_es31a;
+ GLboolean APPLE_object_purgeable;
+ GLboolean ATI_meminfo;
+ GLboolean ATI_texture_compression_3dc;
+ GLboolean ATI_texture_mirror_once;
+ GLboolean ATI_texture_env_combine3;
+ GLboolean ATI_fragment_shader;
+ GLboolean GREMEDY_string_marker;
+ GLboolean INTEL_blackhole_render;
+ GLboolean INTEL_conservative_rasterization;
+ GLboolean INTEL_performance_query;
+ GLboolean INTEL_shader_atomic_float_minmax;
+ GLboolean INTEL_shader_integer_functions2;
+ GLboolean KHR_blend_equation_advanced;
+ GLboolean KHR_blend_equation_advanced_coherent;
+ GLboolean KHR_robustness;
+ GLboolean KHR_texture_compression_astc_hdr;
+ GLboolean KHR_texture_compression_astc_ldr;
+ GLboolean KHR_texture_compression_astc_sliced_3d;
+ GLboolean MESA_framebuffer_flip_y;
+ GLboolean MESA_tile_raster_order;
+ GLboolean MESA_pack_invert;
+ GLboolean EXT_shader_framebuffer_fetch;
+ GLboolean EXT_shader_framebuffer_fetch_non_coherent;
+ GLboolean MESA_shader_integer_functions;
+ GLboolean MESA_ycbcr_texture;
+ GLboolean NV_alpha_to_coverage_dither_control;
+ GLboolean NV_compute_shader_derivatives;
+ GLboolean NV_conditional_render;
+ GLboolean NV_copy_image;
+ GLboolean NV_fill_rectangle;
+ GLboolean NV_fog_distance;
+ GLboolean NV_point_sprite;
+ GLboolean NV_primitive_restart;
+ GLboolean NV_shader_atomic_float;
+ GLboolean NV_texture_barrier;
+ GLboolean NV_texture_env_combine4;
+ GLboolean NV_texture_rectangle;
+ GLboolean NV_vdpau_interop;
+ GLboolean NV_conservative_raster;
+ GLboolean NV_conservative_raster_dilate;
+ GLboolean NV_conservative_raster_pre_snap_triangles;
+ GLboolean NV_conservative_raster_pre_snap;
+ GLboolean NV_viewport_array2;
+ GLboolean NV_viewport_swizzle;
+ GLboolean NVX_gpu_memory_info;
+ GLboolean TDFX_texture_compression_FXT1;
+ GLboolean OES_EGL_image;
+ GLboolean OES_draw_texture;
+ GLboolean OES_depth_texture_cube_map;
+ GLboolean OES_EGL_image_external;
+ GLboolean OES_texture_float;
+ GLboolean OES_texture_float_linear;
+ GLboolean OES_texture_half_float;
+ GLboolean OES_texture_half_float_linear;
+ GLboolean OES_compressed_ETC1_RGB8_texture;
+ GLboolean OES_geometry_shader;
+ GLboolean OES_texture_compression_astc;
+ GLboolean extension_sentinel;
+ /** The extension string */
+ const GLubyte *String;
+ /** Number of supported extensions */
+ GLuint Count;
+ /**
+ * The context version which extension helper functions compare against.
+ * By default, the value is equal to ctx->Version. This changes to ~0
+ * while meta is in progress.
+ */
+ GLubyte Version;
+};
+
+
+/**
+ * A stack of matrices (projection, modelview, color, texture, etc).
+ */
+struct gl_matrix_stack
+{
+ GLmatrix *Top; /**< points into Stack */
+ GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
+ unsigned StackSize; /**< Number of elements in Stack */
+ GLuint Depth; /**< 0 <= Depth < MaxDepth */
+ GLuint MaxDepth; /**< size of Stack[] array */
+ GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
+};
+
+
+/**
+ * \name Bits for image transfer operations
+ * \sa __struct gl_contextRec::ImageTransferState.
+ */
+/*@{*/
+#define IMAGE_SCALE_BIAS_BIT 0x1
+#define IMAGE_SHIFT_OFFSET_BIT 0x2
+#define IMAGE_MAP_COLOR_BIT 0x4
+#define IMAGE_CLAMP_BIT 0x800
+
+
+/** Pixel Transfer ops */
+#define IMAGE_BITS (IMAGE_SCALE_BIAS_BIT | \
+ IMAGE_SHIFT_OFFSET_BIT | \
+ IMAGE_MAP_COLOR_BIT)
+
+
+/**
+ * \name Bits to indicate what state has changed.
+ */
+/*@{*/
+#define _NEW_MODELVIEW (1u << 0) /**< gl_context::ModelView */
+#define _NEW_PROJECTION (1u << 1) /**< gl_context::Projection */
+#define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */
+#define _NEW_COLOR (1u << 3) /**< gl_context::Color */
+#define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */
+/* gap */
+#define _NEW_FOG (1u << 6) /**< gl_context::Fog */
+#define _NEW_HINT (1u << 7) /**< gl_context::Hint */
+#define _NEW_LIGHT (1u << 8) /**< gl_context::Light */
+#define _NEW_LINE (1u << 9) /**< gl_context::Line */
+#define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */
+#define _NEW_POINT (1u << 11) /**< gl_context::Point */
+#define _NEW_POLYGON (1u << 12) /**< gl_context::Polygon */
+#define _NEW_POLYGONSTIPPLE (1u << 13) /**< gl_context::PolygonStipple */
+#define _NEW_SCISSOR (1u << 14) /**< gl_context::Scissor */
+#define _NEW_STENCIL (1u << 15) /**< gl_context::Stencil */
+#define _NEW_TEXTURE_OBJECT (1u << 16) /**< gl_context::Texture (bindings only) */
+#define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */
+#define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */
+#define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */
+/* gap */
+#define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */
+#define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */
+#define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */
+#define _NEW_MULTISAMPLE (1u << 24) /**< gl_context::Multisample */
+#define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
+#define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
+#define _NEW_PROGRAM_CONSTANTS (1u << 27)
+/* gap */
+#define _NEW_FRAG_CLAMP (1u << 29)
+/* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
+#define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::varying_vp_inputs */
+#define _NEW_ALL ~0
+/*@}*/
+
+
+/**
+ * Composite state flags
+ */
+/*@{*/
+#define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)
+
+#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
+ _NEW_TEXTURE_STATE | \
+ _NEW_POINT | \
+ _NEW_PROGRAM | \
+ _NEW_MODELVIEW)
+
+#define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \
+ _NEW_FOG | \
+ _NEW_PROGRAM)
+
+
+/*@}*/
+
+
+
+
+/* This has to be included here. */
+#include "dd.h"
+
+
+/** Opaque declaration of display list payload data type */
+union gl_dlist_node;
+
+
+/**
+ * Per-display list information.
+ */
+struct gl_display_list
+{
+ GLuint Name;
+ 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;
+};
+
+
+/**
+ * State used during display list compilation and execution.
+ */
+struct gl_dlist_state
+{
+ 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];
+ uint32_t CurrentAttrib[VERT_ATTRIB_MAX][8];
+
+ 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.
+ */
+ GLenum16 ShadeModel;
+ } Current;
+};
+
+/**
+ * Driver-specific state flags.
+ *
+ * These are or'd with gl_context::NewDriverState to notify a driver about
+ * a state change. The driver sets the flags at context creation and
+ * the meaning of the bits set is opaque to core Mesa.
+ */
+struct gl_driver_flags
+{
+ /** gl_context::Array::_DrawArrays (vertex array state) */
+ uint64_t NewArray;
+
+ /** gl_context::TransformFeedback::CurrentObject */
+ uint64_t NewTransformFeedback;
+
+ /** gl_context::TransformFeedback::CurrentObject::shader_program */
+ uint64_t NewTransformFeedbackProg;
+
+ /** gl_context::RasterDiscard */
+ uint64_t NewRasterizerDiscard;
+
+ /** gl_context::TileRasterOrder* */
+ uint64_t NewTileRasterOrder;
+
+ /**
+ * gl_context::UniformBufferBindings
+ * gl_shader_program::UniformBlocks
+ */
+ uint64_t NewUniformBuffer;
+
+ /**
+ * gl_context::ShaderStorageBufferBindings
+ * gl_shader_program::ShaderStorageBlocks
+ */
+ uint64_t NewShaderStorageBuffer;
+
+ uint64_t NewTextureBuffer;
+
+ /**
+ * gl_context::AtomicBufferBindings
+ */
+ uint64_t NewAtomicBuffer;
+
+ /**
+ * gl_context::ImageUnits
+ */
+ uint64_t NewImageUnits;
+
+ /**
+ * gl_context::TessCtrlProgram::patch_default_*
+ */
+ uint64_t NewDefaultTessLevels;
+
+ /**
+ * gl_context::IntelConservativeRasterization
+ */
+ uint64_t NewIntelConservativeRasterization;
+
+ /**
+ * gl_context::NvConservativeRasterization
+ */
+ uint64_t NewNvConservativeRasterization;
+
+ /**
+ * gl_context::ConservativeRasterMode/ConservativeRasterDilate
+ * gl_context::SubpixelPrecisionBias
+ */
+ uint64_t NewNvConservativeRasterizationParams;
+
+ /**
+ * gl_context::Scissor::WindowRects
+ */
+ uint64_t NewWindowRectangles;
+
+ /** gl_context::Color::sRGBEnabled */
+ uint64_t NewFramebufferSRGB;
+
+ /** gl_context::Scissor::EnableFlags */
+ uint64_t NewScissorTest;
+
+ /** gl_context::Scissor::ScissorArray */
+ uint64_t NewScissorRect;
+
+ /** gl_context::Color::Alpha* */
+ uint64_t NewAlphaTest;
+
+ /** gl_context::Color::Blend/Dither */
+ uint64_t NewBlend;
+
+ /** gl_context::Color::BlendColor */
+ uint64_t NewBlendColor;
+
+ /** gl_context::Color::Color/Index */
+ uint64_t NewColorMask;
+
+ /** gl_context::Depth */
+ uint64_t NewDepth;
+
+ /** gl_context::Color::LogicOp/ColorLogicOp/IndexLogicOp */
+ uint64_t NewLogicOp;
+
+ /** gl_context::Multisample::Enabled */
+ uint64_t NewMultisampleEnable;
+
+ /** gl_context::Multisample::SampleAlphaTo* */
+ uint64_t NewSampleAlphaToXEnable;
+
+ /** gl_context::Multisample::SampleCoverage/SampleMaskValue */
+ uint64_t NewSampleMask;
+
+ /** gl_context::Multisample::(Min)SampleShading */
+ uint64_t NewSampleShading;
+
+ /** gl_context::Stencil */
+ uint64_t NewStencil;
+
+ /** gl_context::Transform::ClipOrigin/ClipDepthMode */
+ uint64_t NewClipControl;
+
+ /** gl_context::Transform::EyeUserPlane */
+ uint64_t NewClipPlane;
+
+ /** gl_context::Transform::ClipPlanesEnabled */
+ uint64_t NewClipPlaneEnable;
+
+ /** gl_context::Transform::DepthClamp */
+ uint64_t NewDepthClamp;
+
+ /** gl_context::Line */
+ uint64_t NewLineState;
+
+ /** gl_context::Polygon */
+ uint64_t NewPolygonState;
+
+ /** gl_context::PolygonStipple */
+ uint64_t NewPolygonStipple;
+
+ /** gl_context::ViewportArray */
+ uint64_t NewViewport;
+
+ /** Shader constants (uniforms, program parameters, state constants) */
+ uint64_t NewShaderConstants[MESA_SHADER_STAGES];
+
+ /** Programmable sample location state for gl_context::DrawBuffer */
+ uint64_t NewSampleLocations;
+};
+
+struct gl_buffer_binding
+{
+ struct gl_buffer_object *BufferObject;
+ /** Start of uniform 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.
+ */
+struct gl_image_unit
+{
+ /**
+ * Texture object bound to this unit.
+ */
+ struct gl_texture_object *TexObj;
+
+ /**
+ * Level of the texture object bound to this unit.
+ */
+ GLubyte Level;
+
+ /**
+ * \c GL_TRUE if the whole level is bound as an array of layers, \c
+ * GL_FALSE if only some specific layer of the texture is bound.
+ * \sa Layer
+ */
+ GLboolean Layered;
+
+ /**
+ * Layer of the texture object bound to this unit as specified by the
+ * application.
+ */
+ GLushort Layer;
+
+ /**
+ * Layer of the texture object bound to this unit, or zero if
+ * Layered == false.
+ */
+ GLushort _Layer;
+
+ /**
+ * Access allowed to this texture image. Either \c GL_READ_ONLY,
+ * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
+ */
+ GLenum16 Access;
+
+ /**
+ * GL internal format that determines the interpretation of the
+ * image memory when shader image operations are performed through
+ * this unit.
+ */
+ GLenum16 Format;
+
+ /**
+ * Mesa format corresponding to \c Format.
+ */
+ mesa_format _ActualFormat:16;
+};
+
+/**
+ * Shader subroutines storage
+ */
+struct gl_subroutine_index_binding
+{
+ GLuint NumIndex;
+ GLuint *IndexPtr;
+};
+
+struct gl_texture_handle_object
+{
+ struct gl_texture_object *texObj;
+ struct gl_sampler_object *sampObj;
+ GLuint64 handle;
+};
+
+struct gl_image_handle_object
+{
+ struct gl_image_unit imgObj;
+ GLuint64 handle;
+};
+
+struct gl_memory_object
+{
+ GLuint Name; /**< hash table ID/name */
+ GLboolean Immutable; /**< denotes mutability state of parameters */
+ GLboolean Dedicated; /**< import memory from a dedicated allocation */
+};
+
+struct gl_semaphore_object
+{
+ GLuint Name; /**< hash table ID/name */
+};
+
+/**
+ * Mesa rendering context.
+ *
+ * This is the central context data structure for Mesa. Almost all
+ * OpenGL state is contained in this structure.
+ * Think of this as a base class from which device drivers will derive
+ * sub classes.
+ */
+struct gl_context
+{
+ /** State possibly shared with other contexts in the address space */
+ struct gl_shared_state *Shared;
+
+ /** \name API function pointer tables */
+ /*@{*/
+ gl_api API;
+
+ /**
+ * The current dispatch table for non-displaylist-saving execution, either
+ * BeginEnd or OutsideBeginEnd
+ */
+ struct _glapi_table *Exec;
+ /**
+ * The normal dispatch table for non-displaylist-saving, non-begin/end
+ */
+ struct _glapi_table *OutsideBeginEnd;
+ /** The dispatch table used between glNewList() and glEndList() */
+ struct _glapi_table *Save;
+ /**
+ * The dispatch table used between glBegin() and glEnd() (outside of a
+ * display list). Only valid functions between those two are set, which is
+ * mostly just the set in a GLvertexformat struct.
+ */
+ struct _glapi_table *BeginEnd;
+ /**
+ * Dispatch table for when a graphics reset has happened.
+ */
+ struct _glapi_table *ContextLost;
+ /**
+ * Dispatch table used to marshal API calls from the client program to a
+ * separate server thread. NULL if API calls are not being marshalled to
+ * another thread.
+ */
+ struct _glapi_table *MarshalExec;
+ /**
+ * Dispatch table currently in use for fielding API calls from the client
+ * program. If API calls are being marshalled to another thread, this ==
+ * MarshalExec. Otherwise it == CurrentServerDispatch.
+ */
+ struct _glapi_table *CurrentClientDispatch;
+
+ /**
+ * Dispatch table currently in use for performing API calls. == Save or
+ * Exec.
+ */
+ struct _glapi_table *CurrentServerDispatch;
+
+ /*@}*/
+
+ struct glthread_state GLThread;
+
+ struct gl_config Visual;
+ struct gl_framebuffer *DrawBuffer; /**< buffer for writing */
+ struct gl_framebuffer *ReadBuffer; /**< buffer for reading */
+ struct gl_framebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
+ struct gl_framebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
+
+ /**
+ * Device driver function pointer table
+ */
+ struct dd_function_table Driver;
+
+ /** Core/Driver constants */
+ struct gl_constants Const;
+
+ /** \name The various 4x4 matrix stacks */
+ /*@{*/
+ struct gl_matrix_stack ModelviewMatrixStack;
+ struct gl_matrix_stack ProjectionMatrixStack;
+ struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];
+ struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
+ struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
+ /*@}*/
+
+ /** Combined modelview and projection matrix */
+ GLmatrix _ModelProjectMatrix;
+
+ /** \name Display lists */
+ struct gl_dlist_state ListState;
+
+ GLboolean ExecuteFlag; /**< Execute GL commands? */
+ GLboolean CompileFlag; /**< Compile GL commands into display list? */
+
+ /** Extension information */
+ struct gl_extensions Extensions;
+
+ /** GL version integer, for example 31 for GL 3.1, or 20 for GLES 2.0. */
+ GLuint Version;
+ char *VersionString;
+
+ /** \name State attribute stack (for glPush/PopAttrib) */
+ /*@{*/
+ GLuint AttribStackDepth;
+ struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
+ /*@}*/
+
+ /** \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.
+ */
+ /*@{*/
+ struct gl_accum_attrib Accum; /**< Accum buffer attributes */
+ struct gl_colorbuffer_attrib Color; /**< Color buffer attributes */
+ struct gl_current_attrib Current; /**< Current attributes */
+ struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
+ struct gl_eval_attrib Eval; /**< Eval attributes */
+ struct gl_fog_attrib Fog; /**< Fog attributes */
+ struct gl_hint_attrib Hint; /**< Hint attributes */
+ struct gl_light_attrib Light; /**< Light attributes */
+ struct gl_line_attrib Line; /**< Line attributes */
+ struct gl_list_attrib List; /**< List attributes */
+ struct gl_multisample_attrib Multisample;
+ struct gl_pixel_attrib Pixel; /**< Pixel attributes */
+ struct gl_point_attrib Point; /**< Point attributes */
+ struct gl_polygon_attrib Polygon; /**< Polygon attributes */
+ GLuint PolygonStipple[32]; /**< Polygon stipple */
+ struct gl_scissor_attrib Scissor; /**< Scissor attributes */
+ struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
+ struct gl_texture_attrib Texture; /**< Texture attributes */
+ struct gl_transform_attrib Transform; /**< Transformation attributes */
+ struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
+ GLuint SubpixelPrecisionBias[2]; /**< Viewport attributes */
+ /*@}*/
+
+ /** \name Client attribute stack */
+ /*@{*/
+ GLuint ClientAttribStackDepth;
+ struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
+ /*@}*/
+
+ /** \name Client attribute groups */
+ /*@{*/
+ struct gl_array_attrib Array; /**< Vertex arrays */
+ struct gl_pixelstore_attrib Pack; /**< Pixel packing */
+ struct gl_pixelstore_attrib Unpack; /**< Pixel unpacking */
+ struct gl_pixelstore_attrib DefaultPacking; /**< Default params */
+ /*@}*/
+
+ /** \name Other assorted state (not pushed/popped on attribute stack) */
+ /*@{*/
+ struct gl_pixelmaps PixelMaps;
+
+ struct gl_evaluators EvalMap; /**< All evaluators */
+ struct gl_feedback Feedback; /**< Feedback */
+ struct gl_selection Select; /**< Selection */
+
+ struct gl_program_state Program; /**< general program state */
+ struct gl_vertex_program_state VertexProgram;
+ struct gl_fragment_program_state FragmentProgram;
+ struct gl_geometry_program_state GeometryProgram;
+ struct gl_compute_program_state ComputeProgram;
+ struct gl_tess_ctrl_program_state TessCtrlProgram;
+ struct gl_tess_eval_program_state TessEvalProgram;
+ struct gl_ati_fragment_shader_state ATIFragmentShader;
+
+ struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */
+ struct gl_pipeline_object Shader; /**< GLSL shader object state */
+
+ /**
+ * Current active shader pipeline state
+ *
+ * Almost all internal users want ::_Shader instead of ::Shader. The
+ * exceptions are bits of legacy GLSL API that do not know about separate
+ * shader objects.
+ *
+ * If a program is active via \c glUseProgram, this will point to
+ * \c ::Shader.
+ *
+ * If a program pipeline is active via \c glBindProgramPipeline, this will
+ * point to \c ::Pipeline.Current.
+ *
+ * If neither a program nor a program pipeline is active, this will point to
+ * \c ::Pipeline.Default. This ensures that \c ::_Shader will never be
+ * \c NULL.
+ */
+ struct gl_pipeline_object *_Shader;
+
+ /**
+ * NIR containing the functions that implement software fp64 support.
+ */
+ struct nir_shader *SoftFP64;
+
+ struct gl_query_state Query; /**< occlusion, timer queries */
+
+ struct gl_transform_feedback_state TransformFeedback;
+
+ struct gl_perf_monitor_state PerfMonitor;
+ struct gl_perf_query_state PerfQuery;
+
+ struct gl_buffer_object *DrawIndirectBuffer; /** < GL_ARB_draw_indirect */
+ struct gl_buffer_object *ParameterBuffer; /** < GL_ARB_indirect_parameters */
+ struct gl_buffer_object *DispatchIndirectBuffer; /** < GL_ARB_compute_shader */
+
+ struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
+ struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
+
+ struct gl_buffer_object *QueryBuffer; /**< GL_ARB_query_buffer_object */
+
+ /**
+ * Current GL_ARB_uniform_buffer_object binding referenced by
+ * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc.
+ */
+ struct gl_buffer_object *UniformBuffer;
+
+ /**
+ * Current GL_ARB_shader_storage_buffer_object binding referenced by
+ * GL_SHADER_STORAGE_BUFFER target for glBufferData, glMapBuffer, etc.
+ */
+ struct gl_buffer_object *ShaderStorageBuffer;
+
+ /**
+ * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1.
+ * This is set up using glBindBufferRange() or glBindBufferBase(). They are
+ * associated with uniform blocks by glUniformBlockBinding()'s state in the
+ * shader program.
+ */
+ struct gl_buffer_binding
+ UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
+
+ /**
+ * Array of shader storage buffers for ARB_shader_storage_buffer_object
+ * and GL 4.3. This is set up using glBindBufferRange() or
+ * glBindBufferBase(). They are associated with shader storage blocks by
+ * glShaderStorageBlockBinding()'s state in the shader program.
+ */
+ struct gl_buffer_binding
+ ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
+
+ /**
+ * Object currently associated with the GL_ATOMIC_COUNTER_BUFFER
+ * target.
+ */
+ struct gl_buffer_object *AtomicBuffer;
+
+ /**
+ * Object currently associated w/ the GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
+ * target.
+ */
+ struct gl_buffer_object *ExternalVirtualMemoryBuffer;
+
+ /**
+ * Array of atomic counter buffer binding points.
+ */
+ struct gl_buffer_binding
+ AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
+
+ /**
+ * Array of image units for ARB_shader_image_load_store.
+ */
+ 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;
+
+ GLenum16 ErrorValue; /**< Last error code */
+
+ /**
+ * Recognize and silence repeated error debug messages in buggy apps.
+ */
+ const char *ErrorDebugFmtString;
+ GLuint ErrorDebugCount;
+
+ /* GL_ARB_debug_output/GL_KHR_debug */
+ simple_mtx_t DebugMutex;
+ struct gl_debug_state *Debug;
+
+ 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? */
+ GLboolean _AllowDrawOutOfOrder;
+
+ 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; /* may be for model- or eyespace lighting */
+ GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
+ GLboolean _NeedEyeCoords;
+ GLboolean _ForceEyeCoords;
+
+ GLuint TextureStateTimestamp; /**< detect changes to shared state */
+
+ struct gl_list_extensions *ListExt; /**< driver dlist extensions */
+
+ /** \name For debugging/development only */
+ /*@{*/
+ GLboolean FirstTimeCurrent;
+ /*@}*/
+
+ /**
+ * False if this context was created without a config. This is needed
+ * because the initial state of glDrawBuffers depends on this
+ */
+ GLboolean HasConfig;
+
+ GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
+
+ GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
+ GLboolean IntelConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */
+ GLboolean ConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_NV */
+ GLfloat ConservativeRasterDilate;
+ GLenum16 ConservativeRasterMode;
+
+ GLboolean IntelBlackholeRender; /**< GL_INTEL_blackhole_render */
+
+ /** 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.
+ *
+ * These will eventually live in the driver or elsewhere.
+ */
+ /*@{*/
+ void *swrast_context;
+ void *swsetup_context;
+ void *swtnl_context;
+ struct vbo_context *vbo_context;
+ struct st_context *st;
+ /*@}*/
+
+ /**
+ * \name NV_vdpau_interop
+ */
+ /*@{*/
+ const void *vdpDevice;
+ const void *vdpGetProcAddress;
+ struct set *vdpSurfaces;
+ /*@}*/
+
+ /**
+ * Has this context observed a GPU reset in any context in the share group?
+ *
+ * Once this field becomes true, it is never reset to false.
+ */
+ GLboolean ShareGroupReset;
+
+ /**
+ * \name OES_primitive_bounding_box
+ *
+ * Stores the arguments to glPrimitiveBoundingBox
+ */
+ GLfloat PrimitiveBoundingBox[8];
+
+ struct disk_cache *Cache;
+
+ /**
+ * \name GL_ARB_bindless_texture
+ */
+ /*@{*/
+ struct hash_table_u64 *ResidentTextureHandles;
+ struct hash_table_u64 *ResidentImageHandles;
+ /*@}*/
+
+ bool shader_builtin_ref;
+};
+
+/**
+ * Information about memory usage. All sizes are in kilobytes.
+ */
+struct gl_memory_info
+{
+ unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
+ unsigned avail_device_memory; /**< free device memory at the moment */
+ unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
+ unsigned avail_staging_memory; /**< free staging memory at the moment */
+ unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
+ unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
+};
+
+#ifndef NDEBUG
+extern int MESA_VERBOSE;
+extern int MESA_DEBUG_FLAGS;
+#else
+# define MESA_VERBOSE 0
+# define MESA_DEBUG_FLAGS 0
+#endif
+
+
+/** The MESA_VERBOSE var is a bitmask of these flags */
+enum _verbose
+{
+ VERBOSE_VARRAY = 0x0001,
+ VERBOSE_TEXTURE = 0x0002,
+ VERBOSE_MATERIAL = 0x0004,
+ VERBOSE_PIPELINE = 0x0008,
+ VERBOSE_DRIVER = 0x0010,
+ VERBOSE_STATE = 0x0020,
+ VERBOSE_API = 0x0040,
+ VERBOSE_DISPLAY_LIST = 0x0100,
+ VERBOSE_LIGHTING = 0x0200,
+ VERBOSE_PRIMS = 0x0400,
+ VERBOSE_VERTS = 0x0800,
+ VERBOSE_DISASSEM = 0x1000,
+ VERBOSE_DRAW = 0x2000,
+ VERBOSE_SWAPBUFFERS = 0x4000
+};
+
+
+/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */
+enum _debug
+{
+ DEBUG_SILENT = (1 << 0),
+ DEBUG_ALWAYS_FLUSH = (1 << 1),
+ DEBUG_INCOMPLETE_TEXTURE = (1 << 2),
+ DEBUG_INCOMPLETE_FBO = (1 << 3),
+ DEBUG_CONTEXT = (1 << 4)
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MTYPES_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/shaderobj.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/shaderobj.h
new file mode 100644
index 0000000000..0d512550de
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/shaderobj.h
@@ -0,0 +1,265 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2004-2007 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef SHADEROBJ_H
+#define SHADEROBJ_H
+
+
+#include "main/glheader.h"
+#include "compiler/shader_enums.h"
+#include "program/ir_to_mesa.h"
+#include "util/macros.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_shader_program_data;
+struct gl_linked_shader;
+struct dd_function_table;
+struct gl_pipeline_object;
+
+/**
+ * Internal functions
+ */
+
+extern void
+_mesa_init_shader_state(struct gl_context * ctx);
+
+extern void
+_mesa_free_shader_state(struct gl_context *ctx);
+
+
+extern void
+_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
+ struct gl_shader *sh);
+
+extern struct gl_shader *
+_mesa_lookup_shader(struct gl_context *ctx, GLuint name);
+
+extern struct gl_shader *
+_mesa_lookup_shader_err(struct gl_context *ctx, GLuint name, const char *caller);
+
+
+
+extern void
+_mesa_reference_shader_program_(struct gl_context *ctx,
+ struct gl_shader_program **ptr,
+ struct gl_shader_program *shProg);
+
+void
+_mesa_reference_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program_data **ptr,
+ struct gl_shader_program_data *data);
+
+static inline void
+_mesa_reference_shader_program(struct gl_context *ctx,
+ struct gl_shader_program **ptr,
+ struct gl_shader_program *shProg)
+{
+ if (*ptr != shProg)
+ _mesa_reference_shader_program_(ctx, ptr, shProg);
+}
+
+extern struct gl_shader *
+_mesa_new_shader(GLuint name, gl_shader_stage type);
+
+extern void
+_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+
+extern void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh);
+
+extern struct gl_shader_program *
+_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name);
+
+extern struct gl_shader_program *
+_mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name,
+ const char *caller);
+
+extern struct gl_shader_program *
+_mesa_new_shader_program(GLuint name);
+
+extern struct gl_shader_program_data *
+_mesa_create_shader_program_data(void);
+
+extern void
+_mesa_clear_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program *shProg);
+
+extern void
+_mesa_free_shader_program_data(struct gl_context *ctx,
+ struct gl_shader_program *shProg);
+
+extern void
+_mesa_delete_shader_program(struct gl_context *ctx,
+ struct gl_shader_program *shProg);
+
+
+extern void
+_mesa_init_shader_object_functions(struct dd_function_table *driver);
+
+static inline gl_shader_stage
+_mesa_shader_enum_to_shader_stage(GLenum v)
+{
+ switch (v) {
+ case GL_VERTEX_SHADER:
+ return MESA_SHADER_VERTEX;
+ case GL_FRAGMENT_SHADER:
+ return MESA_SHADER_FRAGMENT;
+ case GL_GEOMETRY_SHADER:
+ return MESA_SHADER_GEOMETRY;
+ case GL_TESS_CONTROL_SHADER:
+ return MESA_SHADER_TESS_CTRL;
+ case GL_TESS_EVALUATION_SHADER:
+ return MESA_SHADER_TESS_EVAL;
+ case GL_COMPUTE_SHADER:
+ return MESA_SHADER_COMPUTE;
+ default:
+ unreachable("bad value in _mesa_shader_enum_to_shader_stage()");
+ }
+}
+
+/* 8 bytes + another underscore */
+#define MESA_SUBROUTINE_PREFIX_LEN 9
+static inline const char *
+_mesa_shader_stage_to_subroutine_prefix(gl_shader_stage stage)
+{
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ return "__subu_v";
+ case MESA_SHADER_GEOMETRY:
+ return "__subu_g";
+ case MESA_SHADER_FRAGMENT:
+ return "__subu_f";
+ case MESA_SHADER_COMPUTE:
+ return "__subu_c";
+ case MESA_SHADER_TESS_CTRL:
+ return "__subu_t";
+ case MESA_SHADER_TESS_EVAL:
+ return "__subu_e";
+ default:
+ return NULL;
+ }
+}
+
+static inline gl_shader_stage
+_mesa_shader_stage_from_subroutine_uniform(GLenum subuniform)
+{
+ switch (subuniform) {
+ case GL_VERTEX_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_VERTEX;
+ case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_GEOMETRY;
+ case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_FRAGMENT;
+ case GL_COMPUTE_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_COMPUTE;
+ case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_TESS_CTRL;
+ case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+ return MESA_SHADER_TESS_EVAL;
+ }
+ unreachable("not reached");
+}
+
+static inline gl_shader_stage
+_mesa_shader_stage_from_subroutine(GLenum subroutine)
+{
+ switch (subroutine) {
+ case GL_VERTEX_SUBROUTINE:
+ return MESA_SHADER_VERTEX;
+ case GL_GEOMETRY_SUBROUTINE:
+ return MESA_SHADER_GEOMETRY;
+ case GL_FRAGMENT_SUBROUTINE:
+ return MESA_SHADER_FRAGMENT;
+ case GL_COMPUTE_SUBROUTINE:
+ return MESA_SHADER_COMPUTE;
+ case GL_TESS_CONTROL_SUBROUTINE:
+ return MESA_SHADER_TESS_CTRL;
+ case GL_TESS_EVALUATION_SUBROUTINE:
+ return MESA_SHADER_TESS_EVAL;
+ }
+ unreachable("not reached");
+}
+
+static inline GLenum
+_mesa_shader_stage_to_subroutine(gl_shader_stage stage)
+{
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ return GL_VERTEX_SUBROUTINE;
+ case MESA_SHADER_GEOMETRY:
+ return GL_GEOMETRY_SUBROUTINE;
+ case MESA_SHADER_FRAGMENT:
+ return GL_FRAGMENT_SUBROUTINE;
+ case MESA_SHADER_COMPUTE:
+ return GL_COMPUTE_SUBROUTINE;
+ case MESA_SHADER_TESS_CTRL:
+ return GL_TESS_CONTROL_SUBROUTINE;
+ case MESA_SHADER_TESS_EVAL:
+ return GL_TESS_EVALUATION_SUBROUTINE;
+ case MESA_SHADER_NONE:
+ break;
+ case MESA_SHADER_KERNEL:
+ unreachable("not reached");
+ break;
+ }
+ unreachable("not reached");
+}
+
+static inline GLenum
+_mesa_shader_stage_to_subroutine_uniform(gl_shader_stage stage)
+{
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ return GL_VERTEX_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_GEOMETRY:
+ return GL_GEOMETRY_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_FRAGMENT:
+ return GL_FRAGMENT_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_COMPUTE:
+ return GL_COMPUTE_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_TESS_CTRL:
+ return GL_TESS_CONTROL_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_TESS_EVAL:
+ return GL_TESS_EVALUATION_SUBROUTINE_UNIFORM;
+ case MESA_SHADER_NONE:
+ case MESA_SHADER_KERNEL:
+ break;
+ }
+ unreachable("not reached");
+}
+
+extern bool
+_mesa_validate_pipeline_io(struct gl_pipeline_object *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SHADEROBJ_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/uniforms.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/uniforms.h
new file mode 100644
index 0000000000..819cf90ba4
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/uniforms.h
@@ -0,0 +1,523 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef UNIFORMS_H
+#define UNIFORMS_H
+
+#include "main/glheader.h"
+#include "compiler/glsl_types.h"
+#include "compiler/glsl/ir_uniform.h"
+#include "program/prog_parameter.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct gl_program;
+struct _glapi_table;
+
+void GLAPIENTRY
+_mesa_Uniform1f(GLint, GLfloat);
+void GLAPIENTRY
+_mesa_Uniform2f(GLint, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_Uniform3f(GLint, GLfloat, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_Uniform4f(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_Uniform1i(GLint, GLint);
+void GLAPIENTRY
+_mesa_Uniform2i(GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_Uniform3i(GLint, GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_Uniform4i(GLint, GLint, GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_Uniform1fv(GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_Uniform2fv(GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_Uniform3fv(GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_Uniform4fv(GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_Uniform1iv(GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_Uniform2iv(GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_Uniform3iv(GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_Uniform4iv(GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_Uniform1ui(GLint location, GLuint v0);
+void GLAPIENTRY
+_mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1);
+void GLAPIENTRY
+_mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2);
+void GLAPIENTRY
+_mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+void GLAPIENTRY
+_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value);
+void GLAPIENTRY
+_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value);
+void GLAPIENTRY
+_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value);
+void GLAPIENTRY
+_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value);
+void GLAPIENTRY
+_mesa_UniformMatrix2fv(GLint, GLsizei, GLboolean, const GLfloat *);
+void GLAPIENTRY
+_mesa_UniformMatrix3fv(GLint, GLsizei, GLboolean, const GLfloat *);
+void GLAPIENTRY
+_mesa_UniformMatrix4fv(GLint, GLsizei, GLboolean, const GLfloat *);
+void GLAPIENTRY
+_mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+void GLAPIENTRY
+_mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+void GLAPIENTRY
+_mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+void GLAPIENTRY
+_mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+void GLAPIENTRY
+_mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+void GLAPIENTRY
+_mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
+ const GLfloat *value);
+
+void GLAPIENTRY
+_mesa_UniformHandleui64ARB(GLint location, GLuint64 value);
+void GLAPIENTRY
+_mesa_UniformHandleui64vARB(GLint location, GLsizei count,
+ const GLuint64 *value);
+void GLAPIENTRY
+_mesa_ProgramUniformHandleui64ARB(GLuint program, GLint location,
+ GLuint64 value);
+void GLAPIENTRY
+_mesa_ProgramUniformHandleui64vARB(GLuint program, GLint location,
+ GLsizei count, const GLuint64 *values);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1f(GLuint program, GLint, GLfloat);
+void GLAPIENTRY
+_mesa_ProgramUniform2f(GLuint program, GLint, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_ProgramUniform3f(GLuint program, GLint, GLfloat, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_ProgramUniform4f(GLuint program, GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+void GLAPIENTRY
+_mesa_ProgramUniform1i(GLuint program, GLint, GLint);
+void GLAPIENTRY
+_mesa_ProgramUniform2i(GLuint program, GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_ProgramUniform3i(GLuint program, GLint, GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_ProgramUniform4i(GLuint program, GLint, GLint, GLint, GLint, GLint);
+void GLAPIENTRY
+_mesa_ProgramUniform1fv(GLuint program, GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniform2fv(GLuint program, GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniform3fv(GLuint program, GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniform4fv(GLuint program, GLint, GLsizei, const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniform1iv(GLuint program, GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_ProgramUniform2iv(GLuint program, GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_ProgramUniform3iv(GLuint program, GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_ProgramUniform4iv(GLuint program, GLint, GLsizei, const GLint *);
+void GLAPIENTRY
+_mesa_ProgramUniform1ui(GLuint program, GLint location, GLuint v0);
+void GLAPIENTRY
+_mesa_ProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1);
+void GLAPIENTRY
+_mesa_ProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1,
+ GLuint v2);
+void GLAPIENTRY
+_mesa_ProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1,
+ GLuint v2, GLuint v3);
+void GLAPIENTRY
+_mesa_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
+ const GLuint *value);
+void GLAPIENTRY
+_mesa_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
+ const GLuint *value);
+void GLAPIENTRY
+_mesa_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
+ const GLuint *value);
+void GLAPIENTRY
+_mesa_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
+ const GLuint *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2fv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3fv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4fv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLfloat *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *value);
+
+void GLAPIENTRY
+_mesa_GetnUniformfvARB(GLuint, GLint, GLsizei, GLfloat *);
+void GLAPIENTRY
+_mesa_GetUniformfv(GLuint, GLint, GLfloat *);
+void GLAPIENTRY
+_mesa_GetnUniformivARB(GLuint, GLint, GLsizei, GLint *);
+void GLAPIENTRY
+_mesa_GetUniformuiv(GLuint, GLint, GLuint *);
+void GLAPIENTRY
+_mesa_GetnUniformuivARB(GLuint, GLint, GLsizei, GLuint *);
+void GLAPIENTRY
+_mesa_GetUniformuiv(GLuint program, GLint location, GLuint *params);
+void GLAPIENTRY
+_mesa_GetnUniformdvARB(GLuint, GLint, GLsizei, GLdouble *);
+void GLAPIENTRY
+_mesa_GetUniformdv(GLuint, GLint, GLdouble *);
+GLint GLAPIENTRY
+_mesa_GetUniformLocation(GLuint, const GLcharARB *);
+GLint GLAPIENTRY
+_mesa_GetUniformLocation_no_error(GLuint, const GLcharARB *);
+GLuint GLAPIENTRY
+_mesa_GetUniformBlockIndex(GLuint program,
+ const GLchar *uniformBlockName);
+void GLAPIENTRY
+_mesa_GetUniformIndices(GLuint program,
+ GLsizei uniformCount,
+ const GLchar * const *uniformNames,
+ GLuint *uniformIndices);
+
+void GLAPIENTRY
+_mesa_UniformBlockBinding_no_error(GLuint program, GLuint uniformBlockIndex,
+ GLuint uniformBlockBinding);
+
+void GLAPIENTRY
+_mesa_UniformBlockBinding(GLuint program,
+ GLuint uniformBlockIndex,
+ GLuint uniformBlockBinding);
+
+void GLAPIENTRY
+_mesa_ShaderStorageBlockBinding_no_error(GLuint program,
+ GLuint shaderStorageBlockIndex,
+ GLuint shaderStorageBlockBinding);
+
+void GLAPIENTRY
+_mesa_ShaderStorageBlockBinding(GLuint program,
+ GLuint shaderStorageBlockIndex,
+ GLuint shaderStorageBlockBinding);
+void GLAPIENTRY
+_mesa_GetActiveAtomicCounterBufferiv(GLuint program, GLuint bufferIndex,
+ GLenum pname, GLint *params);
+void GLAPIENTRY
+_mesa_GetActiveUniformBlockiv(GLuint program,
+ GLuint uniformBlockIndex,
+ GLenum pname,
+ GLint *params);
+void GLAPIENTRY
+_mesa_GetActiveUniformBlockName(GLuint program,
+ GLuint uniformBlockIndex,
+ GLsizei bufSize,
+ GLsizei *length,
+ GLchar *uniformBlockName);
+void GLAPIENTRY
+_mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
+ GLsizei bufSize, GLsizei *length,
+ GLchar *uniformName);
+void GLAPIENTRY
+_mesa_GetActiveUniform(GLuint, GLuint, GLsizei, GLsizei *,
+ GLint *, GLenum *, GLcharARB *);
+void GLAPIENTRY
+_mesa_GetActiveUniformsiv(GLuint program,
+ GLsizei uniformCount,
+ const GLuint *uniformIndices,
+ GLenum pname,
+ GLint *params);
+void GLAPIENTRY
+_mesa_GetUniformiv(GLuint, GLint, GLint *);
+
+void GLAPIENTRY
+_mesa_Uniform1d(GLint, GLdouble);
+void GLAPIENTRY
+_mesa_Uniform2d(GLint, GLdouble, GLdouble);
+void GLAPIENTRY
+_mesa_Uniform3d(GLint, GLdouble, GLdouble, GLdouble);
+void GLAPIENTRY
+_mesa_Uniform4d(GLint, GLdouble, GLdouble, GLdouble, GLdouble);
+
+void GLAPIENTRY
+_mesa_Uniform1dv(GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_Uniform2dv(GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_Uniform3dv(GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_Uniform4dv(GLint, GLsizei, const GLdouble *);
+
+void GLAPIENTRY
+_mesa_GetUniformi64vARB(GLuint, GLint, GLint64 *);
+void GLAPIENTRY
+_mesa_GetUniformui64vARB(GLuint, GLint, GLuint64 *);
+
+void GLAPIENTRY
+_mesa_GetnUniformi64vARB(GLuint, GLint, GLsizei, GLint64 *);
+void GLAPIENTRY
+_mesa_GetnUniformui64vARB(GLuint, GLint, GLsizei, GLuint64 *);
+
+void GLAPIENTRY
+_mesa_UniformMatrix2dv(GLint, GLsizei, GLboolean, const GLdouble *);
+void GLAPIENTRY
+_mesa_UniformMatrix3dv(GLint, GLsizei, GLboolean, const GLdouble *);
+void GLAPIENTRY
+_mesa_UniformMatrix4dv(GLint, GLsizei, GLboolean, const GLdouble *);
+void GLAPIENTRY
+_mesa_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+void GLAPIENTRY
+_mesa_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+void GLAPIENTRY
+_mesa_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+void GLAPIENTRY
+_mesa_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+void GLAPIENTRY
+_mesa_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+void GLAPIENTRY
+_mesa_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose,
+ const GLdouble *value);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1d(GLuint program, GLint, GLdouble);
+void GLAPIENTRY
+_mesa_ProgramUniform2d(GLuint program, GLint, GLdouble, GLdouble);
+void GLAPIENTRY
+_mesa_ProgramUniform3d(GLuint program, GLint, GLdouble, GLdouble, GLdouble);
+void GLAPIENTRY
+_mesa_ProgramUniform4d(GLuint program, GLint, GLdouble, GLdouble, GLdouble, GLdouble);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1dv(GLuint program, GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniform2dv(GLuint program, GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniform3dv(GLuint program, GLint, GLsizei, const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniform4dv(GLuint program, GLint, GLsizei, const GLdouble *);
+
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2dv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3dv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4dv(GLuint program, GLint, GLsizei, GLboolean,
+ const GLdouble *);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+void GLAPIENTRY
+_mesa_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
+ GLboolean transpose, const GLdouble *value);
+
+void GLAPIENTRY
+_mesa_Uniform1i64ARB(GLint, GLint64);
+void GLAPIENTRY
+_mesa_Uniform2i64ARB(GLint, GLint64, GLint64);
+void GLAPIENTRY
+_mesa_Uniform3i64ARB(GLint, GLint64, GLint64, GLint64);
+void GLAPIENTRY
+_mesa_Uniform4i64ARB(GLint, GLint64, GLint64, GLint64, GLint64);
+
+void GLAPIENTRY
+_mesa_Uniform1i64vARB(GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_Uniform2i64vARB(GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_Uniform3i64vARB(GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_Uniform4i64vARB(GLint, GLsizei, const GLint64 *);
+
+void GLAPIENTRY
+_mesa_Uniform1ui64ARB(GLint, GLuint64);
+void GLAPIENTRY
+_mesa_Uniform2ui64ARB(GLint, GLuint64, GLuint64);
+void GLAPIENTRY
+_mesa_Uniform3ui64ARB(GLint, GLuint64, GLuint64, GLuint64);
+void GLAPIENTRY
+_mesa_Uniform4ui64ARB(GLint, GLuint64, GLuint64, GLuint64, GLuint64);
+
+void GLAPIENTRY
+_mesa_Uniform1ui64vARB(GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_Uniform2ui64vARB(GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_Uniform3ui64vARB(GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_Uniform4ui64vARB(GLint, GLsizei, const GLuint64 *);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1i64ARB(GLuint, GLint, GLint64);
+void GLAPIENTRY
+_mesa_ProgramUniform2i64ARB(GLuint, GLint, GLint64, GLint64);
+void GLAPIENTRY
+_mesa_ProgramUniform3i64ARB(GLuint, GLint, GLint64, GLint64, GLint64);
+void GLAPIENTRY
+_mesa_ProgramUniform4i64ARB(GLuint, GLint, GLint64, GLint64, GLint64, GLint64);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1i64vARB(GLuint, GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform2i64vARB(GLuint, GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform3i64vARB(GLuint, GLint, GLsizei, const GLint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform4i64vARB(GLuint, GLint, GLsizei, const GLint64 *);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1ui64ARB(GLuint, GLint, GLuint64);
+void GLAPIENTRY
+_mesa_ProgramUniform2ui64ARB(GLuint, GLint, GLuint64, GLuint64);
+void GLAPIENTRY
+_mesa_ProgramUniform3ui64ARB(GLuint, GLint, GLuint64, GLuint64, GLuint64);
+void GLAPIENTRY
+_mesa_ProgramUniform4ui64ARB(GLuint, GLint, GLuint64, GLuint64, GLuint64, GLuint64);
+
+void GLAPIENTRY
+_mesa_ProgramUniform1ui64vARB(GLuint, GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform2ui64vARB(GLuint, GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform3ui64vARB(GLuint, GLint, GLsizei, const GLuint64 *);
+void GLAPIENTRY
+_mesa_ProgramUniform4ui64vARB(GLuint, GLint, GLsizei, const GLuint64 *);
+
+void
+_mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
+ struct gl_context *, struct gl_shader_program *,
+ enum glsl_base_type basicType, unsigned src_components);
+
+void
+_mesa_uniform_matrix(GLint location, GLsizei count,
+ GLboolean transpose, const void *values,
+ struct gl_context *, struct gl_shader_program *,
+ GLuint cols, GLuint rows, enum glsl_base_type basicType);
+
+void
+_mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
+ struct gl_context *, struct gl_shader_program *);
+
+void
+_mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
+ GLsizei bufSize, enum glsl_base_type returnType,
+ GLvoid *paramsOut);
+
+extern void
+_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *,
+ unsigned element_stride,
+ unsigned vector_stride,
+ enum gl_uniform_driver_format format,
+ void *data);
+
+extern void
+_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni);
+
+extern void
+_mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
+ unsigned array_index,
+ unsigned count);
+
+extern void
+_mesa_update_shader_textures_used(struct gl_shader_program *shProg,
+ struct gl_program *prog);
+
+extern bool
+_mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
+ char *errMsg, size_t errMsgLength);
+extern bool
+_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *);
+
+extern void
+_mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
+ const struct gl_uniform_storage *uni);
+
+struct gl_builtin_uniform_element {
+ const char *field;
+ gl_state_index16 tokens[STATE_LENGTH];
+ int swizzle;
+};
+
+struct gl_builtin_uniform_desc {
+ const char *name;
+ const struct gl_builtin_uniform_element *elements;
+ unsigned int num_elements;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* UNIFORMS_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/version.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/version.h
new file mode 100644
index 0000000000..4469509c08
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/main/version.h
@@ -0,0 +1,66 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#include <stdbool.h>
+#include "glheader.h"
+#include "menums.h"
+
+struct gl_context;
+struct gl_constants;
+struct gl_extensions;
+
+extern GLuint
+_mesa_get_version(const struct gl_extensions *extensions,
+ struct gl_constants *consts, gl_api api);
+
+extern void
+_mesa_compute_version(struct gl_context *ctx);
+
+extern bool
+_mesa_override_gl_version_contextless(struct gl_constants *consts,
+ gl_api *apiOut, GLuint *versionOut);
+
+extern void
+_mesa_override_gl_version(struct gl_context *ctx);
+
+extern void
+_mesa_override_glsl_version(struct gl_constants *consts);
+
+extern void
+_mesa_get_driver_uuid(struct gl_context *ctx, GLint *uuid);
+
+extern void
+_mesa_get_device_uuid(struct gl_context *ctx, GLint *uuid);
+
+extern int
+_mesa_get_shading_language_version(const struct gl_context *ctx,
+ int index,
+ char **versionOut);
+
+#endif /* VERSION_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/math/m_matrix.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/math/m_matrix.h
new file mode 100644
index 0000000000..c34d9e3022
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/math/m_matrix.h
@@ -0,0 +1,218 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file math/m_matrix.h
+ * Defines basic structures for matrix-handling.
+ */
+
+#ifndef _M_MATRIX_H
+#define _M_MATRIX_H
+
+
+#include "main/glheader.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * \name Symbolic names to some of the entries in the matrix
+ *
+ * These are handy for the viewport mapping, which is expressed as a matrix.
+ */
+/*@{*/
+#define MAT_SX 0
+#define MAT_SY 5
+#define MAT_SZ 10
+#define MAT_TX 12
+#define MAT_TY 13
+#define MAT_TZ 14
+/*@}*/
+
+
+/**
+ * Different kinds of 4x4 transformation matrices.
+ * We use these to select specific optimized vertex transformation routines.
+ */
+enum GLmatrixtype {
+ MATRIX_GENERAL, /**< general 4x4 matrix */
+ MATRIX_IDENTITY, /**< identity matrix */
+ MATRIX_3D_NO_ROT, /**< orthogonal projection and others... */
+ MATRIX_PERSPECTIVE, /**< perspective projection matrix */
+ MATRIX_2D, /**< 2-D transformation */
+ MATRIX_2D_NO_ROT, /**< 2-D scale & translate only */
+ MATRIX_3D /**< 3-D transformation */
+} ;
+
+/**
+ * Matrix type to represent 4x4 transformation matrices.
+ */
+typedef struct {
+ GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
+ GLfloat *inv; /**< 16-element inverse (16-byte aligned) */
+ GLuint flags; /**< possible values determined by (of \link
+ * MatFlags MAT_FLAG_* flags\endlink)
+ */
+ enum GLmatrixtype type;
+} GLmatrix;
+
+
+
+
+extern void
+_math_matrix_ctr( GLmatrix *m );
+
+extern void
+_math_matrix_dtr( GLmatrix *m );
+
+extern void
+_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
+
+extern void
+_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b );
+
+extern void
+_math_matrix_loadf( GLmatrix *mat, const GLfloat *m );
+
+extern void
+_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_rotate( GLmatrix *m, GLfloat angle,
+ GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_ortho( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval );
+
+extern void
+_math_matrix_frustum( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval );
+
+extern void
+_math_matrix_viewport( GLmatrix *m, const float scale[3],
+ const float translate[3], double depthMax );
+
+extern void
+_math_matrix_set_identity( GLmatrix *dest );
+
+extern void
+_math_matrix_copy( GLmatrix *to, const GLmatrix *from );
+
+extern void
+_math_matrix_analyse( GLmatrix *mat );
+
+extern void
+_math_matrix_print( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_length_preserving( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_has_rotation( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_general_scale( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_dirty( const GLmatrix *m );
+
+
+/**
+ * \name Related functions that don't actually operate on GLmatrix structs
+ */
+/*@{*/
+
+extern void
+_math_transposef( GLfloat to[16], const GLfloat from[16] );
+
+extern void
+_math_transposed( GLdouble to[16], const GLdouble from[16] );
+
+extern void
+_math_transposefd( GLfloat to[16], const GLdouble from[16] );
+
+
+/*
+ * Transform a point (column vector) by a matrix: Q = M * P
+ */
+#define TRANSFORM_POINT( Q, M, P ) \
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; \
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; \
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; \
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
+
+
+#define TRANSFORM_POINT3( Q, M, P ) \
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12]; \
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13]; \
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14]; \
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15];
+
+
+/*
+ * Transform a normal (row vector) by a matrix: [NX NY NZ] = N * MAT
+ */
+#define TRANSFORM_NORMAL( TO, N, MAT ) \
+do { \
+ TO[0] = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2]; \
+ TO[1] = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6]; \
+ TO[2] = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10]; \
+} while (0)
+
+
+/**
+ * Transform a direction by a matrix.
+ */
+#define TRANSFORM_DIRECTION( TO, DIR, MAT ) \
+do { \
+ TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8]; \
+ TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9]; \
+ TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\
+} while (0)
+
+
+extern void
+_mesa_transform_vector(GLfloat u[4], const GLfloat v[4], const GLfloat m[16]);
+
+
+/*@}*/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/dummy_errors.c b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/dummy_errors.c
new file mode 100644
index 0000000000..d69f54d1d0
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/dummy_errors.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <stdio.h>
+#include "main/errors.h"
+
+void
+_mesa_error_no_memory(const char *caller)
+{
+ fprintf(stderr, "Mesa error: out of memory in %s", caller);
+}
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/ir_to_mesa.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/ir_to_mesa.h
new file mode 100644
index 0000000000..33eb801bae
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/ir_to_mesa.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef IR_TO_MESA_H
+#define IR_TO_MESA_H
+
+#include "main/glheader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+struct gl_program;
+struct gl_shader;
+struct gl_shader_program;
+struct gl_linked_shader;
+struct gl_program_parameter_list;
+
+void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
+GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
+
+void
+_mesa_generate_parameters_list_for_uniforms(struct gl_context *ctx,
+ struct gl_shader_program
+ *shader_program,
+ struct gl_linked_shader *sh,
+ struct gl_program_parameter_list
+ *params);
+void
+_mesa_associate_uniform_storage(struct gl_context *ctx,
+ struct gl_shader_program *shader_program,
+ struct gl_program *prog);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IR_TO_MESA_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_instruction.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_instruction.h
new file mode 100644
index 0000000000..328566a10f
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_instruction.h
@@ -0,0 +1,293 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file prog_instruction.h
+ *
+ * Vertex/fragment program instruction datatypes and constants.
+ *
+ * \author Brian Paul
+ * \author Keith Whitwell
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+
+#ifndef PROG_INSTRUCTION_H
+#define PROG_INSTRUCTION_H
+
+
+#include "main/glheader.h"
+
+
+/**
+ * Swizzle indexes.
+ * Do not change!
+ */
+/*@{*/
+#define SWIZZLE_X 0
+#define SWIZZLE_Y 1
+#define SWIZZLE_Z 2
+#define SWIZZLE_W 3
+#define SWIZZLE_ZERO 4 /**< For SWZ instruction only */
+#define SWIZZLE_ONE 5 /**< For SWZ instruction only */
+#define SWIZZLE_NIL 7 /**< used during shader code gen (undefined value) */
+/*@}*/
+
+#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
+#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3)
+#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7)
+#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1)
+/** Determine if swz contains SWIZZLE_ZERO/ONE/NIL for any components. */
+#define HAS_EXTENDED_SWIZZLE(swz) (swz & 0x924)
+
+#define SWIZZLE_XYZW MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W)
+#define SWIZZLE_XXXX MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)
+#define SWIZZLE_YYYY MAKE_SWIZZLE4(SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y)
+#define SWIZZLE_ZZZZ MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)
+#define SWIZZLE_WWWW MAKE_SWIZZLE4(SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
+
+
+/**
+ * Writemask values, 1 bit per component.
+ */
+/*@{*/
+#define WRITEMASK_X 0x1
+#define WRITEMASK_Y 0x2
+#define WRITEMASK_XY 0x3
+#define WRITEMASK_Z 0x4
+#define WRITEMASK_XZ 0x5
+#define WRITEMASK_YZ 0x6
+#define WRITEMASK_XYZ 0x7
+#define WRITEMASK_W 0x8
+#define WRITEMASK_XW 0x9
+#define WRITEMASK_YW 0xa
+#define WRITEMASK_XYW 0xb
+#define WRITEMASK_ZW 0xc
+#define WRITEMASK_XZW 0xd
+#define WRITEMASK_YZW 0xe
+#define WRITEMASK_XYZW 0xf
+/*@}*/
+
+
+/**
+ * Per-component negation masks
+ */
+/*@{*/
+#define NEGATE_X 0x1
+#define NEGATE_Y 0x2
+#define NEGATE_Z 0x4
+#define NEGATE_W 0x8
+#define NEGATE_XYZ 0x7
+#define NEGATE_XYZW 0xf
+#define NEGATE_NONE 0x0
+/*@}*/
+
+
+/**
+ * Program instruction opcodes for vertex, fragment and geometry programs.
+ */
+enum prog_opcode {
+ /* ARB_vp ARB_fp NV_vp NV_fp GLSL */
+ /*------------------------------------------*/
+ OPCODE_NOP = 0, /* X */
+ OPCODE_ABS, /* X X 1.1 X */
+ OPCODE_ADD, /* X X X X X */
+ OPCODE_ARL, /* X X X */
+ OPCODE_BGNLOOP, /* opt */
+ OPCODE_BGNSUB, /* opt */
+ OPCODE_BRK, /* 2 opt */
+ OPCODE_CAL, /* 2 2 opt */
+ OPCODE_CMP, /* X X */
+ OPCODE_CONT, /* opt */
+ OPCODE_COS, /* X 2 X X */
+ OPCODE_DDX, /* X X */
+ OPCODE_DDY, /* X X */
+ OPCODE_DP2, /* 2 X */
+ OPCODE_DP3, /* X X X X X */
+ OPCODE_DP4, /* X X X X X */
+ OPCODE_DPH, /* X X 1.1 */
+ OPCODE_DST, /* X X X X */
+ OPCODE_ELSE, /* opt */
+ OPCODE_END, /* X X X X opt */
+ OPCODE_ENDIF, /* opt */
+ OPCODE_ENDLOOP, /* opt */
+ OPCODE_ENDSUB, /* opt */
+ OPCODE_EX2, /* X X 2 X X */
+ OPCODE_EXP, /* X X */
+ OPCODE_FLR, /* X X 2 X X */
+ OPCODE_FRC, /* X X 2 X X */
+ OPCODE_IF, /* opt */
+ OPCODE_KIL, /* X X */
+ OPCODE_LG2, /* X X 2 X X */
+ OPCODE_LIT, /* X X X X */
+ OPCODE_LOG, /* X X */
+ OPCODE_LRP, /* X X */
+ OPCODE_MAD, /* X X X X X */
+ OPCODE_MAX, /* X X X X X */
+ OPCODE_MIN, /* X X X X X */
+ OPCODE_MOV, /* X X X X X */
+ OPCODE_MUL, /* X X X X X */
+ OPCODE_NOISE1, /* X */
+ OPCODE_NOISE2, /* X */
+ OPCODE_NOISE3, /* X */
+ OPCODE_NOISE4, /* X */
+ OPCODE_POW, /* X X X X */
+ OPCODE_RCP, /* X X X X X */
+ OPCODE_RET, /* 2 2 opt */
+ OPCODE_RSQ, /* X X X X X */
+ OPCODE_SCS, /* X X */
+ OPCODE_SGE, /* X X X X X */
+ OPCODE_SIN, /* X 2 X X */
+ OPCODE_SLT, /* X X X X X */
+ OPCODE_SSG, /* 2 X */
+ OPCODE_SUB, /* X X 1.1 X X */
+ OPCODE_SWZ, /* X X X */
+ OPCODE_TEX, /* X 3 X X */
+ OPCODE_TXB, /* X 3 X */
+ OPCODE_TXD, /* X X */
+ OPCODE_TXL, /* 3 2 X */
+ OPCODE_TXP, /* X X */
+ OPCODE_TRUNC, /* X */
+ OPCODE_XPD, /* X X */
+ MAX_OPCODE
+};
+
+
+/**
+ * Number of bits for the src/dst register Index field.
+ * This limits the size of temp/uniform register files.
+ */
+#define INST_INDEX_BITS 12
+
+
+/**
+ * Instruction source register.
+ */
+struct prog_src_register
+{
+ GLuint File:4; /**< One of the PROGRAM_* register file values. */
+ GLint Index:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit.
+ * May be negative for relative addressing.
+ */
+ GLuint Swizzle:12;
+ GLuint RelAddr:1;
+
+ /**
+ * Negation.
+ * This will either be NEGATE_NONE or NEGATE_XYZW, except for the SWZ
+ * instruction which allows per-component negation.
+ */
+ GLuint Negate:4;
+};
+
+
+/**
+ * Instruction destination register.
+ */
+struct prog_dst_register
+{
+ GLuint File:4; /**< One of the PROGRAM_* register file values */
+ GLuint Index:INST_INDEX_BITS; /**< Unsigned, never negative */
+ GLuint WriteMask:4;
+ GLuint RelAddr:1;
+};
+
+
+/**
+ * Vertex/fragment program instruction.
+ */
+struct prog_instruction
+{
+ enum prog_opcode Opcode;
+ struct prog_src_register SrcReg[3];
+ struct prog_dst_register DstReg;
+
+ /**
+ * Saturate each value of the vectored result to the range [0,1].
+ *
+ * \since
+ * ARB_fragment_program
+ */
+ GLuint Saturate:1;
+
+ /**
+ * \name Extra fields for TEX, TXB, TXD, TXL, TXP instructions.
+ */
+ /*@{*/
+ /** Source texture unit. */
+ GLuint TexSrcUnit:5;
+
+ /** Source texture target, one of TEXTURE_{1D,2D,3D,CUBE,RECT}_INDEX */
+ GLuint TexSrcTarget:4;
+
+ /** True if tex instruction should do shadow comparison */
+ GLuint TexShadow:1;
+ /*@}*/
+
+ /**
+ * For BRA and CAL instructions, the location to jump to.
+ * For BGNLOOP, points to ENDLOOP (and vice-versa).
+ * For BRK, points to ENDLOOP
+ * For IF, points to ELSE or ENDIF.
+ * For ELSE, points to ENDIF.
+ */
+ GLint BranchTarget;
+};
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_program;
+
+extern void
+_mesa_init_instructions(struct prog_instruction *inst, GLuint count);
+
+extern struct prog_instruction *
+_mesa_copy_instructions(struct prog_instruction *dest,
+ const struct prog_instruction *src, GLuint n);
+
+extern GLuint
+_mesa_num_inst_src_regs(enum prog_opcode opcode);
+
+extern GLuint
+_mesa_num_inst_dst_regs(enum prog_opcode opcode);
+
+extern GLboolean
+_mesa_is_tex_instruction(enum prog_opcode opcode);
+
+extern GLboolean
+_mesa_check_soa_dependencies(const struct prog_instruction *inst);
+
+extern const char *
+_mesa_opcode_string(enum prog_opcode opcode);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* PROG_INSTRUCTION_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_parameter.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_parameter.h
new file mode 100644
index 0000000000..1fb0c5b7d1
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_parameter.h
@@ -0,0 +1,244 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file prog_parameter.c
+ * Program parameter lists and functions.
+ * \author Brian Paul
+ */
+
+#ifndef PROG_PARAMETER_H
+#define PROG_PARAMETER_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "prog_statevars.h"
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * 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.
+ *
+ * NOTE: PROGRAM_STATE_VAR, PROGRAM_CONSTANT, and PROGRAM_UNIFORM can all be
+ * considered to be "uniform" variables since they can only be set outside
+ * glBegin/End. They're also all stored in the same Parameters array.
+ */
+typedef enum
+{
+ PROGRAM_TEMPORARY, /**< machine->Temporary[] */
+ PROGRAM_ARRAY, /**< Arrays & Matrixes */
+ PROGRAM_INPUT, /**< machine->Inputs[] */
+ PROGRAM_OUTPUT, /**< machine->Outputs[] */
+ PROGRAM_STATE_VAR, /**< gl_program->Parameters[] */
+ PROGRAM_CONSTANT, /**< gl_program->Parameters[] */
+ PROGRAM_UNIFORM, /**< gl_program->Parameters[] */
+ PROGRAM_WRITE_ONLY, /**< A dummy, write-only register */
+ PROGRAM_ADDRESS, /**< machine->AddressReg */
+ PROGRAM_SAMPLER, /**< for shader samplers, compile-time only */
+ PROGRAM_SYSTEM_VALUE,/**< InstanceId, PrimitiveID, etc. */
+ PROGRAM_UNDEFINED, /**< Invalid/TBD value */
+ PROGRAM_IMMEDIATE, /**< Immediate value, used by TGSI */
+ 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;
+
+
+/**
+ * Actual data for constant values of parameters.
+ */
+typedef union gl_constant_value
+{
+ GLfloat f;
+ GLint b;
+ GLint i;
+ GLuint u;
+} gl_constant_value;
+
+
+/**
+ * Program parameter.
+ * Used by shaders/programs for uniforms, constants, varying vars, etc.
+ */
+struct gl_program_parameter
+{
+ const char *Name; /**< Null-terminated string */
+ gl_register_file Type:5; /**< PROGRAM_CONSTANT or STATE_VAR */
+
+ /**
+ * We need to keep track of whether the param is padded for use in the
+ * shader cache.
+ */
+ bool Padded:1;
+
+ GLenum16 DataType; /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
+
+ /**
+ * Number of components (1..4), or more.
+ * If the number of components is greater than 4,
+ * this parameter is part of a larger uniform like a GLSL matrix or array.
+ * The next program parameter's Size will be Size-4 of this parameter.
+ */
+ GLushort Size;
+ /**
+ * A sequence of STATE_* tokens and integers to identify GL state.
+ */
+ gl_state_index16 StateIndexes[STATE_LENGTH];
+
+ /**
+ * Index of this parameter's uniform storage.
+ */
+ uint32_t UniformStorageIndex;
+
+ /**
+ * Index of the first uniform storage that is associated with the same
+ * variable as this parameter.
+ */
+ uint32_t MainUniformStorageIndex;
+};
+
+
+/**
+ * List of gl_program_parameter instances.
+ */
+struct gl_program_parameter_list
+{
+ GLuint Size; /**< allocated size of Parameters, ParameterValues */
+ GLuint NumParameters; /**< number of used parameters in array */
+ unsigned NumParameterValues; /**< number of used parameter values array */
+ struct gl_program_parameter *Parameters; /**< Array [Size] */
+ unsigned *ParameterValueOffset;
+ gl_constant_value *ParameterValues; /**< Array [Size] of gl_constant_value */
+ GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
+ might invalidate ParameterValues[] */
+};
+
+
+extern struct gl_program_parameter_list *
+_mesa_new_parameter_list(void);
+
+extern struct gl_program_parameter_list *
+_mesa_new_parameter_list_sized(unsigned size);
+
+extern void
+_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
+
+extern void
+_mesa_reserve_parameter_storage(struct gl_program_parameter_list *paramList,
+ unsigned reserve_slots);
+
+extern GLint
+_mesa_add_parameter(struct gl_program_parameter_list *paramList,
+ gl_register_file type, const char *name,
+ GLuint size, GLenum datatype,
+ const gl_constant_value *values,
+ const gl_state_index16 state[STATE_LENGTH],
+ bool pad_and_align);
+
+extern GLint
+_mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
+ const gl_constant_value values[4], GLuint size,
+ GLenum datatype, GLuint *swizzleOut);
+
+static inline GLint
+_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
+ const gl_constant_value values[4], GLuint size,
+ GLuint *swizzleOut)
+{
+ return _mesa_add_typed_unnamed_constant(paramList, values, size, GL_NONE,
+ swizzleOut);
+}
+
+extern GLint
+_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
+ const gl_state_index16 stateTokens[STATE_LENGTH],
+ const unsigned size, bool pad_and_align);
+
+extern GLint
+_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
+ const gl_state_index16 stateTokens[]);
+
+
+static inline GLint
+_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
+ const char *name)
+{
+ if (!paramList)
+ return -1;
+
+ /* name must be null-terminated */
+ for (GLint i = 0; i < (GLint) paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ strcmp(paramList->Parameters[i].Name, name) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static inline bool
+_mesa_gl_datatype_is_64bit(GLenum datatype)
+{
+ switch (datatype) {
+ case GL_DOUBLE:
+ case GL_DOUBLE_VEC2:
+ case GL_DOUBLE_VEC3:
+ case GL_DOUBLE_VEC4:
+ case GL_DOUBLE_MAT2:
+ case GL_DOUBLE_MAT2x3:
+ case GL_DOUBLE_MAT2x4:
+ case GL_DOUBLE_MAT3:
+ case GL_DOUBLE_MAT3x2:
+ case GL_DOUBLE_MAT3x4:
+ case GL_DOUBLE_MAT4:
+ case GL_DOUBLE_MAT4x2:
+ case GL_DOUBLE_MAT4x3:
+ case GL_INT64_ARB:
+ case GL_INT64_VEC2_ARB:
+ case GL_INT64_VEC3_ARB:
+ case GL_INT64_VEC4_ARB:
+ case GL_UNSIGNED_INT64_ARB:
+ case GL_UNSIGNED_INT64_VEC2_ARB:
+ case GL_UNSIGNED_INT64_VEC3_ARB:
+ case GL_UNSIGNED_INT64_VEC4_ARB:
+ return true;
+ default:
+ return false;
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PROG_PARAMETER_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_statevars.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_statevars.h
new file mode 100644
index 0000000000..de457d1a7f
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/prog_statevars.h
@@ -0,0 +1,156 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef PROG_STATEVARS_H
+#define PROG_STATEVARS_H
+
+
+#include "main/glheader.h"
+#include "compiler/shader_enums.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct gl_context;
+struct gl_program_parameter_list;
+
+
+/**
+ * Used for describing GL state referenced from inside ARB vertex and
+ * fragment programs.
+ * A string such as "state.light[0].ambient" gets translated into a
+ * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
+ *
+ * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
+ * always be the array index.
+ */
+typedef enum gl_state_index_ {
+ STATE_MATERIAL = 100, /* start at 100 so small ints are seen as ints */
+
+ STATE_LIGHT,
+ STATE_LIGHTMODEL_AMBIENT,
+ STATE_LIGHTMODEL_SCENECOLOR,
+ STATE_LIGHTPROD,
+
+ STATE_TEXGEN,
+
+ STATE_FOG_COLOR,
+ STATE_FOG_PARAMS,
+
+ STATE_CLIPPLANE,
+
+ STATE_POINT_SIZE,
+ STATE_POINT_ATTENUATION,
+
+ STATE_MODELVIEW_MATRIX,
+ STATE_PROJECTION_MATRIX,
+ STATE_MVP_MATRIX,
+ STATE_TEXTURE_MATRIX,
+ STATE_PROGRAM_MATRIX,
+ STATE_MATRIX_INVERSE,
+ STATE_MATRIX_TRANSPOSE,
+ STATE_MATRIX_INVTRANS,
+
+ STATE_AMBIENT,
+ STATE_DIFFUSE,
+ STATE_SPECULAR,
+ STATE_EMISSION,
+ STATE_SHININESS,
+ STATE_HALF_VECTOR,
+
+ STATE_POSITION, /**< xyzw = position */
+ STATE_ATTENUATION, /**< xyz = attenuation, w = spot exponent */
+ STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */
+ STATE_SPOT_CUTOFF, /**< x = cutoff, yzw = undefined */
+
+ STATE_TEXGEN_EYE_S,
+ STATE_TEXGEN_EYE_T,
+ STATE_TEXGEN_EYE_R,
+ STATE_TEXGEN_EYE_Q,
+ STATE_TEXGEN_OBJECT_S,
+ STATE_TEXGEN_OBJECT_T,
+ STATE_TEXGEN_OBJECT_R,
+ STATE_TEXGEN_OBJECT_Q,
+
+ STATE_TEXENV_COLOR,
+
+ STATE_NUM_SAMPLES, /* An integer, not a float like the other state vars */
+
+ STATE_DEPTH_RANGE,
+
+ STATE_VERTEX_PROGRAM,
+ STATE_FRAGMENT_PROGRAM,
+
+ STATE_ENV,
+ STATE_LOCAL,
+
+ STATE_INTERNAL, /* Mesa additions */
+ STATE_CURRENT_ATTRIB, /* ctx->Current vertex attrib value */
+ STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED, /* ctx->Current vertex attrib value after passthrough vertex processing */
+ STATE_NORMAL_SCALE,
+ STATE_FOG_PARAMS_OPTIMIZED, /* for faster fog calc */
+ STATE_POINT_SIZE_CLAMPED, /* includes implementation dependent size clamp */
+ STATE_LIGHT_SPOT_DIR_NORMALIZED, /* pre-normalized spot dir */
+ STATE_LIGHT_POSITION, /* object vs eye space */
+ STATE_LIGHT_POSITION_NORMALIZED, /* object vs eye space */
+ STATE_LIGHT_HALF_VECTOR, /* object vs eye space */
+ STATE_PT_SCALE, /**< Pixel transfer RGBA scale */
+ STATE_PT_BIAS, /**< Pixel transfer RGBA bias */
+ STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */
+ STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */
+ STATE_TCS_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TCS (integer) */
+ STATE_TES_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TES (integer) */
+ /**
+ * A single enum gl_blend_support_qualifier value representing the
+ * currently active advanced blending equation, or zero if disabled.
+ */
+ STATE_ADVANCED_BLENDING_MODE,
+ STATE_ALPHA_REF, /* alpha-test reference value */
+ STATE_CLIP_INTERNAL, /* similar to STATE_CLIPPLANE, but in clip-space */
+ STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */
+} gl_state_index;
+
+
+extern void
+_mesa_load_state_parameters(struct gl_context *ctx,
+ struct gl_program_parameter_list *paramList);
+
+
+extern GLbitfield
+_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
+
+
+extern char *
+_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* PROG_STATEVARS_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/program.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/program.h
new file mode 100644
index 0000000000..7de6804047
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/program.h
@@ -0,0 +1,169 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file program.c
+ * Vertex and fragment program support functions.
+ * \author Brian Paul
+ */
+
+
+/**
+ * \mainpage Mesa vertex and fragment program module
+ *
+ * This module or directory contains most of the code for vertex and
+ * fragment programs and shaders, including state management, parsers,
+ * and (some) software routines for executing programs
+ */
+
+#ifndef PROGRAM_H
+#define PROGRAM_H
+
+#include "prog_parameter.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct gl_program _mesa_DummyProgram;
+
+
+extern void
+_mesa_init_program(struct gl_context *ctx);
+
+extern void
+_mesa_free_program_data(struct gl_context *ctx);
+
+extern void
+_mesa_update_default_objects_program(struct gl_context *ctx);
+
+extern void
+_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string);
+
+extern struct gl_program *
+_mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
+ GLuint id, bool is_arb_asm);
+
+extern struct gl_program *
+_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
+ bool is_arb_asm);
+
+extern void
+_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog);
+
+extern struct gl_program *
+_mesa_lookup_program(struct gl_context *ctx, GLuint id);
+
+extern void
+_mesa_reference_program_(struct gl_context *ctx,
+ struct gl_program **ptr,
+ struct gl_program *prog);
+
+static inline void
+_mesa_reference_program(struct gl_context *ctx,
+ struct gl_program **ptr,
+ struct gl_program *prog)
+{
+ if (*ptr != prog)
+ _mesa_reference_program_(ctx, ptr, prog);
+}
+
+extern GLboolean
+_mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);
+
+extern GLboolean
+_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count,
+ void *mem_ctx);
+
+extern void
+_mesa_find_used_registers(const struct gl_program *prog,
+ gl_register_file file,
+ GLboolean used[], GLuint usedSize);
+
+extern GLint
+_mesa_find_free_register(const GLboolean used[],
+ GLuint maxRegs, GLuint firstReg);
+
+extern GLint
+_mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
+ const struct gl_program *prog);
+
+static inline GLuint
+_mesa_program_enum_to_shader_stage(GLenum v)
+{
+ switch (v) {
+ case GL_VERTEX_PROGRAM_ARB:
+ return MESA_SHADER_VERTEX;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ return MESA_SHADER_FRAGMENT;
+ case GL_FRAGMENT_SHADER_ATI:
+ return MESA_SHADER_FRAGMENT;
+ case GL_GEOMETRY_PROGRAM_NV:
+ return MESA_SHADER_GEOMETRY;
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ return MESA_SHADER_TESS_CTRL;
+ case GL_TESS_EVALUATION_PROGRAM_NV:
+ return MESA_SHADER_TESS_EVAL;
+ case GL_COMPUTE_PROGRAM_NV:
+ return MESA_SHADER_COMPUTE;
+ default:
+ assert(0);
+ return ~0;
+ }
+}
+
+
+static inline GLenum
+_mesa_shader_stage_to_program(unsigned stage)
+{
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ return GL_VERTEX_PROGRAM_ARB;
+ case MESA_SHADER_FRAGMENT:
+ return GL_FRAGMENT_PROGRAM_ARB;
+ case MESA_SHADER_GEOMETRY:
+ return GL_GEOMETRY_PROGRAM_NV;
+ case MESA_SHADER_TESS_CTRL:
+ return GL_TESS_CONTROL_PROGRAM_NV;
+ case MESA_SHADER_TESS_EVAL:
+ return GL_TESS_EVALUATION_PROGRAM_NV;
+ case MESA_SHADER_COMPUTE:
+ return GL_COMPUTE_PROGRAM_NV;
+ }
+
+ assert(!"Unexpected shader stage in _mesa_shader_stage_to_program");
+ return GL_VERTEX_PROGRAM_ARB;
+}
+
+
+GLbitfield
+gl_external_samplers(const struct gl_program *prog);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* PROGRAM_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.c b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.c
new file mode 100644
index 0000000000..f86588b76b
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.c
@@ -0,0 +1,314 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "main/errors.h"
+#include "symbol_table.h"
+#include "util/hash_table.h"
+#include "util/u_string.h"
+
+struct symbol {
+ /** Symbol name. */
+ char *name;
+
+ /**
+ * Link to the next symbol in the table with the same name
+ *
+ * The linked list of symbols with the same name is ordered by scope
+ * from inner-most to outer-most.
+ */
+ struct symbol *next_with_same_name;
+
+ /**
+ * Link to the next symbol in the table with the same scope
+ *
+ * The linked list of symbols with the same scope is unordered. Symbols
+ * in this list my have unique names.
+ */
+ struct symbol *next_with_same_scope;
+
+ /** Scope depth where this symbol was defined. */
+ unsigned depth;
+
+ /**
+ * Arbitrary user supplied data.
+ */
+ void *data;
+};
+
+
+/**
+ * Element of the scope stack.
+ */
+struct scope_level {
+ /** Link to next (inner) scope level. */
+ struct scope_level *next;
+
+ /** Linked list of symbols with the same scope. */
+ struct symbol *symbols;
+};
+
+
+/**
+ *
+ */
+struct _mesa_symbol_table {
+ /** Hash table containing all symbols in the symbol table. */
+ struct hash_table *ht;
+
+ /** Top of scope stack. */
+ struct scope_level *current_scope;
+
+ /** Current scope depth. */
+ unsigned depth;
+};
+
+void
+_mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table)
+{
+ struct scope_level *const scope = table->current_scope;
+ struct symbol *sym = scope->symbols;
+
+ table->current_scope = scope->next;
+ table->depth--;
+
+ free(scope);
+
+ while (sym != NULL) {
+ struct symbol *const next = sym->next_with_same_scope;
+ struct hash_entry *hte = _mesa_hash_table_search(table->ht,
+ sym->name);
+ if (sym->next_with_same_name) {
+ /* If there is a symbol with this name in an outer scope update
+ * the hash table to point to it.
+ */
+ hte->key = sym->next_with_same_name->name;
+ hte->data = sym->next_with_same_name;
+ } else {
+ _mesa_hash_table_remove(table->ht, hte);
+ free(sym->name);
+ }
+
+ free(sym);
+ sym = next;
+ }
+}
+
+
+void
+_mesa_symbol_table_push_scope(struct _mesa_symbol_table *table)
+{
+ struct scope_level *const scope = calloc(1, sizeof(*scope));
+ if (scope == NULL) {
+ _mesa_error_no_memory(__func__);
+ return;
+ }
+
+ scope->next = table->current_scope;
+ table->current_scope = scope;
+ table->depth++;
+}
+
+
+static struct symbol *
+find_symbol(struct _mesa_symbol_table *table, const char *name)
+{
+ struct hash_entry *entry = _mesa_hash_table_search(table->ht, name);
+ return entry ? (struct symbol *) entry->data : NULL;
+}
+
+
+/**
+ * Determine the scope "distance" of a symbol from the current scope
+ *
+ * \return
+ * A non-negative number for the number of scopes between the current scope
+ * and the scope where a symbol was defined. A value of zero means the current
+ * scope. A negative number if the symbol does not exist.
+ */
+int
+_mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table,
+ const char *name)
+{
+ struct symbol *const sym = find_symbol(table, name);
+
+ if (sym) {
+ assert(sym->depth <= table->depth);
+ return sym->depth - table->depth;
+ }
+
+ return -1;
+}
+
+
+void *
+_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *table,
+ const char *name)
+{
+ struct symbol *const sym = find_symbol(table, name);
+ if (sym)
+ return sym->data;
+
+ return NULL;
+}
+
+
+int
+_mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
+ const char *name, void *declaration)
+{
+ struct symbol *new_sym;
+ struct symbol *sym = find_symbol(table, name);
+
+ if (sym && sym->depth == table->depth)
+ return -1;
+
+ new_sym = calloc(1, sizeof(*sym));
+ if (new_sym == NULL) {
+ _mesa_error_no_memory(__func__);
+ return -1;
+ }
+
+ if (sym) {
+ /* Store link to symbol in outer scope with the same name */
+ new_sym->next_with_same_name = sym;
+ new_sym->name = sym->name;
+ } else {
+ new_sym->name = strdup(name);
+ if (new_sym->name == NULL) {
+ free(new_sym);
+ _mesa_error_no_memory(__func__);
+ return -1;
+ }
+ }
+
+ new_sym->next_with_same_scope = table->current_scope->symbols;
+ new_sym->data = declaration;
+ new_sym->depth = table->depth;
+
+ table->current_scope->symbols = new_sym;
+
+ _mesa_hash_table_insert(table->ht, new_sym->name, new_sym);
+
+ return 0;
+}
+
+int
+_mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table,
+ const char *name,
+ void *declaration)
+{
+ struct symbol *sym = find_symbol(table, name);
+
+ /* If the symbol doesn't exist, it cannot be replaced. */
+ if (sym == NULL)
+ return -1;
+
+ sym->data = declaration;
+ return 0;
+}
+
+int
+_mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *table,
+ const char *name, void *declaration)
+{
+ struct scope_level *top_scope;
+ struct symbol *inner_sym = NULL;
+ struct symbol *sym = find_symbol(table, name);
+
+ while (sym) {
+ if (sym->depth == 0)
+ return -1;
+
+ inner_sym = sym;
+
+ /* Get symbol from the outer scope with the same name */
+ sym = sym->next_with_same_name;
+ }
+
+ /* Find the top-level scope */
+ for (top_scope = table->current_scope; top_scope->next != NULL;
+ top_scope = top_scope->next) {
+ /* empty */
+ }
+
+ sym = calloc(1, sizeof(*sym));
+ if (sym == NULL) {
+ _mesa_error_no_memory(__func__);
+ return -1;
+ }
+
+ if (inner_sym) {
+ /* In case we add the global out of order store a link to the global
+ * symbol in global.
+ */
+ inner_sym->next_with_same_name = sym;
+
+ sym->name = inner_sym->name;
+ } else {
+ sym->name = strdup(name);
+ if (sym->name == NULL) {
+ free(sym);
+ _mesa_error_no_memory(__func__);
+ return -1;
+ }
+ }
+
+ sym->next_with_same_scope = top_scope->symbols;
+ sym->data = declaration;
+
+ top_scope->symbols = sym;
+
+ _mesa_hash_table_insert(table->ht, sym->name, sym);
+
+ return 0;
+}
+
+
+
+struct _mesa_symbol_table *
+_mesa_symbol_table_ctor(void)
+{
+ struct _mesa_symbol_table *table = calloc(1, sizeof(*table));
+
+ if (table != NULL) {
+ table->ht = _mesa_hash_table_create(NULL, _mesa_hash_string,
+ _mesa_key_string_equal);
+
+ _mesa_symbol_table_push_scope(table);
+ }
+
+ return table;
+}
+
+
+void
+_mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
+{
+ while (table->current_scope != NULL) {
+ _mesa_symbol_table_pop_scope(table);
+ }
+
+ _mesa_hash_table_destroy(table->ht, NULL);
+ free(table);
+}
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.h
new file mode 100644
index 0000000000..6db2164fc2
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/program/symbol_table.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#ifndef MESA_SYMBOL_TABLE_H
+#define MESA_SYMBOL_TABLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _mesa_symbol_table;
+
+extern void _mesa_symbol_table_push_scope(struct _mesa_symbol_table *table);
+
+extern void _mesa_symbol_table_pop_scope(struct _mesa_symbol_table *table);
+
+extern int _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *symtab,
+ const char *name, void *declaration);
+
+extern int _mesa_symbol_table_replace_symbol(struct _mesa_symbol_table *table,
+ const char *name,
+ void *declaration);
+
+extern int
+_mesa_symbol_table_add_global_symbol(struct _mesa_symbol_table *symtab,
+ const char *name,
+ void *declaration);
+
+extern int _mesa_symbol_table_symbol_scope(struct _mesa_symbol_table *table,
+ const char *name);
+
+extern void *_mesa_symbol_table_find_symbol(struct _mesa_symbol_table *symtab,
+ const char *name);
+
+extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void);
+
+extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MESA_SYMBOL_TABLE_H */
diff --git a/third_party/rust/glslopt/glsl-optimizer/src/mesa/vbo/vbo.h b/third_party/rust/glslopt/glsl-optimizer/src/mesa/vbo/vbo.h
new file mode 100644
index 0000000000..bd99e24651
--- /dev/null
+++ b/third_party/rust/glslopt/glsl-optimizer/src/mesa/vbo/vbo.h
@@ -0,0 +1,162 @@
+/*
+ * mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \brief Public interface to the VBO module
+ * \author Keith Whitwell
+ */
+
+
+#ifndef _VBO_H
+#define _VBO_H
+
+#include <stdbool.h>
+#include "main/glheader.h"
+#include "main/draw.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gl_context;
+
+GLboolean
+_vbo_CreateContext(struct gl_context *ctx, bool use_buffer_objects);
+
+void
+_vbo_DestroyContext(struct gl_context *ctx);
+
+void
+vbo_exec_update_eval_maps(struct gl_context *ctx);
+
+void
+_vbo_install_exec_vtxfmt(struct gl_context *ctx);
+
+void
+vbo_initialize_exec_dispatch(const struct gl_context *ctx,
+ struct _glapi_table *exec);
+
+void
+vbo_initialize_save_dispatch(const struct gl_context *ctx,
+ struct _glapi_table *exec);
+
+void
+vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags);
+
+void
+vbo_save_SaveFlushVertices(struct gl_context *ctx);
+
+void
+vbo_save_NotifyBegin(struct gl_context *ctx, GLenum mode,
+ bool no_current_update);
+
+void
+vbo_save_NewList(struct gl_context *ctx, GLuint list, GLenum mode);
+
+void
+vbo_save_EndList(struct gl_context *ctx);
+
+void
+vbo_save_BeginCallList(struct gl_context *ctx, struct gl_display_list *list);
+
+void
+vbo_save_EndCallList(struct gl_context *ctx);
+
+
+void
+vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj);
+
+void
+vbo_get_minmax_index_mapped(unsigned count, unsigned index_size,
+ unsigned restartIndex, bool restart,
+ const void *indices,
+ unsigned *min_index, unsigned *max_index);
+
+void
+vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim,
+ const struct _mesa_index_buffer *ib,
+ GLuint *min_index, GLuint *max_index, GLuint nr_prims);
+
+void
+vbo_sw_primitive_restart(struct gl_context *ctx,
+ const struct _mesa_prim *prim,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint num_instances, GLuint base_instance,
+ struct gl_buffer_object *indirect,
+ GLsizeiptr indirect_offset);
+
+
+const struct gl_array_attributes*
+_vbo_current_attrib(const struct gl_context *ctx, gl_vert_attrib attr);
+
+
+const struct gl_vertex_buffer_binding*
+_vbo_current_binding(const struct gl_context *ctx);
+
+
+void GLAPIENTRY
+_es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
+
+void GLAPIENTRY
+_es_Normal3f(GLfloat x, GLfloat y, GLfloat z);
+
+void GLAPIENTRY
+_es_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+
+void GLAPIENTRY
+_es_Materialfv(GLenum face, GLenum pname, const GLfloat *params);
+
+void GLAPIENTRY
+_es_Materialf(GLenum face, GLenum pname, GLfloat param);
+
+void GLAPIENTRY
+_es_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+void GLAPIENTRY
+_es_VertexAttrib1f(GLuint indx, GLfloat x);
+
+void GLAPIENTRY
+_es_VertexAttrib1fv(GLuint indx, const GLfloat* values);
+
+void GLAPIENTRY
+_es_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
+
+void GLAPIENTRY
+_es_VertexAttrib2fv(GLuint indx, const GLfloat* values);
+
+void GLAPIENTRY
+_es_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
+
+void GLAPIENTRY
+_es_VertexAttrib3fv(GLuint indx, const GLfloat* values);
+
+void GLAPIENTRY
+_es_VertexAttrib4fv(GLuint indx, const GLfloat* values);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif