[Mesa-dev] [PATCH 3/4] radeonsi: fix texture reinterpretation after DCC fast clear

Marek Olšák maraeo at gmail.com
Wed Sep 7 11:46:01 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

The problem is that TC-compatible DCC clear codes translate
into different clear values when you change the format.

I have a new piglit reproducing the issue.
---
 src/gallium/drivers/radeon/r600_texture.c | 32 +++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 074fed8..e452588 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1662,56 +1662,64 @@ static const struct u_resource_vtbl r600_texture_vtbl =
 	NULL,				/* get_handle */
 	r600_texture_destroy,		/* resource_destroy */
 	r600_texture_transfer_map,	/* transfer_map */
 	u_default_transfer_flush_region, /* transfer_flush_region */
 	r600_texture_transfer_unmap,	/* transfer_unmap */
 };
 
 /* DCC channel type categories within which formats can be reinterpreted
  * while keeping the same DCC encoding. The swizzle must also match. */
 enum dcc_channel_type {
-	dcc_channel_any32,
-	dcc_channel_int16,
+	dcc_channel_float32,
+	dcc_channel_uint32,
+	dcc_channel_sint32,
 	dcc_channel_float16,
-	dcc_channel_any_10_10_10_2,
-	dcc_channel_any8,
+	dcc_channel_uint16,
+	dcc_channel_sint16,
+	dcc_channel_uint_10_10_10_2,
+	dcc_channel_uint8,
+	dcc_channel_sint8,
 	dcc_channel_incompatible,
 };
 
 /* Return the type of DCC encoding. */
 static enum dcc_channel_type
 vi_get_dcc_channel_type(const struct util_format_description *desc)
 {
 	int i;
 
 	/* Find the first non-void channel. */
 	for (i = 0; i < desc->nr_channels; i++)
 		if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
 			break;
 	if (i == desc->nr_channels)
 		return dcc_channel_incompatible;
 
 	switch (desc->channel[i].size) {
 	case 32:
-		if (desc->nr_channels == 4)
-			return dcc_channel_incompatible;
-		else
-			return dcc_channel_any32;
+		if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+			return dcc_channel_float32;
+		if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
+			return dcc_channel_uint32;
+		return dcc_channel_sint32;
 	case 16:
 		if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
 			return dcc_channel_float16;
-		else
-			return dcc_channel_int16;
+		if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
+			return dcc_channel_uint16;
+		return dcc_channel_sint16;
 	case 10:
-		return dcc_channel_any_10_10_10_2;
+		return dcc_channel_uint_10_10_10_2;
 	case 8:
-		return dcc_channel_any8;
+		if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
+			return dcc_channel_uint8;
+		return dcc_channel_sint8;
 	default:
 		return dcc_channel_incompatible;
 	}
 }
 
 /* Return if it's allowed to reinterpret one format as another with DCC enabled. */
 bool vi_dcc_formats_compatible(enum pipe_format format1,
 			       enum pipe_format format2)
 {
 	const struct util_format_description *desc1, *desc2;
-- 
2.7.4



More information about the mesa-dev mailing list