Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_context.h
index 61eab8f2f8d112d6555c68031d71b6d120968e13..6e25cac30159c419eec0a56ef7d3e0f8b2ef3720 100644 (file)
  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v 1.5 2002/02/24 21:51:10 dawes Exp $ */
 
 /*
+ * New fixes:
+ *     Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
  * Original rewrite:
  *     Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
  *
 #ifndef __TDFX_CONTEXT_H__
 #define __TDFX_CONTEXT_H__
 
-#ifdef GLX_DIRECT_RENDERING
-
 #include <sys/time.h>
 #include "dri_util.h"
 #ifdef XFree86Server
 #include "GL/xf86glx.h"
 #else
-#include "glheader.h"
+#include "main/glheader.h"
 #endif
 #if defined(__linux__)
 #include <signal.h>
 #include "drm.h"
 #include "drm_sarea.h"
 #include "tdfx_glide.h"
+#include "xmlconfig.h"
 
-#include "clip.h"
-#include "context.h"
-#include "macros.h"
-#include "matrix.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/clip.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/matrix.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "tdfx_screen.h"
 
 #define TDFX_UPLOAD_FOG_MODE           0x00000400
 #define TDFX_UPLOAD_FOG_COLOR          0x00000800
 #define TDFX_UPLOAD_FOG_TABLE          0x00001000
+#define TDFX_UPLOAD_CONSTANT_COLOR     0x00002000
 
 #define TDFX_UPLOAD_CLIP               0x00002000
 #define TDFX_UPLOAD_CULL               0x00004000
 
 /* Flags for software fallback cases */
 /* See correponding strings in tdfx_tris.c */
-#define TDFX_FALLBACK_TEXTURE_1D_3D    0x0001
+#define TDFX_FALLBACK_TEXTURE_MAP      0x0001
 #define TDFX_FALLBACK_DRAW_BUFFER      0x0002
 #define TDFX_FALLBACK_SPECULAR         0x0004
 #define TDFX_FALLBACK_STENCIL          0x0008
 #define TDFX_FALLBACK_COLORMASK                0x0100
 #define TDFX_FALLBACK_BLEND            0x0200
 #define TDFX_FALLBACK_LINE_STIPPLE     0x0400
+#define TDFX_FALLBACK_DISABLE          0x0800
 
 /* Different Glide vertex layouts
  */
 #define TDFX_LAYOUT_NOTEX      1
 #define TDFX_LAYOUT_SINGLE     2
 #define TDFX_LAYOUT_MULTI      3
-#define TDFX_LAYOUT_PROJECT    4
-#define TDFX_NUM_LAYOUTS       5
+#define TDFX_LAYOUT_PROJ1      4
+#define TDFX_LAYOUT_PROJ2      5
+#define TDFX_NUM_LAYOUTS       6
 
 #define TDFX_XY_OFFSET         0
 #define TDFX_Z_OFFSET          8
 #define TDFX_Q_OFFSET          12
 #define TDFX_ARGB_OFFSET       16
-#define TDFX_PAD_OFFSET                20
-#define TDFX_FOG_OFFSET         20 /* experimental */
+#define TDFX_FOG_OFFSET         20
 #define TDFX_ST0_OFFSET                24
 #define TDFX_ST1_OFFSET                32
 #define TDFX_Q0_OFFSET         40
@@ -316,7 +319,10 @@ typedef struct tdfxTexInfo_t
 
    GLfloat sScale, tScale;  /* texcoord scale factor */
 
+   GrTexTable_t paltype;
    GuTexPalette palette;
+
+   GLboolean padded;
 }
 tdfxTexInfo;
 
