summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/savage/savageioctl.c
diff options
context:
space:
mode:
authorFelix Kuehling <[email protected]>2005-01-03 22:24:44 +0000
committerFelix Kuehling <[email protected]>2005-01-03 22:24:44 +0000
commite3748eb19ba444f411ad66905dfddbe809225ca0 (patch)
tree726327849feaf57de43d5992201190042f252020 /src/mesa/drivers/dri/savage/savageioctl.c
parent87889aeab46ece5800cca9390fe95e83515b313d (diff)
Added support for floating point depth buffers on Savage4-based
hardware. By also reversing the depth range this can compensate the loss of accuracy of far objects caused by the projective transformation. Software fallbacks work but are slightly slower since floats in a custom (non IEEE) format have to be encoded and decoded. I havn't done anything about polygon offsets yet. There doesn't seem to be an easy way do get it right except making the offset unit as big as the lowest resolution of depth values. For now float depth is disabled by default but can be enabled through driconf (though I have seen only positive effects so far).
Diffstat (limited to 'src/mesa/drivers/dri/savage/savageioctl.c')
-rw-r--r--src/mesa/drivers/dri/savage/savageioctl.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c
index dd7a84e2e72..62e7142d246 100644
--- a/src/mesa/drivers/dri/savage/savageioctl.c
+++ b/src/mesa/drivers/dri/savage/savageioctl.c
@@ -38,6 +38,7 @@
#include "savageioctl.h"
#include "savage_bci.h"
#include "savagestate.h"
+#include "savagespan.h"
#include "drm.h"
#include <sys/ioctl.h>
@@ -333,10 +334,17 @@ static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
fprintf (stderr, "%s\n", __FUNCTION__);
clearColor = imesa->ClearColor;
- if(imesa->savageScreen->zpp == 2)
- clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_16);
- else
- clearDepth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE_24);
+ if (imesa->float_depth) {
+ if (imesa->savageScreen->zpp == 2)
+ clearDepth = savageEncodeFloat16(1.0 - ctx->Depth.Clear);
+ else
+ clearDepth = savageEncodeFloat24(1.0 - ctx->Depth.Clear);
+ } else {
+ if (imesa->savageScreen->zpp == 2)
+ clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_16);
+ else
+ clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_24);
+ }
colorMask = *((GLuint *) &ctx->Color.ColorMask);
depthMask = 0;