X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fmtypes.h;h=578ac9485d7ff000efaab1ffd4e4b1f83e8940f6;hb=375e73d85948b43aa509e25f0a210ebd10238b6f;hp=deab97d3ec4ccdf58c4973fa803cdf8321b75170;hpb=919c53e87a1f6f5322bc1f1486bb3e6b954b00d5;p=mesa.git diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index deab97d3ec4..578ac9485d7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -48,18 +48,6 @@ extern "C" { #endif -/** - * Stencil buffer data type. - */ -#if STENCIL_BITS==8 - typedef GLubyte GLstencil; -#elif STENCIL_BITS==16 - typedef GLushort GLstencil; -#else -# error "illegal number of stencil bits" -#endif - - /** * \name 64-bit extension of GLbitfield. */ @@ -68,6 +56,12 @@ 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)) /** @@ -83,6 +77,8 @@ struct gl_texture_object; struct gl_context; struct st_context; struct gl_uniform_storage; +struct prog_instruction; +struct gl_program_parameter_list; /*@}*/ @@ -92,19 +88,6 @@ struct gl_uniform_storage; #define PRIM_UNKNOWN (GL_POLYGON+3) -/** - * Shader stages. Note that these will become 5 with tessellation. - * These MUST have the same values as gallium's PIPE_SHADER_* - */ -typedef enum -{ - MESA_SHADER_VERTEX = 0, - MESA_SHADER_FRAGMENT = 1, - MESA_SHADER_GEOMETRY = 2, - MESA_SHADER_TYPES = 3 -} gl_shader_type; - - /** * Indexes for vertex program attributes. @@ -122,7 +105,6 @@ typedef enum VERT_ATTRIB_COLOR1 = 4, VERT_ATTRIB_FOG = 5, VERT_ATTRIB_COLOR_INDEX = 6, - VERT_ATTRIB_POINT_SIZE = 6, /*alias*/ VERT_ATTRIB_EDGEFLAG = 7, VERT_ATTRIB_TEX0 = 8, VERT_ATTRIB_TEX1 = 9, @@ -132,65 +114,97 @@ typedef enum VERT_ATTRIB_TEX5 = 13, VERT_ATTRIB_TEX6 = 14, VERT_ATTRIB_TEX7 = 15, - VERT_ATTRIB_GENERIC0 = 16, - VERT_ATTRIB_GENERIC1 = 17, - VERT_ATTRIB_GENERIC2 = 18, - VERT_ATTRIB_GENERIC3 = 19, - VERT_ATTRIB_GENERIC4 = 20, - VERT_ATTRIB_GENERIC5 = 21, - VERT_ATTRIB_GENERIC6 = 22, - VERT_ATTRIB_GENERIC7 = 23, - VERT_ATTRIB_GENERIC8 = 24, - VERT_ATTRIB_GENERIC9 = 25, - VERT_ATTRIB_GENERIC10 = 26, - VERT_ATTRIB_GENERIC11 = 27, - VERT_ATTRIB_GENERIC12 = 28, - VERT_ATTRIB_GENERIC13 = 29, - VERT_ATTRIB_GENERIC14 = 30, - VERT_ATTRIB_GENERIC15 = 31, - VERT_ATTRIB_MAX = 32 + VERT_ATTRIB_POINT_SIZE = 16, + VERT_ATTRIB_GENERIC0 = 17, + VERT_ATTRIB_GENERIC1 = 18, + VERT_ATTRIB_GENERIC2 = 19, + VERT_ATTRIB_GENERIC3 = 20, + VERT_ATTRIB_GENERIC4 = 21, + VERT_ATTRIB_GENERIC5 = 22, + VERT_ATTRIB_GENERIC6 = 23, + VERT_ATTRIB_GENERIC7 = 24, + VERT_ATTRIB_GENERIC8 = 25, + VERT_ATTRIB_GENERIC9 = 26, + VERT_ATTRIB_GENERIC10 = 27, + VERT_ATTRIB_GENERIC11 = 28, + VERT_ATTRIB_GENERIC12 = 29, + VERT_ATTRIB_GENERIC13 = 30, + VERT_ATTRIB_GENERIC14 = 31, + VERT_ATTRIB_GENERIC15 = 32, + VERT_ATTRIB_MAX = 33 } gl_vert_attrib; +/** + * Symbolic constats to help iterating over + * specific blocks of vertex attributes. + * + * VERT_ATTRIB_FF + * includes all fixed function attributes as well as + * the aliased GL_NV_vertex_program shader attributes. + * VERT_ATTRIB_TEX + * include the classic texture coordinate attributes. + * Is a subset of VERT_ATTRIB_FF. + * VERT_ATTRIB_GENERIC_NV + * include the NV shader attributes. + * Is a subset of VERT_ATTRIB_FF. + * VERT_ATTRIB_GENERIC + * include the OpenGL 2.0+ GLSL generic shader attributes. + * These alias the generic GL_ARB_vertex_shader attributes. + */ +#define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i)) +#define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0 + +#define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i)) +#define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS + +#define VERT_ATTRIB_GENERIC_NV(i) (VERT_ATTRIB_POS + (i)) +#define VERT_ATTRIB_GENERIC_NV_MAX MAX_VERTEX_GENERIC_ATTRIBS + +#define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i)) +#define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS + /** * Bitflags for vertex attributes. * These are used in bitfields in many places. */ /*@{*/ -#define VERT_BIT_POS (1 << VERT_ATTRIB_POS) -#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT) -#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL) -#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0) -#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1) -#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG) -#define VERT_BIT_COLOR_INDEX (1 << VERT_ATTRIB_COLOR_INDEX) -#define VERT_BIT_EDGEFLAG (1 << VERT_ATTRIB_EDGEFLAG) -#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0) -#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1) -#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2) -#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3) -#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4) -#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5) -#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6) -#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7) -#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0) -#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1) -#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2) -#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3) -#define VERT_BIT_GENERIC4 (1 << VERT_ATTRIB_GENERIC4) -#define VERT_BIT_GENERIC5 (1 << VERT_ATTRIB_GENERIC5) -#define VERT_BIT_GENERIC6 (1 << VERT_ATTRIB_GENERIC6) -#define VERT_BIT_GENERIC7 (1 << VERT_ATTRIB_GENERIC7) -#define VERT_BIT_GENERIC8 (1 << VERT_ATTRIB_GENERIC8) -#define VERT_BIT_GENERIC9 (1 << VERT_ATTRIB_GENERIC9) -#define VERT_BIT_GENERIC10 (1 << VERT_ATTRIB_GENERIC10) -#define VERT_BIT_GENERIC11 (1 << VERT_ATTRIB_GENERIC11) -#define VERT_BIT_GENERIC12 (1 << VERT_ATTRIB_GENERIC12) -#define VERT_BIT_GENERIC13 (1 << VERT_ATTRIB_GENERIC13) -#define VERT_BIT_GENERIC14 (1 << VERT_ATTRIB_GENERIC14) -#define VERT_BIT_GENERIC15 (1 << VERT_ATTRIB_GENERIC15) - -#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u))) -#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g))) +#define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS) +#define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT) +#define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL) +#define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0) +#define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1) +#define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG) +#define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX) +#define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG) +#define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0) +#define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1) +#define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2) +#define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3) +#define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4) +#define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5) +#define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6) +#define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7) +#define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE) +#define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0) + +#define VERT_BIT(i) BITFIELD64_BIT(i) +#define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX) + +#define VERT_BIT_FF(i) VERT_BIT(i) +#define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX) +#define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i)) +#define VERT_BIT_TEX_ALL \ + BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX) +#define VERT_BIT_FF_NVALIAS \ + BITFIELD64_RANGE(VERT_ATTRIB_POS, VERT_ATTRIB_TEX(VERT_ATTRIB_TEX_MAX)) + +#define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i)) +#define VERT_BIT_GENERIC_NV_ALL \ + BITFIELD64_RANGE(VERT_ATTRIB_GENERIC_NV(0), VERT_ATTRIB_GENERIC_NV_MAX) + +#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i)) +#define VERT_BIT_GENERIC_ALL \ + BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX) /*@}*/ @@ -615,21 +629,26 @@ struct gl_config /*@}*/ -#define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */ -#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */ - /** - * Material shininess lookup table. + * Material state. */ -struct gl_shine_tab +struct gl_material { - struct gl_shine_tab *next, *prev; - GLfloat tab[SHINE_TABLE_SIZE+1]; - GLfloat shininess; - GLuint refcount; + 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. */ @@ -645,7 +664,6 @@ struct gl_light GLfloat SpotDirection[4]; /**< spotlight direction in eye coordinates */ GLfloat SpotExponent; GLfloat SpotCutoff; /**< in degrees */ - GLfloat _CosCutoffNeg; /**< = cos(SpotCutoff) */ GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */ GLfloat ConstantAttenuation; GLfloat LinearAttenuation; @@ -656,7 +674,7 @@ struct gl_light * \name Derived fields */ /*@{*/ - GLbitfield _Flags; /**< State */ + 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 */ @@ -664,12 +682,9 @@ struct gl_light GLfloat _NormSpotDirection[4]; /**< normalized spotlight direction */ GLfloat _VP_inf_spot_attenuation; - GLfloat _SpotExpTable[EXP_TABLE_SIZE][2]; /**< to replace a pow() call */ GLfloat _MatAmbient[2][3]; /**< material ambient * light ambient */ GLfloat _MatDiffuse[2][3]; /**< material diffuse * light diffuse */ GLfloat _MatSpecular[2][3]; /**< material spec * light specular */ - GLfloat _dli; /**< CI diffuse light intensity */ - GLfloat _sli; /**< CI specular light intensity */ /*@}*/ }; @@ -687,15 +702,6 @@ struct gl_lightmodel }; -/** - * Material state. - */ -struct gl_material -{ - GLfloat Attrib[MAT_ATTRIB_MAX][4]; -}; - - /** * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT) */ @@ -760,6 +766,11 @@ struct gl_colorbuffer_attrib 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; @@ -894,23 +905,6 @@ struct gl_fog_attrib }; -/** - * \brief Layout qualifiers for gl_FragDepth. - * - * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with - * a layout qualifier. - * - * \see enum ir_depth_layout - */ -enum gl_frag_depth_layout { - FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ - FRAG_DEPTH_LAYOUT_ANY, - FRAG_DEPTH_LAYOUT_GREATER, - FRAG_DEPTH_LAYOUT_LESS, - FRAG_DEPTH_LAYOUT_UNCHANGED -}; - - /** * Hint attribute group (GL_HINT_BIT). * @@ -929,16 +923,6 @@ struct gl_hint_attrib GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */ }; -/** - * 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) -/*@}*/ - /** * Lighting attribute group (GL_LIGHT_BIT). @@ -949,20 +933,19 @@ struct gl_light_attrib struct gl_lightmodel Model; /**< Lighting model */ /** - * Must flush FLUSH_VERTICES before referencing: + * Front and back material values. + * Note: must call FLUSH_VERTICES() before using. */ - /*@{*/ - struct gl_material Material; /**< Includes front & back values */ - /*@}*/ + struct gl_material Material; GLboolean Enabled; /**< Lighting enabled flag */ 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 */ + GLbitfield _ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ GLboolean ColorMaterialEnabled; - GLenum ClampVertexColor; + GLenum ClampVertexColor; /**< GL_TRUE, GL_FALSE, GL_FIXED_ONLY */ GLboolean _ClampVertexColor; struct gl_light EnabledList; /**< List sentinel */ @@ -973,7 +956,6 @@ struct gl_light_attrib /*@{*/ GLboolean _NeedEyeCoords; GLboolean _NeedVertices; /**< Use fast shader? */ - GLbitfield _Flags; /**< LIGHT_* flags, see above */ GLfloat _BaseColor[2][3]; /*@}*/ }; @@ -1023,7 +1005,6 @@ struct gl_pixelmap { GLint Size; GLfloat Map[MAX_PIXEL_MAP_TABLE]; - GLubyte Map8[MAX_PIXEL_MAP_TABLE]; /**< converted to 8-bit color */ }; @@ -1199,46 +1180,6 @@ typedef enum /*@}*/ -/** - * 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 image state. Drivers will typically create a subclass of this * with extra fields for memory buffers, etc. @@ -1340,7 +1281,9 @@ struct gl_texture_object GLenum Swizzle[4]; /**< GL_EXT_texture_swizzle */ GLuint _Swizzle; /**< same as Swizzle, but SWIZZLE_* format */ GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */ - GLboolean _Complete; /**< Is texture object complete? */ + 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 */ @@ -1351,18 +1294,11 @@ struct gl_texture_object /** GL_ARB_texture_buffer_object */ struct gl_buffer_object *BufferObject; GLenum BufferObjectFormat; + /** Equivalent Mesa format for BufferObjectFormat. */ + gl_format _BufferObjectFormat; /** GL_OES_EGL_image_external */ GLint RequiredTextureImageUnits; - - /** - * \name For device driver. - * Note: instead of attaching driver data to this pointer, it's preferable - * to instead use this struct as a base class for your own texture object - * class. Driver->NewTextureObject() can be used to implement the - * allocation. - */ - void *DriverData; /**< Arbitrary device driver data */ }; @@ -1390,6 +1326,46 @@ struct gl_tex_env_combine_state }; +/** + * 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. */ @@ -1600,38 +1576,44 @@ struct gl_array_object GLint RefCount; _glthread_Mutex Mutex; - GLboolean VBOonly; /**< require all arrays to live in VBOs? */ - /** Conventional vertex arrays */ - /*@{*/ - struct gl_client_array Vertex; - struct gl_client_array Weight; - struct gl_client_array Normal; - struct gl_client_array Color; - struct gl_client_array SecondaryColor; - struct gl_client_array FogCoord; - struct gl_client_array Index; - struct gl_client_array EdgeFlag; - struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; - struct gl_client_array PointSize; - /*@}*/ + /** + * 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; /** - * Generic arrays for vertex programs/shaders. - * For NV vertex programs, these attributes alias and take priority - * over the conventional attribs above. For ARB vertex programs and - * GLSL vertex shaders, these attributes are separate. + * Has this array object been bound? */ - struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS]; + GLboolean _Used; + + /** Vertex attribute arrays */ + struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; - /** Mask of _NEW_ARRAY_* values indicating which arrays are enabled */ - GLbitfield _Enabled; + /** Mask of VERT_BIT_* values indicating which arrays are enabled */ + GLbitfield64 _Enabled; + + /** Mask of VERT_BIT_* values indicating changed/dirty arrays */ + GLbitfield64 NewArrays; /** * Min of all enabled arrays' _MaxElement. When arrays reside inside VBOs * we can determine the max legal (in bounds) glDrawElements array index. */ GLuint _MaxElement; + + struct gl_buffer_object *ElementArrayBufferObj; }; @@ -1657,12 +1639,13 @@ struct gl_array_attrib GLboolean PrimitiveRestart; GLuint RestartIndex; - GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */ - GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */ - /* GL_ARB_vertex_buffer_object */ struct gl_buffer_object *ArrayBufferObj; - struct gl_buffer_object *ElementArrayBufferObj; + + /** + * Vertex arrays as consumed by a driver. + * The array pointer is set up only by the VBO module. */ + const struct gl_client_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */ }; @@ -1759,6 +1742,107 @@ struct gl_evaluators }; +struct gl_transform_feedback_varying_info +{ + char *Name; + GLenum Type; + GLint Size; +}; + + +/** + * Per-output info vertex shaders for transform feedback. + */ +struct gl_transform_feedback_output +{ + unsigned OutputRegister; + unsigned OutputBuffer; + unsigned NumComponents; + + /** offset (in DWORDs) of this output within the interleaved structure */ + unsigned 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. + */ + unsigned ComponentOffset; +}; + + +/** Post-link transform feedback info. */ +struct gl_transform_feedback_info +{ + unsigned NumOutputs; + + /** + * Number of transform feedback buffers in use by this program. + */ + unsigned NumBuffers; + + 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; + + /** + * 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. + */ + unsigned BufferStride[MAX_FEEDBACK_BUFFERS]; +}; + + +/** + * Transform feedback object state + */ +struct gl_transform_feedback_object +{ + GLuint Name; /**< AKA the object ID */ + GLint RefCount; + GLboolean Active; /**< Is transform feedback enabled? */ + GLboolean Paused; /**< Is transform feedback paused? */ + GLboolean EndedAnytime; /**< Has EndTransformFeedback been called + at least once? */ + + /** 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) */ + GLsizeiptr Size[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; +}; + + /** * Names of the various vertex/fragment program register files, etc. * @@ -1820,22 +1904,24 @@ enum glsl_interp_qualifier }; -/** Vertex and fragment instructions */ -struct prog_instruction; -struct gl_program_parameter_list; -struct gl_uniform_list; - -/** Post-link transform feedback info. */ -struct gl_transform_feedback_info { - unsigned NumOutputs; - - struct { - unsigned OutputRegister; - unsigned OutputBuffer; - unsigned NumComponents; - } Outputs[MAX_PROGRAM_OUTPUTS]; +/** + * \brief Layout qualifiers for gl_FragDepth. + * + * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with + * a layout qualifier. + * + * \see enum ir_depth_layout + */ +enum gl_frag_depth_layout +{ + FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ + FRAG_DEPTH_LAYOUT_ANY, + FRAG_DEPTH_LAYOUT_GREATER, + FRAG_DEPTH_LAYOUT_LESS, + FRAG_DEPTH_LAYOUT_UNCHANGED }; + /** * Base class for any kind of program object */ @@ -1850,7 +1936,7 @@ struct gl_program struct prog_instruction *Instructions; - GLbitfield InputsRead; /**< Bitmask of which input regs are read */ + GLbitfield64 InputsRead; /**< Bitmask of which input regs are read */ GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */ GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ @@ -1867,8 +1953,6 @@ struct gl_program /** Map from sampler unit to texture unit (set by glUniform1i()) */ GLubyte SamplerUnits[MAX_SAMPLERS]; - /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ - gl_texture_index SamplerTargets[MAX_SAMPLERS]; /** Bitmask of which register files are read/written with indirect * addressing. Mask of (1 << PROGRAM_x) bits. @@ -1937,6 +2021,12 @@ struct gl_fragment_program * GLSL, the value is INTERP_QUALIFIER_NONE. */ enum glsl_interp_qualifier InterpQualifier[FRAG_ATTRIB_MAX]; + + /** + * Bitfield indicating, for each fragment shader input, 1 if that input + * uses centroid interpolation, 0 otherwise. Unused inputs are 0. + */ + GLbitfield64 IsCentroid; }; @@ -2079,57 +2169,6 @@ struct gl_ati_fragment_shader_state }; -/** - * Occlusion/timer query object. - */ -struct gl_query_object -{ - GLenum Target; /**< The query target, when active */ - GLuint Id; /**< hash table ID/name */ - GLuint64EXT Result; /**< the counter */ - GLboolean Active; /**< inside Begin/EndQuery */ - GLboolean Ready; /**< result is ready? */ -}; - - -/** - * 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; - struct gl_query_object *PrimitivesWritten; - - /** GL_ARB_timer_query */ - struct gl_query_object *TimeElapsed; - - GLenum CondRenderMode; -}; - - -/** Sync object state */ -struct gl_sync_object { - struct simple_node link; - GLenum Type; /**< GL_SYNC_FENCE */ - GLuint Name; /**< Fence name */ - 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? */ -}; - - /** Set by #pragma directives */ struct gl_sl_pragmas { @@ -2158,6 +2197,24 @@ struct gl_shader unsigned Version; /**< GLSL version used for linking */ + /** + * \name Sampler tracking + * + * \note Each of these fields is only set post-linking. + */ + /*@{*/ + unsigned num_samplers; /**< Number of samplers used by this shader. */ + GLbitfield active_samplers; /**< Bitfield of which samplers are used */ + GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */ + /*@}*/ + + /** + * Number of uniform components used by this shader. + * + * This field is only set post-linking. + */ + unsigned num_uniform_components; + struct exec_list *ir; struct glsl_symbol_table *symbols; @@ -2167,6 +2224,19 @@ struct gl_shader }; +/** + * Shader stages. Note that these will become 5 with tessellation. + * These MUST have the same values as gallium's PIPE_SHADER_* + */ +typedef enum +{ + MESA_SHADER_VERTEX = 0, + MESA_SHADER_FRAGMENT = 1, + MESA_SHADER_GEOMETRY = 2, + MESA_SHADER_TYPES = 3 +} gl_shader_type; + + /** * A GLSL program object. * Basically a linked collection of vertex and fragment shaders. @@ -2209,8 +2279,15 @@ struct gl_shader_program * 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 */ + /** + * Transform feedback varyings last specified by + * glTransformFeedbackVaryings(). + * + * For the current set of transform feeedback varyings used for transform + * feedback output, see LinkedTransformFeedback. + */ struct { GLenum BufferMode; GLuint NumVarying; @@ -2220,6 +2297,9 @@ struct gl_shader_program /** Post-link transform feedback info. */ struct gl_transform_feedback_info LinkedTransformFeedback; + /** Post-link gl_FragDepth layout for ARB_conservative_depth. */ + enum gl_frag_depth_layout FragDepthLayout; + /** Geometry shader state - copied into gl_geometry_program at link time */ struct { GLint VerticesOut; @@ -2231,6 +2311,8 @@ struct gl_shader_program /** Vertex shader state - copied into gl_vertex_program at link time */ struct { GLboolean UsesClipDistance; /**< True if gl_ClipDistance is written to. */ + GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or + 0 if not present. */ } Vert; /* post-link info: */ @@ -2258,7 +2340,6 @@ struct gl_shader_program /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */ gl_texture_index SamplerTargets[MAX_SAMPLERS]; - struct gl_program_parameter_list *Varying; GLboolean LinkStatus; /**< GL_LINK_STATUS */ GLboolean Validated; GLboolean _Used; /**< Ever used for drawing? */ @@ -2285,6 +2366,7 @@ struct gl_shader_program #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 */ /** @@ -2303,6 +2385,8 @@ struct gl_shader_state struct gl_shader_program *CurrentGeometryProgram; struct gl_shader_program *CurrentFragmentProgram; + struct gl_shader_program *_CurrentFragmentProgram; + /** * Program used by glUniform calls. * @@ -2313,6 +2397,7 @@ struct gl_shader_state GLbitfield Flags; /**< Mask of GLSL_x flags */ }; + /** * Compiler options for a single GLSL shaders type */ @@ -2345,50 +2430,58 @@ struct gl_shader_compiler_options struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */ }; + /** - * Transform feedback object state + * Occlusion/timer query object. */ -struct gl_transform_feedback_object +struct gl_query_object { - GLuint Name; /**< AKA the object ID */ - GLint RefCount; - GLboolean Active; /**< Is transform feedback enabled? */ - GLboolean Paused; /**< Is transform feedback paused? */ - - /** The feedback buffers */ - GLuint BufferNames[MAX_FEEDBACK_ATTRIBS]; - struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS]; - - /** Start of feedback data in dest buffer */ - GLintptr Offset[MAX_FEEDBACK_ATTRIBS]; - /** Max data to put into dest buffer (in bytes) */ - GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS]; + GLenum Target; /**< The query target, when active */ + GLuint Id; /**< hash table ID/name */ + GLuint64EXT Result; /**< the counter */ + GLboolean Active; /**< inside Begin/EndQuery */ + GLboolean Ready; /**< result is ready? */ }; /** - * Context state for transform feedback. + * Context state for query objects. */ -struct gl_transform_feedback +struct gl_query_state { - GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */ - - GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ + struct _mesa_HashTable *QueryObjects; + struct gl_query_object *CurrentOcclusionObject; /* GL_ARB_occlusion_query */ + struct gl_query_object *CurrentTimerObject; /* GL_EXT_timer_query */ - /** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */ - struct gl_buffer_object *CurrentBuffer; + /** GL_NV_conditional_render */ + struct gl_query_object *CondRenderQuery; - /** The table of all transform feedback objects */ - struct _mesa_HashTable *Objects; + /** GL_EXT_transform_feedback */ + struct gl_query_object *PrimitivesGenerated; + struct gl_query_object *PrimitivesWritten; - /** The current xform-fb object (GL_TRANSFORM_FEEDBACK_BINDING) */ - struct gl_transform_feedback_object *CurrentObject; + /** GL_ARB_timer_query */ + struct gl_query_object *TimeElapsed; - /** The default xform-fb object (Name==0) */ - struct gl_transform_feedback_object *DefaultObject; + GLenum CondRenderMode; }; +/** Sync object state */ +struct gl_sync_object +{ + struct simple_node link; + GLenum Type; /**< GL_SYNC_FENCE */ + GLuint Name; /**< Fence name */ + 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: @@ -2404,7 +2497,7 @@ struct gl_shared_state struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS]; /** Fallback texture used when a bound texture is incomplete */ - struct gl_texture_object *FallbackTex; + struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS]; /** * \name Thread safety and statechange notification for texture @@ -2448,112 +2541,38 @@ struct gl_shared_state /** GL_ARB_sampler_objects */ struct _mesa_HashTable *SamplerObjects; - - void *DriverData; /**< Device driver shared state */ }; - /** - * A renderbuffer stores colors or depth values or stencil values. - * A framebuffer object will have a collection of these. - * Data are read/written to the buffer with a handful of Get/Put functions. - * - * Instances of this object are allocated with the Driver's NewRenderbuffer - * hook. Drivers will likely wrap this class inside a driver-specific - * class to simulate inheritance. + * 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 { - _glthread_Mutex Mutex; /**< for thread safety */ + _glthread_Mutex Mutex; /**< for thread safety */ GLuint ClassID; /**< Useful for drivers */ GLuint Name; GLint RefCount; GLuint Width, Height; - GLint RowStride; /**< Padded width in units of pixels */ - GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ - + GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */ GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */ - GLubyte NumSamples; - GLenum InternalFormat; /**< The user-specified format */ GLenum _BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or GL_STENCIL_INDEX. */ gl_format Format; /**< The actual renderbuffer memory format */ - GLenum DataType; /**< Type of values passed to the Get/Put functions */ - GLvoid *Data; /**< This may not be used by some kinds of RBs */ - - /* Used to wrap one renderbuffer around another: */ - struct gl_renderbuffer *Wrapped; - - /* Delete this renderbuffer */ + /** Delete this renderbuffer */ void (*Delete)(struct gl_renderbuffer *rb); - /* Allocate new storage for this renderbuffer */ - GLboolean (*AllocStorage)(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); - - /* Lock/Unlock are called before/after calling the Get/Put functions. - * Not sure this is the right place for these yet. - void (*Lock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - void (*Unlock)(struct gl_context *ctx, struct gl_renderbuffer *rb); - */ - - /* Return a pointer to the element/pixel at (x,y). - * Should return NULL if the buffer memory can't be directly addressed. - */ - void *(*GetPointer)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLint x, GLint y); - - /* Get/Read a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, void *values); - - /* Get/Read values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*GetValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], void *values); - - /* Put/Write a row of values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - /* Put/Write a row of RGB values. This is a special-case routine that's - * only used for RGBA renderbuffers when the source data is GL_RGB. That's - * a common case for glDrawPixels and some triangle routines. - * The values will be of format GL_RGB and type DataType. - */ - void (*PutRowRGB)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *values, const GLubyte *mask); - - - /* Put/Write a row of identical values. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoRow)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - GLint x, GLint y, const void *value, const GLubyte *mask); - - /* Put/Write values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count, - const GLint x[], const GLint y[], const void *values, - const GLubyte *mask); - /* Put/Write identical values at arbitrary locations. - * The values will be of format _BaseFormat and type DataType. - */ - void (*PutMonoValues)(struct gl_context *ctx, struct gl_renderbuffer *rb, - GLuint count, const GLint x[], const GLint y[], - const void *value, const GLubyte *mask); }; @@ -2649,11 +2668,6 @@ struct gl_framebuffer struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS]; struct gl_renderbuffer *_ColorReadBuffer; - /** The Actual depth/stencil buffers to use. May be wrappers around the - * depth/stencil buffers attached above. */ - struct gl_renderbuffer *_DepthBuffer; - struct gl_renderbuffer *_StencilBuffer; - /** Delete this framebuffer */ void (*Delete)(struct gl_framebuffer *fb); }; @@ -2701,6 +2715,9 @@ struct gl_program_constants /* ES 2.0 and GL_ARB_ES2_compatibility */ struct gl_precision LowFloat, MediumFloat, HighFloat; struct gl_precision LowInt, MediumInt, HighInt; + /* GL_ARB_uniform_buffer_object */ + GLuint MaxUniformBlocks; + GLuint MaxCombinedUniformComponents; }; @@ -2766,12 +2783,27 @@ struct gl_constants GLuint MaxVertexVaryingComponents; /**< Between vert and geom shader */ GLuint MaxGeometryVaryingComponents; /**< Between geom and frag shader */ + /** @{ + * GL_ARB_uniform_buffer_object + */ + GLuint MaxCombinedUniformBlocks; + GLuint MaxUniformBufferBindings; + GLuint MaxUniformBlockSize; + GLuint UniformBufferOffsetAlignment; + /** @} */ + /** GL_ARB_geometry_shader4 */ GLuint MaxGeometryOutputVertices; GLuint MaxGeometryTotalOutputComponents; GLuint GLSLVersion; /**< GLSL version supported (ex: 120 = 1.20) */ + /** + * Changes default GLSL extension behavior from "error" to "warn". It's out + * of spec, but it can make some apps work that otherwise wouldn't. + */ + GLboolean ForceGLSLExtensionsWarn; + /** * Does the driver support real 32-bit integers? (Otherwise, integers are * simulated via floats.) @@ -2802,19 +2834,20 @@ struct gl_constants GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */ /** GL_EXT_transform_feedback */ - GLuint MaxTransformFeedbackSeparateAttribs; + GLuint MaxTransformFeedbackBuffers; GLuint MaxTransformFeedbackSeparateComponents; GLuint MaxTransformFeedbackInterleavedComponents; + GLuint MaxVertexStreams; /** GL_EXT_gpu_shader4 */ GLint MinProgramTexelOffset, MaxProgramTexelOffset; - /* GL_EXT_framebuffer_sRGB */ - GLboolean sRGBCapable; /* can enable sRGB blend/update on FBOs */ - /* GL_ARB_robustness */ GLenum ResetStrategy; + /* GL_ARB_blend_func_extended */ + GLuint MaxDualSourceDrawBuffers; + /** * Whether the implementation strips out and ignores texture borders. * @@ -2822,12 +2855,26 @@ struct gl_constants * borders and mipmapped textures. (Note: not static border color, but the * old 1-pixel border around each edge). Implementations then have to do * slow fallbacks to be correct, or just ignore the border and be fast but - * wrong. Setting the flag stripts the border off of TexImage calls, + * wrong. Setting the flag strips the border off of TexImage calls, * providing "fast but wrong" at significantly reduced driver complexity. * * Texture borders are deprecated in GL 3.0. **/ GLboolean StripTextureBorder; + + /** + * For drivers which can do a better job at eliminating unused varyings + * and uniforms than the GLSL compiler. + * + * XXX Remove these as soon as a better solution is available. + */ + GLboolean GLSLSkipStrictMaxVaryingLimitCheck; + GLboolean GLSLSkipStrictMaxUniformLimitCheck; + + /** + * Force software support for primitive restart in the VBO module. + */ + GLboolean PrimitiveRestartInSoftware; }; @@ -2841,8 +2888,10 @@ struct gl_extensions GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ GLboolean ARB_ES2_compatibility; + GLboolean ARB_base_instance; GLboolean ARB_blend_func_extended; GLboolean ARB_color_buffer_float; + GLboolean ARB_conservative_depth; GLboolean ARB_copy_buffer; GLboolean ARB_depth_buffer_float; GLboolean ARB_depth_clamp; @@ -2866,6 +2915,7 @@ struct gl_extensions GLboolean ARB_point_sprite; GLboolean ARB_sampler_objects; GLboolean ARB_seamless_cube_map; + GLboolean ARB_shader_bit_encoding; GLboolean ARB_shader_objects; GLboolean ARB_shader_stencil_export; GLboolean ARB_shader_texture_lod; @@ -2888,6 +2938,7 @@ struct gl_extensions GLboolean ARB_texture_storage; GLboolean ARB_timer_query; GLboolean ARB_transform_feedback2; + GLboolean ARB_transform_feedback3; GLboolean ARB_transpose_matrix; GLboolean ARB_uniform_buffer_object; GLboolean ARB_vertex_array_object; @@ -2941,7 +2992,6 @@ struct gl_extensions GLboolean EXT_vertex_array_bgra; GLboolean OES_standard_derivatives; /* vendor extensions */ - GLboolean AMD_conservative_depth; GLboolean AMD_seamless_cubemap_per_texture; GLboolean APPLE_packed_pixels; GLboolean APPLE_vertex_array_object; @@ -2966,6 +3016,7 @@ struct gl_extensions GLboolean NV_light_max_exponent; GLboolean NV_point_sprite; GLboolean NV_primitive_restart; + GLboolean NV_read_buffer; GLboolean NV_texture_barrier; GLboolean NV_texgen_reflection; GLboolean NV_texture_env_combine4; @@ -2978,6 +3029,7 @@ struct gl_extensions GLboolean OES_EGL_image; GLboolean OES_draw_texture; GLboolean OES_EGL_image_external; + GLboolean OES_compressed_ETC1_RGB8_texture; GLboolean extension_sentinel; /** The extension string */ const GLubyte *String; @@ -3049,83 +3101,34 @@ struct gl_matrix_stack #define _NEW_PROGRAM_CONSTANTS (1 << 27) #define _NEW_BUFFER_OBJECT (1 << 28) #define _NEW_FRAG_CLAMP (1 << 29) +#define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */ +#define _NEW_VARYING_VP_INPUTS (1 << 31) /**< gl_context::varying_vp_inputs */ #define _NEW_ALL ~0 -/*@}*/ - /** - * \name Bits to track array state changes - * - * Also used to summarize array enabled. + * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for + * clarity. */ -/*@{*/ -#define _NEW_ARRAY_VERTEX VERT_BIT_POS -#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT -#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL -#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0 -#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1 -#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG -#define _NEW_ARRAY_INDEX VERT_BIT_COLOR_INDEX -#define _NEW_ARRAY_EDGEFLAG VERT_BIT_EDGEFLAG -#define _NEW_ARRAY_POINT_SIZE VERT_BIT_COLOR_INDEX /* aliased */ -#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0 -#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1 -#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2 -#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3 -#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4 -#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5 -#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6 -#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7 -#define _NEW_ARRAY_ATTRIB_0 VERT_BIT_GENERIC0 /* start at bit 16 */ -#define _NEW_ARRAY_ALL 0xffffffff - - -#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i)) -#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i)) +#define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM /*@}*/ - /** * \name A bunch of flags that we think might be useful to drivers. * * Set in the __struct gl_contextRec::_TriangleCaps bitfield. */ /*@{*/ -#define DD_FLATSHADE 0x1 -#define DD_SEPARATE_SPECULAR 0x2 -#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */ -#define DD_TRI_LIGHT_TWOSIDE 0x8 -#define DD_TRI_UNFILLED 0x10 -#define DD_TRI_SMOOTH 0x20 -#define DD_TRI_STIPPLE 0x40 -#define DD_TRI_OFFSET 0x80 -#define DD_LINE_SMOOTH 0x100 -#define DD_LINE_STIPPLE 0x200 -#define DD_POINT_SMOOTH 0x400 -#define DD_POINT_ATTEN 0x800 -#define DD_TRI_TWOSTENCIL 0x1000 -/*@}*/ - - -/** - * \name Define the state changes under which each of these bits might change - */ -/*@{*/ -#define _DD_NEW_FLATSHADE _NEW_LIGHT -#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM) -#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON -#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT -#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON -#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON -#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON -#define _DD_NEW_TRI_OFFSET _NEW_POLYGON -#define _DD_NEW_LINE_SMOOTH _NEW_LINE -#define _DD_NEW_LINE_STIPPLE _NEW_LINE -#define _DD_NEW_LINE_WIDTH _NEW_LINE -#define _DD_NEW_POINT_SMOOTH _NEW_POINT -#define _DD_NEW_POINT_SIZE _NEW_POINT -#define _DD_NEW_POINT_ATTEN _NEW_POINT +#define DD_SEPARATE_SPECULAR (1 << 0) +#define DD_TRI_LIGHT_TWOSIDE (1 << 1) +#define DD_TRI_UNFILLED (1 << 2) +#define DD_TRI_SMOOTH (1 << 3) +#define DD_TRI_STIPPLE (1 << 4) +#define DD_TRI_OFFSET (1 << 5) +#define DD_LINE_SMOOTH (1 << 6) +#define DD_LINE_STIPPLE (1 << 7) +#define DD_POINT_SMOOTH (1 << 8) +#define DD_POINT_ATTEN (1 << 9) /*@}*/ @@ -3138,6 +3141,12 @@ struct gl_matrix_stack _NEW_POINT | \ _NEW_PROGRAM | \ _NEW_MODELVIEW) + +#define _MESA_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | \ + _NEW_FOG | \ + _NEW_PROGRAM) + + /*@}*/ @@ -3193,12 +3202,6 @@ struct gl_dlist_state GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX]; GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4]; - GLubyte ActiveIndex; - GLfloat CurrentIndex; - - GLubyte ActiveEdgeFlag; - GLboolean CurrentEdgeFlag; - struct { /* State known to have been set by the currently-compiling display * list. Used to eliminate some redundant state changes. @@ -3207,6 +3210,70 @@ struct gl_dlist_state } Current; }; +/** + * An error, warning, or other piece of debug information for an application + * to consume via GL_ARB_debug_output. + */ +struct gl_debug_msg +{ + GLenum source; + GLenum type; + GLuint id; + GLenum severity; + GLsizei length; + GLcharARB *message; +}; + +typedef enum { + API_ERROR_UNKNOWN, + API_ERROR_COUNT +} gl_api_error; + +typedef enum { + WINSYS_ERROR_UNKNOWN, + WINSYS_ERROR_COUNT +} gl_winsys_error; + +typedef enum { + SHADER_ERROR_UNKNOWN, + SHADER_ERROR_COUNT +} gl_shader_error; + +typedef enum { + OTHER_ERROR_UNKNOWN, + OTHER_ERROR_OUT_OF_MEMORY, + OTHER_ERROR_COUNT +} gl_other_error; + +struct gl_client_namespace +{ + struct _mesa_HashTable *IDs; + unsigned ZeroID; /* a HashTable won't take zero, so store its state here */ + struct simple_node Severity[3]; /* lists of IDs in the hash table */ +}; + +struct gl_client_debug +{ + GLboolean Defaults[3][2][6]; /* severity, source, type */ + struct gl_client_namespace Namespaces[2][6]; /* source, type */ +}; + +struct gl_debug_state +{ + GLDEBUGPROCARB Callback; + GLvoid *CallbackData; + GLboolean SyncOutput; + GLboolean ApiErrors[API_ERROR_COUNT]; + GLboolean WinsysErrors[WINSYS_ERROR_COUNT]; + GLboolean ShaderErrors[SHADER_ERROR_COUNT]; + GLboolean OtherErrors[OTHER_ERROR_COUNT]; + struct gl_client_debug ClientIDs; + struct gl_debug_msg Log[MAX_DEBUG_LOGGED_MESSAGES]; + GLint NumMessages; + GLint NextMsg; + GLint NextMsgLength; /* redundant, but copied here from Log[NextMsg].length + for the sake of the offsetof() code in get.c */ +}; /** * Enum for the OpenGL APIs we know about and may support. @@ -3218,6 +3285,31 @@ typedef enum API_OPENGLES2 } gl_api; +/** + * Driver-specific state flags. + * + * These are or'd with gl_context::NewDriverState to notify a driver about + * a state change. The driver sets the flags at context creation and + * the meaning of the bits set is opaque to core Mesa. + */ +struct gl_driver_flags +{ + GLbitfield NewArray; /**< Vertex array state */ +}; + +struct gl_uniform_buffer_binding +{ + struct gl_buffer_object *BufferObject; + /** Start of uniform block data in the buffer */ + GLintptr Offset; + /** Size of data allowed to be referenced from the buffer (in bytes) */ + GLsizeiptr Size; + /** + * glBindBufferBase() indicates that the Size should be ignored and only + * limited by the current size of the BufferObject. + */ + GLboolean AutomaticSize; +}; /** * Mesa rendering context. @@ -3350,10 +3442,25 @@ struct gl_context struct gl_query_state Query; /**< occlusion, timer queries */ - struct gl_transform_feedback TransformFeedback; + struct gl_transform_feedback_state TransformFeedback; struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */ struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */ + + /** + * Current GL_ARB_uniform_buffer_object binding referenced by + * GL_UNIFORM_BUFFER target for glBufferData, glMapBuffer, etc. + */ + struct gl_buffer_object *UniformBuffer; + + /** + * Array of uniform buffers for GL_ARB_uniform_buffer_object and GL 3.1. + * This is set up using glBindBufferRange() or glBindBufferBase(). They are + * associated with uniform blocks by glUniformBlockBinding()'s state in the + * shader program. + */ + struct gl_uniform_buffer_binding *UniformBufferBindings; + /*@}*/ struct gl_meta_state *Meta; /**< for "meta" operations */ @@ -3372,12 +3479,18 @@ struct gl_context const char *ErrorDebugFmtString; GLuint ErrorDebugCount; + /* GL_ARB_debug_output */ + struct gl_debug_state Debug; + GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ + GLbitfield NewDriverState;/**< bitwise-or of flags from DriverFlags */ + + struct gl_driver_flags DriverFlags; GLboolean ViewportInitialized; /**< has viewport size been initialized? */ - GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */ + GLbitfield64 varying_vp_inputs; /**< mask of VERT_BIT_* flags */ /** \name Derived state */ /*@{*/ @@ -3393,10 +3506,6 @@ struct gl_context GLuint TextureStateTimestamp; /**< detect changes to shared state */ - struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */ - struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ - /**@}*/ - struct gl_list_extensions *ListExt; /**< driver dlist extensions */ /** \name For debugging/development only */ @@ -3415,6 +3524,8 @@ struct gl_context */ GLboolean mvp_with_dp4; + GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ + /** * \name Hooks for module contexts. * @@ -3468,7 +3579,10 @@ enum _verbose /** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ enum _debug { - DEBUG_ALWAYS_FLUSH = 0x1 + DEBUG_SILENT = (1 << 0), + DEBUG_ALWAYS_FLUSH = (1 << 1), + DEBUG_INCOMPLETE_TEXTURE = (1 << 2), + DEBUG_INCOMPLETE_FBO = (1 << 3) };