@@ -344,49 +350,20 @@ struct tdfxSharedState {
 /* ================================================================
  * The vertex structures.
  */
-typedef struct {
-   GLubyte     blue;
-   GLubyte     green;
-   GLubyte     red;
-   GLubyte     alpha;
-} tdfx_color_t;
-
-typedef struct {
-   GLfloat x, y, z;                    /* Coordinates in screen space */
-   GLfloat rhw;                                /* Reciprocal homogeneous w */
-   tdfx_color_t color;         /* Diffuse color */
-   GLuint pad;                 
-   GLfloat tu0, tv0;                   /* Texture 0 coordinates */
-   GLfloat tu1, tv1;                   /* Texture 1 coordinates */
-} tdfx_vertex;
-
-typedef struct {
+/* The size of this union is not of relevence:
+ */
+typedef struct tdfx_vertex_t {
    GLfloat x, y, z;                    /* Coordinates in screen space */
    GLfloat rhw;                                /* Reciprocal homogeneous w */
-   tdfx_color_t color;         /* Diffuse color */
-   GLuint pad;                 
+   GLubyte color[4];           /* Diffuse color */
+   GLfloat fog;
    GLfloat tu0, tv0;           /* Texture 0 coordinates */
    GLfloat tu1, tv1;           /* Texture 1 coordinates */
    GLfloat tq0, tq1;           /* Texture 0/1 q coords */
-} tdfx_ptex_vertex;
-
-typedef struct {
-   GLfloat x, y, z;                    /* Coordinates in screen space */
-   tdfx_color_t color;         /* Diffuse color */
-} tdfx_tiny_vertex;
-
-/* The size of this union is not of relevence:
- */
-union tdfx_vertex_t {
-   tdfx_vertex v;
-   tdfx_tiny_vertex tv;
-   tdfx_ptex_vertex pv;
-   GLfloat f[16];
-   GLuint ui[16];
-   GLubyte ub4[16][4];
-};
-
-typedef union tdfx_vertex_t tdfxVertex, *tdfxVertexPtr;
+   unsigned char pspec[4];     /* B, G, R, A [0..255] */
+   float psize;                /* point size */
+   long pad[16 - 14];  /* ensure 64b structure */
+} tdfxVertex, *tdfxVertexPtr;
 
 
 /* ================================================================
@@ -528,8 +505,10 @@ struct tdfx_color {
    /* Blending */
    GrAlphaBlendFnc_t BlendSrcRGB;      /* Blend source RGB factor */
    GrAlphaBlendFnc_t BlendDstRGB;      /* Blend destination RGB factor */
+   GrAlphaBlendOp_t BlendEqRGB;                /* Blend source RGB op */
    GrAlphaBlendFnc_t BlendSrcA;                /* Blend source alpha factor */
    GrAlphaBlendFnc_t BlendDstA;                /* Blend destination alpha factor */
+   GrAlphaBlendOp_t BlendEqA;          /* Blend source alpha op */
 
    GrDitherMode_t Dither;              /* Dither enable */
 };
