r600g: don't decompress depth or stencil if there isn't any
authorMarek Olšák <maraeo@gmail.com>
Sat, 28 Jul 2012 11:55:59 +0000 (13:55 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sat, 4 Aug 2012 11:53:07 +0000 (13:53 +0200)
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state.c

index 87a301fa0405b76fa42f8b3be1a0bfd6e50436db..75ed9eff35e33c33f50cbbb270f7cc3cce7ebe2b 100644 (file)
@@ -1722,9 +1722,12 @@ static void evergreen_emit_db_misc_state(struct r600_context *rctx, struct r600_
                db_count_control |= S_028004_PERFECT_ZPASS_COUNTS(1);
                db_render_override |= S_02800C_NOOP_CULL_DISABLE(1);
        }
+
        if (a->flush_depthstencil_through_cb) {
-               db_render_control |= S_028000_DEPTH_COPY_ENABLE(1) |
-                                    S_028000_STENCIL_COPY_ENABLE(1) |
+               assert(a->copy_depth || a->copy_stencil);
+
+               db_render_control |= S_028000_DEPTH_COPY_ENABLE(a->copy_depth) |
+                                    S_028000_STENCIL_COPY_ENABLE(a->copy_stencil) |
                                     S_028000_COPY_CENTROID(1);
        }
 
index 9c4e911bee0bf0ed745e4231a4fcf36b5760f8cb..3623b2e7ae201647edefcd31450a2b4cd46d04d3 100644 (file)
@@ -130,6 +130,8 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
        float depth = 1.0f;
        struct r600_resource_texture *flushed_depth_texture = staging ?
                        staging : texture->flushed_depth_texture;
+       const struct util_format_description *desc =
+               util_format_description(texture->resource.b.b.format);
 
        if (!staging && !texture->dirty_db_mask)
                return;
@@ -138,11 +140,11 @@ void r600_blit_uncompress_depth(struct pipe_context *ctx,
            rctx->family == CHIP_RV620 || rctx->family == CHIP_RV635)
                depth = 0.0f;
 
-       if (!rctx->db_misc_state.flush_depthstencil_through_cb) {
-               /* Enable decompression in DB_RENDER_CONTROL */
-               rctx->db_misc_state.flush_depthstencil_through_cb = true;
-               r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
-       }
+       /* Enable decompression in DB_RENDER_CONTROL */
+       rctx->db_misc_state.flush_depthstencil_through_cb = true;
+       rctx->db_misc_state.copy_depth = util_format_has_depth(desc);
+       rctx->db_misc_state.copy_stencil = util_format_has_stencil(desc);
+       r600_atom_dirty(rctx, &rctx->db_misc_state.atom);
 
        for (level = first_level; level <= last_level; level++) {
                if (!staging && !(texture->dirty_db_mask & (1 << level)))
index 724707e0fb848d37bfb38ff939fbbc26df80fd94..7f50739506a6b099638dfbef11668d5f0128df39 100644 (file)
@@ -80,6 +80,7 @@ struct r600_db_misc_state {
        struct r600_atom atom;
        bool occlusion_query_enabled;
        bool flush_depthstencil_through_cb;
+       bool copy_depth, copy_stencil;
 };
 
 struct r600_cb_misc_state {
index 82f5ffb16f3a026c0ae08e50085183a8fead1ec0..9d9ee1f0de2dee6f1cd86ed94eb85a0f8dab7831 100644 (file)
@@ -1684,8 +1684,10 @@ static void r600_emit_db_misc_state(struct r600_context *rctx, struct r600_atom
                db_render_override |= S_028D10_NOOP_CULL_DISABLE(1);
        }
        if (a->flush_depthstencil_through_cb) {
-               db_render_control |= S_028D0C_DEPTH_COPY_ENABLE(1) |
-                                    S_028D0C_STENCIL_COPY_ENABLE(1) |
+               assert(a->copy_depth || a->copy_stencil);
+
+               db_render_control |= S_028D0C_DEPTH_COPY_ENABLE(a->copy_depth) |
+                                    S_028D0C_STENCIL_COPY_ENABLE(a->copy_stencil) |
                                     S_028D0C_COPY_CENTROID(1);
        }