[Piglit] [PATCH] Alter shader_runner GL/GLSL ES version requirement syntax.

Stuart Abercrombie sabercrombie at chromium.org
Tue Jan 15 19:25:35 PST 2013


The current syntax isn't compatible with the same shader_test
supporting GL and GLES in the future.

Modify existing GL ES tests to use the new syntax, and remove
explicit #version directives, which will instead be inserted based on
GLSL >= requirements.

v2 Added check for trailing chars. Formatting.
---
 tests/shaders/shader_runner.c                      |   24 +++++++++----------
 .../spec/glsl-es-1.00/execution/sanity.shader_test |    7 +----
 .../spec/glsl-es-3.00/execution/sanity.shader_test |    8 +-----
 3 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index db92b8f..8dfeb2a 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -459,15 +459,8 @@ process_comparison(const char *src, enum comparison *cmp)
 
 
 /**
- * To specify an ES version, append "es" to the version. For example:
- * 	GL >= 3.0 es
- * 	GLSL >= 3.00 es
- *
- * GLSL ES 1.00 is a special case. Despite being an ES shading language,
- * the #version directive lacks "es"; that is, the directive is
- * `#version 100` rather than `#version 100 es`. Therefore be lenient in
- * parsing that version. Interpret `GLSL >= 100` and `GLSL >= 100 es`
- * identically.
+ * " ES" before the comparison operator indicates the version
+ * pertains to GL ES.
  */
 void
 parse_version_comparison(const char *line, enum comparison *cmp,
@@ -476,8 +469,12 @@ parse_version_comparison(const char *line, enum comparison *cmp,
 	unsigned major;
 	unsigned minor;
 	unsigned full_num;
-	bool es;
+	bool es = false;
 
+	if (string_match(" ES", line)) {
+		es = true;
+		line += 3;
+	}
 	line = eat_whitespace(line);
 	line = process_comparison(line, cmp);
 
@@ -486,7 +483,10 @@ parse_version_comparison(const char *line, enum comparison *cmp,
 	line = eat_text(line);
 
 	line = eat_whitespace(line);
-	es = string_match("es", line);
+	if (*line != '\n') {
+		printf("Unexpected characters following version comparison\n");
+		piglit_report_result(PIGLIT_FAIL);
+	}
 
 	/* This hack is so that we can tell the difference between GL versions
 	 * and GLSL versions.  All GL versions look like 3.2, and we want the
@@ -495,8 +495,6 @@ parse_version_comparison(const char *line, enum comparison *cmp,
 	 */
 	if (tag == VERSION_GLSL) {
 		full_num = (major * 100) + minor;
-		if (full_num == 100)
-			es = true;
 	} else {
 		full_num = (major * 10) + minor;
 	}
diff --git a/tests/spec/glsl-es-1.00/execution/sanity.shader_test b/tests/spec/glsl-es-1.00/execution/sanity.shader_test
index a1dc07a..0884e2c 100644
--- a/tests/spec/glsl-es-1.00/execution/sanity.shader_test
+++ b/tests/spec/glsl-es-1.00/execution/sanity.shader_test
@@ -1,11 +1,10 @@
 # Fill the window with red, then green, then blue.
 
 [require]
-GL >= 2.0 es
+GL ES >= 2.0
+GLSL ES >= 1.00
 
 [vertex shader]
-#version 100
-
 attribute vec4 vertex;
 
 void main() {
@@ -13,8 +12,6 @@ void main() {
 }
 
 [fragment shader]
-#version 100
-
 uniform vec4 u_color;
 
 void main() {
diff --git a/tests/spec/glsl-es-3.00/execution/sanity.shader_test b/tests/spec/glsl-es-3.00/execution/sanity.shader_test
index e7e6ded..1709d78 100644
--- a/tests/spec/glsl-es-3.00/execution/sanity.shader_test
+++ b/tests/spec/glsl-es-3.00/execution/sanity.shader_test
@@ -1,12 +1,10 @@
 # Fill the window with red, then green, then blue.
 
 [require]
-GL >= 3.0 es
-GLSL >= 3.00 es
+GL ES >= 3.0
+GLSL ES >= 3.00
 
 [vertex shader]
-#version 300 es
-
 in vec4 vertex;
 
 void main() {
@@ -14,8 +12,6 @@ void main() {
 }
 
 [fragment shader]
-#version 300 es
-
 uniform vec4 u_color;
 out vec4 color;
 
-- 
1.7.5.4



More information about the Piglit mailing list