summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/a3xx
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2014-12-02 23:27:03 -0500
committerIlia Mirkin <[email protected]>2014-12-06 18:18:33 -0500
commitfc94b2c2a0600e3e84412d3a01491f2d069119a3 (patch)
tree8ad60bb858bafded5e7303d512a295b60b497ed6 /src/gallium/drivers/freedreno/a3xx
parent97fef2db5c2c6ec0b22bf5b7d968a4dc4b218363 (diff)
freedreno/a3xx: fix border color swizzle to match texture format desc
This is a hack since it uses the texture information together with the sampler, but I don't see a better way to do it. In OpenGL, there is a 1:1 correspondence. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/a3xx')
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_emit.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index f721303cefe..f9dada79073 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -202,10 +202,24 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
(BORDERCOLOR_SIZE * tex_off[sb]) +
(BORDERCOLOR_SIZE * i));
- bcolor[0] = util_float_to_half(sampler->base.border_color.f[2]);
- bcolor[1] = util_float_to_half(sampler->base.border_color.f[1]);
- bcolor[2] = util_float_to_half(sampler->base.border_color.f[0]);
- bcolor[3] = util_float_to_half(sampler->base.border_color.f[3]);
+ /*
+ * XXX HACK ALERT XXX
+ *
+ * The border colors need to be swizzled in a particular
+ * format-dependent order. Even though samplers don't know about
+ * formats, we can assume that with a GL state tracker, there's a
+ * 1:1 correspondence between sampler and texture. Take advantage
+ * of that knowledge.
+ */
+ if (i < tex->num_textures && tex->textures[i]) {
+ const struct util_format_description *desc =
+ util_format_description(tex->textures[i]->format);
+ for (j = 0; j < 4; j++) {
+ if (desc->swizzle[j] < 4)
+ bcolor[desc->swizzle[j]] =
+ util_float_to_half(sampler->base.border_color.f[j]);
+ }
+ }
OUT_RING(ring, sampler->texsamp0);
OUT_RING(ring, sampler->texsamp1);