Mesa (master): radeonsi: decompress DCC in set_sampler_view instead of create_sampler_view (v2)

Marek Olšák mareko at kemper.freedesktop.org
Fri Mar 31 18:58:15 UTC 2017


Module: Mesa
Branch: master
Commit: 7d2fa8dc105158e7d2d28763cb9ed020ae64b67f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d2fa8dc105158e7d2d28763cb9ed020ae64b67f

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Mar 24 03:16:41 2017 +0100

radeonsi: decompress DCC in set_sampler_view instead of create_sampler_view (v2)

v2: don't add a new decompress helper function

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/gallium/drivers/radeonsi/si_descriptors.c | 14 +++++++++++---
 src/gallium/drivers/radeonsi/si_pipe.h        |  1 +
 src/gallium/drivers/radeonsi/si_state.c       |  7 ++++---
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index f28202f20a..2b911585a6 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -480,12 +480,21 @@ static void si_set_sampler_view(struct si_context *sctx,
 
 	if (view) {
 		struct r600_texture *rtex = (struct r600_texture *)view->texture;
+		bool is_buffer = rtex->resource.b.b.target == PIPE_BUFFER;
+
+		if (unlikely(!is_buffer && rview->dcc_incompatible)) {
+			if (vi_dcc_enabled(rtex, view->u.tex.first_level))
+				if (!r600_texture_disable_dcc(&sctx->b, rtex))
+					sctx->b.decompress_dcc(&sctx->b.b, rtex);
+
+			rview->dcc_incompatible = false;
+		}
 
 		assert(rtex); /* views with texture == NULL aren't supported */
 		pipe_sampler_view_reference(&views->views[slot], view);
 		memcpy(desc, rview->state, 8*4);
 
-		if (rtex->resource.b.b.target == PIPE_BUFFER) {
+		if (is_buffer) {
 			rtex->resource.bind_history |= PIPE_BIND_SAMPLER_VIEW;
 
 			si_set_buf_desc_address(&rtex->resource,
@@ -505,8 +514,7 @@ static void si_set_sampler_view(struct si_context *sctx,
 						       desc);
 		}
 
-		if (rtex->resource.b.b.target != PIPE_BUFFER &&
-		    rtex->fmask.size) {
+		if (!is_buffer && rtex->fmask.size) {
 			memcpy(desc + 8,
 			       rview->fmask_state, 8*4);
 		} else {
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index e1df3b6526..3a6503a7a4 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -127,6 +127,7 @@ struct si_sampler_view {
 	unsigned			base_level;
 	unsigned			block_width;
 	bool is_stencil_sampler;
+	bool dcc_incompatible;
 };
 
 #define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 2c2e3c77f6..f8c6faf955 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -3437,9 +3437,10 @@ si_create_sampler_view_custom(struct pipe_context *ctx,
 		}
 	}
 
-	vi_disable_dcc_if_incompatible_format(&sctx->b, texture,
-					      state->u.tex.first_level,
-					      state->format);
+	view->dcc_incompatible =
+		vi_dcc_formats_are_incompatible(texture,
+						state->u.tex.first_level,
+						state->format);
 
 	si_make_texture_descriptor(sctx->screen, tmp, true,
 				   state->target, pipe_format, state_swizzle,




More information about the mesa-commit mailing list