summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorFelix Kuehling <fxkuehl@gmx.de>2005-01-23 01:42:01 +0000
committerFelix Kuehling <fxkuehl@gmx.de>2005-01-23 01:42:01 +0000
commit3b50f004333a922a259a4f733395c27002965ded (patch)
tree2ad70683c6932caca4218fb48f095147a52f1052 /src/mesa
parent36a35c5614336bffdac4827c1e04bcaa8ab2fa27 (diff)
My last attempt to fix polygon offsets with the reversed viewport depth
range used by the savage driver by negating ctx->MRD broke polygon offsets with software fallbacks. This one adds a REVERSE_DEPTH parameter to t_dd_tritmp.h (defaults to 0) that allows reversing polygon offsets for hardware rendering but not for software fallbacks. For software fallbacks depth values are reversed after polygon offsets have been applied by the depth span functions.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c3
-rw-r--r--src/mesa/drivers/dri/savage/savagetris.c1
-rw-r--r--src/mesa/tnl_dd/t_dd_tritmp.h11
3 files changed, 9 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 9814288933..c2eb8d10b1 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -394,9 +394,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
ctx->Const.MaxLineWidthAA = 3.0;
ctx->Const.LineWidthGranularity = 1.0;
#endif
- /* This is needed to get polygon offset right with reversed depth range
- * (see savageCalcViewport). Not sure if it has any other side effects. */
- ctx->MRD *= -1.0;
/* Dri stuff
*/
diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c
index fdd0f12724..f5faa3fe56 100644
--- a/src/mesa/drivers/dri/savage/savagetris.c
+++ b/src/mesa/drivers/dri/savage/savagetris.c
@@ -388,6 +388,7 @@ static struct {
#define TAB rast_tab
#define DEPTH_SCALE imesa->depth_scale
+#define REVERSE_DEPTH 1
#define UNFILLED_TRI unfilled_tri
#define UNFILLED_QUAD unfilled_quad
#define VERT_X(_v) _v->v.x
diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h
index 5b17a6f6f0..bc1617eae3 100644
--- a/src/mesa/tnl_dd/t_dd_tritmp.h
+++ b/src/mesa/tnl_dd/t_dd_tritmp.h
@@ -49,7 +49,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.
@@ -108,6 +109,10 @@
#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
@@ -269,7 +274,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if ( bc < 0.0f ) bc = -bc;
offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
}
- offset *= ctx->MRD;
+ offset *= REVERSE_DEPTH ? -ctx->MRD : ctx->MRD;
}
}
@@ -545,7 +550,7 @@ static void TAG(quad)( GLcontext *ctx,
if ( bc < 0.0f ) bc = -bc;
offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
}
- offset *= ctx->MRD;
+ offset *= REVERSE_DEPTH ? -ctx->MRD : ctx->MRD;
}
}