r300g: fix another crash with hyperz
authorMarek Olšák <maraeo@gmail.com>
Fri, 8 Apr 2011 21:16:17 +0000 (23:16 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 8 Apr 2011 21:17:15 +0000 (23:17 +0200)
https://bugs.freedesktop.org/show_bug.cgi?id=36086

src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_state.c

index 056b52f25dd502f726b7ef47712b7a4c94b6ce2f..ede0a2317d88e7da9297ae2dac9e13411dbba322 100644 (file)
@@ -304,16 +304,10 @@ static void r300_clear_render_target(struct pipe_context *pipe,
 {
     struct r300_context *r300 = r300_context(pipe);
 
-    r300->hyperz_locked = TRUE;
-    r300_mark_atom_dirty(r300, &r300->hyperz_state);
-
     r300_blitter_begin(r300, R300_CLEAR_SURFACE);
     util_blitter_clear_render_target(r300->blitter, dst, rgba,
                                      dstx, dsty, width, height);
     r300_blitter_end(r300);
-
-    r300->hyperz_locked = FALSE;
-    r300_mark_atom_dirty(r300, &r300->hyperz_state);
 }
 
 /* Clear a region of a depth stencil surface. */
@@ -332,21 +326,14 @@ static void r300_clear_depth_stencil(struct pipe_context *pipe,
     if (r300->zmask_in_use && !r300->hyperz_locked) {
         if (fb->zsbuf->texture == dst->texture) {
             r300_decompress_zmask(r300);
-        } else {
-            r300->hyperz_locked = TRUE;
-            r300_mark_atom_dirty(r300, &r300->hyperz_state);
         }
     }
 
+    /* XXX Do not decompress ZMask of the currently-set zbuffer. */
     r300_blitter_begin(r300, R300_CLEAR_SURFACE);
     util_blitter_clear_depth_stencil(r300->blitter, dst, clear_flags, depth, stencil,
                                      dstx, dsty, width, height);
     r300_blitter_end(r300);
-
-    if (r300->hyperz_locked) {
-        r300->hyperz_locked = FALSE;
-        r300_mark_atom_dirty(r300, &r300->hyperz_state);
-    }
 }
 
 void r300_decompress_zmask(struct r300_context *r300)
@@ -433,9 +420,6 @@ static void r300_resource_copy_region(struct pipe_context *pipe,
         if (fb->zsbuf->texture == src ||
             fb->zsbuf->texture == dst) {
             r300_decompress_zmask(r300);
-        } else {
-            r300->hyperz_locked = TRUE;
-            r300_mark_atom_dirty(r300, &r300->hyperz_state);
         }
     }
 
@@ -511,11 +495,6 @@ static void r300_resource_copy_region(struct pipe_context *pipe,
         r300_resource_set_properties(pipe->screen, src, 0, &old_src);
     if (old_dst.format != new_dst.format)
         r300_resource_set_properties(pipe->screen, dst, 0, &old_dst);
-
-    if (r300->hyperz_locked) {
-        r300->hyperz_locked = FALSE;
-        r300_mark_atom_dirty(r300, &r300->hyperz_state);
-    }
 }
 
 void r300_init_blit_functions(struct r300_context *r300)
index 61d6751e5d325d96bb6ab2688f0cc658d70f35a6..c92f871829a57705b50162287609dbb729e5b324 100644 (file)
@@ -856,6 +856,7 @@ r300_set_framebuffer_state(struct pipe_context* pipe,
             }
         }
     }
+    assert(state->zsbuf || r300->hyperz_locked || !r300->zmask_in_use);
 
     /* Need to reset clamping or colormask. */
     r300_mark_atom_dirty(r300, &r300->blend_state);