[Piglit] [PATCH 2/8] util: move shader related code to piglit-shader.[ch]

Chia-I Wu olvaffe at gmail.com
Sat Sep 3 09:29:25 PDT 2011


Just move the code around. There should be no functional change.
---
 tests/util/CMakeLists.gl.txt |    1 +
 tests/util/CMakeLists.txt    |    1 +
 tests/util/piglit-shader.c   |  255 ++++++++++++++++++++++++++++++++++++++++++
 tests/util/piglit-shader.h   |  158 ++++++++++++++++++++++++++
 tests/util/piglit-util.c     |  229 -------------------------------------
 tests/util/piglit-util.h     |  134 +----------------------
 6 files changed, 416 insertions(+), 362 deletions(-)
 create mode 100644 tests/util/piglit-shader.c
 create mode 100644 tests/util/piglit-shader.h

diff --git a/tests/util/CMakeLists.gl.txt b/tests/util/CMakeLists.gl.txt
index 88af8fd..5b52776 100644
--- a/tests/util/CMakeLists.gl.txt
+++ b/tests/util/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ set(UTIL_SOURCES
 IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 	add_definitions ( -DUSE_GLX )
 	add_library (piglitglxutil
+		    piglit-shader.c
 		    piglit-shader-gl.c
 		    piglit-util.c
 		    piglit-util-gl.c
diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index 3daccea..5da4cd9 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -12,6 +12,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 set(UTIL_SOURCES
 	fdo-bitmap.c
 	piglit-util.c
+	piglit-shader.c
 	shader-load.c
 	piglit-framework.c
 	rgb9e5.c
diff --git a/tests/util/piglit-shader.c b/tests/util/piglit-shader.c
new file mode 100644
index 0000000..0588608
--- /dev/null
+++ b/tests/util/piglit-shader.c
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) The Piglit project 2007
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "piglit-util.h"
+
+void piglit_get_glsl_version(bool *es, int* major, int* minor)
+{
+	bool es_local;
+	int major_local;
+	int minor_local;
+
+	const char *version_string;
+	int c; /* scanf count */
+
+	version_string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
+	es_local = strncmp("OpenGL ES", version_string, 10) == 0;
+	if (es_local) {
+		c = sscanf(version_string,
+		           "OpenGL ES GLSL ES %i.%i",
+		           &major_local,
+		           &minor_local);
+	} else {
+		c = sscanf(version_string,
+		           "%i.%i",
+		           &major_local,
+		           &minor_local);
+	}
+	assert(c == 2);
+
+	/* Write outputs. */
+	if (es != NULL)
+		*es = es_local;
+	if (major != NULL)
+		*major = major_local;
+	if (minor != NULL)
+		*minor = minor_local;
+}
+
+/**
+ * Convenience function to compile a GLSL shader from a file.
+ */
+GLuint
+piglit_compile_shader(GLenum target, char *filename)
+{
+	GLuint prog;
+	struct stat st;
+	int err;
+	GLchar *prog_string;
+	FILE *f;
+	const char *source_dir;
+	char filename_with_path[FILENAME_MAX];
+
+	source_dir = getenv("PIGLIT_SOURCE_DIR");
+	if (source_dir == NULL) {
+		source_dir = SOURCE_DIR;
+	}
+
+	snprintf(filename_with_path, FILENAME_MAX - 1,
+		 "%s/tests/%s", source_dir, filename);
+	filename_with_path[FILENAME_MAX - 1] = 0;
+
+	err = stat(filename_with_path, &st);
+	if (err == -1) {
+		fprintf(stderr, "Couldn't stat program %s: %s\n", filename, strerror(errno));
+		fprintf(stderr, "You can override the source dir by setting the PIGLIT_SOURCE_DIR environment variable.\n");
+		exit(1);
+	}
+
+	prog_string = malloc(st.st_size + 1);
+	if (prog_string == NULL) {
+		fprintf(stderr, "malloc\n");
+		exit(1);
+	}
+
+	f = fopen(filename_with_path, "r");
+	if (f == NULL) {
+		fprintf(stderr, "Couldn't open program: %s\n", strerror(errno));
+		exit(1);
+	}
+	fread(prog_string, 1, st.st_size, f);
+	prog_string[st.st_size] = '\0';
+	fclose(f);
+
+	prog = piglit_compile_shader_text(target, prog_string);
+
+	free(prog_string);
+
+	return prog;
+}
+
+/** Return a string name for a shader target enum */
+static const char *
+shader_name(GLenum target)
+{
+   switch (target) {
+   case GL_VERTEX_SHADER:
+      return "vertex";
+#if defined USE_OPENGL
+   case GL_GEOMETRY_SHADER:
+      return "geometry";
+#endif
+   case GL_FRAGMENT_SHADER:
+      return "fragment";
+   default:
+      assert(!"Unexpected shader target in shader_name()");
+   }
+}
+
+/**
+ * Convenience function to compile a GLSL shader.
+ */
+GLuint
+piglit_compile_shader_text(GLenum target, const char *text)
+{
+	GLuint prog;
+	GLint ok;
+
+	piglit_require_GLSL();
+
+	prog = piglit_CreateShader(target);
+	piglit_ShaderSource(prog, 1, (const GLchar **) &text, NULL);
+	piglit_CompileShader(prog);
+
+	piglit_GetShaderiv(prog, GL_COMPILE_STATUS, &ok);
+
+	{
+		GLchar *info;
+		GLint size;
+
+		piglit_GetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
+		info = malloc(size);
+
+		piglit_GetShaderInfoLog(prog, size, NULL, info);
+		if (!ok) {
+			fprintf(stderr, "Failed to compile %s shader: %s\n",
+				shader_name(target),
+				info);
+			piglit_DeleteShader(prog);
+			prog = 0;
+		}
+		else if (0) {
+			/* Enable this to get extra compilation info.
+			 * Even if there's no compilation errors, the info
+			 * log may have some remarks.
+			 */
+			fprintf(stderr, "Shader compiler warning: %s\n", info);
+		}
+		free(info);
+	}
+
+	return prog;
+}
+
+static GLboolean
+link_check_status(GLint prog, FILE *output)
+{
+	GLchar *info = NULL;
+	GLint size;
+	GLint ok;
+
+	piglit_require_GLSL();
+
+	piglit_GetProgramiv(prog, GL_LINK_STATUS, &ok);
+
+	/* Some drivers return a size of 1 for an empty log.  This is the size
+	 * of a log that contains only a terminating NUL character.
+	 */
+	piglit_GetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
+	if (size > 1) {
+		info = malloc(size);
+		piglit_GetProgramInfoLog(prog, size, NULL, info);
+	}
+
+	if (!ok) {
+		fprintf(output, "Failed to link: %s\n",
+			(info != NULL) ? info : "<empty log>");
+	}
+	else if (0 && info != NULL) {
+		/* Enable this to get extra linking info.
+		 * Even if there's no link errors, the info log may
+		 * have some remarks.
+		 */
+		printf("Linker warning: %s\n", info);
+	}
+
+	free(info);
+
+	return ok;
+}
+
+GLboolean
+piglit_link_check_status(GLint prog)
+{
+	return link_check_status(prog, stderr);
+}
+
+/**
+ * Check link status
+ *
+ * Similar to piglit_link_check_status except it logs error messages
+ * to standard output instead of standard error.  This is useful for
+ * tests that want to produce negative link results.
+ *
+ * \sa piglit_link_check_status
+ */
+GLboolean
+piglit_link_check_status_quiet(GLint prog)
+{
+	return link_check_status(prog, stdout);
+}
+
+
+GLint piglit_link_simple_program(GLint vs, GLint fs)
+{
+	GLint prog;
+
+	piglit_require_GLSL();
+
+	prog = piglit_CreateProgram();
+	if (fs)
+		piglit_AttachShader(prog, fs);
+	if (vs)
+		piglit_AttachShader(prog, vs);
+	piglit_LinkProgram(prog);
+
+	if (!piglit_link_check_status(prog)) {
+		piglit_DeleteProgram(prog);
+		prog = 0;
+	}
+
+	return prog;
+}
diff --git a/tests/util/piglit-shader.h b/tests/util/piglit-shader.h
new file mode 100644
index 0000000..fca080d
--- /dev/null
+++ b/tests/util/piglit-shader.h
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) The Piglit project 2007
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#pragma once
+
+/**
+ * Null parameters are ignored.
+ *
+ * \param es Is it GLSL ES?
+ */
+void piglit_get_glsl_version(bool *es, int* major, int* minor);
+
+GLuint piglit_compile_shader(GLenum target, char *filename);
+GLuint piglit_compile_shader_text(GLenum target, const char *text);
+GLboolean piglit_link_check_status(GLint prog);
+GLboolean piglit_link_check_status_quiet(GLint prog);
+GLint piglit_link_simple_program(GLint vs, GLint fs);
+
+/**
+ * \name Portable wrappers for GLSL functions\
+ *
+ * \note
+ * One of \c piglit_require_GLSL, \c piglit_require_vertex_shader, or
+ * \c piglit_require_fragment_shader must be called before using these
+ * wrappers.
+ */
+/*@{*/
+#if defined(USE_OPENGL_ES2)
+#define piglit_AttachShader glAttachShader
+#define piglit_BindAttribLocation glBindAttribLocation
+#define piglit_CompileShader glCompileShader
+#define piglit_CreateProgram glCreateProgram
+#define piglit_CreateShader glCreateShader
+#define piglit_DeleteProgram glDeleteProgram
+#define piglit_DeleteShader glDeleteShader
+#define piglit_GetActiveUniform glGetActiveUniform
+#define piglit_GetAttribLocation glGetAttribLocation
+#define piglit_GetProgramInfoLog glGetProgramInfoLog
+#define piglit_GetProgramiv glGetProgramiv
+#define piglit_GetShaderInfoLog glGetShaderInfoLog
+#define piglit_GetShaderiv glGetShaderiv
+#define piglit_GetUniformLocation glGetUniformLocation
+#define piglit_LinkProgram glLinkProgram
+#define piglit_ShaderSource glShaderSource
+#define piglit_UseProgram glUseProgram
+#define piglit_Uniform1f glUniform1f
+#define piglit_Uniform2f glUniform2f
+#define piglit_Uniform3f glUniform3f
+#define piglit_Uniform4f glUniform4f
+#define piglit_Uniform1fv glUniform1fv
+#define piglit_Uniform2fv glUniform2fv
+#define piglit_Uniform3fv glUniform3fv
+#define piglit_Uniform4fv glUniform4fv
+#define piglit_Uniform1i glUniform1i
+#define piglit_Uniform2iv glUniform2iv
+#define piglit_Uniform3iv glUniform3iv
+#define piglit_Uniform4iv glUniform4iv
+#define piglit_UniformMatrix2fv glUniformMatrix2fv
+#define piglit_UniformMatrix3fv glUniformMatrix3fv
+#define piglit_UniformMatrix4fv glUniformMatrix4fv
+#define piglit_GetUniformfv glGetUniformfv
+#define piglit_VertexAttribPointer glVertexAttribPointer
+#define piglit_EnableVertexAttribArray glEnableVertexAttribArray
+#define piglit_DisableVertexAttribArray glDisableVertexAttribArray
+#define piglit_UniformMatrix2x3fv assert(!"glUniformMatrix2x3fv does not exist in ES")
+#define piglit_UniformMatrix2x4fv assert(!"glUniformMatrix2x4fv does not exist in ES")
+#define piglit_UniformMatrix3x2fv assert(!"glUniformMatrix3x2fv does not exist in ES")
+#define piglit_UniformMatrix3x4fv assert(!"glUniformMatrix3x4fv does not exist in ES")
+#define piglit_UniformMatrix4x2fv assert(!"glUniformMatrix4x2fv does not exist in ES")
+#define piglit_UniformMatrix4x3fv assert(!"glUniformMatrix4x3fv does not exist in ES")
+#else
+extern PFNGLATTACHSHADERPROC piglit_AttachShader;
+extern PFNGLBINDATTRIBLOCATIONPROC piglit_BindAttribLocation;
+extern PFNGLCOMPILESHADERPROC piglit_CompileShader;
+extern PFNGLCREATEPROGRAMPROC piglit_CreateProgram;
+extern PFNGLCREATESHADERPROC piglit_CreateShader;
+extern PFNGLDELETEPROGRAMPROC piglit_DeleteProgram;
+extern PFNGLDELETESHADERPROC piglit_DeleteShader;
+extern PFNGLGETACTIVEUNIFORMPROC piglit_GetActiveUniform;
+extern PFNGLGETATTRIBLOCATIONPROC piglit_GetAttribLocation;
+extern PFNGLGETPROGRAMINFOLOGPROC piglit_GetProgramInfoLog;
+extern PFNGLGETPROGRAMIVPROC piglit_GetProgramiv;
+extern PFNGLGETSHADERINFOLOGPROC piglit_GetShaderInfoLog;
+extern PFNGLGETSHADERIVPROC piglit_GetShaderiv;
+extern PFNGLGETUNIFORMLOCATIONPROC piglit_GetUniformLocation;
+extern PFNGLLINKPROGRAMPROC piglit_LinkProgram;
+extern PFNGLSHADERSOURCEPROC piglit_ShaderSource;
+extern PFNGLUSEPROGRAMPROC piglit_UseProgram;
+extern PFNGLUNIFORM1FPROC piglit_Uniform1f;
+extern PFNGLUNIFORM2FPROC piglit_Uniform2f;
+extern PFNGLUNIFORM3FPROC piglit_Uniform3f;
+extern PFNGLUNIFORM4FPROC piglit_Uniform4f;
+extern PFNGLUNIFORM1FVPROC piglit_Uniform1fv;
+extern PFNGLUNIFORM2FVPROC piglit_Uniform2fv;
+extern PFNGLUNIFORM3FVPROC piglit_Uniform3fv;
+extern PFNGLUNIFORM4FVPROC piglit_Uniform4fv;
+extern PFNGLUNIFORM1IPROC piglit_Uniform1i;
+extern PFNGLUNIFORM2IPROC piglit_Uniform2i;
+extern PFNGLUNIFORM3IPROC piglit_Uniform3i;
+extern PFNGLUNIFORM4IPROC piglit_Uniform4i;
+extern PFNGLUNIFORM1IVPROC piglit_Uniform1iv;
+extern PFNGLUNIFORM2IVPROC piglit_Uniform2iv;
+extern PFNGLUNIFORM3IVPROC piglit_Uniform3iv;
+extern PFNGLUNIFORM4IVPROC piglit_Uniform4iv;
+extern PFNGLUNIFORM1UIPROC piglit_Uniform1ui;
+extern PFNGLUNIFORM2UIPROC piglit_Uniform2ui;
+extern PFNGLUNIFORM3UIPROC piglit_Uniform3ui;
+extern PFNGLUNIFORM4UIPROC piglit_Uniform4ui;
+extern PFNGLUNIFORM1UIVPROC piglit_Uniform1uiv;
+extern PFNGLUNIFORM2UIVPROC piglit_Uniform2uiv;
+extern PFNGLUNIFORM3UIVPROC piglit_Uniform3uiv;
+extern PFNGLUNIFORM4UIVPROC piglit_Uniform4uiv;
+extern PFNGLUNIFORMMATRIX2FVPROC piglit_UniformMatrix2fv;
+extern PFNGLUNIFORMMATRIX3FVPROC piglit_UniformMatrix3fv;
+extern PFNGLUNIFORMMATRIX4FVPROC piglit_UniformMatrix4fv;
+extern PFNGLGETUNIFORMFVPROC piglit_GetUniformfv;
+extern PFNGLVERTEXATTRIBPOINTERPROC piglit_VertexAttribPointer;
+extern PFNGLENABLEVERTEXATTRIBARRAYPROC piglit_EnableVertexAttribArray;
+extern PFNGLDISABLEVERTEXATTRIBARRAYPROC piglit_DisableVertexAttribArray;
+extern PFNGLUNIFORMMATRIX2X3FVPROC piglit_UniformMatrix2x3fv;
+extern PFNGLUNIFORMMATRIX2X4FVPROC piglit_UniformMatrix2x4fv;
+extern PFNGLUNIFORMMATRIX3X2FVPROC piglit_UniformMatrix3x2fv;
+extern PFNGLUNIFORMMATRIX3X4FVPROC piglit_UniformMatrix3x4fv;
+extern PFNGLUNIFORMMATRIX4X2FVPROC piglit_UniformMatrix4x2fv;
+extern PFNGLUNIFORMMATRIX4X3FVPROC piglit_UniformMatrix4x3fv;
+#endif
+/*@}*/
+
+/**
+ * Require a specific version of GLSL.
+ *
+ * \param version Integer version, for example 130
+ */
+extern void piglit_require_GLSL_version(int version);
+/** Require any version of GLSL */
+extern void piglit_require_GLSL(void);
+extern void piglit_require_fragment_shader(void);
+extern void piglit_require_vertex_shader(void);
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 11117ed..248d46a 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <sys/stat.h>
 
 #include "config.h"
 #if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_SETRLIMIT)
@@ -90,39 +89,6 @@ void piglit_get_gl_version(bool *es, int* major, int* minor)
 		*minor = minor_local;
 }
 
