From f8bc628b2ceb13c8d1ddfa28b81dbef4159928b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 24 Jan 2017 23:37:56 +0100 Subject: [PATCH] gallium/radeon: merge dirty_fb_counter and dirty_tex_descriptor_counter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit to simplify things in draw_vbo a little Reviewed-by: Nicolai Hähnle --- src/gallium/drivers/r600/r600_state_common.c | 8 ++++---- src/gallium/drivers/radeon/r600_pipe_common.h | 21 ++++++++------------- src/gallium/drivers/radeon/r600_texture.c | 18 +++++------------- src/gallium/drivers/radeonsi/si_state_draw.c | 16 +++++----------- 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index a9dbc8b..c8502e9 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -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); } diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index fb5bf75..6eff9aa 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -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; diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 0b77c82..55c8e6f 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -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, diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c index 16d9057..b6bd3f1 100644 --- a/src/gallium/drivers/radeonsi/si_state_draw.c +++ b/src/gallium/drivers/radeonsi/si_state_draw.c @@ -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); } -- 2.7.4