<div class="gmail_quote">On 27 August 2012 17:23, Stuart Abercrombie <span dir="ltr"><<a href="mailto:sabercrombie@google.com" target="_blank">sabercrombie@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for the detailed response. I had various other changes bundled<br>
up with this but I thought it best to get some feedback before going<br>
too far.<br>
<br>
1. I got ESSL from gles2_shader_runner.c. I wanted to use a more<br>
obvious string but the way the parser is written made it more<br>
convenient to have a string the same length as GLSL. It's easy enough<br>
to change with a minor cost in source ugliness.<br>
<br>
2. I envisaged all the shader_test files specifying both GLSL<br>
versions. Since all .shader_test files would need modification in the<br>
end I was thinking they could be updated to conform to new<br>
expectations.<br>
<br>
I guess there's some value in handling missing GLSL version<br>
specifiers.</blockquote><div><br></div><div>The main value I see is to cover the case where there is no GLSL ES version that makes sense for the test (e.g. clipping tests) or where there is no desktop GLSL version that makes sense (probably rarer, but I bet we'll come up with a few).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I assume then that we would also have a GL ES version<br>
requirement to go with the GL version requirement, operating in a<br>
similar way.<br></blockquote><div><br></div><div>Ah, good point, yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
3. I'm very glad to hear about the multiple file loading being<br>
unnecessary. That does indeed make things much simpler.<br>
<br>
4. I thought a lot about trying to use the existing GLSL requirement<br>
instead of introducing a new one. As you say, the problem lies with<br>
general comparison operators. I verified that operators other than >=<br>
weren't being used, so I was tempted to do exactly what you suggest<br>
and reject them.<br>
<br>
In the end I was worried about a) effectively introducing a more<br>
irregular syntax and b) foreclosing the possibility of testing GLSL<br>
features with #version strings decoupled from the GLSL requirement<br>
(not that I can think of a particular scenario for this). I'm fine<br>
with a) if you are. As for b), it seems it would be covered by your<br>
suggestion of making #version strings in the source optional.<br>
<br>
Minor problems:<br>
<br>
1. Thanks. I was planning to revisit this.<br>
<br>
2. I hadn't noticed the Open GL ES 3 #version syntax change -- thanks.<br>
<br>
The multi-patch plan sounds good. I'll pursue that.<br>
<span class="HOEnZb"><font color="#888888"><br>
Stuart<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Mon, Aug 27, 2012 at 1:46 PM, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> On 24 August 2012 16:09, Stuart Abercrombie <<a href="mailto:sabercrombie@chromium.org">sabercrombie@chromium.org</a>><br>
> wrote:<br>
>><br>
>> The idea is to allow different GLSL versions for GL vs GL ES. There<br>
>> shouldn't be a functional change until shader scripts are altered too.<br>
>><br>
>> Added ES GLSL version string parsing.<br>
><br>
><br>
> I like where you're going with this. A few comments before we get into the<br>
> patch itself:<br>
><br>
> 1. "ESSL" is a nonstandard name for the GLES shading language. Let's use<br>
> "GLSL ES".<br>
><br>
> 2. How to we want the two different builds of shader_runner to handle the<br>
> following four possible requirements sections?<br>
><br>
> (a)<br>
> GLSL >= 130<br>
><br>
> (b)<br>
> GLSL ES >= 300<br>
><br>
> (c)<br>
> GLSL >= 130<br>
> GLSL ES >= 300<br>
><br>
> (d) (no versions specified)<br>
><br>
> My expectation would be:<br>
> - test (a) should only be run when desktop GLSL version 130 or above is<br>
> available, and should be skipped when testing GLES.<br>
> - test (b) should only be run when GLSL ES version 300 or above is<br>
> available, and should be skipped when testing desktop GL*.<br>
> - test (c) should be run with GLSL version 130 when testing desktop GL, and<br>
> GLSL ES version 300 when testing GLES*.<br>
> - test (d) should produce an error message regardless of whether desktop GL<br>
> or GLSL ES is being tested.<br>
><br>
> *At a later date we will probably also to be able to run the GLSL ES tests<br>
> under desktop GL using the ARB_ES{2,3}_compatibility extension, but I'm<br>
> happy not to worry about that yet :)<br>
><br>
> As written, the patch will run test (a) when desktop GLSL version 130 or<br>
> above is available, as expected, but it will aso run test (a) when testing<br>
> GLES, which is unlikely to be the test author's intention. Vice versa for<br>
> test (b). Test (c) will work as I would expect. Test (d) will be run on<br>
> all implementations, which I again think is unlikely to be the author's<br>
> intention (because in this case the author probably just forgot to include<br>
> the version annotation).<br>
><br>
> 3. A lot of the complexity of the patch has to do with the fact that the<br>
> version string is inserted into element 0 of the shader_strings array, so<br>
> the code has to treat it specially, and the special treatment that was<br>
> previously given to shader_strings[0] has to be shifted over to<br>
> shader_strings[1]. I don't think we actually have to introduce this kind of<br>
> complication, because it turns out that the only reason that shader_strings<br>
> is an array in the first place is to support a feature that is never used<br>
> (the ability to specify multiple files in a single "[vertex shader file]" or<br>
> "[fragment shader file]" and have them concatenated). I've talked to Ian<br>
> about this and we both agree that this feature isn't necessary.<br>
><br>
> 4. It seems inconvenient for every test to have to specify both "GLSL >=<br>
> xxx" and "GLSL_#version xxx" in the requirements section. My recommendation<br>
> would be to compute the version string based on the "GLSL >= xxx" line, and<br>
> add logic that suppresses autogeneration of a "#version" line if a<br>
> "#version" line is already present. Note that if we do this we have to<br>
> decide how to handle requirements of the form "GLSL > xxx", "GLSL < xxx" and<br>
> "GLSL != xxx". I think for now we could just reject those constructs (they<br>
> aren't used anyhow), and if later they turn out to be needed we can figure<br>
> out what to do when we get to that.<br>
><br>
> (Note: eventually Chad and I would like shader_runner to be able to run a<br>
> "GLSL >= 1.10" test on *all* GLSL versions instead of just one, but I think<br>
> we can leave that for a later task).<br>
><br>
> So I would recommend breaking this into 5 patches:<br>
><br>
> 1. Get rid of the ability to specify multiple files in a single "[vertex<br>
> shader file]" or "[fragment shader file]", and replace the shader_strings<br>
> array with a single shader_string.<br>
> 2. Make shader_runner able to generate a "#version" line (if none is already<br>
> present).<br>
> 3. If there are any tests that don't have a version requirement line, add a<br>
> "GLSL >= 1.10" requirement (though I don't think there are any).<br>
> 4. Make shader_runner produce an error if there is no version requirement<br>
> line.<br>
> 5. Make shader_runner support "GLSL ES >= xxx" version requirements.<br>
><br>
> A few more specific comments follow.<br>
><br>
>><br>
>> ---<br>
>> tests/shaders/shader_runner.c | 85<br>
>> +++++++++++++++++++++++++++++-----------<br>
>> 1 files changed, 61 insertions(+), 24 deletions(-)<br>
>><br>
>> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c<br>
>> index aa60a62..b9d506a 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_pound_version = 0.0;<br>
>> static int gl_max_fragment_uniform_components;<br>
>> static int gl_max_vertex_uniform_components;<br>
>><br>
>> @@ -69,6 +70,7 @@ GLuint *uniform_block_bos;<br>
>> * Some test script sections, such as "[vertex shader file]", can supply<br>
>> shader<br>
>> * source code from multiple disk files. This array stores those<br>
>> strings.<br>
>> */<br>
>> +char shader_ver_string[100];<br>
>> char *shader_strings[256];<br>
>> GLsizei shader_string_sizes[256];<br>
>> unsigned num_shader_strings = 0;<br>
>> @@ -129,6 +131,16 @@ compile_glsl(GLenum target, bool release_text)<br>
>> break;<br>
>> }<br>
>><br>
>> + // Insert version string, if there is one<br>
>> + if (glsl_pound_version != 0.0f) {<br>
>> + sprintf(shader_ver_string, "#version %d\n",<br>
>> + (int)(100.0f * glsl_pound_version));<br>
><br>
><br>
> Two minor problems here:<br>
><br>
> 1. This is going to cause rounding errors. For example, 4.1 represented as<br>
> a float is actually 4.0999999, so when you multiply by 100.0 and take the<br>
> integer part you'll get 409 instead of 410. I'd recommend using round().<br>
><br>
> 2. The correct version string for GLSL ES 1.00 is "#version 100", but the<br>
> correct version string for GLSL ES 3.00 is "#version 300 es". I think it's<br>
> reasonable to assume that all future versions of GLSL ES will use the "es"<br>
> suffix on the version string as well.<br>
><br>
>><br>
>> + } else {<br>
>> + sprintf(shader_ver_string, "\n");<br>
>> + }<br>
>> + shader_strings[0] = shader_ver_string;<br>
>> + shader_string_sizes[0] = strlen(shader_strings[0]);<br>
>> +<br>
>> piglit_ShaderSource(shader, num_shader_strings,<br>
>> (const GLchar **) shader_strings,<br>
>> shader_string_sizes);<br>
>> @@ -155,7 +167,7 @@ compile_glsl(GLenum target, bool release_text)<br>
>> }<br>
>><br>
>> if (release_text) {<br>
>> - for (i = 0; i < num_shader_strings; i++)<br>
>> + for (i = 1; i < num_shader_strings; i++)<br>
>> free(shader_strings[i]);<br>
>> }<br>
>><br>
>> @@ -419,11 +431,15 @@ process_requirement(const char *line)<br>
>> } else if (string_match("!GL_", line)) {<br>
>> strcpy_to_space(buffer, line + 1);<br>
>> piglit_require_not_extension(buffer);<br>
>> - } else if (string_match("GLSL", line)) {<br>
>> +#if defined USE_OPENGL<br>
>> + } else if (string_match("GLSL ", line)) {<br>
>> +#else<br>
>> + } else if (string_match("ESSL ", line)) {<br>
>> +#endif<br>
>> enum comparison cmp;<br>
>> float version;<br>
>><br>
>> - line = eat_whitespace(line + 4);<br>
>> + line = eat_whitespace(line + 5);<br>
>><br>
>> line = process_comparison(line, &cmp);<br>
>><br>
>> @@ -435,12 +451,22 @@ process_requirement(const char *line)<br>
>> version,<br>
>> glsl_version);<br>
>> piglit_report_result(PIGLIT_SKIP);<br>
>> - }<br>
>> - } else if (string_match("GL", line)) {<br>
>> + }<br>
>> +#if defined USE_OPENGL<br>
>> + } else if (string_match("GLSL_#version", line)) {<br>
>> +#else<br>
>> + } else if (string_match("ESSL_#version", line)) {<br>
>> +#endif<br>
>> + line = eat_whitespace(line + 14);<br>
>> +<br>
>> + glsl_pound_version = strtod(line, NULL);<br>
>> +<br>
>> + printf("GLSL #version= %f\n", glsl_pound_version);<br>
>> + } else if (string_match("GL ", line)) {<br>
>> enum comparison cmp;<br>
>> float version;<br>
>><br>
>> - line = eat_whitespace(line + 2);<br>
>> + line = eat_whitespace(line + 3);<br>
>><br>
>> line = process_comparison(line, &cmp);<br>
>><br>
>> @@ -481,8 +507,8 @@ leave_state(enum states state, const char *line)<br>
>> break;<br>
>><br>
>> case vertex_shader:<br>
>> - shader_string_sizes[0] = line - shader_strings[0];<br>
>> - num_shader_strings = 1;<br>
>> + shader_string_sizes[1] = line - shader_strings[1];<br>
>> + num_shader_strings = 2;<br>
>> compile_glsl(GL_VERTEX_SHADER, false);<br>
>> break;<br>
>><br>
>> @@ -492,8 +518,8 @@ leave_state(enum states state, const char *line)<br>
>><br>
>> case vertex_program:<br>
>> compile_and_bind_program(GL_VERTEX_PROGRAM_ARB,<br>
>> - shader_strings[0],<br>
>> - line - shader_strings[0]);<br>
>> + shader_strings[1],<br>
>> + line - shader_strings[1]);<br>
>> break;<br>
>><br>
>> case geometry_shader:<br>
>> @@ -503,8 +529,8 @@ leave_state(enum states state, const char *line)<br>
>> break;<br>
>><br>
>> case fragment_shader:<br>
>> - shader_string_sizes[0] = line - shader_strings[0];<br>
>> - num_shader_strings = 1;<br>
>> + shader_string_sizes[1] = line - shader_strings[1];<br>
>> + num_shader_strings = 2;<br>
>> compile_glsl(GL_FRAGMENT_SHADER, false);<br>
>> break;<br>
>><br>
>> @@ -514,8 +540,8 @@ leave_state(enum states state, const char *line)<br>
>><br>
>> case fragment_program:<br>
>> compile_and_bind_program(GL_FRAGMENT_PROGRAM_ARB,<br>
>> - shader_strings[0],<br>
>> - line - shader_strings[0]);<br>
>> + shader_strings[1],<br>
>> + line - shader_strings[1]);<br>
>> break;<br>
>><br>
>> case vertex_data:<br>
>> @@ -629,24 +655,24 @@ process_test_script(const char *script_name)<br>
>> state = requirements;<br>
>> } else if (string_match("[vertex shader]", line))<br>
>> {<br>
>> state = vertex_shader;<br>
>> - shader_strings[0] = NULL;<br>
>> + shader_strings[1] = NULL;<br>
>> } else if (string_match("[vertex program]", line))<br>
>> {<br>
>> state = vertex_program;<br>
>> - shader_strings[0] = NULL;<br>
>> + shader_strings[1] = NULL;<br>
>> } else if (string_match("[vertex shader file]",<br>
>> line)) {<br>
>> state = vertex_shader_file;<br>
>> - shader_strings[0] = NULL;<br>
>> - num_shader_strings = 0;<br>
>> + shader_strings[1] = NULL;<br>
>> + num_shader_strings = 1;<br>
>> } else if (string_match("[fragment shader]",<br>
>> line)) {<br>
>> state = fragment_shader;<br>
>> - shader_strings[0] = NULL;<br>
>> + shader_strings[1] = NULL;<br>
>> } else if (string_match("[fragment program]",<br>
>> line)) {<br>
>> state = fragment_program;<br>
>> - shader_strings[0] = NULL;<br>
>> + shader_strings[1] = NULL;<br>
>> } else if (string_match("[fragment shader file]",<br>
>> line)) {<br>
>> state = fragment_shader_file;<br>
>> - shader_strings[0] = NULL;<br>
>> - num_shader_strings = 0;<br>
>> + shader_strings[1] = NULL;<br>
>> + num_shader_strings = 1;<br>
>> } else if (string_match("[vertex data]", line)) {<br>
>> state = vertex_data;<br>
>> vertex_data_start = NULL;<br>
>> @@ -671,8 +697,8 @@ process_test_script(const char *script_name)<br>
>> case geometry_program:<br>
>> case fragment_shader:<br>
>> case fragment_program:<br>
>> - if (shader_strings[0] == NULL)<br>
>> - shader_strings[0] = (char *) line;<br>
>> + if (shader_strings[1] == NULL)<br>
>> + shader_strings[1] = (char *) line;<br>
>> break;<br>
>><br>
>> case vertex_shader_file:<br>
>> @@ -1542,6 +1568,7 @@ piglit_display(void)<br>
>> void<br>
>> piglit_init(int argc, char **argv)<br>
>> {<br>
>> + const char es_glsl_skip[] = "OpenGL ES GLSL ES ";<br>
>> const char *glsl_version_string;<br>
>><br>
>> piglit_require_GLSL();<br>
>> @@ -1550,8 +1577,18 @@ piglit_init(int argc, char **argv)<br>
>><br>
>> glsl_version_string = (char *)<br>
>> glGetString(GL_SHADING_LANGUAGE_VERSION);<br>
>> +<br>
>> +#if defined USE_OPENGL<br>
>> glsl_version = (glsl_version_string == NULL)<br>
>> ? 0.0 : strtod(glsl_version_string, NULL);<br>
>> +#else<br>
>> + if (glsl_version_string == NULL ||<br>
>> + strlen(glsl_version_string) <= strlen(es_glsl_skip)) {<br>
>> + glsl_version = 0.0;<br>
>> + } else {<br>
>> + glsl_version = strtod(&glsl_version_string[strlen(es_glsl_skip)],<br>
>> NULL);<br>
>> + }<br>
>> +#endif<br>
>><br>
>> glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS,<br>
>> &gl_max_fragment_uniform_components);<br>
>> --<br>
>> 1.7.7.3<br>
>><br>
>> _______________________________________________<br>
>> Piglit mailing list<br>
>> <a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
>> <a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
><br>
><br>
</div></div></blockquote></div><br>