@@ -601,6 +580,7 @@ struct tdfx_glide {
    FxBool HaveTextureBufferExt;                /* TEXTUREBUFFER */
    FxBool HaveTexFmtExt;               /* TEXFMT */
    FxBool HaveTexUMAExt;               /* TEXUMA */
+   FxBool HaveMirrorExt;               /* MIRROR */
    FxBool HaveTexus2;                  /* Texus 2 - FXT1 */
 
    /* Glide library function pointers */
@@ -838,6 +818,7 @@ struct tdfx_context {
 
    /* Mirror of hardware state, Glide parameters
     */
+   GLuint tmu_source[TDFX_NUM_TMU];
    struct tdfx_texsource       TexSource[TDFX_NUM_TMU];
    struct tdfx_texparams       TexParams[TDFX_NUM_TMU];
    struct tdfx_texpalette      TexPalette;
@@ -879,10 +860,9 @@ struct tdfx_context {
 
    /* Variable-size Glide vertex formats
     */
-   GLuint vertexFormat;            /* the current format */
-   GLuint vertex_stride_shift;
+   GLuint vertexFormat;                /* the current format */
    void *layout[TDFX_NUM_LAYOUTS];
-   GLubyte *verts;                        /* tdfxVertices, arbitarily packed */
+   tdfxVertex *verts;
    
    GLfloat hw_viewport[16];
    
@@ -903,6 +883,7 @@ struct tdfx_context {
    int screen_height;
 
    GLboolean haveTwoTMUs;      /* True if we have 2 tmu's  */
+   GLboolean haveHwAlpha;
    GLboolean haveHwStencil;
    GLboolean haveHwStipple;
 
@@ -911,10 +892,20 @@ struct tdfx_context {
    char rendererString[100];
 
    /* stuff added for DRI */
-   __DRIscreenPrivate *driScreen;
-   __DRIcontextPrivate *driContext;
-   __DRIdrawablePrivate *driDrawable;
-   drmContext hHWContext;
+   __DRIscreen *driScreen;
+   __DRIcontext *driContext;
+
+   /**
+    * DRI drawable bound to this context for drawing.
+    */
+   __DRIdrawable       *driDrawable;
+
+   /**
+    * DRI drawable bound to this context for reading.
+    */
+   __DRIdrawable       *driReadable;
+
+   drm_context_t hHWContext;
    drm_hw_lock_t *driHwLock;
    int driFd;
    tdfxScreenPrivate *fxScreen;
@@ -937,7 +928,9 @@ struct tdfx_context {
 
    tdfxStats stats;
 
-   GLboolean debugFallbacks;
+   /* Configuration cache
+    */
+   driOptionCache optionCache;
 };
 
 #define TDFX_CONTEXT(ctx)      ((tdfxContextPtr)((ctx)->DriverCtx))
@@ -945,19 +938,19 @@ struct tdfx_context {
 
 extern GLboolean
 tdfxCreateContext( const __GLcontextModes *mesaVis,
-                   __DRIcontextPrivate *driContextPriv,
+                   __DRIcontext *driContextPriv,
                    void *sharedContextPrivate );
 
 extern void
-tdfxDestroyContext( __DRIcontextPrivate *driContextPriv );
+tdfxDestroyContext( __DRIcontext *driContextPriv );
 
 extern GLboolean
-tdfxUnbindContext( __DRIcontextPrivate *driContextPriv );
+tdfxUnbindContext( __DRIcontext *driContextPriv );
 
 extern GLboolean
-tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv );
+tdfxMakeCurrent( __DRIcontext *driContextPriv,
+                 __DRIdrawable *driDrawPriv,
+                 __DRIdrawable *driReadPriv );
 
 extern GLboolean
 tdfxInitGlide( tdfxContextPtr tmesa );
@@ -990,9 +983,9 @@ FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
 #define TDFXPACKCOLOR4444( r, g, b, a )                                           \
    ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((g) & 0xf0) | ((r) >> 4))
 
-static __inline__ GrColor_t tdfxPackColor( GLuint cpp,
-                                          GLubyte r, GLubyte g,
-                                          GLubyte b, GLubyte a )
+static INLINE GrColor_t tdfxPackColor( GLuint cpp,
+                                       GLubyte r, GLubyte g,
+                                       GLubyte b, GLubyte a )
 {
    switch ( cpp ) {
    case 2:
@@ -1004,7 +997,7 @@ static __inline__ GrColor_t tdfxPackColor( GLuint cpp,
   }
 }
 
-#define DO_DEBUG               0
+#define DO_DEBUG               1
 #if DO_DEBUG
 extern int TDFX_DEBUG;
 #else
@@ -1013,12 +1006,11 @@ extern int TDFX_DEBUG;
 
 #define DEBUG_ALWAYS_SYNC      0x01
 #define DEBUG_VERBOSE_API      0x02
-#define DEBUG_VERBOSE_MSG      0x04
-#define DEBUG_VERBOSE_LRU      0x08
-#define DEBUG_VERBOSE_DRI      0x10
-#define DEBUG_VERBOSE_IOCTL    0x20
-#define DEBUG_VERBOSE_2D       0x40
+#define DEBUG_VERBOSE_DRI      0x04
+#define DEBUG_VERBOSE_FALL     0x08
 
-#endif /* GLX_DIRECT_RENDERING */
+/* conf */
+#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
+#define FX_TC_NAPALM 0
 
 #endif /* __TDFX_CONTEXT_H__ */