Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / tnl_dd / t_dd_tritmp.h
index 5b17a6f6f0064483111f9fb41d549649511e6ef3..1ae70f4059f221c252b991e3b1dd0aa2502b8ec5 100644 (file)
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  6.3
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2005  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"),
@@ -49,7 +48,8 @@
  * VERT_X(v): Alias for vertex x value.
  * VERT_Y(v): Alias for vertex y value.
  * VERT_Z(v): Alias for vertex z value.
- * DEPTH_SCALE: Scale for offset.
+ * DEPTH_SCALE: Scale for constant offset.
+ * REVERSE_DEPTH: Viewport depth range reversed.
  *
  * VERTEX: Hardware vertex type.
  * GET_VERTEX(n): Retreive vertex with index n.
 #define VERT_Z_ADD(v,val) VERT_Z(v) += val
 #endif
 
+#ifndef REVERSE_DEPTH
+#define REVERSE_DEPTH 0
+#endif
+
 /* disable twostencil for un-aware drivers */
 #ifndef HAVE_STENCIL_TWOSIDE
 #define HAVE_STENCIL_TWOSIDE 0
@@ -127,10 +131,10 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
    VERTEX *v[3];
-   GLfloat offset;
+   GLfloat offset = 0;
    GLfloat z[3];
    GLenum mode = GL_FILL;
-   GLuint facing;
+   GLuint facing = 0;
    LOCAL_VARS(3);
 
 /*     fprintf(stderr, "%s\n", __FUNCTION__); */
@@ -151,10 +155,6 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
       {
         facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
 
-         if (DO_TWOSTENCIL && ctx->Stencil.TestTwoSide) {
-            ctx->_Facing = facing; /* mixed mode rendering: for 2-sided stencil test */
-         }
-
         if (DO_UNFILLED) {
            if (facing) {
               mode = ctx->Polygon.BackMode;
@@ -267,9 +267,9 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
            GLfloat bc  = b * ic;
            if ( ac < 0.0f ) ac = -ac;
            if ( bc < 0.0f ) bc = -bc;
-           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD;
         }
-        offset *= ctx->MRD;
+        offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
       }
    }
 
@@ -389,15 +389,15 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
 
 #if DO_QUAD
 #if DO_FULL_QUAD
-static void TAG(quad)( GLcontext *ctx,
+static void TAG(quadr)( GLcontext *ctx,
                       GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
    VERTEX *v[4];
-   GLfloat offset;
+   GLfloat offset = 0;
    GLfloat z[4];
    GLenum mode = GL_FILL;
-   GLuint facing;
+   GLuint facing = 0;
    LOCAL_VARS(4);
 
    v[0] = (VERTEX *)GET_VERTEX(e0);
@@ -417,10 +417,6 @@ static void TAG(quad)( GLcontext *ctx,
       {
         facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
 
-         if (DO_TWOSTENCIL && ctx->Stencil.TestTwoSide) {
-            ctx->_Facing = facing; /* mixed mode rendering: for 2-sided stencil test */
-         }
-
         if (DO_UNFILLED) {
            if (facing) {
               mode = ctx->Polygon.BackMode;
@@ -543,9 +539,9 @@ static void TAG(quad)( GLcontext *ctx,
            GLfloat bc  = b * ic;
            if ( ac < 0.0f ) ac = -ac;
            if ( bc < 0.0f ) bc = -bc;
-           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD;
         }
-        offset *= ctx->MRD;
+        offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
       }
    }
 
@@ -677,7 +673,7 @@ static void TAG(quad)( GLcontext *ctx,
    }
 }
 #else
-static void TAG(quad)( GLcontext *ctx, GLuint e0,
+static void TAG(quadr)( GLcontext *ctx, GLuint e0,
                       GLuint e1, GLuint e2, GLuint e3 )
 {
    if (DO_UNFILLED) {
@@ -744,7 +740,7 @@ static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
 static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
-   int i;
+   GLuint i;
    LOCAL_VARS(1);
 
    if (VB->Elts == 0) {
@@ -769,7 +765,7 @@ static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
 static void TAG(init)( void )
 {
 #if DO_QUAD
-   TAB[IND].quad = TAG(quad);
+   TAB[IND].quad = TAG(quadr);
 #endif
 #if DO_TRI
    TAB[IND].triangle = TAG(triangle);