radeonsi: use a bitmask-based loop in si_decompress_textures
authorMarek Olšák <marek.olsak@amd.com>
Tue, 17 Jan 2017 19:46:39 +0000 (20:46 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 18 Jan 2017 18:51:31 +0000 (19:51 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_pipe.h

index 5b533732a4db95b7e60290a9b152027510322ebd..da6c0cda2bb45b64917fd1ab966a91de73f0f539 100644 (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,
index 0472d2340762e48eef0e545a7a877b8fb30c1d07..a535fa0e965de39cde72d502c2fc386e281f6423 100644 (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);
        }
 }
 
index c9ae27e36b632e69960422a4e9e455084460fb3a..e7d071d3dd3fc095e0d3f7129ae0bfc3f1c951f7 100644 (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];