nouveau: nv10: rescale depth near and far
authorPatrice Mandin <pmandin@caramail.com>
Fri, 16 Feb 2007 18:54:55 +0000 (19:54 +0100)
committerPatrice Mandin <pmandin@caramail.com>
Fri, 16 Feb 2007 18:54:55 +0000 (19:54 +0100)
src/mesa/drivers/dri/nouveau/nv10_state.c

index e64fcb12f56913d97b55a1670a49596dfe1c1129..803dd962b597070185d9beb768ba9541893c6e00 100644 (file)
@@ -187,9 +187,15 @@ static void nv10DepthMask(GLcontext *ctx, GLboolean flag)
 static void nv10DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
 {
        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
+
+       GLfloat depth_scale = 16777216.0;
+       if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 16) {
+               depth_scale = 32768.0;
+       }
+
        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval);
-       OUT_RING_CACHEf(farval);
+       OUT_RING_CACHEf(nearval * depth_scale);
+       OUT_RING_CACHEf(farval * depth_scale);
 
        nv10ViewportScale(nmesa);
 }