[Mesa-dev] [PATCH 1/4] radeonsi: clamp integer clear color values for DCC fast clear

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


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

It should be possible to get TC-compatible fast clear more often now.
---
 src/gallium/drivers/radeon/r600_texture.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 2f04019..aee768f 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -2244,27 +2244,35 @@ static void vi_get_fast_clear_parameters(enum pipe_format surface_format,
 	} else
 		return;
 
 	for (i = 0; i < 4; ++i) {
 		int index = desc->swizzle[i] - PIPE_SWIZZLE_X;
 
 		if (desc->swizzle[i] < PIPE_SWIZZLE_X ||
 		    desc->swizzle[i] > PIPE_SWIZZLE_W)
 			continue;
 
-		if (util_format_is_pure_sint(surface_format)) {
+		if (desc->channel[i].pure_integer &&
+		    desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
+			/* Use the maximum value for clamping the clear color. */
+			int max = u_bit_consecutive(0, desc->channel[i].size - 1);
+
 			values[i] = color->i[i] != 0;
-			if (color->i[i] != 0 && color->i[i] != INT32_MAX)
+			if (color->i[i] != 0 && MIN2(color->i[i], max) != max)
 				return;
-		} else if (util_format_is_pure_uint(surface_format)) {
+		} else if (desc->channel[i].pure_integer &&
+			   desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
+			/* Use the maximum value for clamping the clear color. */
+			unsigned max = u_bit_consecutive(0, desc->channel[i].size);
+
 			values[i] = color->ui[i] != 0U;
-			if (color->ui[i] != 0U && color->ui[i] != UINT32_MAX)
+			if (color->ui[i] != 0U && MIN2(color->ui[i], max) != max)
 				return;
 		} else {
 			values[i] = color->f[i] != 0.0F;
 			if (color->f[i] != 0.0F && color->f[i] != 1.0F)
 				return;
 		}
 
 		if (index == extra_channel)
 			extra_value = values[i];
 		else
-- 
2.7.4



More information about the mesa-dev mailing list