-void piglit_get_glsl_version(bool *es, int* major, int* minor)
-{
-	bool es_local;
-	int major_local;
-	int minor_local;
-
-	const char *version_string;
-	int c; /* scanf count */
-
-	version_string = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
-	es_local = strncmp("OpenGL ES", version_string, 10) == 0;
-	if (es_local) {
-		c = sscanf(version_string,
-		           "OpenGL ES GLSL ES %i.%i",
-		           &major_local,
-		           &minor_local);
-	} else {
-		c = sscanf(version_string,
-		           "%i.%i",
-		           &major_local,
-		           &minor_local);
-	}
-	assert(c == 2);
-
-	/* Write outputs. */
-	if (es != NULL)
-		*es = es_local;
-	if (major != NULL)
-		*major = major_local;
-	if (minor != NULL)
-		*minor = minor_local;
-}
-
 bool piglit_is_extension_supported(const char *name)
 {
 	char *extensions;
@@ -304,201 +270,6 @@ piglit_report_result(enum piglit_result result)
 	}
 }
 
-/**
- * Convenience function to compile a GLSL shader from a file.
- */
-GLuint
-piglit_compile_shader(GLenum target, char *filename)
-{
-	GLuint prog;
-	struct stat st;
-	int err;
-	GLchar *prog_string;
-	FILE *f;
-	const char *source_dir;
-	char filename_with_path[FILENAME_MAX];
-
-	source_dir = getenv("PIGLIT_SOURCE_DIR");
-	if (source_dir == NULL) {
-		source_dir = SOURCE_DIR;
-	}
-
-	snprintf(filename_with_path, FILENAME_MAX - 1,
-		 "%s/tests/%s", source_dir, filename);
-	filename_with_path[FILENAME_MAX - 1] = 0;
-
-	err = stat(filename_with_path, &st);
-	if (err == -1) {
-		fprintf(stderr, "Couldn't stat program %s: %s\n", filename, strerror(errno));
-		fprintf(stderr, "You can override the source dir by setting the PIGLIT_SOURCE_DIR environment variable.\n");
-		exit(1);
-	}
-
-	prog_string = malloc(st.st_size + 1);
-	if (prog_string == NULL) {
-		fprintf(stderr, "malloc\n");
-		exit(1);
-	}
-
-	f = fopen(filename_with_path, "r");
-	if (f == NULL) {
-		fprintf(stderr, "Couldn't open program: %s\n", strerror(errno));
-		exit(1);
-	}
-	fread(prog_string, 1, st.st_size, f);
-	prog_string[st.st_size] = '\0';
-	fclose(f);
-
-	prog = piglit_compile_shader_text(target, prog_string);
-
-	free(prog_string);
-
-	return prog;
-}
-
-/** Return a string name for a shader target enum */
-static const char *
-shader_name(GLenum target)
-{
-   switch (target) {
-   case GL_VERTEX_SHADER:
-      return "vertex";
-#if defined USE_OPENGL
-   case GL_GEOMETRY_SHADER:
-      return "geometry";
-#endif
-   case GL_FRAGMENT_SHADER:
-      return "fragment";
-   default:
-      assert(!"Unexpected shader target in shader_name()");
-   }
-}
-
-/**
- * Convenience function to compile a GLSL shader.
- */
-GLuint
-piglit_compile_shader_text(GLenum target, const char *text)
-{
-	GLuint prog;
-	GLint ok;
-
-	piglit_require_GLSL();
-
-	prog = piglit_CreateShader(target);
-	piglit_ShaderSource(prog, 1, (const GLchar **) &text, NULL);
-	piglit_CompileShader(prog);
-
-	piglit_GetShaderiv(prog, GL_COMPILE_STATUS, &ok);
-
-	{
-		GLchar *info;
-		GLint size;
-
-		piglit_GetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
-		info = malloc(size);
-
-		piglit_GetShaderInfoLog(prog, size, NULL, info);
-		if (!ok) {
-			fprintf(stderr, "Failed to compile %s shader: %s\n",
-				shader_name(target),
-				info);
-			piglit_DeleteShader(prog);
-			prog = 0;
-		}
-		else if (0) {
-			/* Enable this to get extra compilation info.
-			 * Even if there's no compilation errors, the info
-			 * log may have some remarks.
-			 */
-			fprintf(stderr, "Shader compiler warning: %s\n", info);
-		}
-		free(info);
-	}
-
-	return prog;
-}
-
-static GLboolean
-link_check_status(GLint prog, FILE *output)
-{
-	GLchar *info = NULL;
-	GLint size;
-	GLint ok;
-
-	piglit_require_GLSL();
-
-	piglit_GetProgramiv(prog, GL_LINK_STATUS, &ok);
-
-	/* Some drivers return a size of 1 for an empty log.  This is the size
-	 * of a log that contains only a terminating NUL character.
-	 */
-	piglit_GetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
-	if (size > 1) {
-		info = malloc(size);
-		piglit_GetProgramInfoLog(prog, size, NULL, info);
-	}
-
-	if (!ok) {
-		fprintf(output, "Failed to link: %s\n",
-			(info != NULL) ? info : "<empty log>");
-	}
-	else if (0 && info != NULL) {
-		/* Enable this to get extra linking info.
-		 * Even if there's no link errors, the info log may
-		 * have some remarks.
-		 */
-		printf("Linker warning: %s\n", info);
-	}
-
-	free(info);
-
-	return ok;
-}
-
-GLboolean
-piglit_link_check_status(GLint prog)
-{
-	return link_check_status(prog, stderr);
-}
-
-/**
- * Check link status
- *
- * Similar to piglit_link_check_status except it logs error messages
- * to standard output instead of standard error.  This is useful for
- * tests that want to produce negative link results.
- *
- * \sa piglit_link_check_status
- */
-GLboolean
-piglit_link_check_status_quiet(GLint prog)
-{
-	return link_check_status(prog, stdout);
-}
-
-
-GLint piglit_link_simple_program(GLint vs, GLint fs)
-{
-	GLint prog;
-
-	piglit_require_GLSL();
-
-	prog = piglit_CreateProgram();
-	if (fs)
-		piglit_AttachShader(prog, fs);
-	if (vs)
-		piglit_AttachShader(prog, vs);
-	piglit_LinkProgram(prog);
-
-	if (!piglit_link_check_status(prog)) {
-		piglit_DeleteProgram(prog);
-		prog = 0;
-	}
-
-	return prog;
-}
-
 float piglit_tolerance[4] = { 0.01, 0.01, 0.01, 0.01 };
 
 void
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 567b8c9..0829428 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -82,6 +82,7 @@ enum piglit_result {
 };
 
 #include "piglit-framework.h"
