[Piglit] [PATCH V4 2/5] shader_runner: add support for setting uniform by location

Timothy Arceri timothy.arceri at collabora.com
Sun Dec 6 16:06:34 PST 2015


For example to set an int at location 1 to the value 0:
uniform int 1 0

Previously only name could be used to set the uniform.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/shaders/shader_runner.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index da21af2..262157b 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1626,26 +1626,30 @@ set_uniform(const char *line, int ubo_array_index)
 	double d[16];
 	int ints[16];
 	unsigned uints[16];
-	GLuint prog;
 	GLint loc;
 	const char *type;
 
-	glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *) &prog);
-
 	type = eat_whitespace(line);
 	line = eat_text(type);
 
 	line = strcpy_to_space(name, eat_whitespace(line));
 
-	if (set_ubo_uniform(name, type, line, ubo_array_index))
-		return;
+	if (isdigit(name[0])) {
+		loc = strtol(name, NULL, 0);
+	} else {
+		GLuint prog;
 
-	loc = glGetUniformLocation(prog, name);
-	if (loc < 0) {
-		printf("cannot get location of uniform \"%s\"\n",
-		       name);
-		piglit_report_result(PIGLIT_FAIL);
-	}
+		if (set_ubo_uniform(name, type, line, ubo_array_index))
+			return;
+
+		glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *) &prog);
+		loc = glGetUniformLocation(prog, name);
+		if (loc < 0) {
+			printf("cannot get location of uniform \"%s\"\n",
+			       name);
+			piglit_report_result(PIGLIT_FAIL);
+		}
+        }
 
 	if (string_match("float", type)) {
 		get_floats(line, f, 1);
-- 
2.4.3



More information about the Piglit mailing list