On 24 October 2011 14:56, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net">eric@anholt.net</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;">
<div class="im">On Thu, 20 Oct 2011 14:12:24 -0700, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> This patch adds the ability for shader_runner tests to include a<br>
> "[vertex data]" section containing data in columnar format, for example:<br>
><br>
> [vertex data]<br>
> vertex/float/3 foo/uint/1 bar/int/2<br>
> 0.0 0.0 0.0 0xe0000000 0 0<br>
> 0.0 1.0 0.0 0x70000000 1 1<br>
> 1.0 1.0 0.0 0x00000000 0 1<br>
><br>
> Each column header is of the form ATTRNAME/TYPE/COUNT, where ATTRNAME<br>
> is the name of the vertex attribute to be bound to this column, TYPE<br>
> is the type of data that follows ("float", "int", or "uint"), and<br>
> COUNT is the vector length of the data (e.g. "3" for vec3 data).<br>
><br>
> To send vertex data to the shader, use the new shader_runner command<br>
> "draw arrays". The parameters are the same as for the glDrawArrays()<br>
> command, so for example to draw triangle primitives using 3 elements<br>
> from the vertex data array starting at element 0, use the command:<br>
><br>
> draw arrays GL_TRIANGLES 0 3<br>
><br>
> More detailed examples can be found in the tests/shaders/vbo<br>
> directory.<br>
><br>
> The implementation is largely in a new file, piglit-vbo.cpp, so that<br>
> it can be re-used by other piglit tests if necessary.<br>
<br>
</div>For the other commits,<br>
Reviewed-by: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
<br>
For this one, comments inline.<br>
<div><div></div><div class="h5"><br>
> + } else if (sscanf(line, "draw arrays %31s %d %d", s, &x, &y)) {<br>
> + GLenum mode = decode_mode(s);<br>
> + int first = x;<br>
> + size_t count = (size_t) y;<br>
> + if (first < 0) {<br>
> + printf("draw arrays 'first' must be >= 0\n");<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + } else if ((size_t) first >= num_vbo_rows) {<br>
> + printf("draw arrays 'first' must be < %lu\n",<br>
> + num_vbo_rows);<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> + if (count <= 0) {<br>
> + printf("draw arrays 'count' must be > 0\n");<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + } else if (count > num_vbo_rows - (size_t) first) {<br>
> + printf("draw arrays cannot draw beyond %lu\n",<br>
> + num_vbo_rows);<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> + /* TODO: wrapper? */<br>
> + glDrawArrays(mode, first, count);<br>
> } else if (string_match("disable", line)) {<br>
> do_enable_disable(line + 7, false);<br>
> } else if (string_match("enable", line)) {<br>
<br>
</div></div>Not sure what the TODO is about here.<br></blockquote><div><br>Whoops, that was a reminder to myself to see if I needed to call a piglit_DrawArrays() wrapper function instead of calling glDrawArrays() directly. I'm pretty sure I don't, since this function is part of OpenGL 2.1 and every implementation that's worth testing these days supports OpenGL 2.1. I'll remove the comment.<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> @@ -1523,4 +1600,7 @@ piglit_init(int argc, char **argv)<br>
><br>
> process_test_script(argv[1]);<br>
> link_and_use_shaders();<br>
> + if (vertex_data_start != NULL)<br>
> + num_vbo_rows = setup_vbo_from_text(prog, vertex_data_start,<br>
> + vertex_data_end);<br>
> }<br>
> diff --git a/tests/shaders/vbo/vbo-generic-float.shader_test b/tests/shaders/vbo/vbo-generic-float.shader_test<br>
> new file mode 100644<br>
> index 0000000..8982211<br>
> --- /dev/null<br>
> +++ b/tests/shaders/vbo/vbo-generic-float.shader_test<br>
<br>
</div>The 3 new testcases in here surprised me -- I expected that patch 6/6<br>
was going to be the new testcases, though I suspect you wrote these for<br>
testing this shader_runner code.<br>
<br>
I would think that vbo-generic-uint would be part of<br>
tests/spec/glsl-1.30/ and the others part of tests/spec/glsl-1.10/? But<br>
given the other interpolation tests, it seems like generic-uint is the<br>
only interesting one here.<br></blockquote><div><br>Yes, you're right--the other tests don't really verify any interesting functionality of the GL implementation. I only wrote them to help me verify that the new shader_runner functionality worked correctly. I was considering dropping them entirely, but they seemed like a nice source of extra documentation for how this new shader_runner feature works. That was my primary motivation for putting them in tests/shaders/vbo--so they would be nearer to the shader_runner.c code they were illustrating.<br>
<br>But perhaps I'm overthinking things. I'd be just as happy moving vbo-generic-uint to tests/spec/glsl-1.30/ and dropping the others.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
> diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp<br>
> new file mode 100644<br>
> index 0000000..fdba6b1<br>
> --- /dev/null<br>
> +++ b/tests/util/piglit-vbo.cpp<br>
<br>
</div><div><div></div><div class="h5">> +/**<br>
> + * \file piglit-vbo.cpp<br>
> + *<br>
> + * This file adds the facility for specifying vertex data to piglit<br>
> + * tests using a columnar text format, for example:<br>
> + *<br>
> + * \verbatim<br>
> + * vertex/float/3 foo/uint/1 bar/int/2<br>
> + * 0.0 0.0 0.0 10 0 0 # comment<br>
> + * 0.0 1.0 0.0 5 1 1<br>
> + * 1.0 1.0 0.0 0 0 1<br>
> + * \endverbatim<br>
> + *<br>
> + * The format consists of a row of column headers followed by any<br>
> + * number of rows of data. Each column header has the form<br>
> + * "ATTRNAME/TYPE/COUNT", where ATTRNAME is the name of the vertex<br>
> + * attribute to be bound to this column, TYPE is the type of data that<br>
> + * follows ("float", "int", or "uint"), and COUNT is the vector length<br>
> + * of the data (e.g. "3" for vec3 data).<br>
> + *<br>
> + * The data follows the column headers in space-separated form. "#"<br>
> + * can be used for comments, as in shell scripts.<br>
> + *<br>
> + * To process textual vertex data, call the function<br>
> + * setup_vbo_from_text(), passing the int identifying the linked<br>
> + * program, and the string containing the vertex data. The return<br>
> + * value is the number of rows of vertex data found.<br>
> + *<br>
> + * If an error occurs, setup_vbo_from_text() will print out a<br>
> + * description of the error and exit with PIGLIT_FAIL.<br>
> + *<br>
> + * For the example above, the call to setup_vbo_from_text() is roughly<br>
> + * equivalent to the following GL operations:<br>
> + *<br>
> + * \code<br>
> + * struct vertex_attributes {<br>
> + * GLfloat vertex[3];<br>
> + * GLuint foo;<br>
> + * GLint bar[2];<br>
> + * } vertex_data[] = {<br>
> + * { { 0.0, 0.0, 0.0 }, 10, { 0, 0 } },<br>
> + * { { 0.0, 1.0, 0.0 }, 5, { 1, 1 } },<br>
> + * { { 1.0, 1.0, 0.0 }, 0, { 0, 1 } }<br>
> + * };<br>
> + * size_t stride = sizeof(vertex_data[0]);<br>
> + * GLint vertex_index = glGetAttribLocation(prog, "vertex");<br>
> + * GLint foo_index = glGetAttribLocation(prog, "foo");<br>
> + * GLint bar_index = glGetAttribLocation(prog, "bar");<br>
> + * GLuint buffer_handle;<br>
> + * glGenBuffers(1, &buffer_handle);<br>
> + * glBindBuffer(GL_ARRAY_BUFFER, buffer_handle);<br>
> + * glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), &vertex_data,<br>
> + * GL_STATIC_DRAW);<br>
> + * glVertexAttribPointer(vertex_index, 3, GL_FLOAT, GL_FALSE, stride,<br>
> + * (void *) offsetof(vertex_attributes, vertex));<br>
> + * glVertexAttribIPointer(foo_index, 3, GL_UNSIGNED_INT, stride,<br>
> + * (void *) offsetof(vertex_attributes, foo));<br>
> + * glVertexAttribIPointer(bar_index, 3, GL_INT, stride,<br>
> + * (void *) offsetof(vertex_attributes, bar));<br>
> + * glEnableVertexAttribArray(vertex_index);<br>
> + * glEnableVertexAttribArray(foo_index);<br>
> + * glEnableVertexAttribArray(bar_index);<br>
> + * \endcode<br>
> + */<br>
<br>
</div></div>Don't we need to do something to ensure that our vertex data ends up as<br>
attribute 0? Or that one of them does? Or is this something that is<br>
guaranteed by the API?<br></blockquote><div><br>I don't think it matters whether our vertex data (or any of the vertex attributes) ends up as attribute 0. The only things that are special about attribute 0 are that (a) it aliases gl_Vertex, and (b) when using the begin/end paradigm, it is the attribute that triggers the vertex shader to execute. (a) shouldn't matter because this feature is intended to be used with shaders that don't use gl_Vertex (perhaps I should document that more clearly). (b) shouldn't matter because this feature doesn't use the begin/end paradigm.<br>
</div></div>