[Piglit] [PATCH 2/7] gl-1.0-blend: Enable EXT_blend_subtract tests on implementations that lack EXT_blend_minmax

Ian Romanick idr at freedesktop.org
Thu Apr 26 21:29:11 UTC 2018


From: Ian Romanick <ian.d.romanick at intel.com>

And vice versa.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/spec/gl-1.0/blend.c | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/tests/spec/gl-1.0/blend.c b/tests/spec/gl-1.0/blend.c
index 0cacf69cb..278ef75ac 100644
--- a/tests/spec/gl-1.0/blend.c
+++ b/tests/spec/gl-1.0/blend.c
@@ -115,14 +115,20 @@ static const GLenum dst_factors[] = {
 	GL_CONSTANT_ALPHA,
 	GL_ONE_MINUS_CONSTANT_ALPHA
 };
-static const GLenum operators[] = {
+
+static const GLenum subtract_operators[] = {
 	GL_FUNC_ADD,
 	GL_FUNC_SUBTRACT,
-	GL_FUNC_REVERSE_SUBTRACT,
+	GL_FUNC_REVERSE_SUBTRACT
+};
+
+static const GLenum minmax_operators[] = {
 	GL_MIN,
 	GL_MAX
 };
 
+GLenum operators[ARRAY_SIZE(subtract_operators) + ARRAY_SIZE(minmax_operators)];
+
 struct image {
 	GLuint name;
 	GLfloat *data;
@@ -714,14 +720,8 @@ run_all_factor_sets(void)
 		have_blend_color = true;
 		have_sep_func = true;
 	} else {
-		/* glBlendEquation is added by either extension.
-		 * However, there is only one table of operators to
-		 * test, and it includes the operators from both
-		 * extensions.  In Mesa, only R100 supports
-		 * GL_EXT_blend_subtract but not GL_EXT_blend_minmax.
-		 */
 		have_blend_equation =
-			piglit_is_extension_supported("GL_EXT_blend_subtract") &&
+			piglit_is_extension_supported("GL_EXT_blend_subtract") ||
 			piglit_is_extension_supported("GL_EXT_blend_minmax");
 		have_blend_color =
 			piglit_is_extension_supported("GL_EXT_blend_color");
@@ -753,15 +753,27 @@ run_all_factor_sets(void)
 		num_dst_factors_sep = 1;
 	}
 
-	if (have_blend_equation) {
-		num_operators_rgb = ARRAY_SIZE(operators);
-		num_operators_a = ARRAY_SIZE(operators);
+	num_operators_rgb = 0;
+	if (piglit_is_extension_supported("GL_EXT_blend_subtract")) {
+		memcpy(&operators[num_operators_rgb],
+		       subtract_operators,
+		       ARRAY_SIZE(subtract_operators) * sizeof(operators[0]));
+		num_operators_rgb += ARRAY_SIZE(subtract_operators);
 	}
 	else {
-		num_operators_rgb = 1; /* just ADD */
-		num_operators_a = 1; /* just ADD */
+		num_operators_rgb = 1;
+		operators[0] = GL_FUNC_ADD;
+	}
+
+	if (piglit_is_extension_supported("GL_EXT_blend_minmax")) {
+		memcpy(&operators[num_operators_rgb],
+		       minmax_operators,
+		       ARRAY_SIZE(minmax_operators) * sizeof(operators[0]));
+		num_operators_rgb += ARRAY_SIZE(minmax_operators);
 	}
 
+	num_operators_a = num_operators_rgb;
+
 	for (op = 0; op < num_operators_rgb; ++op) {
 		for (opa = 0; opa < num_operators_a; ++opa) {
 			if (operators[op] == GL_FUNC_ADD && 
-- 
2.14.3



More information about the Piglit mailing list