blob: 69241beadd1bca9d5dc1f2c630b3bf5c4b533cf9 [file] [log] [blame]
/*
* 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/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/bitscan.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \name 64-bit extension of GLbitfield.
*/
/*@{*/
typedef GLuint64 GLbitfield64;
/** Set a single bit */
#define BITFIELD64_BIT(b) ((GLbitfield64)1 << (b))
/** Set all bits up to excluding bit b */
#define BITFIELD64_MASK(b) \
((b) == 64 ? (~(GLbitfield64)0) : BITFIELD64_BIT(b) - 1)
/** Set count bits starting from bit b */
#define BITFIELD64_RANGE(b, count) \
(BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b))
/**
* \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 set;
struct set_entry;
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:
return GL_FALSE;
default:
return GL_TRUE;
}
}
/**
* 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
} gl_buffer_index;
/**
* 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)
/**
* 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 rgbMode;
GLboolean floatMode;
GLuint doubleBufferMode;
GLuint stereoMode;
GLboolean haveAccumBuffer;
GLboolean haveDepthBuffer;
GLboolean haveStencilBuffer;
GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
GLuint redMask, greenMask, blueMask, alphaMask;
GLint rgbBits; /* total bits for rgb */
GLint indexBits; /* total bits for colorindex */
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;
GLint 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;
};
/**
* \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_INDEX_AMBIENT 0
#define MAT_INDEX_DIFFUSE 1
#define MAT_INDEX_SPECULAR 2
#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? */
GLenum 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 */
GLubyte ColorMask[MAX_DRAW_BUFFERS][4]; /**< Each flag is 0xff or 0x0 */
GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
/**
* \name alpha testing
*/
/*@{*/
GLboolean AlphaEnabled; /**< Alpha test enabled flag */
GLenum AlphaFunc; /**< Alpha test function */
GLfloat AlphaRefUnclamped;
GLclampf AlphaRef; /**< Alpha reference value */
/*@}*/
/**
* \name Blending
*/
/*@{*/
GLbitfield BlendEnabled; /**< Per-buffer blend enable flags */
/* NOTE: this does _not_ depend on fragment clamping or any other clamping
* control, only on the fixed-pointness of the render target.
* The query does however depend on fragment color clamping.
*/
GLfloat BlendColorUnclamped[4]; /**< Blending color */
GLfloat BlendColor[4]; /**< Blending color */
struct
{
GLenum SrcRGB; /**< RGB blend source term */
GLenum DstRGB; /**< RGB blend dest term */
GLenum SrcA; /**< Alpha blend source term */
GLenum DstA; /**< Alpha blend dest term */
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
/**
* 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 */
GLenum LogicOp; /**< Logic operator */
/*@}*/
GLboolean DitherFlag; /**< Dither enable flag */
GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */
};
/**
* 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
{
GLenum 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;
/*@}*/
};
/**
* Fog attribute group (GL_FOG_BIT).
*/
struct gl_fog_attrib
{
GLboolean Enabled; /**< Fog enabled flag */
GLboolean ColorSumEnabled;
GLfloat ColorUnclamped[4]; /**< Fog color */
GLfloat Color[4]; /**< Fog color */
GLfloat Density; /**< Density >= 0.0 */
GLfloat Start; /**< Start distance in eye coords */
GLfloat End; /**< End distance in eye coords */
GLfloat Index; /**< Fog index */
GLenum Mode; /**< Fog mode */
GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */
GLenum FogDistanceMode; /**< GL_NV_fog_distance */
};
/**
* Hint attribute group (GL_HINT_BIT).
*
* Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
*/
struct gl_hint_attrib
{
GLenum PerspectiveCorrection;
GLenum PointSmooth;
GLenum LineSmooth;
GLenum PolygonSmooth;
GLenum Fog;
GLenum TextureCompression; /**< GL_ARB_texture_compression */
GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
};
/**
* Lighting attribute group (GL_LIGHT_BIT).
*/
struct gl_light_attrib
{
struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
struct gl_lightmodel Model; /**< Lighting model */
/**
* Front and back material values.
* Note: must call FLUSH_VERTICES() before using.
*/
struct gl_material Material;
GLboolean Enabled; /**< Lighting enabled flag */
GLboolean ColorMaterialEnabled;
GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
GLenum ProvokingVertex; /**< GL_EXT_provoking_vertex */
GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
GLboolean _ClampVertexColor;
GLenum 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;
GLfloat MinSampleShadingValue;
/** The GL spec defines this as an array but >32x MSAA is madness */
GLbitfield SampleMaskValue;
};
/**
* 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
{
GLenum 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*/
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
};
/**
* Polygon attribute group (GL_POLYGON_BIT).
*/
struct gl_polygon_attrib
{
GLenum FrontFace; /**< Either GL_CW or GL_CCW */
GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
GLboolean CullFlag; /**< Culling on/off flag */
GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
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 */
GLenum 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) */
GLboolean _Enabled; /**< Enabled and stencil buffer present */
GLboolean _WriteEnabled; /**< _Enabled and non-zero writemasks */
GLboolean _TestTwoSide;
GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
GLenum Function[3]; /**< Stencil function */
GLenum FailFunc[3]; /**< Fail function */
GLenum ZPassFunc[3]; /**< Depth buffer pass function */
GLenum ZFailFunc[3]; /**< Depth buffer fail function */
GLint Ref[3]; /**< Reference value */
GLuint ValueMask[3]; /**< Value mask */
GLuint WriteMask[3]; /**< Write mask */
GLuint Clear; /**< Clear value */
};
/**
* An index for each type of texture object. These correspond to the GL
* texture target enums, such as GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, etc.
* 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;
/**
* 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 */
GLenum _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
{
mtx_t Mutex;
GLuint Name;
GLint RefCount;
GLchar *Label; /**< GL_KHR_debug */
GLenum WrapS; /**< S-axis texture image wrap mode */
GLenum WrapT; /**< T-axis texture image wrap mode */
GLenum WrapR; /**< R-axis texture image wrap mode */
GLenum MinFilter; /**< minification filter */
GLenum MagFilter; /**< magnification filter */
union gl_color_union BorderColor; /**< Interpreted according to texture format */
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
GLfloat LodBias; /**< OpenGL 1.4 */
GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLenum CompareMode; /**< GL_ARB_shadow */
GLenum CompareFunc; /**< GL_ARB_shadow */
GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
};
/**
* Texture object state. Contains the array of mipmap images, border color,
* wrap modes, filter modes, and shadow/texcompare state.
*/
struct gl_texture_object
{
mtx_t Mutex; /**< for thread safety */
GLint RefCount; /**< reference count */
GLuint Name; /**< the user-visible texture object ID */
GLchar *Label; /**< GL_KHR_debug */
GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
Only valid when Target is valid. */
struct gl_sampler_object Sampler;
GLenum DepthMode; /**< GL_ARB_depth_texture */
bool StencilSampling; /**< Should we sample stencil instead of depth? */
GLfloat Priority; /**< in [0,1] */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
GLint ImmutableLevels; /**< ES 3.0 / ARB_texture_view */
GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - p in spec) */
GLint CropRect[4]; /**< GL_OES_draw_texture */
GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */
GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLboolean _BaseComplete; /**< Is the base texture level valid? */
GLboolean _MipmapComplete; /**< Is the whole mipmap valid? */
GLboolean _IsIntegerFormat; /**< Does the texture store integer values? */
GLboolean _RenderToTexture; /**< Any rendering to this texture? */
GLboolean Purgeable; /**< Is the buffer purgeable under memory
pressure? */
GLboolean Immutable; /**< GL_ARB_texture_storage */
GLboolean _IsFloat; /**< GL_OES_float_texture */
GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
GLuint MinLevel; /**< GL_ARB_texture_view */
GLuint MinLayer; /**< GL_ARB_texture_view */
GLuint NumLevels; /**< GL_ARB_texture_view */
GLuint NumLayers; /**< GL_ARB_texture_view */
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_ARB_texture_buffer_object */
struct gl_buffer_object *BufferObject;
GLenum BufferObjectFormat;
/** Equivalent Mesa format for BufferObjectFormat. */
mesa_format _BufferObjectFormat;
/** GL_ARB_texture_buffer_range */
GLintptr BufferOffset;
GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
/** GL_OES_EGL_image_external */
GLint RequiredTextureImageUnits;
/** GL_ARB_shader_image_load_store */
GLenum ImageFormatCompatibilityType;
};
/** Up to four combiner sources are possible with GL_NV_texture_env_combine4 */
#define MAX_COMBINER_TERMS 4
/**
* Texture combine environment state.
*/
struct gl_tex_env_combine_state
{
GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
/** Source terms: GL_PRIMARY_COLOR, GL_TEXTURE, etc */
GLenum SourceRGB[MAX_COMBINER_TERMS];
GLenum SourceA[MAX_COMBINER_TERMS];
/** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */
GLenum OperandRGB[MAX_COMBINER_TERMS];
GLenum OperandA[MAX_COMBINER_TERMS];
GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
GLuint ScaleShiftA; /**< 0, 1 or 2 */
GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */
GLuint _NumArgsA; /**< Number of inputs used for the A combiner */
};
/**
* 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
{
GLenum Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */
GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */
GLfloat ObjectPlane[4];
GLfloat EyePlane[4];
};
/**
* Texture unit state. Contains enable flags, texture environment/function/
* combiners, texgen state, and pointers to current texture objects.
*/
struct gl_texture_unit
{
GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
GLclampf EnvColor[4];
GLfloat EnvColorUnclamped[4];
struct gl_texgen GenS;
struct gl_texgen GenT;
struct gl_texgen GenR;
struct gl_texgen GenQ;
GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
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;
/**
* \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;
/**
* Currently enabled combiner state. This will point to either
* \c Combine or \c _EnvMode.
*/
struct gl_tex_env_combine_state *_CurrentCombine;
/** 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;
};
/**
* Texture attribute group (GL_TEXTURE_BIT).
*/
struct gl_texture_attrib
{
GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */
/** GL_ARB_seamless_cubemap */
GLboolean CubeMapSeamless;
struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
/** GL_ARB_texture_buffer_object */
struct gl_buffer_object *BufferObject;
/** Texture coord units/sets used for fragment texturing */
GLbitfield _EnabledCoordUnits;
/** Texture coord units that have texgen enabled */
GLbitfield _TexGenEnabled;
/** Texture coord units that have non-identity matrices */
GLbitfield _TexMatEnabled;
/** Bitwise-OR of all Texture.Unit[i]._GenFlags */
GLbitfield _GenFlags;
/** Largest index of a texture unit with _Current != NULL. */
GLint _MaxEnabledTexImageUnit;
/** Largest index + 1 of texture units that have had any CurrentTex set. */
GLint NumCurrentTexUsed;
struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_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
{
GLenum MatrixMode; /**< Matrix mode */
gl_clip_plane EyeUserPlane[MAX_CLIP_PLANES]; /**< User clip planes */
gl_clip_plane _ClipUserPlane[MAX_CLIP_PLANES]; /**< derived */
GLbitfield ClipPlanesEnabled; /**< on/off bitmask */
GLboolean Normalize; /**< Normalize all normals? */
GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
GLboolean DepthClamp; /**< GL_ARB_depth_clamp */
/** GL_ARB_clip_control */
GLenum ClipOrigin; /**< GL_LOWER_LEFT or GL_UPPER_LEFT */
GLenum ClipDepthMode; /**< GL_NEGATIVE_ONE_TO_ONE or GL_ZERO_TO_ONE */
};
/**
* Viewport attribute group (GL_VIEWPORT_BIT).
*/
struct gl_viewport_attrib
{
GLfloat X, Y; /**< position */
GLfloat Width, Height; /**< size */
GLdouble Near, Far; /**< Depth buffer range */
};
typedef enum {
MAP_USER,
MAP_INTERNAL,
MAP_COUNT
} gl_map_buffer_index;
/**
* 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_DISABLE_MINMAX_CACHE = 0x40,
} gl_buffer_usage;
/**
* GL_ARB_vertex/pixel_buffer_object buffer object
*/
struct gl_buffer_object
{
mtx_t Mutex;
GLint RefCount;
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
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 */
struct hash_table *MinMaxCache;
unsigned MinMaxCacheHitIndices;
unsigned MinMaxCacheMissIndices;
bool MinMaxCacheDirty;
};
/**
* 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 */
};
/**
* Vertex array information which is derived from gl_array_attributes
* and gl_vertex_buffer_binding information. Used by the VBO module and
* device drivers.
*/
struct gl_vertex_array
{
GLint Size; /**< components per element (1,2,3,4) */
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum Format; /**< default: GL_RGBA, but may be GL_BGRA */
GLsizei StrideB; /**< actual stride in bytes */
GLuint _ElementSize; /**< size of each element in bytes */
const GLubyte *Ptr; /**< Points to array data */
GLboolean Normalized; /**< GL_ARB_vertex_program */
GLboolean Integer; /**< Integer-valued? */
GLboolean Doubles; /**< double precision values are not converted to floats */
GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
};
/**
* 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
{
GLint Size; /**< Components per element (1,2,3,4) */
GLenum Type; /**< Datatype: GL_FLOAT, GL_INT, etc */
GLenum Format; /**< Default: GL_RGBA, but may be GL_BGRA */
GLsizei Stride; /**< Stride as specified with gl*Pointer() */
const GLubyte *Ptr; /**< Points to client array data. Not used when a VBO is bound */
GLintptr RelativeOffset; /**< Offset of the first element relative to the binding offset */
GLboolean Enabled; /**< Whether the array is enabled */
GLboolean Normalized; /**< Fixed-point values are normalized when converted to floats */
GLboolean Integer; /**< Fixed-point values are not converted to floats */
GLboolean Doubles; /**< double precision values are not converted to floats */
GLuint _ElementSize; /**< Size of each element in bytes */
GLuint BufferBindingIndex; /**< Vertex buffer binding */
};
/**
* 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 */
GLbitfield64 _BoundArrays; /**< Arrays bound to this binding point */
};
/**
* A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+,
* GL_ARB_vertex_array_object, or the original GL_APPLE_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 */
mtx_t Mutex;
/**
* Does the VAO use ARB semantics or Apple semantics?
*
* There are several ways in which ARB_vertex_array_object and
* APPLE_vertex_array_object VAOs have differing semantics. At the very
* least,
*
* - ARB VAOs require that all array data be sourced from vertex buffer
* objects, but Apple VAOs do not.
*
* - ARB VAOs require that names come from GenVertexArrays.
*
* This flag notes which behavior governs this VAO.
*/
GLboolean ARBsemantics;
/**
* Has this array object been bound?
*/
GLboolean EverBound;
/**
* Derived vertex attribute arrays
*
* This is a legacy data structure created from gl_vertex_attrib_array and
* gl_vertex_buffer_binding, for compatibility with existing driver code.
*/
struct gl_vertex_array _VertexAttrib[VERT_ATTRIB_MAX];
/** 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. */
GLbitfield64 VertexAttribBufferMask;
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
GLbitfield64 _Enabled;
/** Mask of VERT_BIT_* values indicating changed/dirty arrays */
GLbitfield64 NewArrays;
/** The index buffer (also known as the element array buffer in OpenGL). */
struct gl_buffer_object *IndexBufferObj;
};
/** Used to signal when transitioning from one kind of drawing method
* to another.
*/
typedef enum {
DRAW_NONE, /**< Initial value only */
DRAW_BEGIN_END,
DRAW_DISPLAY_LIST,
DRAW_ARRAYS
} gl_draw_method;
/**
* Enum for the OpenGL APIs we know about and may support.
*
* 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;
/**
* Vertex array state
*/
struct gl_array_attrib
{
/** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
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;
/** Array objects (GL_ARB/APPLE_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;
/*@}*/
/** One of the DRAW_xxx flags, not consumed by drivers */
gl_draw_method DrawMethod;
/* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
/**
* Vertex arrays as consumed by a driver.
* The array pointer is set up only by the VBO module.
*/
const struct gl_vertex_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
/** Legal array datatypes and the API for which they have been computed */
GLbitfield LegalTypesMask;
gl_api LegalTypesMaskAPI;
};
/**
* Feedback buffer state
*/
struct gl_feedback
{
GLenum 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;
GLenum 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
{
GLenum 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.
*/
GLenum 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;
};
/**
* 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;
};
/**
* 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_FILE_MAX
} gl_register_file;
/**
* 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;
mtx_t Mutex;
GLuint Id;
GLint RefCount;
GLubyte *String; /**< Null-terminated program text */
GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
GLenum Format; /**< String encoding format */
GLboolean _Used; /**< Ever used for drawing? Used for debugging */
struct nir_shader *nir;
bool is_arb_asm; /** Is this an ARB assembly-style program */
GLbitfield64 SecondaryOutputsWritten; /**< Subset of OutputsWritten outputs written with non-zero index. */
GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
GLbitfield ExternalSamplersUsed; /**< Texture units used for samplerExternalOES */
/* Vertex and geometry shaders fields */
unsigned ClipDistanceArraySize;
unsigned CullDistanceArraySize;
/* Fragement shader only fields */
GLboolean OriginUpperLeft;
GLboolean PixelCenterInteger;
/** 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 or \c
* GL_READ_WRITE.
*
* It may be different, though only more strict than the value of
* \c gl_image_unit::Access for the corresponding image unit.
*/
GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
struct gl_uniform_block **UniformBlocks;
struct gl_uniform_block **ShaderStorageBlocks;
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 _Enabled; /**< Enabled and _valid_ user program? */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
/** Computed two sided lighting for fixed function/programs. */
GLboolean _TwoSideEnabled;
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 */
/** Should fixed-function T&L be implemented with a vertex prog? */
GLboolean _MaintainTnlProgram;
/** Program to emulate fixed-function T&L (see above) */
struct gl_program *_TnlProgram;
/** Cache of fixed-function programs */
struct gl_program_cache *Cache;
GLboolean _Overriden;
};
/**
* 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 */
GLboolean _Enabled; /**< Enabled and _valid_ user program? */
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 */
/** Should fixed-function texturing be implemented with a fragment prog? */
GLboolean _MaintainTexEnvProgram;
/** Program to emulate fixed-function texture env/combine (see above) */
struct gl_program *_TexEnvProgram;
/** 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 */
GLubyte cur_pass;
GLubyte last_optype;
GLboolean interpinp1;
GLboolean isValid;
GLuint swizzlerq;
struct gl_program *Program;
};
/**
* Context state for GL_ATI_fragment_shader
*/
struct gl_ati_fragment_shader_state
{
GLboolean Enabled;
GLboolean _Enabled; /**< enabled and valid shader? */
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
{
bool uses_gl_fragcoord;
bool redeclares_gl_fragcoord;
bool PostDepthCoverage;
bool InnerCoverage;
bool ARB_fragment_coord_conventions_enable;
/**
* Fragment shader state from GLSL 1.50 layout qualifiers.
*/
bool origin_upper_left;
bool pixel_center_integer;
struct {
/** Global xfb_stride out qualifier if any */
GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
} TransformFeedback;
/**
* 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.
*/
GLenum PrimitiveMode;
/**
* GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
* in this shader.
*/
GLenum Spacing;
/**
* GL_CW, GL_CCW, or 0 if it's not set in this shader.
*/
GLenum 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 .. MAX_GEOMETRY_SHADER_INVOCATIONS
*/
GLint Invocations;
/**
* GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
* GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
* shader.
*/
GLenum InputType;
/**
* GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
* it's not set in this shader.
*/
GLenum OutputType;
} Geom;
/**
* Whether early fragment tests are enabled as defined by
* ARB_shader_image_load_store.
*/
bool EarlyFragmentTests;
/**
* 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;
} 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 active_samplers; /**< Bitfield of which samplers are used */
GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
/*@}*/
/**
* Map from sampler unit to texture unit (set by glUniform1i())
*
* A sampler unit is associated with each sampler uniform by the linker.
* The sampler unit associated with each uniform is stored in the
* \c gl_uniform_storage::sampler field.
*/
GLubyte SamplerUnits[MAX_SAMPLERS];
/** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
gl_texture_index SamplerTargets[MAX_SAMPLERS];
/**
* 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;
/**
* Number of image uniforms defined in the shader. It specifies
* the number of valid elements in the \c ImageUnits and \c
* ImageAccess arrays.
*/
GLuint NumImages;
struct gl_shader_info info;
};
static inline GLbitfield gl_external_samplers(struct gl_linked_shader *shader)
{
GLbitfield external_samplers = 0;
GLbitfield mask = shader->active_samplers;
while (mask) {
int idx = u_bit_scan(&mask);
if (shader->SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX)
external_samplers |= (1 << idx);
}
return external_samplers;
}
/**
* A GLSL shader object.
*/
struct gl_shader
{
/** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
* GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
* Must be the first field.
*/
GLenum Type;
gl_shader_stage Stage;
GLuint Name; /**< AKA the handle */
GLint RefCount; /**< Reference count */
GLchar *Label; /**< GL_KHR_debug */
GLboolean DeletePending;
GLboolean CompileStatus;
bool IsES; /**< True if this shader uses GLSL ES */
#ifdef DEBUG
unsigned SourceChecksum; /**< for debug/logging purposes */
#endif
const GLchar *Source; /**< Source code string */
GLchar *InfoLog;
unsigned Version; /**< GLSL version used for linking */
struct exec_list *ir;
struct glsl_symbol_table *symbols;
/**
* A bitmask of gl_advanced_blend_mode values
*/
GLbitfield BlendSupport;
struct gl_shader_info info;
};
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;
};
enum gl_uniform_block_packing
{
ubo_packing_std140,
ubo_packing_shared,
ubo_packing_packed,
ubo_packing_std430
};
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. When
* updated in the program, _NEW_BUFFER_OBJECT will be set.
*/
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 gl_uniform_block_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
{
GLenum Type; /** Program interface type. */
const void *Data; /** Pointer to resource associated data structure. */
uint8_t StageReferences; /** Bitmask of shader stage references. */
};
/**
* A data structure to be shared by gl_shader_program and gl_program.
*/
struct gl_shader_program_data
{
GLint RefCount; /**< Reference count */
unsigned NumUniformStorage;
unsigned NumHiddenUniforms;
struct gl_uniform_storage *UniformStorage;
unsigned NumUniformBlocks;
struct gl_uniform_block *UniformBlocks;
unsigned NumShaderStorageBlocks;
struct gl_uniform_block *ShaderStorageBlocks;
struct gl_active_atomic_buffer *AtomicBuffers;
unsigned NumAtomicBuffers;
GLboolean LinkStatus; /**< GL_LINK_STATUS */
GLboolean Validated;
GLchar *InfoLog;
unsigned Version; /**< GLSL version used for linking */
/* Mask of stages this program was linked against */
unsigned linked_stages;
};
/**
* A GLSL program object.
* Basically a linked collection of vertex and fragment shaders.
*/
struct gl_shader_program
{
GLenum Type; /**< Always GL_SHADER_PROGRAM (internal token) */
GLuint Name; /**< aka handle or ID */
GLchar *Label; /**< GL_KHR_debug */
GLint RefCount; /**< Reference count */
GLboolean DeletePending;
/**
* Is the application intending to glGetProgramBinary this program?
*/
GLboolean BinaryRetreivableHint;
/**
* 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 {
GLenum 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 *xfb_program;
/** Post-link gl_FragDepth layout for ARB_conservative_depth. */
enum gl_frag_depth_layout FragDepthLayout;
/**
* Tessellation Evaluation shader state from layout qualifiers.
*/
struct {
/**
* True if gl_ClipDistance is written to. Copied into
* gl_program by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
} TessEval;
/**
* Geometry shader state - copied into gl_program by
* _mesa_copy_linked_program_data().
*/
struct {
GLint VerticesIn;
/**
* True if gl_ClipDistance is written to. Copied into
* gl_program by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
bool UsesEndPrimitive;
bool UsesStreams;
} Geom;
/** Vertex shader state */
struct {
/**
* True if gl_ClipDistance is written to. Copied into gl_program
* by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
} Vert;
/**
* Compute shader state - copied into gl_program by
* _mesa_copy_linked_program_data().
*/
struct {
/**
* If this shader contains a compute stage, size specified using
* local_size_{x,y,z}. Otherwise undefined.
*/
unsigned LocalSize[3];
/**
* Size of shared variables accessed by the compute shader.
*/
unsigned SharedSize;
/**
* Whether a variable work group size has been specified.
*/
bool LocalSizeVariable;
} 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;
/**
* Size of the gl_ClipDistance array that is output from the last pipeline
* stage before the fragment shader.
*/
unsigned LastClipDistanceArraySize;
unsigned LastCullDistanceArraySize;
/**
* 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];
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
unsigned NumProgramResourceList;
/* 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_OPT 0x4 /**< Force optimizations (override pragmas) */
#define GLSL_NO_OPT 0x8 /**< Force no optimizations (override pragmas) */
#define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */
#define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */
#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */
#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */
#define GLSL_REPORT_ERRORS 0x100 /**< Print compilation errors */
#define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error */
/**
* 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;
mtx_t Mutex;
GLchar *Label; /**< GL_KHR_debug */
/**
* Programs used for rendering
*
* There is a separate program set for each shader stage.
*/
struct gl_shader_program *CurrentProgram[MESA_SHADER_STAGES];
struct gl_program *_CurrentFragmentProgram;
/**
* 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 EmitNoFunctions;
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]
**/
/**
* \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;
GLboolean LowerBufferInterfaceBlocks; /**< Lower UBO and SSBO access to intrinsics. */
/** Clamp UBO and SSBO block indices so they don't go out-of-bounds. */
GLboolean ClampBlockIndicesToArrayBounds;
const struct nir_shader_compiler_options *NirOptions;
};
/**
* Occlusion/timer query object.
*/
struct gl_query_object
{
GLenum 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_timer_query */
struct gl_query_object *TimeElapsed;
/** GL_ARB_pipeline_statistics_query */
struct gl_query_object *pipeline_stats[MAX_PIPELINE_STATISTICS];
GLenum CondRenderMode;
};
/** Sync object state */
struct gl_sync_object
{
GLenum Type; /**< GL_SYNC_FENCE */
GLuint Name; /**< Fence name */
GLchar *Label; /**< GL_KHR_debug */
GLint RefCount; /**< Reference count */
GLboolean DeletePending; /**< Object was deleted while there were still
* live references (e.g., sync not yet finished)
*/
GLenum SyncCondition;
GLbitfield Flags; /**< Flags passed to glFenceSync */
GLuint StatusFlag:1; /**< Has the sync object been signaled? */
};
/**
* State which can be shared by multiple contexts:
*/
struct gl_shared_state
{
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 */
/*@}*/
/** Default buffer object for vertex arrays that aren't in VBOs */
struct gl_buffer_object *NullBufferObj;
/**
* \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;
/**
* 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;
};
/**
* 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
{
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;
GLenum InternalFormat; /**< The user-specified format */
GLenum _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);
};