On 10 September 2012 17:55, Stuart Abercrombie <span dir="ltr"><<a href="mailto:sabercrombie@chromium.org" target="_blank">sabercrombie@chromium.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The version number is taken from the GLSL version requirement, if there is one.<br>
<br>
This is part of the effort to make version handling more flexible for GLES.<br>
---<br>
 tests/shaders/shader_runner.c |   41 ++++++++++++++++++++++++++++++++++-------<br>
 1 files changed, 34 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c<br>
index 6e3a470..88b36f8 100644<br>
--- a/tests/shaders/shader_runner.c<br>
+++ b/tests/shaders/shader_runner.c<br>
@@ -48,6 +48,7 @@ extern float piglit_tolerance[4];<br>
<br>
 static float gl_version = 0.0;<br>
 static float glsl_version = 0.0;<br>
+static float glsl_req_version = 0.0;<br>
 static int gl_max_fragment_uniform_components;<br>
 static int gl_max_vertex_uniform_components;<br>
<br>
@@ -121,9 +122,29 @@ compile_glsl(GLenum target, bool release_text)<br>
                break;<br>
        }<br>
<br>
-       piglit_ShaderSource(shader, 1,<br>
-                           &shader_string,<br>
-                           &shader_string_size);<br>
+       if (glsl_req_version != 0.0f &&<br>
+           !string_match("#version ", shader_string)) {<br>
+               char *shader_strings[2];<br>
+               char version_string[100];<br>
+               GLint shader_string_sizes[2];<br>
+<br>
+               /* Add a #version directive based on the GLSL requirement. */<br>
+               sprintf(version_string, "#version %ld\n",<br>
+                       lround(100.0f * glsl_req_version));<br>
+               shader_strings[0] = version_string;<br>
+               shader_string_sizes[0] = strlen(version_string);<br>
+               shader_strings[1] = shader_string;<br>
+               shader_string_sizes[1] = shader_string_size;<br>
+<br>
+               piglit_ShaderSource(shader, 2,<br>
+                                   shader_strings,<br>
+                                   shader_string_sizes);<br>
+<br>
+       } else {<br>
+               piglit_ShaderSource(shader, 1,<br>
+                                   &shader_string,<br>
+                                   &shader_string_size);<br>
+       }<br>
<br>
        piglit_CompileShader(shader);<br>
<br>
@@ -416,18 +437,24 @@ process_requirement(const char *line)<br>
                piglit_require_not_extension(buffer);<br>
        } else if (string_match("GLSL", line)) {<br>
                enum comparison cmp;<br>
-               float version;<br>
<br>
                line = eat_whitespace(line + 4);<br>
<br>
                line = process_comparison(line, &cmp);<br>
<br>
-               version = strtod(line, NULL);<br>
-               if (!compare(version, glsl_version, cmp)) {<br>
+               /* We only allow >= because we potentially use the<br>
+                * version number to insert a #version directive. */<br>
+               if (cmp != greater_equal) {<br>
+                       printf("Unsupported GLSL version comparison\n");<br>
+                       piglit_report_result(PIGLIT_FAIL);<br>
+               }<br>
+<br>
+               glsl_req_version = strtod(line, NULL);<br>
+               if (!compare(glsl_req_version, glsl_version, cmp)) {<br>
                        printf("Test requires GLSL version %s %.1f.  "<br>
                               "Actual version is %.1f.\n",<br>
                               comparison_string(cmp),<br>
-                              version,<br>
+                              glsl_req_version,<br>
                               glsl_version);<br>
                        piglit_report_result(PIGLIT_SKIP);<br>
                }<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.3<br>
<br>
</font></span></blockquote></div><br>Looks reasonable to me.<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br><br>What was patch 1/2?  I don't see it on the list.<br>