[Piglit] [PATCH 04/15] shader_runner: Support setting of patch parameters.

Fabian Bieler fabianbieler at fastmail.fm
Mon Mar 24 15:02:43 PDT 2014


Add patch parameter directive to set GL_PATCH_VERTICES,
GL_PATCH_DEFAULT_OUTER_LEVEL and GL_PATCH_DEFAULT_INNER_LEVEL.

e.g.:
patch parameter vertices 4
patch parameter default level outer 1.5 2.0 2.5 3.5
patch parameter default level inner 0.0 0.0

Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
---
 tests/shaders/shader_runner.c | 47 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7b9ec97..0da0d1d 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1535,6 +1535,51 @@ set_parameter(const char *line)
 	}
 }
 
+void
+set_patch_parameter(const char *line)
+{
+#ifdef PIGLIT_USE_OPENGL
+	float f[4];
+	int i, count;
+	const char *const line0 = line;
+
+	if (gl_version.num < 40)
+		piglit_require_extension("GL_ARB_tessellation_shader");
+
+	if (string_match("vertices ", line)) {
+		line += strlen("vertices ");
+		count = sscanf(line, "%d", &i);
+		if (count != 1) {
+			fprintf(stderr, "Couldn't parse patch parameter command:\n%s\n", line0);
+			piglit_report_result(PIGLIT_FAIL);
+		}
+		glPatchParameteri(GL_PATCH_VERTICES, i);
+	} else if (string_match("default level outer ", line)) {
+		line += strlen("default level outer ");
+		count = sscanf(line, "%f %f %f %f", &f[0], &f[1], &f[2], &f[3]);
+		if (count != 4) {
+			fprintf(stderr, "Couldn't parse patch parameter command:\n%s\n", line0);
+			piglit_report_result(PIGLIT_FAIL);
+		}
+		glPatchParameterfv(GL_PATCH_DEFAULT_OUTER_LEVEL, f);
+	} else if (string_match("default level inner ", line)) {
+		line += strlen("default level inner ");
+		count = sscanf(line, "%f %f", &f[0], &f[1]);
+		if (count != 2) {
+			fprintf(stderr, "Couldn't parse patch parameter command:\n%s\n", line0);
+			piglit_report_result(PIGLIT_FAIL);
+		}
+		glPatchParameterfv(GL_PATCH_DEFAULT_INNER_LEVEL, f);
+	} else {
+		fprintf(stderr, "Couldn't parse patch parameter command:\n%s\n", line);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+#else
+	printf("patch parameters are only available in desktop GL\n");
+	piglit_report_result(PIGLIT_SKIP);
+#endif
+}
+
 struct string_to_enum enable_table[] = {
 	{ "GL_CLIP_PLANE0", GL_CLIP_PLANE0 },
 	{ "GL_CLIP_PLANE1", GL_CLIP_PLANE1 },
@@ -2038,6 +2083,8 @@ piglit_display(void)
 			set_uniform(line + 7);
 		} else if (string_match("parameter ", line)) {
 			set_parameter(line + strlen("parameter "));
+		} else if (string_match("patch parameter ", line)) {
+			set_patch_parameter(line + strlen("patch parameter "));
 		} else if (string_match("link error", line)) {
 			link_error_expected = true;
 			if (link_ok) {
-- 
1.8.3.2



More information about the Piglit mailing list