On 29 August 2012 16:42, 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>The patch has indentation errors that need to be fixed. Piglit uses tabs for indentation, and is intended to be viewed with a tab width of 8.<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 | 67 +++++++++++++++++++----------------------<br>
1 files changed, 31 insertions(+), 36 deletions(-)<br>
<br>
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c<br>
index aa60a62..add8a0c 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,8 @@ compile_glsl(GLenum target, bool release_text)<br>
{<br>
GLuint shader = piglit_CreateShader(target);<br>
GLint ok;<br>
- unsigned i;<br>
+ GLchar** shader_string_ptr;<br>
+ GLint* shader_len_ptr;<br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
switch (target) {<br>
case GL_VERTEX_SHADER:<br>
@@ -129,9 +123,11 @@ 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>
+ shader_string_ptr = &shader_string;<br>
+ shader_len_ptr = &shader_string_size;<br>
+ piglit_ShaderSource(shader, 1,<br>
+ shader_string_ptr,<br>
+ shader_len_ptr);<br></blockquote><div><br>This seems unnecessarily wordy. How about just:<br><br>piglit_ShaderSource(shader, 1, &shader_string, &shader_string_size);<br><br>Other than those two comments, the patch looks good.<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
piglit_CompileShader(shader);<br>
<br>
@@ -155,8 +151,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 +275,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 +304,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 +480,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 +490,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 +501,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 +511,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 +626,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 +666,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>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.3<br>
<br>
</font></span></blockquote></div><br>