summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300/r300_state.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-05-29 04:36:36 +0200
committerMarek Olšák <[email protected]>2011-05-29 05:15:27 +0200
commitf76787b3eae3f0b8af839fabfb24b57715a017f6 (patch)
tree5818a1c505a045b525971e0cc60dff4185ee58e0 /src/gallium/drivers/r300/r300_state.c
parentd18792f93d6dcdf7ef971522bdfba1ceeb0c6668 (diff)
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_state.c')
-rw-r--r--src/gallium/drivers/r300/r300_state.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index bc6c67dd034..84d9da3ad9d 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -549,6 +549,10 @@ static void*
dsa->z_stencil_control |=
(r300_translate_depth_stencil_function(state->depth.func) <<
R300_Z_FUNC_SHIFT);
+ } else {
+ /* We must enable depth test, otherwise occlusion queries won't work. */
+ dsa->z_buffer_control |= R300_Z_ENABLE;
+ dsa->z_stencil_control |= R300_ZS_ALWAYS;
}
/* Stencil buffer setup. */
@@ -632,11 +636,13 @@ static void*
OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
END_CB;
+ /* We must enable depth test, otherwise occlusion queries won't work.
+ * We setup a dummy zbuffer to silent the CS checker, see emit_fb_state. */
BEGIN_CB(dsa->cb_zb_no_readwrite, 10);
OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
OUT_CB_REG_SEQ(R300_ZB_CNTL, 3);
- OUT_CB(0);
- OUT_CB(0);
+ OUT_CB(R300_Z_ENABLE);
+ OUT_CB(R300_ZS_ALWAYS);
OUT_CB(0);
OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0);
OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
@@ -645,8 +651,8 @@ static void*
BEGIN_CB(dsa->cb_fp16_zb_no_readwrite, 10);
OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function_fp16);
OUT_CB_REG_SEQ(R300_ZB_CNTL, 3);
- OUT_CB(0);
- OUT_CB(0);
+ OUT_CB(R300_Z_ENABLE);
+ OUT_CB(R300_ZS_ALWAYS);
OUT_CB(0);
OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0);
OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
@@ -792,12 +798,14 @@ void r300_mark_fb_state_dirty(struct r300_context *r300,
/* Now compute the fb_state atom size. */
r300->fb_state.size = 2 + (8 * state->nr_cbufs);
- if (r300->cbzb_clear)
+ if (r300->cbzb_clear) {
r300->fb_state.size += 10;
- else if (state->zsbuf) {
+ } else if (state->zsbuf) {
r300->fb_state.size += 10;
if (r300->hyperz_enabled)
r300->fb_state.size += 8;
+ } else if (state->nr_cbufs) {
+ r300->fb_state.size += 10;
}
/* The size of the rest of atoms stays the same. */