+#include "piglit-shader.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
 
@@ -104,13 +105,6 @@ void piglit_glutInit(int argc, char **argv);
 void piglit_get_gl_version(bool *es, int* major, int* minor);
 
 /**
- * Null parameters are ignored.
- *
- * \param es Is it GLSL ES?
- */
-void piglit_get_glsl_version(bool *es, int* major, int* minor);
-
-/**
  * \precondition name is not null
  */
 bool piglit_is_extension_supported(const char *name);
@@ -165,11 +159,6 @@ int piglit_use_vertex_program(void);
 void piglit_require_fragment_program(void);
 void piglit_require_vertex_program(void);
 GLuint piglit_compile_program(GLenum target, const char* text);
-GLuint piglit_compile_shader(GLenum target, char *filename);
-GLuint piglit_compile_shader_text(GLenum target, const char *text);
-GLboolean piglit_link_check_status(GLint prog);
-GLboolean piglit_link_check_status_quiet(GLint prog);
-GLint piglit_link_simple_program(GLint vs, GLint fs);
 GLvoid piglit_draw_rect(float x, float y, float w, float h);
 GLvoid piglit_draw_rect_z(float z, float x, float y, float w, float h);
 GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,
@@ -220,127 +209,6 @@ extern const GLenum cube_face_targets[6];
  */
 extern GLint piglit_ARBfp_pass_through;
 
