summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_state_surface.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-12-10 18:02:27 -0700
committerBrian Paul <brian.paul@tungstengraphics.com>2008-12-10 18:06:44 -0700
commitd0bc5293d6e1e9c34fa822b7c2928932ed22462c (patch)
tree097faccccfa6a17402b1cbb86c4db719bfea9fdf /src/gallium/drivers/softpipe/sp_state_surface.c
parent8137da952b6f30329adf7d49d2d9e58625534dd4 (diff)
gallium: added draw_set_mrd() function to fix polygon offset
The Minimum Resolvable Depth factor depends on the driver and can't just be computed from the number of Z buffer bits. Glean's polygon offset test now passes with softpipe. Still need to determine the MRD factor for other gallium drivers, if they use the draw module's polygon offset stage...
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_state_surface.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_state_surface.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index ba8c9eece7..8877b18af9 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -101,6 +101,26 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
}
#endif
+ /* Tell draw module how deep the Z/depth buffer is */
+ {
+ int depth_bits;
+ double mrd;
+ if (sp->framebuffer.zsbuf) {
+ depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format,
+ PIPE_FORMAT_COMP_Z);
+ }
+ else {
+ depth_bits = 0;
+ }
+ if (depth_bits > 16) {
+ mrd = 0.0000001;
+ }
+ else {
+ mrd = 0.00002;
+ }
+ draw_set_mrd(sp->draw, mrd);
+ }
+
sp->framebuffer.width = fb->width;
sp->framebuffer.height = fb->height;