summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_emit.c
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2011-05-29 04:36:36 +0200
committerMarek Olšák <maraeo@gmail.com>2011-05-29 05:15:27 +0200
commitf76787b3eae3f0b8af839fabfb24b57715a017f6 (patch)
tree5818a1c505a045b525971e0cc60dff4185ee58e0 /src/gallium/drivers/r300/r300_emit.c
parentd18792f93d6dcdf7ef971522bdfba1ceeb0c6668 (diff)
downloadexternal_mesa3d-f76787b3eae3f0b8af839fabfb24b57715a017f6.zip
external_mesa3d-f76787b3eae3f0b8af839fabfb24b57715a017f6.tar.gz
external_mesa3d-f76787b3eae3f0b8af839fabfb24b57715a017f6.tar.bz2
r300g: fix occlusion queries when depth test is disabled or zbuffer is missing
From now on, depth test is always enabled in hardware. If depth test is disabled in Gallium, the hardware Z function is set to ALWAYS. If there is no zbuffer set, the colorbuffer0 memory is set as a zbuffer to silence the CS checker. This fixes piglit: - occlusion-query-discard - NV_conditional_render/bitmap - NV_conditional_render/drawpixels - NV_conditional_render/vertex_array
Diffstat (limited to 'src/gallium/drivers/r300/r300_emit.c')
-rw-r--r--src/gallium/drivers/r300/r300_emit.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 874037e..5d6188e 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -439,6 +439,19 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
OUT_CS_REG(R300_ZB_ZMASK_OFFSET, 0);
OUT_CS_REG(R300_ZB_ZMASK_PITCH, surf->pitch_zmask);
}
+ /* Set up a dummy zbuffer. Otherwise occlusion queries won't work.
+ * Use the first colorbuffer, we will disable writes in the DSA state
+ * so as not to corrupt it. */
+ } else if (fb->nr_cbufs) {
+ surf = r300_surface(fb->cbufs[0]);
+
+ OUT_CS_REG(R300_ZB_FORMAT, R300_DEPTHFORMAT_16BIT_INT_Z);
+
+ OUT_CS_REG(R300_ZB_DEPTHOFFSET, 0);
+ OUT_CS_RELOC(surf);
+
+ OUT_CS_REG(R300_ZB_DEPTHPITCH, 4 | R300_DEPTHMICROTILE_TILED);
+ OUT_CS_RELOC(surf);
}
END_CS;