diff options
author | Marek Olšák <[email protected]> | 2017-01-17 20:46:39 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-01-18 19:51:31 +0100 |
commit | 861d7af1cb33483902796f5b29ce496e4a322e94 (patch) | |
tree | 86c8ffcab97f4e7e5ae1b1450fb8f67eb265e516 | |
parent | 4bde7d3d3c90e3930e56b83f8e517d6ce6ea26d4 (diff) |
radeonsi: use a bitmask-based loop in si_decompress_textures
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/gallium/drivers/radeonsi/si_blit.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_descriptors.c | 21 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.h | 1 |
3 files changed, 31 insertions, 7 deletions
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index 5b533732a4d..da6c0cda2bb 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -618,10 +618,9 @@ static void si_check_render_feedback(struct si_context *sctx) sctx->need_check_render_feedback = false; } -static void si_decompress_textures(struct si_context *sctx, int shader_start, - int shader_end) +static void si_decompress_textures(struct si_context *sctx, unsigned shader_mask) { - unsigned compressed_colortex_counter; + unsigned compressed_colortex_counter, mask; if (sctx->blitter->running) return; @@ -633,8 +632,11 @@ static void si_decompress_textures(struct si_context *sctx, int shader_start, si_update_compressed_colortex_masks(sctx); } - /* Flush depth textures which need to be flushed. */ - for (int i = shader_start; i < shader_end; i++) { + /* Decompress color & depth textures if needed. */ + mask = sctx->compressed_tex_shader_mask & shader_mask; + while (mask) { + unsigned i = u_bit_scan(&mask); + if (sctx->samplers[i].depth_texture_mask) { si_flush_depth_textures(sctx, &sctx->samplers[i]); } @@ -651,12 +653,12 @@ static void si_decompress_textures(struct si_context *sctx, int shader_start, void si_decompress_graphics_textures(struct si_context *sctx) { - si_decompress_textures(sctx, 0, SI_NUM_GRAPHICS_SHADERS); + si_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS)); } void si_decompress_compute_textures(struct si_context *sctx) { - si_decompress_textures(sctx, SI_NUM_GRAPHICS_SHADERS, SI_NUM_SHADERS); + si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE); } static void si_clear(struct pipe_context *ctx, unsigned buffers, diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 0472d234076..a535fa0e965 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -490,6 +490,20 @@ static bool is_compressed_colortex(struct r600_texture *rtex) (rtex->dcc_offset && rtex->dirty_level_mask); } +static void si_update_compressed_tex_shader_mask(struct si_context *sctx, + unsigned shader) +{ + struct si_textures_info *samplers = &sctx->samplers[shader]; + unsigned shader_bit = 1 << shader; + + if (samplers->depth_texture_mask || + samplers->compressed_colortex_mask || + sctx->images[shader].compressed_colortex_mask) + sctx->compressed_tex_shader_mask |= shader_bit; + else + sctx->compressed_tex_shader_mask &= ~shader_bit; +} + static void si_set_sampler_views(struct pipe_context *ctx, enum pipe_shader_type shader, unsigned start, unsigned count, @@ -539,6 +553,8 @@ static void si_set_sampler_views(struct pipe_context *ctx, samplers->compressed_colortex_mask &= ~(1u << slot); } } + + si_update_compressed_tex_shader_mask(sctx, shader); } static void @@ -759,6 +775,8 @@ si_set_shader_images(struct pipe_context *pipe, for (i = 0, slot = start_slot; i < count; ++i, ++slot) si_set_shader_image(ctx, shader, slot, NULL); } + + si_update_compressed_tex_shader_mask(ctx, shader); } static void @@ -1491,6 +1509,7 @@ void si_update_compressed_colortex_masks(struct si_context *sctx) for (int i = 0; i < SI_NUM_SHADERS; ++i) { si_samplers_update_compressed_colortex_mask(&sctx->samplers[i]); si_images_update_compressed_colortex_mask(&sctx->images[i]); + si_update_compressed_tex_shader_mask(sctx, i); } } @@ -1706,6 +1725,8 @@ void si_update_all_texture_descriptors(struct si_context *sctx) si_set_sampler_view(sctx, shader, i, samplers->views[i], true); } + + si_update_compressed_tex_shader_mask(sctx, shader); } } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index c9ae27e36b6..e7d071d3dd3 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -268,6 +268,7 @@ struct si_context { struct si_descriptors vertex_buffers; struct si_descriptors descriptors[SI_NUM_DESCS]; unsigned descriptors_dirty; + unsigned compressed_tex_shader_mask; struct si_buffer_resources rw_buffers; struct si_buffer_resources const_buffers[SI_NUM_SHADERS]; struct si_buffer_resources shader_buffers[SI_NUM_SHADERS]; |