[Mesa-dev] [PATCH v3 55/63] radeonsi: decompress DCC for resident textures/images

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Jun 9 13:35:53 UTC 2017


Analogous to bound textures/images. We should also update the
resident descriptors and disable COMPRESSION_EN for avoiding
useless DCC fetches, but I postpone this optimization for a
separate series.

v3: - remove use of si_update_check_render_feedback()
v2: - store pipe_sampler_view instead of si_sampler_view

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com> (v2)
---
 src/gallium/drivers/radeonsi/si_blit.c        | 62 +++++++++++++++++++++++++++
 src/gallium/drivers/radeonsi/si_descriptors.c | 21 +++++++++
 2 files changed, 83 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index 74bc2e9a51..2740d040df 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -631,6 +631,64 @@ static void si_check_render_feedback_images(struct si_context *sctx,
 	}
 }
 
+static void si_check_render_feedback_resident_textures(struct si_context *sctx)
+{
+	unsigned num_resident_tex_handles;
+	unsigned i;
+
+	num_resident_tex_handles = sctx->resident_tex_handles.size /
+				   sizeof(struct si_texture_handle *);
+
+	for (i = 0; i < num_resident_tex_handles; i++) {
+		struct si_texture_handle *tex_handle =
+			*util_dynarray_element(&sctx->resident_tex_handles,
+					       struct si_texture_handle *, i);
+		struct pipe_sampler_view *view;
+		struct r600_texture *tex;
+
+		view = tex_handle->view;
+		if (view->texture->target == PIPE_BUFFER)
+			continue;
+
+		tex = (struct r600_texture *)view->texture;
+
+		si_check_render_feedback_texture(sctx, tex,
+						 view->u.tex.first_level,
+						 view->u.tex.last_level,
+						 view->u.tex.first_layer,
+						 view->u.tex.last_layer);
+	}
+}
+
+static void si_check_render_feedback_resident_images(struct si_context *sctx)
+{
+	unsigned num_resident_img_handles;
+	unsigned i;
+
+	num_resident_img_handles = sctx->resident_img_handles.size /
+				   sizeof(struct si_image_handle *);
+
+	for (i = 0; i < num_resident_img_handles; i++) {
+		struct si_image_handle *img_handle =
+			*util_dynarray_element(&sctx->resident_img_handles,
+					       struct si_image_handle *, i);
+		struct pipe_image_view *view;
+		struct r600_texture *tex;
+
+		view = &img_handle->view;
+		if (view->resource->target == PIPE_BUFFER)
+			continue;
+
+		tex = (struct r600_texture *)view->resource;
+
+		si_check_render_feedback_texture(sctx, tex,
+						 view->u.tex.level,
+						 view->u.tex.level,
+						 view->u.tex.first_layer,
+						 view->u.tex.last_layer);
+	}
+}
+
 static void si_check_render_feedback(struct si_context *sctx)
 {
 
@@ -641,6 +699,10 @@ static void si_check_render_feedback(struct si_context *sctx)
 		si_check_render_feedback_images(sctx, &sctx->images[i]);
 		si_check_render_feedback_textures(sctx, &sctx->samplers[i]);
 	}
+
+	si_check_render_feedback_resident_images(sctx);
+	si_check_render_feedback_resident_textures(sctx);
+
 	sctx->need_check_render_feedback = false;
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 0cdccdfed1..980448181c 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2238,6 +2238,15 @@ static void si_make_texture_handle_resident(struct pipe_context *ctx,
 	sview = (struct si_sampler_view *)tex_handle->view;
 
 	if (resident) {
+		if (sview->base.texture->target != PIPE_BUFFER) {
+			struct r600_texture *rtex =
+				(struct r600_texture *)sview->base.texture;
+
+			if (rtex->dcc_offset &&
+			    p_atomic_read(&rtex->framebuffers_bound))
+				sctx->need_check_render_feedback = true;
+		}
+
 		/* Add the texture handle to the per-context list. */
 		util_dynarray_append(&sctx->resident_tex_handles,
 				     struct si_texture_handle *, tex_handle);
@@ -2340,6 +2349,18 @@ static void si_make_image_handle_resident(struct pipe_context *ctx,
 	view = &img_handle->view;
 
 	if (resident) {
+		struct r600_resource *res =
+			(struct r600_resource *)view->resource;
+
+		if (res->b.b.target != PIPE_BUFFER) {
+			struct r600_texture *rtex = (struct r600_texture *)res;
+			unsigned level = view->u.tex.level;
+
+			if (vi_dcc_enabled(rtex, level) &&
+			    p_atomic_read(&rtex->framebuffers_bound))
+				sctx->need_check_render_feedback = true;
+		}
+
 		/* Add the image handle to the per-context list. */
 		util_dynarray_append(&sctx->resident_img_handles,
 				     struct si_image_handle *, img_handle);
-- 
2.13.1



More information about the mesa-dev mailing list