nvfx: fix GPU hardlocks when depth buffer is absent
[mesa.git] / src / gallium / drivers / nvfx / nvfx_state_emit.c
index 7a706ea6d77a80b283391e3e9b2e5fbd3fc323fc..19512194be6073de68152c1ace618edb0ae408df 100644 (file)
@@ -113,11 +113,19 @@ nvfx_state_validate_common(struct nvfx_context *nvfx)
    etracer, neverball, foobillard, glest totally misrender
    TODO: find the right fix
 */
-       if(dirty & (NVFX_NEW_VIEWPORT | NVFX_NEW_RAST | NVFX_NEW_ZSA) || (all_swizzled > 0))
+       if(dirty & (NVFX_NEW_VIEWPORT | NVFX_NEW_RAST | NVFX_NEW_ZSA) || (all_swizzled >= 0))
        {
                nvfx_state_viewport_validate(nvfx);
        }
 
+       if(dirty & NVFX_NEW_ZSA || (all_swizzled >= 0))
+       {
+               WAIT_RING(chan, 3);
+               OUT_RING(chan, RING_3D(NV34TCL_DEPTH_WRITE_ENABLE, 2));
+               OUT_RING(chan, nvfx->framebuffer.zsbuf && nvfx->zsa->pipe.depth.writemask);
+               OUT_RING(chan, nvfx->framebuffer.zsbuf && nvfx->zsa->pipe.depth.enabled);
+       }
+
        if(flush_tex_cache)
        {
                // TODO: what about nv30?