Mesa (master): freedreno/a3xx: fix integer and 32-bit float border colors

Ilia Mirkin imirkin at kemper.freedesktop.org
Sat Apr 18 22:56:21 UTC 2015


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

Author: Ilia Mirkin <imirkin at alum.mit.edu>
Date:   Mon Apr  6 01:15:09 2015 -0400

freedreno/a3xx: fix integer and 32-bit float border colors

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>

---

 src/gallium/drivers/freedreno/a3xx/fd3_emit.c |   31 ++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index f961fc0..ee473e6 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -217,6 +217,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
 			uint16_t *bcolor = (uint16_t *)((uint8_t *)ptr +
 					(BORDERCOLOR_SIZE * tex_off[sb]) +
 					(BORDERCOLOR_SIZE * i));
+			uint32_t *bcolor32 = (uint32_t *)&bcolor[16];
 
 			/*
 			 * XXX HACK ALERT XXX
@@ -231,7 +232,35 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
 				const struct util_format_description *desc =
 					util_format_description(tex->textures[i]->format);
 				for (j = 0; j < 4; j++) {
-					if (desc->swizzle[j] < 4)
+					if (desc->swizzle[j] >= 4)
+						continue;
+
+					const struct util_format_channel_description *chan =
+						&desc->channel[desc->swizzle[j]];
+					int size = chan->size;
+
+					/* The Z16 texture format we use seems to look in the
+					 * 32-bit border color slots
+					 */
+					if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS)
+						size = 32;
+
+					/* Formats like R11G11B10 or RGB9_E5 don't specify
+					 * per-channel sizes properly.
+					 */
+					if (desc->layout == UTIL_FORMAT_LAYOUT_OTHER)
+						size = 16;
+
+					if (chan->pure_integer && size > 16)
+						bcolor32[desc->swizzle[j] + 4] =
+							sampler->base.border_color.i[j];
+					else if (size > 16)
+						bcolor32[desc->swizzle[j]] =
+							fui(sampler->base.border_color.f[j]);
+					else if (chan->pure_integer)
+						bcolor[desc->swizzle[j] + 8] =
+							sampler->base.border_color.i[j];
+					else
 						bcolor[desc->swizzle[j]] =
 							util_float_to_half(sampler->base.border_color.f[j]);
 				}




More information about the mesa-commit mailing list