X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fmtypes.h;h=269eef59cb3059818e440919bd21deb00baeb2a4;hb=9527bb4e704e3d9229cb7977ae598ed207a0502d;hp=dccc152ad878e205a38fc67c129fb17c8ff852cf;hpb=d5f42f96e16f4b1242e51fb9eec6f608b221a1c4;p=mesa.git diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index dccc152ad87..269eef59cb3 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -39,6 +39,7 @@ #include "c11/threads.h" #include "main/glheader.h" +#include "main/menums.h" #include "main/config.h" #include "glapi/glapi.h" #include "math/m_matrix.h" /* GLmatrix */ @@ -54,31 +55,8 @@ extern "C" { #endif - -/** Set a single bit */ -#define BITFIELD_BIT(b) ((GLbitfield)1 << (b)) -/** Set all bits up to excluding bit b */ -#define BITFIELD_MASK(b) \ - ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1) -/** Set count bits starting from bit b */ -#define BITFIELD_RANGE(b, count) \ - (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b)) - - -/** - * \name 64-bit extension of GLbitfield. - */ -/*@{*/ -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)) +#define GET_COLORMASK_BIT(mask, buf, chan) (((mask) >> (4 * (buf) + (chan))) & 0x1) +#define GET_COLORMASK(mask, buf) (((mask) >> (4 * (buf))) & 0xf) /** @@ -131,34 +109,6 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot) } } -/** - * 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; - /** * Bit flags for all renderbuffers */ @@ -263,6 +213,9 @@ struct gl_config /* EXT_framebuffer_sRGB */ GLint sRGBCapable; + + /* EGL_KHR_mutable_render_buffer */ + GLuint mutableRenderBuffer; /* bool */ }; @@ -413,43 +366,6 @@ union gl_color_union GLuint ui[4]; }; -/** - * Remapped color logical operations - * - * With the exception of NVIDIA hardware, which consumes the OpenGL enumerants - * directly, everything wants this mapping of color logical operations. - * - * Fun fact: These values are just the bit-reverse of the low-nibble of the GL - * enumerant values (i.e., `GL_NOOP & 0x0f` is `b0101' while - * \c COLOR_LOGICOP_NOOP is `b1010`). - * - * Fun fact #2: These values are just an encoding of the operation as a table - * of bit values. The result of the logic op is: - * - * result_bit = (logic_op >> (2 * src_bit + dst_bit)) & 1 - * - * For the GL enums, the result is: - * - * result_bit = logic_op & (1 << (2 * src_bit + dst_bit)) - */ -enum PACKED gl_logicop_mode { - COLOR_LOGICOP_CLEAR = 0, - COLOR_LOGICOP_NOR = 1, - COLOR_LOGICOP_AND_INVERTED = 2, - COLOR_LOGICOP_COPY_INVERTED = 3, - COLOR_LOGICOP_AND_REVERSE = 4, - COLOR_LOGICOP_INVERT = 5, - COLOR_LOGICOP_XOR = 6, - COLOR_LOGICOP_NAND = 7, - COLOR_LOGICOP_AND = 8, - COLOR_LOGICOP_EQUIV = 9, - COLOR_LOGICOP_NOOP = 10, - COLOR_LOGICOP_OR_INVERTED = 11, - COLOR_LOGICOP_COPY = 12, - COLOR_LOGICOP_OR_REVERSE = 13, - COLOR_LOGICOP_OR = 14, - COLOR_LOGICOP_SET = 15 -}; /** * Color buffer attribute group (GL_COLOR_BUFFER_BIT). @@ -459,7 +375,9 @@ 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 */ + + /** 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 */ @@ -651,7 +569,6 @@ struct gl_fog_attrib GLfloat Index; /**< Fog index */ GLenum16 Mode; /**< Fog mode */ GLenum16 FogCoordinateSource;/**< GL_EXT_fog_coord */ - GLfloat _Scale; /**< (End == Start) ? 1.0 : 1.0 / (End - Start) */ GLenum16 FogDistanceMode; /**< GL_NV_fog_distance */ }; @@ -844,8 +761,8 @@ struct gl_point_attrib struct gl_polygon_attrib { GLenum16 FrontFace; /**< Either GL_CW or GL_CCW */ - GLenum16 FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLenum16 BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ + 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 */ @@ -912,29 +829,6 @@ struct gl_stencil_attrib }; -/** - * 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 */ @@ -961,7 +855,7 @@ typedef enum struct gl_texture_image { GLint InternalFormat; /**< Internal format as given by the user */ - GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, + GLenum16 _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA, * GL_LUMINANCE, GL_LUMINANCE_ALPHA, * GL_INTENSITY, GL_DEPTH_COMPONENT or * GL_DEPTH_STENCIL_EXT only. Used for @@ -1016,14 +910,15 @@ struct gl_sampler_object { simple_mtx_t Mutex; GLuint Name; - GLint RefCount; 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 */ @@ -1031,7 +926,6 @@ struct gl_sampler_object GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ GLenum16 CompareMode; /**< GL_ARB_shadow */ GLenum16 CompareFunc; /**< GL_ARB_shadow */ - GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */ GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */ /** GL_ARB_bindless_texture */ @@ -1046,27 +940,26 @@ struct gl_sampler_object */ struct gl_texture_object { - simple_mtx_t Mutex; /**< for thread safety */ - GLint RefCount; /**< reference count */ - GLuint Name; /**< the user-visible texture object ID */ - GLchar *Label; /**< GL_KHR_debug */ - GLenum16 Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ - gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index. - Only valid when Target is valid. */ + 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; - GLenum16 DepthMode; /**< GL_ARB_depth_texture */ - + gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index. + Only valid when Target is valid. */ 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) */ + 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 */ - GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ + 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? */ @@ -1080,31 +973,32 @@ struct gl_texture_object bool StencilSampling; /**< Should we sample stencil instead of depth? */ bool HandleAllocated; /**< GL_ARB_bindless_texture */ - GLuint MinLevel; /**< GL_ARB_texture_view */ - GLuint MinLayer; /**< GL_ARB_texture_view */ - GLuint NumLevels; /**< GL_ARB_texture_view */ - GLuint NumLayers; /**< GL_ARB_texture_view */ + /** GL_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; - /** Actual texture images, indexed by [cube face] and [mipmap level] */ - struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS]; + /** GL_ARB_shader_image_load_store */ + GLenum16 ImageFormatCompatibilityType; /** GL_ARB_texture_buffer_object */ - struct gl_buffer_object *BufferObject; 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 */ - /** GL_OES_EGL_image_external */ - GLint RequiredTextureImageUnits; - - /** GL_ARB_shader_image_load_store */ - GLenum16 ImageFormatCompatibilityType; + /** 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; @@ -1129,10 +1023,10 @@ struct gl_tex_env_combine_state /** Source operands: GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, etc */ GLenum16 OperandRGB[MAX_COMBINER_TERMS]; GLenum16 OperandA[MAX_COMBINER_TERMS]; - GLuint ScaleShiftRGB; /**< 0, 1 or 2 */ - GLuint ScaleShiftA; /**< 0, 1 or 2 */ - GLuint _NumArgsRGB; /**< Number of inputs used for the RGB combiner */ - GLuint _NumArgsA; /**< Number of inputs used for the A combiner */ + 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 */ }; @@ -1263,19 +1157,40 @@ struct gl_tex_env_combine_packed struct gl_texgen { GLenum16 Mode; /**< GL_EYE_LINEAR, GL_SPHERE_MAP, etc */ - GLbitfield _ModeBit; /**< TEXGEN_x bit corresponding to Mode */ + GLbitfield8 _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. + * Sampler-related subset of a texture unit, like current texture objects. */ struct gl_texture_unit { - GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */ + 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]; @@ -1285,16 +1200,8 @@ struct gl_texture_unit 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; + GLbitfield8 TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */ + GLbitfield8 _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */ /** * \name GL_EXT_texture_env_combine @@ -1307,20 +1214,14 @@ struct gl_texture_unit */ 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; - - /** 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; - - /** Current compressed TexEnv & Combine state */ - struct gl_tex_env_combine_packed _CurrentCombinePacked; }; @@ -1329,35 +1230,36 @@ struct gl_texture_unit */ 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; + GLuint CurrentUnit; /**< GL_ACTIVE_TEXTURE */ + /** Texture coord units/sets used for fragment texturing */ - GLbitfield _EnabledCoordUnits; + GLbitfield8 _EnabledCoordUnits; /** Texture coord units that have texgen enabled */ - GLbitfield _TexGenEnabled; + GLbitfield8 _TexGenEnabled; /** Texture coord units that have non-identity matrices */ - GLbitfield _TexMatEnabled; + GLbitfield8 _TexMatEnabled; /** Bitwise-OR of all Texture.Unit[i]._GenFlags */ - GLbitfield _GenFlags; + GLbitfield8 _GenFlags; /** Largest index of a texture unit with _Current != NULL. */ - GLint _MaxEnabledTexImageUnit; + GLshort _MaxEnabledTexImageUnit; /** Largest index + 1 of texture units that have had any CurrentTex set. */ - GLint NumCurrentTexUsed; + 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]; }; @@ -1394,18 +1296,10 @@ struct gl_viewport_attrib { GLfloat X, Y; /**< position */ GLfloat Width, Height; /**< size */ - GLdouble Near, Far; /**< Depth buffer range */ + GLfloat Near, Far; /**< Depth buffer range */ }; -typedef enum -{ - MAP_USER, - MAP_INTERNAL, - MAP_COUNT -} gl_map_buffer_index; - - /** * Fields describing a mapped buffer range. */ @@ -1438,7 +1332,6 @@ typedef enum */ struct gl_buffer_object { - simple_mtx_t Mutex; GLint RefCount; GLuint Name; GLchar *Label; /**< GL_KHR_debug */ @@ -1459,6 +1352,7 @@ struct gl_buffer_object 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; @@ -1491,26 +1385,18 @@ struct gl_pixelstore_attrib /** - * Vertex array information which is derived from gl_array_attributes - * and gl_vertex_buffer_binding information. Used by the VBO module and - * device drivers. + * 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. */ -struct gl_vertex_array +typedef enum { - /** if NULL, vertex data are in user memory */ - struct gl_buffer_object *BufferObj; - /** Pointer into user memory, or offset into the BufferObj */ - const GLubyte *Ptr; - GLsizei StrideB; /**< actual stride in bytes */ - GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */ - GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */ - GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */ - unsigned Size:4; /**< components per element (1,2,3,4) */ - unsigned _ElementSize:8; /**< in bytes, up to 4*sizeof(GLdouble) */ - unsigned Normalized:1; /**< GL_ARB_vertex_program */ - unsigned Integer:1; /**< Integer-valued? */ - unsigned Doubles:1; /**< doubles not converted to floats */ -}; + 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; /** @@ -1543,6 +1429,32 @@ struct gl_array_attributes unsigned _ElementSize:8; /**< Size of each element in bytes */ /** Index into gl_vertex_array_object::BufferBinding[] array */ unsigned BufferBindingIndex:6; + + /** + * 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. + */ + unsigned _EffBufferBindingIndex:6; + /** + * 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; }; @@ -1558,6 +1470,35 @@ struct gl_vertex_buffer_binding 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; }; @@ -1580,12 +1521,11 @@ struct gl_vertex_array_object GLboolean EverBound; /** - * Derived vertex attribute arrays - * - * This is a legacy data structure created from gl_array_attributes and - * gl_vertex_buffer_binding, for compatibility with existing driver code. + * 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. */ - struct gl_vertex_array _VertexAttrib[VERT_ATTRIB_MAX]; + bool SharedAndImmutable; /** Vertex attribute arrays */ struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX]; @@ -1599,6 +1539,18 @@ struct gl_vertex_array_object /** 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; + + /** 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; @@ -1607,22 +1559,6 @@ struct gl_vertex_array_object }; -/** - * 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 */ @@ -1661,10 +1597,26 @@ struct gl_array_attrib struct gl_buffer_object *ArrayBufferObj; /** - * Vertex arrays as consumed by a driver. - * The array pointer is set up only by the VBO module. + * 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. */ - const struct gl_vertex_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */ + struct gl_vertex_array_object *_EmptyVAO; /** Legal array datatypes and the API for which they have been computed */ GLbitfield LegalTypesMask; @@ -1818,9 +1770,6 @@ struct gl_transform_feedback_buffer /** Post-link transform feedback info. */ struct gl_transform_feedback_info { - /* Was xfb enabled via the api or in shader layout qualifiers */ - bool api_enabled; - unsigned NumOutputs; /* Bitmask of active buffer indices. */ @@ -2073,36 +2022,16 @@ struct gl_bindless_image /** - * 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. + * 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 { - 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; + 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; /** @@ -2137,7 +2066,7 @@ struct gl_program /** Subset of OutputsWritten outputs written with non-zero index. */ GLbitfield64 SecondaryOutputsWritten; /** TEXTURE_x_BIT bitmask */ - GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; + GLbitfield16 TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /** Bitfield of which samplers are used */ GLbitfield SamplersUsed; /** Texture units used for shadow sampling. */ @@ -2215,7 +2144,7 @@ struct gl_program /** Which texture target is being sampled * (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; + GLubyte SamplerTargets[MAX_SAMPLERS]; /** * Number of samplers declared with the bindless_sampler layout @@ -2331,6 +2260,17 @@ struct gl_vertex_program_state 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; }; /** @@ -2587,6 +2527,14 @@ struct gl_linked_shader 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; }; @@ -2654,6 +2602,10 @@ struct gl_shader bool uses_gl_fragcoord; bool PostDepthCoverage; + bool PixelInterlockOrdered; + bool PixelInterlockUnordered; + bool SampleInterlockOrdered; + bool SampleInterlockUnordered; bool InnerCoverage; /** @@ -2944,6 +2896,12 @@ struct gl_shader_program_data /* 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; }; /** @@ -3206,7 +3164,7 @@ struct gl_shader_compiler_options */ struct gl_query_object { - GLenum Target; /**< The query target, when active */ + GLenum16 Target; /**< The query target, when active */ GLuint Id; /**< hash table ID/name */ GLchar *Label; /**< GL_KHR_debug */ GLuint64EXT Result; /**< the counter */ @@ -3340,6 +3298,9 @@ struct gl_shared_state /** 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 @@ -3378,6 +3339,7 @@ struct gl_renderbuffer */ 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. */ @@ -3537,6 +3499,11 @@ struct gl_framebuffer 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]; @@ -3544,6 +3511,9 @@ struct gl_framebuffer 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); }; @@ -3638,7 +3608,7 @@ struct gl_program_constants struct gl_constants { GLuint MaxTextureMbytes; /**< Max memory per image, in MB */ - GLuint MaxTextureLevels; /**< Max mipmap levels. */ + GLuint MaxTextureLevels; /**< Max mipmap levels. */ GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ GLuint MaxArrayTextureLayers; /**< Max layers in array textures */ @@ -3745,6 +3715,7 @@ struct gl_constants GLuint MaxGeometryTotalOutputComponents; 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 @@ -3763,6 +3734,18 @@ struct gl_constants */ 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 */ @@ -3958,6 +3941,21 @@ struct gl_constants 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_EXT_texture_multisample_blit_scaled implementation assumes that * samples are laid out in a rectangular grid roughly corresponding to @@ -4065,6 +4063,19 @@ struct gl_constants /** 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; + + /** GL_ARB_gl_spirv */ + struct spirv_supported_capabilities SpirVCapabilities; }; @@ -4090,6 +4101,7 @@ struct gl_extensions 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; @@ -4111,6 +4123,7 @@ struct gl_extensions 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; @@ -4132,6 +4145,7 @@ struct gl_extensions 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; @@ -4209,6 +4223,9 @@ struct gl_extensions 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_integer_mix; GLboolean EXT_shader_samples_identical; GLboolean EXT_stencil_two_side; @@ -4235,8 +4252,10 @@ struct gl_extensions 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_framebuffer_multisample_advanced; GLboolean AMD_performance_monitor; GLboolean AMD_pinned_memory; GLboolean AMD_seamless_cubemap_per_texture; @@ -4249,7 +4268,6 @@ struct gl_extensions GLboolean ATI_texture_mirror_once; GLboolean ATI_texture_env_combine3; GLboolean ATI_fragment_shader; - GLboolean ATI_separate_stencil; GLboolean GREMEDY_string_marker; GLboolean INTEL_conservative_rasterization; GLboolean INTEL_performance_query; @@ -4259,10 +4277,11 @@ struct gl_extensions 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 MESA_shader_framebuffer_fetch; - GLboolean MESA_shader_framebuffer_fetch_non_coherent; + GLboolean EXT_shader_framebuffer_fetch; + GLboolean EXT_shader_framebuffer_fetch_non_coherent; GLboolean MESA_shader_integer_functions; GLboolean MESA_ycbcr_texture; GLboolean NV_conditional_render; @@ -4270,10 +4289,15 @@ struct gl_extensions 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 NVX_gpu_memory_info; GLboolean TDFX_texture_compression_FXT1; GLboolean OES_EGL_image; @@ -4434,7 +4458,7 @@ struct gl_dlist_state GLvertexformat ListVtxfmt; GLubyte ActiveAttribSize[VERT_ATTRIB_MAX]; - GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4]; + GLfloat CurrentAttrib[VERT_ATTRIB_MAX][8]; GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; @@ -4447,48 +4471,6 @@ struct gl_dlist_state } Current; }; -/** @{ - * - * These are a mapping of the GL_ARB_debug_output/GL_KHR_debug enums - * to small enums suitable for use as an array index. - */ - -enum mesa_debug_source -{ - 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 -}; - -/** @} */ - /** * Driver-specific state flags. * @@ -4547,6 +4529,17 @@ struct gl_driver_flags */ uint64_t NewIntelConservativeRasterization; + /** + * gl_context::NvConservativeRasterization + */ + uint64_t NewNvConservativeRasterization; + + /** + * gl_context::ConservativeRasterMode/ConservativeRasterDilate + * gl_context::SubpixelPrecisionBias + */ + uint64_t NewNvConservativeRasterizationParams; + /** * gl_context::Scissor::WindowRects */ @@ -4620,6 +4613,9 @@ struct gl_driver_flags /** 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 @@ -4649,7 +4645,7 @@ struct gl_image_unit /** * Level of the texture object bound to this unit. */ - GLuint Level; + GLubyte Level; /** * \c GL_TRUE if the whole level is bound as an array of layers, \c @@ -4662,13 +4658,13 @@ struct gl_image_unit * Layer of the texture object bound to this unit as specified by the * application. */ - GLuint Layer; + GLushort Layer; /** - * Layer of the texture object bound to this unit, or zero if the - * whole level is bound. + * Layer of the texture object bound to this unit, or zero if + * Layered == false. */ - GLuint _Layer; + GLushort _Layer; /** * Access allowed to this texture image. Either \c GL_READ_ONLY, @@ -4686,8 +4682,7 @@ struct gl_image_unit /** * Mesa format corresponding to \c Format. */ - mesa_format _ActualFormat; - + mesa_format _ActualFormat:16; }; /** @@ -4719,6 +4714,11 @@ struct gl_memory_object GLboolean Dedicated; /**< import memory from a dedicated allocation */ }; +struct gl_semaphore_object +{ + GLuint Name; /**< hash table ID/name */ +}; + /** * Mesa rendering context. * @@ -4851,6 +4851,7 @@ struct gl_context 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 */ @@ -5031,7 +5032,10 @@ struct gl_context GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ - GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */ + GLboolean IntelConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_INTEL */ + GLboolean ConservativeRasterization; /**< GL_CONSERVATIVE_RASTERIZATION_NV */ + GLfloat ConservativeRasterDilate; + GLenum16 ConservativeRasterMode; /** Does glVertexAttrib(0) alias glVertex()? */ bool _AttribZeroAliasesVertex;