[Piglit] [PATCH 3/9] shader_runner: Add simple support for binding vertex/fragment programs.
Eric Anholt
eric at anholt.net
Tue Nov 29 16:43:53 PST 2011
This should let us write tests using things like texturing and other
extensions more easily than extending vpfp-generic to do the same.
---
tests/shaders/shader_runner.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 03052d6..047416f 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -169,6 +169,29 @@ compile_glsl(GLenum target, bool release_text)
}
}
+void
+compile_and_bind_program(GLenum target, const char *start, int len)
+{
+ GLuint prog;
+ char *source;
+
+ switch (target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ piglit_require_extension("GL_ARB_vertex_program");
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ piglit_require_extension("GL_ARB_fragment_program");
+ break;
+ }
+
+ source = malloc(len + 1);
+ memcpy(source, start, len);
+ source[len] = 0;
+ prog = piglit_compile_program(target, source);
+
+ glEnable(target);
+ glBindProgramARB(target, prog);
+}
/**
* Copy a string until either whitespace or the end of the string
@@ -462,6 +485,9 @@ leave_state(enum states state, const char *line)
break;
case vertex_program:
+ compile_and_bind_program(GL_VERTEX_PROGRAM_ARB,
+ shader_strings[0],
+ line - shader_strings[0]);
break;
case geometry_shader:
@@ -481,6 +507,9 @@ leave_state(enum states state, const char *line)
break;
case fragment_program:
+ compile_and_bind_program(GL_FRAGMENT_PROGRAM_ARB,
+ shader_strings[0],
+ line - shader_strings[0]);
break;
case vertex_data:
@@ -595,6 +624,9 @@ process_test_script(const char *script_name)
} else if (string_match("[vertex shader]", line)) {
state = vertex_shader;
shader_strings[0] = NULL;
+ } else if (string_match("[vertex program]", line)) {
+ state = vertex_program;
+ shader_strings[0] = NULL;
} else if (string_match("[vertex shader file]", line)) {
state = vertex_shader_file;
shader_strings[0] = NULL;
@@ -602,6 +634,9 @@ process_test_script(const char *script_name)
} else if (string_match("[fragment shader]", line)) {
state = fragment_shader;
shader_strings[0] = NULL;
+ } else if (string_match("[fragment program]", line)) {
+ state = fragment_program;
+ shader_strings[0] = NULL;
} else if (string_match("[fragment shader file]", line)) {
state = fragment_shader_file;
shader_strings[0] = NULL;
--
1.7.7.3
More information about the Piglit
mailing list