gallium/radeon: merge dirty_fb_counter and dirty_tex_descriptor_counter
authorMarek Olšák <marek.olsak@amd.com>
Tue, 24 Jan 2017 22:37:56 +0000 (23:37 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 30 Jan 2017 16:45:29 +0000 (17:45 +0100)
to simplify things in draw_vbo a little

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c
src/gallium/drivers/radeonsi/si_state_draw.c

index a9dbc8bc982f0329a4cb141da1e008a0b966e5ac..c8502e90ea9ab020a27ac2ce5dc11606b25fcc15 100644 (file)
@@ -1669,7 +1669,7 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
        struct radeon_winsys_cs *cs = rctx->b.gfx.cs;
        bool render_cond_bit = rctx->b.render_cond && !rctx->b.render_cond_force_off;
        uint64_t mask;
-       unsigned num_patches, dirty_fb_counter;
+       unsigned num_patches, dirty_tex_counter;
 
        if (!info.indirect && !info.count && (info.indexed || !info.count_from_stream_output)) {
                return;
@@ -1686,9 +1686,9 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info
        }
 
        /* Re-emit the framebuffer state if needed. */
-       dirty_fb_counter = p_atomic_read(&rctx->b.screen->dirty_fb_counter);
-       if (dirty_fb_counter != rctx->b.last_dirty_fb_counter) {
-               rctx->b.last_dirty_fb_counter = dirty_fb_counter;
+       dirty_tex_counter = p_atomic_read(&rctx->b.screen->dirty_tex_counter);
+       if (dirty_tex_counter != rctx->b.last_dirty_tex_counter) {
+               rctx->b.last_dirty_tex_counter = dirty_tex_counter;
                r600_mark_atom_dirty(rctx, &rctx->framebuffer.atom);
        }
 
index fb5bf75df153f650fc4302f6091b2c4c31e53f66..6eff9aaf0951e56d1ef0e6aae7fe84c78f96b835 100644 (file)
@@ -431,12 +431,14 @@ struct r600_common_screen {
        /* Performance counters. */
        struct r600_perfcounters        *perfcounters;
 
-       /* If pipe_screen wants to re-emit the framebuffer state of all
-        * contexts, it should atomically increment this. Each context will
-        * compare this with its own last known value of the counter before
-        * drawing and re-emit the framebuffer state accordingly.
+       /* If pipe_screen wants to recompute and re-emit the framebuffer,
+        * sampler, and image states of all contexts, it should atomically
+        * increment this.
+        *
+        * Each context will compare this with its own last known value of
+        * the counter before drawing and re-emit the states accordingly.
         */
-       unsigned                        dirty_fb_counter;
+       unsigned                        dirty_tex_counter;
 
        /* Atomically increment this counter when an existing texture's
         * metadata is enabled or disabled in a way that requires changing
@@ -444,12 +446,6 @@ struct r600_common_screen {
         */
        unsigned                        compressed_colortex_counter;
 
-       /* Atomically increment this counter when an existing texture's
-        * backing buffer or tile mode parameters have changed that requires
-        * recomputation of shader descriptors.
-        */
-       unsigned                        dirty_tex_descriptor_counter;
-
        struct {
                /* Context flags to set so that all writes from earlier jobs
                 * in the CP are seen by L2 clients.
@@ -568,9 +564,8 @@ struct r600_common_context {
        unsigned                        num_gfx_cs_flushes;
        unsigned                        initial_gfx_cs_size;
        unsigned                        gpu_reset_counter;
-       unsigned                        last_dirty_fb_counter;
+       unsigned                        last_dirty_tex_counter;
        unsigned                        last_compressed_colortex_counter;
-       unsigned                        last_dirty_tex_descriptor_counter;
 
        struct u_upload_mgr             *uploader;
        struct u_suballocator           *allocator_zeroed_memory;
index 0b77c82949012e457dd032ca0f1b74b156c3a9ff..55c8e6f78427504a97e975e7698abe4ee6edec66 100644 (file)
@@ -298,11 +298,6 @@ static void r600_texture_init_metadata(struct r600_texture *rtex,
        metadata->scanout = (surface->flags & RADEON_SURF_SCANOUT) != 0;
 }
 
-static void r600_dirty_all_framebuffer_states(struct r600_common_screen *rscreen)
-{
-       p_atomic_inc(&rscreen->dirty_fb_counter);
-}
-
 static void r600_eliminate_fast_color_clear(struct r600_common_context *rctx,
                                            struct r600_texture *rtex)
 {
@@ -341,7 +336,7 @@ static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,
            r600_resource_reference(&rtex->cmask_buffer, NULL);
 
        /* Notify all contexts about the change. */
-       r600_dirty_all_framebuffer_states(rscreen);
+       p_atomic_inc(&rscreen->dirty_tex_counter);
        p_atomic_inc(&rscreen->compressed_colortex_counter);
 }
 
@@ -365,7 +360,7 @@ static bool r600_texture_discard_dcc(struct r600_common_screen *rscreen,
        rtex->dcc_offset = 0;
 
        /* Notify all contexts about the change. */
-       r600_dirty_all_framebuffer_states(rscreen);
+       p_atomic_inc(&rscreen->dirty_tex_counter);
        return true;
 }
 
@@ -480,8 +475,7 @@ static void r600_degrade_tile_mode_to_linear(struct r600_common_context *rctx,
 
        r600_texture_reference(&new_tex, NULL);
 
-       r600_dirty_all_framebuffer_states(rctx->screen);
-       p_atomic_inc(&rctx->screen->dirty_tex_descriptor_counter);
+       p_atomic_inc(&rctx->screen->dirty_tex_counter);
 }
 
 static boolean r600_texture_get_handle(struct pipe_screen* screen,
@@ -1419,8 +1413,7 @@ static void r600_texture_invalidate_storage(struct r600_common_context *rctx,
        rtex->cmask.base_address_reg =
                (rtex->resource.gpu_address + rtex->cmask.offset) >> 8;
 
-       r600_dirty_all_framebuffer_states(rscreen);
-       p_atomic_inc(&rscreen->dirty_tex_descriptor_counter);
+       p_atomic_inc(&rscreen->dirty_tex_counter);
 
        rctx->num_alloc_tex_transfer_bytes += rtex->size;
 }
@@ -2403,8 +2396,7 @@ static void si_set_optimal_micro_tile_mode(struct r600_common_screen *rscreen,
 
        rtex->surface.micro_tile_mode = rtex->last_msaa_resolve_target_micro_mode;
 
-       p_atomic_inc(&rscreen->dirty_fb_counter);
-       p_atomic_inc(&rscreen->dirty_tex_descriptor_counter);
+       p_atomic_inc(&rscreen->dirty_tex_counter);
 }
 
 void evergreen_do_fast_color_clear(struct r600_common_context *rctx,
index 16d905772a6fff8629d7738e7604120c9fb31da0..b6bd3f186ad85c9fc762b8e2379982c60ad4fbed 100644 (file)
@@ -957,7 +957,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
        struct si_context *sctx = (struct si_context *)ctx;
        struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
        struct pipe_index_buffer ib = {};
-       unsigned mask, dirty_fb_counter, dirty_tex_counter, rast_prim;
+       unsigned mask, dirty_tex_counter, rast_prim;
 
        if (likely(!info->indirect)) {
                /* SI-CI treat instance_count==0 as instance_count==1. There is
@@ -986,21 +986,15 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
                return;
        }
 
-       /* Re-emit the framebuffer state if needed. */
-       dirty_fb_counter = p_atomic_read(&sctx->b.screen->dirty_fb_counter);
-       if (unlikely(dirty_fb_counter != sctx->b.last_dirty_fb_counter)) {
-               sctx->b.last_dirty_fb_counter = dirty_fb_counter;
+       /* Recompute and re-emit the texture resource states if needed. */
+       dirty_tex_counter = p_atomic_read(&sctx->b.screen->dirty_tex_counter);
+       if (unlikely(dirty_tex_counter != sctx->b.last_dirty_tex_counter)) {
+               sctx->b.last_dirty_tex_counter = dirty_tex_counter;
                sctx->framebuffer.dirty_cbufs |=
                        ((1 << sctx->framebuffer.state.nr_cbufs) - 1);
                sctx->framebuffer.dirty_zsbuf = true;
                sctx->framebuffer.do_update_surf_dirtiness = true;
                si_mark_atom_dirty(sctx, &sctx->framebuffer.atom);
-       }
-
-       /* Invalidate & recompute texture descriptors if needed. */
-       dirty_tex_counter = p_atomic_read(&sctx->b.screen->dirty_tex_descriptor_counter);
-       if (unlikely(dirty_tex_counter != sctx->b.last_dirty_tex_descriptor_counter)) {
-               sctx->b.last_dirty_tex_descriptor_counter = dirty_tex_counter;
                si_update_all_texture_descriptors(sctx);
        }