radeonsi: use a bitmask-based loop in si_decompress_textures

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák 2017-01-17 20:46:39 +01:00
parent 4bde7d3d3c
commit 861d7af1cb
3 changed files with 31 additions and 7 deletions

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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];