[Piglit] [PATCH] gl-1.0-logicop: allow testing single mode on the command line

Brian Paul brianp at vmware.com
Thu Nov 9 20:52:29 UTC 2017


And require GL 1.1 since that's when color logicops were introduced.
Technically, we should move/rename the test, but it's hardly worth it.
---
 tests/spec/gl-1.0/logicop.c | 90 +++++++++++++++++++++++++++++----------------
 1 file changed, 58 insertions(+), 32 deletions(-)

diff --git a/tests/spec/gl-1.0/logicop.c b/tests/spec/gl-1.0/logicop.c
index 9ff80be..d415335 100644
--- a/tests/spec/gl-1.0/logicop.c
+++ b/tests/spec/gl-1.0/logicop.c
@@ -46,7 +46,7 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-	config.supports_gl_compat_version = 10;
+	config.supports_gl_compat_version = 11;
 
 	config.window_visual = PIGLIT_GL_VISUAL_RGBA |
 		PIGLIT_GL_VISUAL_DOUBLE;
@@ -54,12 +54,28 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
-void
-piglit_init(int argc, char **argv)
-{
-	srand(0);
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
-}
+
+static const GLenum logicop_modes[] = {
+	GL_CLEAR,
+	GL_SET,
+	GL_COPY,
+	GL_COPY_INVERTED,
+	GL_NOOP,
+	GL_INVERT,
+	GL_AND,
+	GL_NAND,
+	GL_OR,
+	GL_NOR,
+	GL_XOR,
+	GL_EQUIV,
+	GL_AND_REVERSE,
+	GL_AND_INVERTED,
+	GL_OR_REVERSE,
+	GL_OR_INVERTED
+};
+
+static GLenum test_single = 0;  /* 0 = test all logicop modes */
+
 
 static GLubyte*
 random_image_data(void)
@@ -67,7 +83,7 @@ random_image_data(void)
 	int i;
 	GLubyte *img = malloc(4 * img_width * img_height * sizeof(GLubyte));
 	for (i = 0; i < 4 * img_width * img_height; ++i) {
-		img[i] = rand() % 256;
+		img[i] = /*rand()*/ (100+i) % 256;
 	}
 	return img;
 }
@@ -284,32 +300,42 @@ piglit_display(void)
 	enum piglit_result subtest;
 	unsigned int op;
 
-	static GLenum logicop_modes[] = {
-		GL_CLEAR,
-		GL_SET,
-		GL_COPY,
-		GL_COPY_INVERTED,
-		GL_NOOP,
-		GL_INVERT,
-		GL_AND,
-		GL_NAND,
-		GL_OR,
-		GL_NOR,
-		GL_XOR,
-		GL_EQUIV,
-		GL_AND_REVERSE,
-		GL_AND_INVERTED,
-		GL_OR_REVERSE,
-		GL_OR_INVERTED
-	};
-
 	for (op = 0; op < ARRAY_SIZE(logicop_modes); ++op) {
-		subtest = test_logicop(logicop_modes[op]);
-		piglit_report_subtest_result(subtest, "%s",
-			piglit_get_gl_enum_name(logicop_modes[op]));
-		if (subtest == PIGLIT_FAIL)
-			result = PIGLIT_FAIL;
+		if (test_single == 0 || test_single == logicop_modes[op]) {
+			subtest = test_logicop(logicop_modes[op]);
+			piglit_report_subtest_result(subtest, "%s",
+				piglit_get_gl_enum_name(logicop_modes[op]));
+			if (subtest == PIGLIT_FAIL)
+				result = PIGLIT_FAIL;
+		}
 	}
 
 	return result;
 }
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	srand(0);
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+	if (argc > 1) {
+		/* argv[1] may be one of the logic op modes, like "GL_XOR" */
+		int i;
+
+		for (i = 0; i < ARRAY_SIZE(logicop_modes); i++) {
+			const char * mode =
+				piglit_get_gl_enum_name(logicop_modes[i]);
+			if (strcmp(argv[1], mode) == 0) {
+				test_single = logicop_modes[i];
+				break;
+			}
+		}
+		if (test_single == 0) {
+			printf("Invalid glLogicOp mode %s\n", argv[1]);
+			piglit_report_result(PIGLIT_SKIP);
+		}
+	}
+
+}
-- 
1.9.1



More information about the Piglit mailing list