radeonsi: isolate real framebuffer changes from the decompression passes (v3)
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 30 May 2017 20:36:28 +0000 (22:36 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 7 Jun 2017 18:17:14 +0000 (20:17 +0200)
When a stencil buffer is part of the framebuffer state, it is
decompressed but because it's bindless, all draw calls set
stencil_dirty_level_mask to 1.

v2: Marek - set the flags outside the loop
          - also clear and set framebuffer.do_update_surf_dirtiness there
          - do it in the DB->CB copy path too
v3: Marek - save and restore the do_update_surf_dirtiness flag

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_state.c

index 333f9cfb6020e854e0c25c9345ba7496d02106df..46cb6469b66c17f67a8a94de5c4430a67694e4f9 100644 (file)
@@ -120,6 +120,10 @@ si_blit_dbcb_copy(struct si_context *sctx,
 
        assert(sctx->dbcb_depth_copy_enabled || sctx->dbcb_stencil_copy_enabled);
 
+       bool old_update_dirtiness = sctx->framebuffer.do_update_surf_dirtiness;
+       sctx->decompression_enabled = true;
+       sctx->framebuffer.do_update_surf_dirtiness = false;
+
        while (level_mask) {
                unsigned level = u_bit_scan(&level_mask);
 
@@ -163,6 +167,8 @@ si_blit_dbcb_copy(struct si_context *sctx,
                        fully_copied_levels |= 1u << level;
        }
 
+       sctx->decompression_enabled = false;
+       sctx->framebuffer.do_update_surf_dirtiness = old_update_dirtiness;
        sctx->dbcb_depth_copy_enabled = false;
        sctx->dbcb_stencil_copy_enabled = false;
        si_mark_atom_dirty(sctx, &sctx->db_render_state);
@@ -218,6 +224,10 @@ si_blit_decompress_zs_planes_in_place(struct si_context *sctx,
 
        surf_tmpl.format = texture->resource.b.b.format;
 
+       bool old_update_dirtiness = sctx->framebuffer.do_update_surf_dirtiness;
+       sctx->decompression_enabled = true;
+       sctx->framebuffer.do_update_surf_dirtiness = false;
+
        while (level_mask) {
                unsigned level = u_bit_scan(&level_mask);
 
@@ -255,6 +265,8 @@ si_blit_decompress_zs_planes_in_place(struct si_context *sctx,
        if (planes & PIPE_MASK_S)
                texture->stencil_dirty_level_mask &= ~fully_decompressed_mask;
 
+       sctx->decompression_enabled = false;
+       sctx->framebuffer.do_update_surf_dirtiness = old_update_dirtiness;
        sctx->db_flush_depth_inplace = false;
        sctx->db_flush_stencil_inplace = false;
        si_mark_atom_dirty(sctx, &sctx->db_render_state);
@@ -438,6 +450,10 @@ static void si_blit_decompress_color(struct pipe_context *ctx,
                custom_blend = sctx->custom_blend_eliminate_fastclear;
        }
 
+       bool old_update_dirtiness = sctx->framebuffer.do_update_surf_dirtiness;
+       sctx->decompression_enabled = true;
+       sctx->framebuffer.do_update_surf_dirtiness = false;
+
        while (level_mask) {
                unsigned level = u_bit_scan(&level_mask);
 
@@ -468,6 +484,9 @@ static void si_blit_decompress_color(struct pipe_context *ctx,
                        rtex->dirty_level_mask &= ~(1 << level);
                }
        }
+
+       sctx->decompression_enabled = false;
+       sctx->framebuffer.do_update_surf_dirtiness = old_update_dirtiness;
 }
 
 static void
index 03e413306fb62b538881f1e1983c4197baecfa1b..9eb0297459fc968278fe406a276faaafff7707e3 100644 (file)
@@ -383,6 +383,7 @@ struct si_context {
 
        /* Other state */
        bool need_check_render_feedback;
+       bool                    decompression_enabled;
 
        /* Precomputed IA_MULTI_VGT_PARAM */
        union si_vgt_param_key  ia_multi_vgt_param_key;
index 28f5709742e9b5303402f88bd26eacfa54e6defb..458bc109eeb71952efe263ad1406ecaa2006ef87 100644 (file)
@@ -2608,9 +2608,15 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
                si_mark_atom_dirty(sctx, &sctx->msaa_sample_locs.atom);
        }
 
-       sctx->need_check_render_feedback = true;
        sctx->do_update_shaders = true;
-       sctx->framebuffer.do_update_surf_dirtiness = true;
+
+       if (!sctx->decompression_enabled) {
+               /* Prevent textures decompression when the framebuffer state
+                * changes come from the decompression passes themselves.
+                */
+               sctx->need_check_render_feedback = true;
+               sctx->framebuffer.do_update_surf_dirtiness = true;
+       }
 }
 
 static void si_emit_framebuffer_state(struct si_context *sctx, struct r600_atom *atom)