On 12 September 2012 11:18, 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">
This was a solitary patch. I think the git submit feature decided<br>
there were two on account of an old patch file in the same directory.<br>
Sorry for the confusion.<br>
<span><font color="#888888"><br>
Stuart<br>
</font></span><div><div><br>
On Mon, Sep 10, 2012 at 5:55 PM, Stuart Abercrombie<br>
<<a href="mailto:sabercrombie@chromium.org" target="_blank">sabercrombie@chromium.org</a>> wrote:<br>
> 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>
> --<br>
> 1.7.7.3<br>
><br>
</div></div></blockquote></div><br>Whoops, I was just about to push this when I realized that it regresses some piglit tests. It seems that in some of our tests, the "#version" directive isn't at the beginning of the shader (it comes after some comments) so it isn't detected by string_match("#version ", shader_string).<br>
<br>I'll send out an updated patch that uses strstr() to search for "#version ". In principle that could still be fooled (by a commented out #version directive) but I think that's unlikely to be a problem. Assuming my revision looks good to you, I'll push it.<br>