/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "config.h" /* Hardwired parameters */
#include "glapitable.h"
#include "glthread.h"
-
#include "math/m_matrix.h" /* GLmatrix */
-#if defined(MESA_TRACE)
-#include "Trace/tr_context.h"
-#endif
-
/**
* Color channel data type.
/*
* Fixed point arithmetic macros
*/
-#ifdef FIXED_14
-#define FIXED_ONE 0x00004000
-#define FIXED_HALF 0x00002000
-#define FIXED_FRAC_MASK 0x00003FFF
-#define FIXED_SCALE 16384.0f
-#define FIXED_SHIFT 14
-#else
-#define FIXED_ONE 0x00000800
-#define FIXED_HALF 0x00000400
-#define FIXED_FRAC_MASK 0x000007FF
-#define FIXED_SCALE 2048.0f
-#define FIXED_SHIFT 11
+#ifndef FIXED_FRAC_BITS
+#define FIXED_FRAC_BITS 11
#endif
+
+#define FIXED_SHIFT FIXED_FRAC_BITS
+#define FIXED_ONE (1 << FIXED_SHIFT)
+#define FIXED_HALF (1 << (FIXED_SHIFT-1))
+#define FIXED_FRAC_MASK (FIXED_ONE - 1)
#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
#define FIXED_EPSILON 1
+#define FIXED_SCALE ((float) FIXED_ONE)
+#define FIXED_DBL_SCALE ((double) FIXED_ONE)
#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
+#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
#define IntToFixed(I) ((I) << FIXED_SHIFT)
#define FixedToInt(X) ((X) >> FIXED_SHIFT)
#define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
+/* Fragment programs use a different but related set of attributes:
+ */
+
+/* Fragment input registers / attributes */
+#define FRAG_ATTRIB_WPOS 0
+#define FRAG_ATTRIB_COL0 1
+#define FRAG_ATTRIB_COL1 2
+#define FRAG_ATTRIB_FOGC 3
+#define FRAG_ATTRIB_TEX0 4
+#define FRAG_ATTRIB_TEX1 5
+#define FRAG_ATTRIB_TEX2 6
+#define FRAG_ATTRIB_TEX3 7
+#define FRAG_ATTRIB_TEX4 8
+#define FRAG_ATTRIB_TEX5 9
+#define FRAG_ATTRIB_TEX6 10
+#define FRAG_ATTRIB_TEX7 11
+
+/* Bitmasks for the above */
+#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
+#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
+#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
+#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
+#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
+#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
+#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
+#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
+#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
+#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
+#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
+#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
+
+#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
+ FRAG_BIT_TEX1| \
+ FRAG_BIT_TEX2| \
+ FRAG_BIT_TEX3| \
+ FRAG_BIT_TEX4| \
+ FRAG_BIT_TEX5| \
+ FRAG_BIT_TEX6| \
+ FRAG_BIT_TEX7)
+
+
/**
* Maximum number of temporary vertices required for clipping.
GLenum Format; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
GLenum IntFormat;
GLuint Size; /**< number of entries (rows) in table */
- GLvoid *Table; /**< either GLfloat * or GLchan * */
- GLboolean FloatTable; /**< are entries stored as floats? */
+ GLvoid *Table; /**< points to data of <Type> */
+ GLenum Type; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
GLubyte RedSize;
GLubyte GreenSize;
GLubyte BlueSize;
* \name Bit flags used for updating material values.
*/
/*@{*/
-#define FRONT_AMBIENT_BIT 0x1
-#define BACK_AMBIENT_BIT 0x2
-#define FRONT_DIFFUSE_BIT 0x4
-#define BACK_DIFFUSE_BIT 0x8
-#define FRONT_SPECULAR_BIT 0x10
-#define BACK_SPECULAR_BIT 0x20
-#define FRONT_EMISSION_BIT 0x40
-#define BACK_EMISSION_BIT 0x80
-#define FRONT_SHININESS_BIT 0x100
-#define BACK_SHININESS_BIT 0x200
-#define FRONT_INDEXES_BIT 0x400
-#define BACK_INDEXES_BIT 0x800
-
-#define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \
- FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \
- FRONT_SHININESS_BIT | FRONT_INDEXES_BIT)
-
-#define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \
- BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \
- BACK_SHININESS_BIT | BACK_INDEXES_BIT)
+#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)
/*@}*/
*/
struct gl_material
{
- GLfloat Ambient[4];
- GLfloat Diffuse[4];
- GLfloat Specular[4];
- GLfloat Emission[4];
- GLfloat Shininess;
- GLfloat AmbientIndex; /**< for color index lighting */
- GLfloat DiffuseIndex; /**< for color index lighting */
- GLfloat SpecularIndex; /**< for color index lighting */
+ GLfloat Attrib[MAT_ATTRIB_MAX][4];
};
GLenum BlendDstRGB; /**< Blending destination operator */
GLenum BlendSrcA; /**< GL_INGR_blend_func_separate */
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
- GLenum BlendEquation; /**< Blending equation */
+ GLenum BlendEquationRGB; /**< Blending equation */
+ GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
GLfloat BlendColor[4]; /**< Blending color */
/*@}*/
GLenum LogicOp; /**< Logic operator */
GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
+ GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
/*@}*/
GLboolean DitherFlag; /**< Dither enable flag */
/*@{*/
GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Current vertex attributes
* indexed by VERT_ATTRIB_* */
- GLuint Index; /**< Current color index */
+ GLfloat Index; /**< Current color index */
GLboolean EdgeFlag; /**< Current edge flag */
/*@}*/
/**
* \name Values are always valid.
*
- * \note BTW, note how similar this set of attributes is to the SWvertex data type
- * in the software rasterizer...
+ * \note BTW, note how similar this set of attributes is to the SWvertex
+ * data type in the software rasterizer...
*/
/*@{*/
GLfloat RasterPos[4]; /**< Current raster position */
GLfloat RasterDistance; /**< Current raster distance */
GLfloat RasterColor[4]; /**< Current raster color */
GLfloat RasterSecondaryColor[4]; /**< Current raster secondary color */
- GLuint RasterIndex; /**< Current raster index */
+ GLfloat RasterIndex; /**< Current raster index */
GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];/**< Current raster texcoords */
GLboolean RasterPosValid; /**< Raster pos valid flag */
/*@}*/
*/
struct gl_depthbuffer_attrib {
GLenum Func; /**< Function for depth buffer compare */
- GLfloat Clear; /**< Value to clear depth buffer to */
+ GLclampd Clear; /**< Value to clear depth buffer to */
GLboolean Test; /**< Depth buffering enabled flag */
GLboolean Mask; /**< Depth buffer writable? */
GLboolean OcclusionTest; /**< GL_HP_occlusion_test */
GLboolean VertexProgram;
GLboolean VertexProgramPointSize;
GLboolean VertexProgramTwoSide;
- /* GL_NV_point_sprite */
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
GLboolean PointSprite;
};
* Must flush FLUSH_VERTICES before referencing:
*/
/*@{*/
- struct gl_material Material[2]; /**< Material 0=front, 1=back */
+ struct gl_material Material; /**< Includes front & back values */
/*@}*/
GLboolean Enabled; /**< Lighting enabled flag */
GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
GLfloat Threshold; /**< GL_EXT_point_parameters */
GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
- GLboolean PointSprite; /**< GL_NV_point_sprite */
- GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite */
- GLenum SpriteRMode; /**< GL_NV_point_sprite */
+ GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
+ GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV_point_sprite / GL_NV_point_sprite */
+ GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
};
#define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
#define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
+
/**
- * Texel fetch function prototype.
+ * Texel fetch function prototype. We use texel fetch functions to
+ * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
+ * texture images. These functions help to isolate us from the gritty
+ * details of all the various texture image encodings.
*
* \param texImage texture image.
* \param col texel column.
* \param row texel row.
- * \param img texel level.
- * \param texelOut output texel. If \p texImage is color-index, \p texelOut
- * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
- * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
+ * \param img texel image level/layer.
+ * \param texelOut output texel (up to 4 GLchans)
*/
-typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLvoid *texelOut );
+typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLchan *texelOut );
+
+/**
+ * As above, but returns floats.
+ * Used for depth component images and for upcoming signed/float
+ * texture images.
+ */
+typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut );
/**
* Texture format record
* \name Texel fetch function pointers
*/
/*@{*/
- FetchTexelFunc FetchTexel1D;
- FetchTexelFunc FetchTexel2D;
- FetchTexelFunc FetchTexel3D;
+ FetchTexelFuncC FetchTexel1D;
+ FetchTexelFuncC FetchTexel2D;
+ FetchTexelFuncC FetchTexel3D;
+ FetchTexelFuncF FetchTexel1Df;
+ FetchTexelFuncF FetchTexel2Df;
+ FetchTexelFuncF FetchTexel3Df;
/*@}*/
};
const struct gl_texture_format *TexFormat;
- FetchTexelFunc FetchTexel; /**< Texel fetch function pointer */
+ FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
+ FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
GLboolean IsCompressed; /**< GL_ARB_texture_compression */
GLuint CompressedSize; /**< GL_ARB_texture_compression */
/*@}*/
};
+#define FACE_POS_X 0
+#define FACE_NEG_X 1
+#define FACE_POS_Y 2
+#define FACE_NEG_Y 3
+#define FACE_POS_Z 4
+#define FACE_NEG_Z 5
+#define MAX_FACES 6
/**
* Texture object record
GLenum MagFilter; /**< magnification filter */
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
+ GLfloat LodBias; /**< OpenGL 1.4 */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
- struct gl_texture_image *Image[MAX_TEXTURE_LEVELS];
-
- /**
- * \name Texture cube faces
- *
- * Image[] is alias for *PosX[MAX_TEXTURE_LEVELS];
- */
- /*@{*/
- struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS];
- struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS];
- /*@}*/
+ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_EXT_paletted_texture */
struct gl_color_table Palette;
/*@}*/
};
+/**
+ * Texture combine environment state.
+ *
+ * \todo
+ * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
+ * structure will need to be expanded for 4 elements.
+ */
+struct gl_tex_env_combine_state {
+ GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
+ GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
+ GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
+ GLuint ScaleShiftA; /**< 0, 1 or 2 */
+ GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
+ GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
+};
/**
* Texture unit record
/**
* \name GL_EXT_texture_env_combine
*/
- /*@{*/
- GLenum CombineModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineSourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineSourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineOperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
- GLenum CombineOperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
- GLuint CombineScaleShiftRGB; /**< 0, 1 or 2 */
- GLuint CombineScaleShiftA; /**< 0, 1 or 2 */
- /*@}*/
+ 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;
struct gl_texture_object *Current1D;
struct gl_texture_object *Current2D;
};
+/**
+ * GL_ARB_vertex_buffer_object buffer object
+ */
+struct gl_buffer_object {
+ GLint RefCount;
+ GLuint Name;
+ GLenum Usage;
+ GLenum Access;
+ GLvoid *Pointer; /**< Only valid while buffer is mapped */
+ GLuint Size; /**< Size of data array in bytes */
+ GLubyte *Data; /**< The storage */
+};
+
+
+
/**
* Client pixel packing/unpacking attributes
*/
GLenum Type;
GLsizei Stride; /**< user-specified stride */
GLsizei StrideB; /**< actual stride in bytes */
- void *Ptr;
- GLuint Flags;
+ const GLubyte *Ptr;
GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
GLboolean Normalized; /**< GL_ARB_vertex_program */
+
+ /**< GL_ARB_vertex_buffer_object */
+ struct gl_buffer_object *BufferObj;
+ GLuint _MaxElement;
+
+ GLuint Flags;
};
struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
- GLint TexCoordInterleaveFactor;
GLint ActiveTexture; /**< Client Active Texture */
- GLuint LockFirst;
- GLuint LockCount;
+ GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
+ GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
GLuint _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
GLuint NewState; /**< _NEW_ARRAY_* */
- /* GL_ARB_vertex_buffer_object */
- GLuint ArrayBufferBinding;
- GLuint VertexArrayBufferBinding;
- GLuint NormalArrayBufferBinding;
- GLuint ColorArrayBufferBinding;
- GLuint IndexArrayBufferBinding;
- GLuint TextureArrayBufferBinding;
- GLuint EdgeFlagArrayBufferBinding;
- GLuint SecondaryColorArrayBufferBinding;
- GLuint FogCoordArrayBufferBinding;
- GLuint WeightArrayBufferBinding;
- GLuint ElementArrayBufferBinding;
- GLuint VertexAttribArrayBufferBinding[VERT_ATTRIB_MAX];
+#if FEATURE_ARB_vertex_buffer_object
+ struct gl_buffer_object *NullBufferObj;
+ struct gl_buffer_object *ArrayBufferObj;
+ struct gl_buffer_object *ElementArrayBufferObj;
+#endif
+ GLuint _MaxElement; /* Min of all enabled array's maxes */
};
/**
* 1-D Evaluator control points
*/
-struct gl_1d_map {
+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 {
+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;
/**
* All evaluator control points
*/
-struct gl_evaluators {
+struct gl_evaluators
+{
/**
* \name 1-D maps
*/
/**
- * \name NV_vertex_program runtime state
- */
-/*@{*/
-
-
-/**
- * Machine state (i.e. the register file)
+ * NV_fragment_program runtime state
*/
-struct vp_machine
+struct fp_machine
{
- GLfloat Registers[MAX_NV_VERTEX_PROGRAM_TEMPS
- + MAX_NV_VERTEX_PROGRAM_PARAMS
- + MAX_NV_VERTEX_PROGRAM_INPUTS
- + MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
- GLint AddressReg; /* might someday be a 4-vector */
+ GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
+ GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
+ GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
+ GLuint CondCodes[4];
};
/**
- * NV_fragment_program runtime state
+ * Names of the various vertex/fragment register files
*/
-struct fp_machine
+enum register_file
{
- GLfloat Registers[MAX_NV_FRAGMENT_PROGRAM_TEMPS
- + MAX_NV_FRAGMENT_PROGRAM_PARAMS
- + MAX_NV_FRAGMENT_PROGRAM_INPUTS
- + MAX_NV_FRAGMENT_PROGRAM_OUTPUTS
- + MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS][4];
- GLuint CondCodes[4];
+ PROGRAM_TEMPORARY = 10,
+ PROGRAM_INPUT,
+ PROGRAM_OUTPUT,
+ PROGRAM_LOCAL_PARAM,
+ PROGRAM_ENV_PARAM,
+ PROGRAM_NAMED_PARAM,
+ PROGRAM_STATE_VAR,
+ PROGRAM_WRITE_ONLY,
+ PROGRAM_ADDRESS
};
struct vp_instruction;
struct fp_instruction;
-/**
- * Program parameters
- */
-struct program_parameter
-{
- const char *Name;
- GLfloat Values[4];
- GLboolean Constant;
-};
+struct program_parameter_list;
/**
GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
GLuint InputsRead; /* Bitmask of which input regs are read */
GLuint OutputsWritten; /* Bitmask of which output regs are written to */
+ struct program_parameter_list *Parameters; /**< array [NumParameters] */
};
GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
GLuint NumTexInstructions;
GLuint NumTexIndirections;
- struct program_parameter *Parameters; /**< array [NumParameters] */
- GLuint NumParameters;
+ GLenum FogOption;
+ struct program_parameter_list *Parameters; /**< array [NumParameters] */
};
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
struct vertex_program *Current; /**< ptr to currently bound program */
- struct vp_machine Machine; /**< machine state */
GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
+
+ GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
+ /* Only used during program execution (may be moved someday): */
+ GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
+ GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
+ GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
+ GLint AddressReg[4];
+
+#if FEATURE_MESA_program_debug
+ GLprogramcallbackMESA Callback;
+ GLvoid *CallbackData;
+ GLboolean CallbackEnabled;
+ GLuint CurrentPosition;
+#endif
};
GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
struct fragment_program *Current; /* ptr to currently bound program */
struct fp_machine Machine; /* machine state */
+ GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
+
+#if FEATURE_MESA_program_debug
+ GLprogramcallbackMESA Callback;
+ GLvoid *CallbackData;
+ GLboolean CallbackEnabled;
+ GLuint CurrentPosition;
+#endif
};
-/*@}*/
/*
* State for GL_ARB_occlusion_query
/**
* State which can be shared by multiple contexts:
*/
-struct gl_shared_state {
+struct gl_shared_state
+{
_glthread_Mutex Mutex; /**< for thread safety */
GLint RefCount; /**< Reference count */
struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
#endif
/*@}*/
+#if FEATURE_ARB_vertex_buffer_object
+ struct _mesa_HashTable *BufferObjects;
+#endif
+
void *DriverData; /**< Device driver shared state */
};
* In C++ terms, think of this as a base class from which device drivers
* will make derived classes.
*/
-struct gl_frame_buffer {
+struct gl_frame_buffer
+{
GLvisual Visual; /**< The corresponding visual */
GLuint Width, Height; /**< size of frame buffer in pixels */
/** \name Software alpha planes */
/*@{*/
- GLvoid *FrontLeftAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *BackLeftAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *FrontRightAlpha; /**< array [Width*Height] of GLubyte */
- GLvoid *BackRightAlpha; /**< array [Width*Height] of GLubyte */
+ GLchan *FrontLeftAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *BackLeftAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *FrontRightAlpha; /**< array [Width*Height] of GLchan */
+ GLchan *BackRightAlpha; /**< array [Width*Height] of GLchan */
/*@}*/
/**
* Constants which may be overridden by device driver during context creation
* but are never changed after that.
*/
-struct gl_constants {
+struct gl_constants
+{
GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
/* vertex or fragment program */
GLuint MaxProgramMatrices;
GLuint MaxProgramMatrixStackDepth;
+ /* vertex array / buffer object bounds checking */
+ GLboolean CheckArrayBounds;
};
/**
* List of extensions.
*/
-struct gl_extensions {
+struct gl_extensions
+{
/**
* \name Flags to quickly test if certain extensions are available.
*
GLboolean ARB_multisample;
GLboolean ARB_multitexture;
GLboolean ARB_occlusion_query;
+ GLboolean ARB_point_sprite;
GLboolean ARB_shadow;
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_compression;
GLboolean ARB_texture_env_dot3;
GLboolean ARB_texture_mirrored_repeat;
GLboolean ARB_texture_non_power_of_two;
+ GLboolean ARB_transpose_matrix;
GLboolean ARB_vertex_buffer_object;
GLboolean ARB_vertex_program;
GLboolean ARB_window_pos;
- GLboolean ATI_texture_mirror_once;
- GLboolean ATI_texture_env_combine3;
+ GLboolean EXT_abgr;
+ GLboolean EXT_bgra;
GLboolean EXT_blend_color;
+ GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_logic_op;
GLboolean EXT_blend_minmax;
GLboolean EXT_blend_subtract;
+ GLboolean EXT_clip_volume_hint;
GLboolean EXT_convolution;
GLboolean EXT_compiled_vertex_array;
+ GLboolean EXT_copy_texture;
GLboolean EXT_depth_bounds_test;
+ GLboolean EXT_draw_range_elements;
GLboolean EXT_fog_coord;
GLboolean EXT_histogram;
GLboolean EXT_multi_draw_arrays;
GLboolean EXT_paletted_texture;
+ GLboolean EXT_packed_pixels;
GLboolean EXT_point_parameters;
+ GLboolean EXT_polygon_offset;
+ GLboolean EXT_rescale_normal;
GLboolean EXT_shadow_funcs;
GLboolean EXT_secondary_color;
+ GLboolean EXT_separate_specular_color;
GLboolean EXT_shared_texture_palette;
GLboolean EXT_stencil_wrap;
GLboolean EXT_stencil_two_side;
+ GLboolean EXT_subtexture;
+ GLboolean EXT_texture;
+ GLboolean EXT_texture_object;
GLboolean EXT_texture3D;
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_env_dot3;
GLboolean EXT_texture_filter_anisotropic;
GLboolean EXT_texture_lod_bias;
+ GLboolean EXT_texture_mirror_clamp;
+ GLboolean EXT_vertex_array;
GLboolean EXT_vertex_array_set;
+ /* vendor extensions */
+ GLboolean APPLE_client_storage;
+ GLboolean APPLE_packed_pixels;
+ GLboolean ATI_texture_mirror_once;
+ GLboolean ATI_texture_env_combine3;
GLboolean HP_occlusion_test;
GLboolean IBM_rasterpos_clip;
+ GLboolean IBM_multimode_draw_arrays;
GLboolean MESA_pack_invert;
GLboolean MESA_packed_depth_stencil;
+ GLboolean MESA_program_debug;
GLboolean MESA_resize_buffers;
GLboolean MESA_ycbcr_texture;
GLboolean NV_blend_square;
GLboolean NV_fragment_program;
+ GLboolean NV_light_max_exponent;
GLboolean NV_point_sprite;
+ GLboolean NV_texgen_reflection;
GLboolean NV_texture_rectangle;
GLboolean NV_vertex_program;
GLboolean NV_vertex_program1_1;
GLboolean SGIS_generate_mipmap;
GLboolean SGIS_pixel_texture;
GLboolean SGIS_texture_edge_clamp;
+ GLboolean SGIS_texture_lod;
GLboolean SGIX_depth_texture;
GLboolean SGIX_pixel_texture;
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean TDFX_texture_compression_FXT1;
- GLboolean APPLE_client_storage;
+ GLboolean S3_s3tc;
/*@}*/
/* The extension string */
const GLubyte *String;
/**
* \name Bits to indicate what state has changed.
*
- * 6 unused flags.
+ * 4 unused flags.
*/
/*@{*/
#define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
#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 0x1 /* alias conventional arrays */
+#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
#define _NEW_ARRAY_ALL 0xffffffff
*/
/*@{*/
#define _DD_NEW_FLATSHADE _NEW_LIGHT
-#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG)
+#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
/**
* Vertex format to be lazily swapped into current dispatch.
*/
- GLvertexformat *Current;
+ const GLvertexformat *Current;
/**
* \name Record of functions swapped out.
/*@}*/
};
+struct mesa_list_state {
+ GLuint CallDepth; /**< Current recursion calling depth */
+ Node *CurrentListPtr; /**< Head of list being compiled */
+ GLuint CurrentListNum; /**< Number of the list being compiled */
+ Node *CurrentBlock; /**< Pointer to current block of nodes */
+ GLuint CurrentPos; /**< Index into current block of nodes */
+ GLvertexformat ListVtxfmt;
+
+ GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
+ GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
+
+ GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
+ GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
+
+ GLubyte ActiveIndex;
+ GLfloat CurrentIndex;
+
+ GLubyte ActiveEdgeFlag;
+ GLboolean CurrentEdgeFlag;
+};
+
/**
* Mesa context
struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
/*@}*/
- GLboolean ExecPrefersFloat; /**< What preference for color conversion? */
- GLboolean SavePrefersFloat;
-
GLvisual Visual;
GLframebuffer *DrawBuffer; /**< buffer for writing */
GLframebuffer *ReadBuffer; /**< buffer for reading */
GLmatrix _ModelProjectMatrix;
/** \name Display lists */
- /*@{*/
- GLuint CallDepth; /**< Current recursion calling depth */
+ struct mesa_list_state ListState;
+
GLboolean ExecuteFlag; /**< Execute GL commands? */
GLboolean CompileFlag; /**< Compile GL commands into display list? */
- Node *CurrentListPtr; /**< Head of list being compiled */
- GLuint CurrentListNum; /**< Number of the list being compiled */
- Node *CurrentBlock; /**< Pointer to current block of nodes */
- GLuint CurrentPos; /**< Index into current block of nodes */
- /*@}*/
/** Extensions */
struct gl_extensions Extensions;
GLuint _NeedEyeCoords;
GLuint _ForceEyeCoords;
GLboolean _RotateMode;
+ GLenum _CurrentProgram; /* currently executing program */
struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
/** \name For debugging/development only */
/*@{*/
- GLboolean NoRaster;
GLboolean FirstTimeCurrent;
/*@}*/
/** Dither disable via MESA_NO_DITHER env var */
GLboolean NoDither;
- GLboolean Rendering;
-
-#if defined(MESA_TRACE)
- struct _glapi_table *TraceDispatch;
- trace_context_t *TraceCtx;
-#else
- void *TraceDispatch;
- void *TraceCtx;
-#endif
-
/** Core tnl module support */
struct gl_tnl_module TnlModule;
#ifdef MESA_DEBUG
extern int MESA_VERBOSE;
extern int MESA_DEBUG_FLAGS;
+# define MESA_FUNCTION __FUNCTION__
#else
# define MESA_VERBOSE 0
# define MESA_DEBUG_FLAGS 0
+# define MESA_FUNCTION "a function"
# ifndef NDEBUG
# define NDEBUG
# endif
#define Elements(x) sizeof(x)/sizeof(*(x))
-/**
- * Flush vertices.
- *
- * \param ctx GL context.
- * \param newstate new state.
- *
- * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
- * and calls dd_function_table::FlushVertices if so. Marks
- * __GLcontextRec::NewState with \p newstate.
- *
- * \todo Eventually let the driver specify what state changes require a flush:
- */
-#define FLUSH_VERTICES(ctx, newstate) \
-do { \
- if (MESA_VERBOSE & VERBOSE_STATE) \
- _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
- if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
- ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
- ctx->NewState |= newstate; \
-} while (0)
-
-/**
- * Flush current state.
- *
- * \param ctx GL context.
- * \param newstate new state.
- *
- * Checks if dd_function_table::NeedFlush is marked to flush current state,
- * and calls dd_function_table::FlushVertices if so. Marks
- * __GLcontextRec::NewState with \p newstate.
- */
-#define FLUSH_CURRENT(ctx, newstate) \
-do { \
- if (MESA_VERBOSE & VERBOSE_STATE) \
- _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
- if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
- ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
- ctx->NewState |= newstate; \
-} while (0)
-
-/**
- * Macro to assert that the API call was made outside the
- * glBegin()/glEnd() pair, with return value.
- *
- * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
- */
-#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
-do { \
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
- _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
- return retval; \
- } \
-} while (0)
-
-/**
- * Macro to assert that the API call was made outside the
- * glBegin()/glEnd() pair.
- *
- * \param ctx GL context.
- */
-#define ASSERT_OUTSIDE_BEGIN_END(ctx) \
-do { \
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
- _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
- return; \
- } \
-} while (0)
-
-/**
- * Macro to assert that the API call was made outside the
- * glBegin()/glEnd() pair and flush the vertices.
- *
- * \param ctx GL context.
- */
-#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
-do { \
- ASSERT_OUTSIDE_BEGIN_END(ctx); \
- FLUSH_VERTICES(ctx, 0); \
-} while (0)
-
-/**
- * Macro to assert that the API call was made outside the
- * glBegin()/glEnd() pair and flush the vertices, with return value.
- *
- * \param ctx GL context.
- * \param retval value to return value in case the assertion fails.
- */
-#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
-do { \
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
- FLUSH_VERTICES(ctx, 0); \
-} while (0)
-
-
#endif /* TYPES_H */