[Piglit] [PATCH 10/16] Move piglit program helper functions to GL common code

Josh Triplett josh at joshtriplett.org
Thu Jul 3 12:38:07 PDT 2014


These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett <josh at joshtriplett.org>
---
 tests/util/piglit-util-gl-common.c | 81 +++++++++++++++++++++++++++++++++++++
 tests/util/piglit-util-gl.c        | 82 --------------------------------------
 2 files changed, 81 insertions(+), 82 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c
index a4c283d..c00c9c7 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1796,3 +1796,84 @@ bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
 	return status;
 }
 
+GLint piglit_ARBfp_pass_through = 0;
+
+int piglit_use_fragment_program(void)
+{
+	static const char source[] =
+		"!!ARBfp1.0\n"
+		"MOV	result.color, fragment.color;\n"
+		"END\n"
+		;
+
+	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+	if (!piglit_is_extension_supported("GL_ARB_fragment_program"))
+		return 0;
+
+	piglit_ARBfp_pass_through =
+		piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
+
+	return (piglit_ARBfp_pass_through != 0);
+}
+
+void piglit_require_fragment_program(void)
+{
+	if (!piglit_use_fragment_program()) {
+		printf("GL_ARB_fragment_program not supported.\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+}
+
+int piglit_use_vertex_program(void)
+{
+	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+	return piglit_is_extension_supported("GL_ARB_vertex_program");
+}
+
+void piglit_require_vertex_program(void)
+{
+	if (!piglit_use_vertex_program()) {
+		printf("GL_ARB_vertex_program not supported.\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+}
+
+GLuint piglit_compile_program(GLenum target, const char* text)
+{
+	GLuint program;
+	GLint errorPos;
+
+	glGenProgramsARB(1, &program);
+	glBindProgramARB(target, program);
+	glProgramStringARB(
+			target,
+			GL_PROGRAM_FORMAT_ASCII_ARB,
+			strlen(text),
+			(const GLubyte *)text);
+	glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
+	if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+		int l = piglit_find_line(text, errorPos);
+		int a;
+
+		fprintf(stderr, "Compiler Error (pos=%d line=%d): %s\n",
+			errorPos, l,
+			(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+
+		for (a=-10; a<10; a++)
+		{
+			if (errorPos+a < 0)
+				continue;
+			if (errorPos+a >= strlen(text))
+				break;
+			fprintf(stderr, "%c", text[errorPos+a]);
+		}
+		fprintf(stderr, "\nin program:\n%s", text);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	if (!glIsProgramARB(program)) {
+		fprintf(stderr, "glIsProgramARB failed\n");
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	return program;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 611b59a..bec2940 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -36,88 +36,6 @@
 #include "piglit-util-gl-common.h"
 
 
-GLint piglit_ARBfp_pass_through = 0;
-
-int piglit_use_fragment_program(void)
-{
-	static const char source[] =
-		"!!ARBfp1.0\n"
-		"MOV	result.color, fragment.color;\n"
-		"END\n"
-		;
-
-	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-	if (!piglit_is_extension_supported("GL_ARB_fragment_program"))
-		return 0;
-
-	piglit_ARBfp_pass_through =
-		piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
-
-	return (piglit_ARBfp_pass_through != 0);
-}
-
-void piglit_require_fragment_program(void)
-{
-	if (!piglit_use_fragment_program()) {
-		printf("GL_ARB_fragment_program not supported.\n");
-		piglit_report_result(PIGLIT_SKIP);
-	}
-}
-
-int piglit_use_vertex_program(void)
-{
-	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-	return piglit_is_extension_supported("GL_ARB_vertex_program");
-}
-
-void piglit_require_vertex_program(void)
-{
-	if (!piglit_use_vertex_program()) {
-		printf("GL_ARB_vertex_program not supported.\n");
-		piglit_report_result(PIGLIT_SKIP);
-	}
-}
-
-GLuint piglit_compile_program(GLenum target, const char* text)
-{
-	GLuint program;
-	GLint errorPos;
-
-	glGenProgramsARB(1, &program);
-	glBindProgramARB(target, program);
-	glProgramStringARB(
-			target,
-			GL_PROGRAM_FORMAT_ASCII_ARB,
-			strlen(text),
-			(const GLubyte *)text);
-	glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos);
-	if (glGetError() != GL_NO_ERROR || errorPos != -1) {
-		int l = piglit_find_line(text, errorPos);
-		int a;
-
-		fprintf(stderr, "Compiler Error (pos=%d line=%d): %s\n",
-			errorPos, l,
-			(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
-
-		for (a=-10; a<10; a++)
-		{
-			if (errorPos+a < 0)
-				continue;
-			if (errorPos+a >= strlen(text))
-				break;
-			fprintf(stderr, "%c", text[errorPos+a]);
-		}
-		fprintf(stderr, "\nin program:\n%s", text);
-		piglit_report_result(PIGLIT_FAIL);
-	}
-	if (!glIsProgramARB(program)) {
-		fprintf(stderr, "glIsProgramARB failed\n");
-		piglit_report_result(PIGLIT_FAIL);
-	}
-
-	return program;
-}
-
 /**
  * Convenience function to draw a triangle.
  */
-- 
2.0.1



More information about the Piglit mailing list