Minor tweaks to help out at a driver level.
[mesa.git] / src / mesa / main / mtypes.h
index 90fdd3b83c441c2d9fbaf3662828f8e999c2ab63..a5f7e366c1fef249428fbb06ba9c466aafd9c6a7 100644 (file)
 #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.
@@ -435,6 +430,7 @@ struct gl_colorbuffer_attrib {
    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 */
@@ -451,22 +447,22 @@ struct gl_current_attrib {
    /*@{*/
    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 */
    /*@}*/
@@ -478,7 +474,7 @@ struct gl_current_attrib {
  */
 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 */
@@ -1073,6 +1069,7 @@ struct gl_texture_object {
    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 */
@@ -1250,6 +1247,21 @@ struct gl_attrib_node {
 };
 
 
+/**
+ * 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
  */
@@ -1278,10 +1290,15 @@ struct gl_client_array {
    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;
 };
 
 
@@ -1300,27 +1317,19 @@ struct gl_array_attrib {
 
    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 */
 };
 
 
@@ -1436,7 +1445,8 @@ enum register_file
    PROGRAM_ENV_PARAM,
    PROGRAM_NAMED_PARAM,
    PROGRAM_STATE_VAR,
-   PROGRAM_WRITE_ONLY
+   PROGRAM_WRITE_ONLY,
+       PROGRAM_ADDRESS
 };
 
 
@@ -1444,16 +1454,7 @@ enum register_file
 struct vp_instruction;
 struct fp_instruction;
 
-
-/**
- * Named program parameters 
- */
-struct program_parameter
-{
-   const char *Name;
-   GLfloat Values[4];
-   GLboolean Constant;
-};
+struct program_parameter_list;
 
 
 /**
@@ -1484,6 +1485,7 @@ struct vertex_program
    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] */
 };
 
 
@@ -1498,8 +1500,7 @@ struct fragment_program
    GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
    GLuint NumTexInstructions;
    GLuint NumTexIndirections;
-   struct program_parameter *Parameters; /**< array [NumParameters] */
-   GLuint NumParameters;
+   struct program_parameter_list *Parameters; /**< array [NumParameters] */
 };
 
 
@@ -1607,6 +1608,10 @@ struct gl_shared_state
 #endif
    /*@}*/
 
+#if FEATURE_ARB_vertex_buffer_object
+   struct _mesa_HashTable *BufferObjects;
+#endif
+
    void *DriverData;  /**< Device driver shared state */
 };
 
@@ -1718,6 +1723,8 @@ struct gl_constants
    /* vertex or fragment program */
    GLuint MaxProgramMatrices;
    GLuint MaxProgramMatrixStackDepth;
+   /* vertex array / buffer object bounds checking */
+   GLboolean CheckArrayBounds;
 };
 
 
@@ -1779,6 +1786,7 @@ struct gl_extensions
    GLboolean EXT_texture_env_dot3;
    GLboolean EXT_texture_filter_anisotropic;
    GLboolean EXT_texture_lod_bias;
+   GLboolean EXT_texture_mirror_clamp;
    GLboolean EXT_vertex_array_set;
    GLboolean HP_occlusion_test;
    GLboolean IBM_rasterpos_clip;
@@ -1806,6 +1814,7 @@ struct gl_extensions
    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;
@@ -1862,7 +1871,7 @@ struct matrix_stack
 /**
  * \name Bits to indicate what state has changed.  
  *
- * 6 unused flags.
+ * 4 unused flags.
  */
 /*@{*/
 #define _NEW_MODELVIEW         0x1        /**< __GLcontextRec::ModelView */
@@ -1919,7 +1928,7 @@ struct matrix_stack
 #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
 
 
@@ -2017,6 +2026,27 @@ struct gl_tnl_module {
    /*@}*/
 };
 
+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
@@ -2048,9 +2078,6 @@ struct __GLcontextRec {
    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 */
@@ -2080,15 +2107,10 @@ struct __GLcontextRec {
    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;
@@ -2208,23 +2230,12 @@ struct __GLcontextRec {
 
    /** \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;
 
@@ -2251,9 +2262,11 @@ extern const char *_mesa_prim_name[GL_POLYGON+4];
 #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
@@ -2284,99 +2297,4 @@ enum _debug {
 #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 */