-/**
- * \name Portable wrappers for GLSL functions\
- *
- * \note
- * One of \c piglit_require_GLSL, \c piglit_require_vertex_shader, or
- * \c piglit_require_fragment_shader must be called before using these
- * wrappers.
- */
-/*@{*/
-#if defined(USE_OPENGL_ES2)
-#define piglit_AttachShader glAttachShader
-#define piglit_BindAttribLocation glBindAttribLocation
-#define piglit_CompileShader glCompileShader
-#define piglit_CreateProgram glCreateProgram
-#define piglit_CreateShader glCreateShader
-#define piglit_DeleteProgram glDeleteProgram
-#define piglit_DeleteShader glDeleteShader
-#define piglit_GetActiveUniform glGetActiveUniform
-#define piglit_GetAttribLocation glGetAttribLocation
-#define piglit_GetProgramInfoLog glGetProgramInfoLog
-#define piglit_GetProgramiv glGetProgramiv
-#define piglit_GetShaderInfoLog glGetShaderInfoLog
-#define piglit_GetShaderiv glGetShaderiv
-#define piglit_GetUniformLocation glGetUniformLocation
-#define piglit_LinkProgram glLinkProgram
-#define piglit_ShaderSource glShaderSource
-#define piglit_UseProgram glUseProgram
-#define piglit_Uniform1f glUniform1f
-#define piglit_Uniform2f glUniform2f
-#define piglit_Uniform3f glUniform3f
-#define piglit_Uniform4f glUniform4f
-#define piglit_Uniform1fv glUniform1fv
-#define piglit_Uniform2fv glUniform2fv
-#define piglit_Uniform3fv glUniform3fv
-#define piglit_Uniform4fv glUniform4fv
-#define piglit_Uniform1i glUniform1i
-#define piglit_Uniform2iv glUniform2iv
-#define piglit_Uniform3iv glUniform3iv
-#define piglit_Uniform4iv glUniform4iv
-#define piglit_UniformMatrix2fv glUniformMatrix2fv
-#define piglit_UniformMatrix3fv glUniformMatrix3fv
-#define piglit_UniformMatrix4fv glUniformMatrix4fv
-#define piglit_GetUniformfv glGetUniformfv
-#define piglit_VertexAttribPointer glVertexAttribPointer
-#define piglit_EnableVertexAttribArray glEnableVertexAttribArray
-#define piglit_DisableVertexAttribArray glDisableVertexAttribArray
-#define piglit_UniformMatrix2x3fv assert(!"glUniformMatrix2x3fv does not exist in ES")
-#define piglit_UniformMatrix2x4fv assert(!"glUniformMatrix2x4fv does not exist in ES")
-#define piglit_UniformMatrix3x2fv assert(!"glUniformMatrix3x2fv does not exist in ES")
-#define piglit_UniformMatrix3x4fv assert(!"glUniformMatrix3x4fv does not exist in ES")
-#define piglit_UniformMatrix4x2fv assert(!"glUniformMatrix4x2fv does not exist in ES")
-#define piglit_UniformMatrix4x3fv assert(!"glUniformMatrix4x3fv does not exist in ES")
-#else
-extern PFNGLATTACHSHADERPROC piglit_AttachShader;
-extern PFNGLBINDATTRIBLOCATIONPROC piglit_BindAttribLocation;
-extern PFNGLCOMPILESHADERPROC piglit_CompileShader;
-extern PFNGLCREATEPROGRAMPROC piglit_CreateProgram;
-extern PFNGLCREATESHADERPROC piglit_CreateShader;
-extern PFNGLDELETEPROGRAMPROC piglit_DeleteProgram;
-extern PFNGLDELETESHADERPROC piglit_DeleteShader;
-extern PFNGLGETACTIVEUNIFORMPROC piglit_GetActiveUniform;
-extern PFNGLGETATTRIBLOCATIONPROC piglit_GetAttribLocation;
-extern PFNGLGETPROGRAMINFOLOGPROC piglit_GetProgramInfoLog;
-extern PFNGLGETPROGRAMIVPROC piglit_GetProgramiv;
-extern PFNGLGETSHADERINFOLOGPROC piglit_GetShaderInfoLog;
-extern PFNGLGETSHADERIVPROC piglit_GetShaderiv;
-extern PFNGLGETUNIFORMLOCATIONPROC piglit_GetUniformLocation;
-extern PFNGLLINKPROGRAMPROC piglit_LinkProgram;
-extern PFNGLSHADERSOURCEPROC piglit_ShaderSource;
-extern PFNGLUSEPROGRAMPROC piglit_UseProgram;
-extern PFNGLUNIFORM1FPROC piglit_Uniform1f;
-extern PFNGLUNIFORM2FPROC piglit_Uniform2f;
-extern PFNGLUNIFORM3FPROC piglit_Uniform3f;
-extern PFNGLUNIFORM4FPROC piglit_Uniform4f;
-extern PFNGLUNIFORM1FVPROC piglit_Uniform1fv;
-extern PFNGLUNIFORM2FVPROC piglit_Uniform2fv;
-extern PFNGLUNIFORM3FVPROC piglit_Uniform3fv;
-extern PFNGLUNIFORM4FVPROC piglit_Uniform4fv;
-extern PFNGLUNIFORM1IPROC piglit_Uniform1i;
-extern PFNGLUNIFORM2IPROC piglit_Uniform2i;
-extern PFNGLUNIFORM3IPROC piglit_Uniform3i;
-extern PFNGLUNIFORM4IPROC piglit_Uniform4i;
-extern PFNGLUNIFORM1IVPROC piglit_Uniform1iv;
-extern PFNGLUNIFORM2IVPROC piglit_Uniform2iv;
-extern PFNGLUNIFORM3IVPROC piglit_Uniform3iv;
-extern PFNGLUNIFORM4IVPROC piglit_Uniform4iv;
-extern PFNGLUNIFORM1UIPROC piglit_Uniform1ui;
-extern PFNGLUNIFORM2UIPROC piglit_Uniform2ui;
-extern PFNGLUNIFORM3UIPROC piglit_Uniform3ui;
-extern PFNGLUNIFORM4UIPROC piglit_Uniform4ui;
-extern PFNGLUNIFORM1UIVPROC piglit_Uniform1uiv;
-extern PFNGLUNIFORM2UIVPROC piglit_Uniform2uiv;
-extern PFNGLUNIFORM3UIVPROC piglit_Uniform3uiv;
-extern PFNGLUNIFORM4UIVPROC piglit_Uniform4uiv;
-extern PFNGLUNIFORMMATRIX2FVPROC piglit_UniformMatrix2fv;
-extern PFNGLUNIFORMMATRIX3FVPROC piglit_UniformMatrix3fv;
-extern PFNGLUNIFORMMATRIX4FVPROC piglit_UniformMatrix4fv;
-extern PFNGLGETUNIFORMFVPROC piglit_GetUniformfv;
-extern PFNGLVERTEXATTRIBPOINTERPROC piglit_VertexAttribPointer;
-extern PFNGLENABLEVERTEXATTRIBARRAYPROC piglit_EnableVertexAttribArray;
-extern PFNGLDISABLEVERTEXATTRIBARRAYPROC piglit_DisableVertexAttribArray;
-extern PFNGLUNIFORMMATRIX2X3FVPROC piglit_UniformMatrix2x3fv;
-extern PFNGLUNIFORMMATRIX2X4FVPROC piglit_UniformMatrix2x4fv;
-extern PFNGLUNIFORMMATRIX3X2FVPROC piglit_UniformMatrix3x2fv;
-extern PFNGLUNIFORMMATRIX3X4FVPROC piglit_UniformMatrix3x4fv;
-extern PFNGLUNIFORMMATRIX4X2FVPROC piglit_UniformMatrix4x2fv;
-extern PFNGLUNIFORMMATRIX4X3FVPROC piglit_UniformMatrix4x3fv;
-#endif
-/*@}*/
-
-/**
- * Require a specific version of GLSL.
- *
- * \param version Integer version, for example 130
- */
-extern void piglit_require_GLSL_version(int version);
-/** Require any version of GLSL */
-extern void piglit_require_GLSL(void);
-extern void piglit_require_fragment_shader(void);
-extern void piglit_require_vertex_shader(void);
-
 #ifndef HAVE_STRCHRNUL
 char *strchrnul(const char *s, int c);
 #endif
-- 
1.7.5.4



More information about the Piglit mailing list