[Piglit] [PATCH 3/3 v. 2] fbo-blending-formats: Fix expected color values for DST_ALPHA blending

Carl Worth cworth at cworth.org
Wed Jan 16 13:29:02 PST 2013


>From 864b6fe055585a5804d4be968f293b124ecebf0e Mon Sep 17 00:00:00 2001
From: Carl Worth <cworth at cworth.org>
Date: Mon, 14 Jan 2013 14:25:55 -0800
Subject: [PATCH 3/3] fbo-blending-formats: Fix expected color values for
 DST_ALPHA blending
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In the case where there are 0 bits of destination alpha, we need to
compute different expected results for the color when rendering with
DST_ALPHA. The results are initialized with calculations that blend
src and destination color such as:

	res4[X] = dst4[X]*(1-dst4[ALPHA]) + src4[X]*dst4[ALPHA]

But when there is no destination alpha channel, instead of the blend
factor dst4[ALPHA] in the above, the result should be computed with
this value replaced with 1.0. In other words, the correct calculation
for the expected result color becomes:

	res4[X] = src4[X]
---

Version 1 of this patch incorrectly set the expected color even when
some color channels have no bits to store values.

The code immediately above detects these cases and smashes the expected
values to 0---version 1 of the patch was then unsmashing the values back
to non-zero values.

Fix this by guarding each assignment with a test for some non-zero
number of bits.

 tests/fbo/fbo-blending-formats.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/fbo/fbo-blending-formats.c b/tests/fbo/fbo-blending-formats.c
index 9085204..3c716bb 100644
--- a/tests/fbo/fbo-blending-formats.c
+++ b/tests/fbo/fbo-blending-formats.c
@@ -217,12 +217,32 @@ static enum piglit_result test_format(const struct format_desc *format)
 			res5[2] = 0;
 		}
 		if (!a) {
+			/* When there are no bits for the alpha channel, we
+			 * always expect to read an alpha value of 1.0.
+			 */
 			res0[3] = 1;
 			res1[3] = 1;
 			res2[3] = 1;
 			res3[3] = 1;
 			res4[3] = 1;
 			res5[3] = 1;
+
+			/* Also blending with
+			 * DST_ALPHA/ONE_MINUS_DST_ALPHA (as in case
+			 * 4) with an implicit destination alpha value
+			 * of 1.0 means that the result color should
+			 * be identical to the source color, (if there
+			 * are any bits to store that color that is).
+			 */
+			if (r)  {
+				res4[0] = src4[0];
+			}
+			if (g) {
+				res4[1] = src4[1];
+			}
+			if (b) {
+				res4[2] = src4[2];
+			}
 		}
         }
 
-- 
1.7.10.4



More information about the Piglit mailing list