On 30 August 2012 11:59, 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 is part of the effort to make version handling more flexible for GLES.<br></blockquote><div><br>Looks great, thanks.<br><br>Pushed to master.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

---<br>
 tests/shaders/shader_runner.c |   65 +++++++++++++++++-----------------------<br>
 1 files changed, 28 insertions(+), 37 deletions(-)<br>
<br>
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c<br>
index aa60a62..6e3a470 100644<br>
--- a/tests/shaders/shader_runner.c<br>
+++ b/tests/shaders/shader_runner.c<br>
@@ -63,15 +63,8 @@ unsigned num_fragment_shaders = 0;<br>
 int num_uniform_blocks;<br>
 GLuint *uniform_block_bos;<br>
<br>
-/**<br>
- * List of strings loaded from files<br>
- *<br>
- * Some test script sections, such as "[vertex shader file]", can supply shader<br>
- * source code from multiple disk files.  This array stores those strings.<br>
- */<br>
-char *shader_strings[256];<br>
-GLsizei shader_string_sizes[256];<br>
-unsigned num_shader_strings = 0;<br>
+char *shader_string;<br>
+GLint shader_string_size;<br>
 const char *vertex_data_start = NULL;<br>
 const char *vertex_data_end = NULL;<br>
 GLuint prog;<br>
@@ -114,7 +107,6 @@ compile_glsl(GLenum target, bool release_text)<br>
 {<br>
        GLuint shader = piglit_CreateShader(target);<br>
        GLint ok;<br>
-       unsigned i;<br>
<br>
        switch (target) {<br>
        case GL_VERTEX_SHADER:<br>
@@ -129,9 +121,9 @@ compile_glsl(GLenum target, bool release_text)<br>
                break;<br>
        }<br>
<br>
-       piglit_ShaderSource(shader, num_shader_strings,<br>
-                           (const GLchar **) shader_strings,<br>
-                           shader_string_sizes);<br>
+       piglit_ShaderSource(shader, 1,<br>
+                           &shader_string,<br>
+                           &shader_string_size);<br>
<br>
        piglit_CompileShader(shader);<br>
<br>
@@ -155,8 +147,7 @@ compile_glsl(GLenum target, bool release_text)<br>
        }<br>
<br>
        if (release_text) {<br>
-               for (i = 0; i < num_shader_strings; i++)<br>
-                       free(shader_strings[i]);<br>
+               free(shader_string);<br>
        }<br>
<br>
        switch (target) {<br>
@@ -280,10 +271,15 @@ comparison_string(enum comparison cmp)<br>
 void<br>
 load_shader_file(const char *line)<br>
 {<br>
-       GLsizei *const size = &shader_string_sizes[num_shader_strings];<br>
+       GLsizei *const size = &shader_string_size;<br>
        char buf[256];<br>
        char *text;<br>
<br>
+       if (shader_string) {<br>
+               printf("Multiple shader files in same section: %s\n", line);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
        strcpy_to_space(buf, line);<br>
<br>
        text = piglit_load_text_file(buf, (unsigned *) size);<br>
@@ -304,8 +300,7 @@ load_shader_file(const char *line)<br>
                piglit_report_result(PIGLIT_FAIL);<br>
        }<br>
<br>
-       shader_strings[num_shader_strings] = text;<br>
-       num_shader_strings++;<br>
+       shader_string = text;<br>
 }<br>
<br>
<br>
@@ -481,8 +476,7 @@ 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_size = line - shader_string;<br>
                compile_glsl(GL_VERTEX_SHADER, false);<br>
                break;<br>
<br>
@@ -492,8 +486,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_string,<br>
+                                        line - shader_string);<br>
                break;<br>
<br>
        case geometry_shader:<br>
@@ -503,8 +497,7 @@ 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_size = line - shader_string;<br>
                compile_glsl(GL_FRAGMENT_SHADER, false);<br>
                break;<br>
<br>
@@ -514,8 +507,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_string,<br>
+                                        line - shader_string);<br>
                break;<br>
<br>
        case vertex_data:<br>
@@ -629,24 +622,22 @@ process_test_script(const char *script_name)<br>
                                state = requirements;<br>
                        } else if (string_match("[vertex shader]", line)) {<br>
                                state = vertex_shader;<br>
-                               shader_strings[0] = NULL;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[vertex program]", line)) {<br>
                                state = vertex_program;<br>
-                               shader_strings[0] = NULL;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[vertex shader file]", line)) {<br>
                                state = vertex_shader_file;<br>
-                               shader_strings[0] = NULL;<br>
-                               num_shader_strings = 0;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[fragment shader]", line)) {<br>
                                state = fragment_shader;<br>
-                               shader_strings[0] = NULL;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[fragment program]", line)) {<br>
                                state = fragment_program;<br>
-                               shader_strings[0] = NULL;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[fragment shader file]", line)) {<br>
                                state = fragment_shader_file;<br>
-                               shader_strings[0] = NULL;<br>
-                               num_shader_strings = 0;<br>
+                               shader_string = NULL;<br>
                        } else if (string_match("[vertex data]", line)) {<br>
                                state = vertex_data;<br>
                                vertex_data_start = NULL;<br>
@@ -671,8 +662,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_string == NULL)<br>
+                                       shader_string = (char *) line;<br>
                                break;<br>
<br>
                        case vertex_shader_file:<br>
@@ -680,7 +671,7 @@ process_test_script(const char *script_name)<br>
                        case fragment_shader_file:<br>
                                line = eat_whitespace(line);<br>
                                if ((line[0] != '\n') && (line[0] != '#'))<br>
-                                   load_shader_file(line);<br>
+                                       load_shader_file(line);<br>
                                break;<br>
<br>
                        case vertex_data:<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.3<br>
<br>
</font></span></blockquote></div><br>