[Piglit] [PATCH 3/4] shader_runner: add support for setting glActiveShaderProgram()

Timothy Arceri timothy.arceri at collabora.com
Fri Dec 4 02:11:05 PST 2015


This will allow us to set uniforms in SSO.

For example to make the fragment program active:
active shader program GL_FRAGMENT_SHADER
---
 tests/shaders/shader_runner.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 7d8cc3f..35e91dc 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -123,6 +123,8 @@ GLint shader_string_size;
 const char *vertex_data_start = NULL;
 const char *vertex_data_end = NULL;
 GLuint prog;
+GLuint sso_vertex_prog;
+GLuint sso_fragment_prog;
 GLuint pipeline;
 size_t num_vbo_rows = 0;
 bool vbo_present = false;
@@ -522,9 +524,11 @@ create_sso(GLenum target, const char *start, int len)
 
 	switch (target) {
 	case GL_VERTEX_SHADER:
+		sso_vertex_prog = prog;
 		glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, prog);
 		break;
 	case GL_FRAGMENT_SHADER:
+		sso_fragment_prog = prog;
 		glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, prog);
 		break;
 	}
@@ -2721,6 +2725,15 @@ piglit_display(void)
 			next_line++;
 
 		if (line[0] == '\0') {
+		} else if (sscanf(line, "active shader program %s", s) == 1) {
+			switch (get_shader_from_string(s, &x)) {
+			case GL_VERTEX_SHADER:
+				glActiveShaderProgram(pipeline, sso_vertex_prog);
+			break;
+			case GL_FRAGMENT_SHADER:
+				glActiveShaderProgram(pipeline, sso_fragment_prog);
+			break;
+			}
 		} else if (sscanf(line, "atomic counters %d", &x) == 1) {
 			GLuint *atomics_buf = calloc(x, sizeof(GLuint));
 			glGenBuffers(1, &atomics_bo);
-- 
2.4.3



More information about the Piglit mailing list