radeonsi: don't enable DCC in the sampler if first_level doesn't have it
authorMarek Olšák <marek.olsak@amd.com>
Mon, 6 Jun 2016 15:33:42 +0000 (17:33 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 7 Jun 2016 22:22:45 +0000 (00:22 +0200)
If first_level > 0 and DCC is disabled for that level, let's skip DCC
reads entirely.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h

index e0c966666a138ad5853dce166057d320639883a4..e80db3950758234507513ca8c85b23cb89593a77 100644 (file)
@@ -312,10 +312,21 @@ static void si_sampler_views_begin_new_cs(struct si_context *sctx,
        }
 }
 
+/* Set texture descriptor fields that can be changed by reallocations.
+ *
+ * \param tex                  texture
+ * \param base_level_info      information of the level of BASE_ADDRESS
+ * \param base_level           the level of BASE_ADDRESS
+ * \param first_level          pipe_sampler_view.u.tex.first_level
+ * \param block_width          util_format_get_blockwidth()
+ * \param is_stencil           select between separate Z & Stencil
+ * \param state                        descriptor to update
+ */
 void si_set_mutable_tex_desc_fields(struct r600_texture *tex,
                                    const struct radeon_surf_level *base_level_info,
-                                   unsigned base_level, unsigned block_width,
-                                   bool is_stencil, uint32_t *state)
+                                   unsigned base_level, unsigned first_level,
+                                   unsigned block_width, bool is_stencil,
+                                   uint32_t *state)
 {
        uint64_t va = tex->resource.gpu_address + base_level_info->offset;
        unsigned pitch = base_level_info->nblk_x * block_width;
@@ -331,7 +342,7 @@ void si_set_mutable_tex_desc_fields(struct r600_texture *tex,
                                                             is_stencil));
        state[4] |= S_008F20_PITCH(pitch - 1);
 
-       if (tex->dcc_offset && base_level_info->dcc_enabled) {
+       if (tex->dcc_offset && tex->surface.level[first_level].dcc_enabled) {
                state[6] |= S_008F28_COMPRESSION_EN(1);
                state[7] = (tex->resource.gpu_address +
                            tex->dcc_offset +
@@ -369,6 +380,7 @@ static void si_set_sampler_view(struct si_context *sctx,
                        si_set_mutable_tex_desc_fields(rtex,
                                                       rview->base_level_info,
                                                       rview->base_level,
+                                                      rview->base.u.tex.first_level,
                                                       rview->block_width,
                                                       is_separate_stencil,
                                                       desc);
@@ -640,7 +652,8 @@ static void si_set_shader_image(struct si_context *ctx,
                                           view->u.tex.last_layer,
                                           width, height, depth,
                                           desc, NULL);
-               si_set_mutable_tex_desc_fields(tex, &tex->surface.level[level], level,
+               si_set_mutable_tex_desc_fields(tex, &tex->surface.level[level],
+                                              level, level,
                                               util_format_get_blockwidth(view->format),
                                               false, desc);
        }
index fc28fc94ebfd8d4027458597a485b32c622a439e..270b9fda079b1475e8e8f5fc1179553d43104527 100644 (file)
@@ -3446,7 +3446,7 @@ static void si_query_opaque_metadata(struct r600_common_screen *rscreen,
                                   res->width0, res->height0, res->depth0,
                                   desc, NULL);
 
-       si_set_mutable_tex_desc_fields(rtex, &rtex->surface.level[0], 0,
+       si_set_mutable_tex_desc_fields(rtex, &rtex->surface.level[0], 0, 0,
                                       rtex->surface.blk_w, false, desc);
 
        /* Clear the base address and set the relative DCC offset. */
index 811a02f9a3c5a472e9f430d97666ed9fb940f757..a4a58bba9051a1221665caf5db155a78c3bcdbb5 100644 (file)
@@ -279,8 +279,9 @@ struct si_buffer_resources {
 void si_ce_enable_loads(struct radeon_winsys_cs *ib);
 void si_set_mutable_tex_desc_fields(struct r600_texture *tex,
                                    const struct radeon_surf_level *base_level_info,
-                                   unsigned base_level, unsigned block_width,
-                                   bool is_stencil, uint32_t *state);
+                                   unsigned base_level, unsigned first_level,
+                                   unsigned block_width, bool is_stencil,
+                                   uint32_t *state);
 void si_set_ring_buffer(struct pipe_context *ctx, uint slot,
                        struct pipe_resource *buffer,
                        unsigned stride, unsigned num_records,