r300g: do not use fastfill if ZMask RAM is not properly initialized
authorMarek Olšák <maraeo@gmail.com>
Sat, 14 Aug 2010 16:37:04 +0000 (18:37 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 15 Aug 2010 06:07:11 +0000 (08:07 +0200)
z_fastfill -> dirty_zmask[level].

src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_hyperz.c
src/gallium/drivers/r300/r300_state.c

index 5fe9b9017d1f05701d4338fbe53c9e2bb7e57748..d44f53ec6f38a1b769c63a93ff06037a90f67ec9 100644 (file)
@@ -99,9 +99,6 @@ static boolean r300_cbzb_clear_allowed(struct r300_context *r300,
     struct pipe_framebuffer_state *fb =
         (struct pipe_framebuffer_state*)r300->fb_state.state;
 
-    if (r300->z_fastfill)
-        clear_buffers &= ~(PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL);
-
     /* Only color clear allowed, and only one colorbuffer. */
     if (clear_buffers != PIPE_CLEAR_COLOR || fb->nr_cbufs != 1)
         return FALSE;
@@ -186,8 +183,10 @@ static void r300_clear(struct pipe_context* pipe,
             r300_depth_clear_value(fb->zsbuf->format, depth, stencil);
 
         r300_mark_fb_state_dirty(r300, R300_CHANGED_ZCLEAR_FLAG);
-        if (r300->z_compression || r300->z_fastfill)
+        if (r300_texture(fb->zsbuf->texture)->zmask_mem[fb->zsbuf->level]) {
             r300->zmask_clear.dirty = TRUE;
+            buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
+        }
         if (r300->hiz_enable)
             r300->hiz_clear.dirty = TRUE;
     }
@@ -222,6 +221,15 @@ static void r300_clear(struct pipe_context* pipe,
         r300_mark_fb_state_dirty(r300, R300_CHANGED_CBZB_FLAG);
     }
 
+    /* Enable fastfill.
+     *
+     * If we cleared the zmask, it's dirty now. The Hyper-Z state update
+     * looks for a dirty zmask and enables fastfill accordingly. */
+    if (fb->zsbuf &&
+        r300_texture(fb->zsbuf->texture)->dirty_zmask[fb->zsbuf->level]) {
+        r300->hyperz_state.dirty = TRUE;
+    }
+
     /* XXX this flush "fixes" a hardlock in the cubestorm xscreensaver */
     if (r300->flush_counter == 0)
         pipe->flush(pipe, 0, NULL);
index 8b772f388744246a35cb836dca6346b53aae4556..98e6d358e91c0399dbb2bcf2eecf323b8fea8bb1 100644 (file)
@@ -565,8 +565,6 @@ struct r300_context {
     boolean two_sided_color;
     /* Incompatible vertex buffer layout? (misaligned stride or buffer_offset) */
     boolean incompatible_vb_layout;
-    /* Whether fast zclear is enabled. */
-    boolean z_fastfill;
 #define R300_Z_COMPRESS_44 1
 #define RV350_Z_COMPRESS_88 2
     int z_compression;
index 3b0adc358464e58e4e688255ed4e10ad4aeede58..1f6244c49e6681e3ece83b60a50f14cd3284d68a 100644 (file)
@@ -129,6 +129,9 @@ static void r300_update_hyperz(struct r300_context* r300)
 {
     struct r300_hyperz_state *z =
         (struct r300_hyperz_state*)r300->hyperz_state.state;
+    struct pipe_framebuffer_state *fb =
+        (struct pipe_framebuffer_state*)r300->fb_state.state;
+    boolean dirty_zmask = FALSE;
 
     z->gb_z_peq_config = 0;
     z->zb_bw_cntl = 0;
@@ -140,23 +143,29 @@ static void r300_update_hyperz(struct r300_context* r300)
         return;
     }
 
+    if (!fb->zsbuf)
+        return;
+
     if (!r300->rws->get_value(r300->rws, R300_CAN_HYPERZ))
         return;
 
+    dirty_zmask = r300_texture(fb->zsbuf->texture)->dirty_zmask[fb->zsbuf->level];
+
+    /* Z fastfill. */
+    if (dirty_zmask) {
+        z->zb_bw_cntl |= R300_FAST_FILL_ENABLE; /*  | R300_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE;*/
+    }
+
     /* Zbuffer compression. */
-    if (r300->z_compression) {
+    if (dirty_zmask && r300->z_compression) {
         z->zb_bw_cntl |= R300_RD_COMP_ENABLE;
         if (r300->z_decomp_rd == false)
             z->zb_bw_cntl |= R300_WR_COMP_ENABLE;
-       /* RV350 and up optimizations. */
-       if (r300->z_compression == RV350_Z_COMPRESS_88)
-           z->gb_z_peq_config |= R300_GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8;
-    }
-
-    /* Z fastfill. */
-    if (r300->z_fastfill) {
-        z->zb_bw_cntl |= R300_FAST_FILL_ENABLE; /*  | R300_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE;*/
     }
+    /* RV350 and up optimizations. */
+    /* The section 10.4.9 in the docs is a lie. */
+    if (r300->z_compression == RV350_Z_COMPRESS_88)
+        z->gb_z_peq_config |= R300_GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8;
 
     if (r300->hiz_enable) {
         bool can_hiz = r300_can_hiz(r300);
index 8abc65a2b8e3460ee88d7235f26c1f5f080a4805..9afaa5f6516d5ad8467b20b4569c1c243b8f420d 100644 (file)
@@ -753,7 +753,6 @@ static void
     r300_mark_fb_state_dirty(r300, R300_CHANGED_FB_STATE);
 
     r300->hiz_enable = false;
-    r300->z_fastfill = false;
     r300->z_compression = false;
     
     if (state->zsbuf) {
@@ -785,7 +784,6 @@ static void
             }
 
             if (tex->zmask_mem[level]) {
-                r300->z_fastfill = 1;
                 /* compression causes hangs on 16-bit */
                 if (zbuffer_bpp == 24)
                     r300->z_compression = compress;
@@ -793,7 +791,7 @@ static void
             DBG(r300, DBG_HYPERZ,
                 "hyper-z features: hiz: %d @ %08x z-compression: %d z-fastfill: %d @ %08x\n", r300->hiz_enable,
                 tex->hiz_mem[level] ? tex->hiz_mem[level]->ofs : 0xdeadbeef,
-                r300->z_compression, r300->z_fastfill,
+                r300->z_compression, tex->zmask_mem[level] ? 1 : 0,
                 tex->zmask_mem[level] ? tex->zmask_mem[level]->ofs : 0xdeadbeef);
         }