[Piglit] [PATCH 2/2] Make shader_runner add a #version directive to shaders lacking one.

Stuart Abercrombie sabercrombie at chromium.org
Wed Sep 12 11:18:42 PDT 2012


This was a solitary patch.  I think the git submit feature decided
there were two on account of an old patch file in the same directory.
Sorry for the confusion.

Stuart

On Mon, Sep 10, 2012 at 5:55 PM, Stuart Abercrombie
<sabercrombie at chromium.org> wrote:
> The version number is taken from the GLSL version requirement, if there is one.
>
> This is part of the effort to make version handling more flexible for GLES.
> ---
>  tests/shaders/shader_runner.c |   41 ++++++++++++++++++++++++++++++++++-------
>  1 files changed, 34 insertions(+), 7 deletions(-)
>
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index 6e3a470..88b36f8 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -48,6 +48,7 @@ extern float piglit_tolerance[4];
>
>  static float gl_version = 0.0;
>  static float glsl_version = 0.0;
> +static float glsl_req_version = 0.0;
>  static int gl_max_fragment_uniform_components;
>  static int gl_max_vertex_uniform_components;
>
> @@ -121,9 +122,29 @@ compile_glsl(GLenum target, bool release_text)
>                 break;
>         }
>
> -       piglit_ShaderSource(shader, 1,
> -                           &shader_string,
> -                           &shader_string_size);
> +       if (glsl_req_version != 0.0f &&
> +           !string_match("#version ", shader_string)) {
> +               char *shader_strings[2];
> +               char version_string[100];
> +               GLint shader_string_sizes[2];
> +
> +               /* Add a #version directive based on the GLSL requirement. */
> +               sprintf(version_string, "#version %ld\n",
> +                       lround(100.0f * glsl_req_version));
> +               shader_strings[0] = version_string;
> +               shader_string_sizes[0] = strlen(version_string);
> +               shader_strings[1] = shader_string;
> +               shader_string_sizes[1] = shader_string_size;
> +
> +               piglit_ShaderSource(shader, 2,
> +                                   shader_strings,
> +                                   shader_string_sizes);
> +
> +       } else {
> +               piglit_ShaderSource(shader, 1,
> +                                   &shader_string,
> +                                   &shader_string_size);
> +       }
>
>         piglit_CompileShader(shader);
>
> @@ -416,18 +437,24 @@ process_requirement(const char *line)
>                 piglit_require_not_extension(buffer);
>         } else if (string_match("GLSL", line)) {
>                 enum comparison cmp;
> -               float version;
>
>                 line = eat_whitespace(line + 4);
>
>                 line = process_comparison(line, &cmp);
>
> -               version = strtod(line, NULL);
> -               if (!compare(version, glsl_version, cmp)) {
> +               /* We only allow >= because we potentially use the
> +                * version number to insert a #version directive. */
> +               if (cmp != greater_equal) {
> +                       printf("Unsupported GLSL version comparison\n");
> +                       piglit_report_result(PIGLIT_FAIL);
> +               }
> +
> +               glsl_req_version = strtod(line, NULL);
> +               if (!compare(glsl_req_version, glsl_version, cmp)) {
>                         printf("Test requires GLSL version %s %.1f.  "
>                                "Actual version is %.1f.\n",
>                                comparison_string(cmp),
> -                              version,
> +                              glsl_req_version,
>                                glsl_version);
>                         piglit_report_result(PIGLIT_SKIP);
>                 }
> --
> 1.7.7.3
>


More information about the Piglit mailing list