On 4 January 2012 13:36, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org">idr@freedesktop.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">
<div class="im">On 01/02/2012 02:32 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This test verifies that the implementation correctly detects all of<br>
the errors specified in the "Errors" section of the<br>
EXT_transform_feedback spec, with the following exceptions (which seem<br>
like they should be handled in separate tests):<br>
<br>
- Errors related to BeginQuery and EndQuery.<br>
<br>
- Error due to mismatch of transform feedback mode and drawing mode<br>
(e.g. drawing GL_LINES when transform feedback is expecting<br>
GL_TRIANGLES).<br>
<br>
- Errors due to exceeding MAX_TRANSFORM_FEEDBACK_<u></u>SEPARATE_ATTIBS in<br>
a call to TransformFeedbackVaryings, GetTransformFeedbackVarying,<br>
or<br>
Get{Integer,Boolean}Indexedv(<u></u>GL_TRANSFORM_FEEDBACK_BUFFER_<u></u>BINDING).<br>
</blockquote>
<br></div>
Aside from one comment in the code below, the series is<br>
<br>
Reviewed-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
For future tests, I think we should structure them differently. Tests like this can be hard to follow because you have to look in N places to see what each subtest actually does. I'm not sure what the right answer is, or I'd suggest using it for this test. :)</blockquote>
<div><br>Yeah, I know where you're coming from. The difficulty seems to be that the tests need to all do nearly the same thing, each with a special exception. How do we avoid duplicating all the stuff that's nearly the same, while at the same time making it easy to understand each subtest?<br>
<br>I'll try to experiment with other designs; let me know if you have any ideas.<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>
<div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
tests/all.tests | 18 +<br>
.../spec/ext_transform_<u></u>feedback/CMakeLists.gl.txt | 1 +<br>
tests/spec/ext_transform_<u></u>feedback/api-errors.c | 377 ++++++++++++++++++++<br>
3 files changed, 396 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/spec/ext_transform_<u></u>feedback/api-errors.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 9002ada..0290f4c 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1392,6 +1392,24 @@ ext_timer_query['time-elapsed'<u></u>] = concurrent_test('ext_timer_<u></u>query-time-elapsed'<br>
<br>
ext_transform_feedback = Group()<br>
spec['EXT_transform_feedback'] = ext_transform_feedback<br>
+for mode in ['interleaved_ok_base', 'interleaved_ok_range',<br>
+ 'interleaved_ok_offset', 'interleaved_unbound',<br>
+ 'interleaved_no_varyings', 'separate_ok_1',<br>
+ 'separate_unbound_0_1', 'separate_ok_2', 'separate_unbound_0_2',<br>
+ 'separate_unbound_1_2', 'separate_no_varyings', 'no_prog_active',<br>
+ 'begin_active', 'useprog_active', 'link_current_active',<br>
+ 'link_other_active', 'bind_base_active', 'bind_range_active',<br>
+ 'bind_offset_active', 'end_inactive', 'bind_base_max',<br>
+ 'bind_range_max', 'bind_offset_max', 'bind_range_size_m4',<br>
+ 'bind_range_size_0', 'bind_range_size_1', 'bind_range_size_2',<br>
+ 'bind_range_size_3', 'bind_range_size_5', 'bind_range_offset_1',<br>
+ 'bind_range_offset_2', 'bind_range_offset_3',<br>
+ 'bind_range_offset_5', 'bind_offset_offset_1',<br>
+ 'bind_offset_offset_2', 'bind_offset_offset_3',<br>
+ 'bind_offset_offset_5', 'not_a_program']:<br>
+ test_name = 'api-errors {0}'.format(mode)<br>
+ ext_transform_feedback[test_<u></u>name] = PlainExecTest(<br>
+ 'ext_transform_feedback-{0} -auto'.format(test_name))<br>
for varying in ['gl_Color', 'gl_SecondaryColor', 'gl_TexCoord',<br>
'gl_FogFragCoord', 'gl_Position', 'gl_PointSize',<br>
'gl_ClipVertex', 'gl_ClipDistance']:<br>
diff --git a/tests/spec/ext_transform_<u></u>feedback/CMakeLists.gl.txt b/tests/spec/ext_transform_<u></u>feedback/CMakeLists.gl.txt<br>
index 8073a70..305f589 100644<br>
--- a/tests/spec/ext_transform_<u></u>feedback/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_transform_<u></u>feedback/CMakeLists.gl.txt<br>
@@ -13,6 +13,7 @@ link_libraries (<br>
)<br>
<br>
add_executable (ext_transform_feedback-<u></u>alignment alignment.c)<br>
+add_executable (ext_transform_feedback-api-<u></u>errors api-errors.c)<br>
add_executable (ext_transform_feedback-<u></u>builtin-varyings builtin-varyings.c)<br>
add_executable (ext_transform_feedback-<u></u>discard-api discard-api.c)<br>
add_executable (ext_transform_feedback-<u></u>discard-bitmap discard-bitmap.c)<br>
diff --git a/tests/spec/ext_transform_<u></u>feedback/api-errors.c b/tests/spec/ext_transform_<u></u>feedback/api-errors.c<br>
new file mode 100644<br>
index 0000000..486f5f4<br>
--- /dev/null<br>
+++ b/tests/spec/ext_transform_<u></u>feedback/api-errors.c<br>
@@ -0,0 +1,377 @@<br>
+/*<br>
+ * Copyright © 2011 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * \file api-errors.c<br>
+ *<br>
+ * Test that the implementation flags various<br>
+ * transform-feedback-related error conditions.<br>
+ *<br>
+ * This test covers all of the error conditions as specified in the<br>
+ * "Errors" section of the EXT_transform_feedback spec, with the<br>
+ * following exceptions:<br>
+ *<br>
+ * - Errors related to BeginQuery and EndQuery.<br>
+ *<br>
+ * - Error due to mismatch of transform feedback mode and drawing mode<br>
+ * (e.g. drawing GL_LINES when transform feedback is expecting<br>
+ * GL_TRIANGLES).<br>
+ *<br>
+ * - Errors due to exceeding MAX_TRANSFORM_FEEDBACK_<u></u>SEPARATE_ATTIBS in<br>
+ * a call to TransformFeedbackVaryings, GetTransformFeedbackVarying,<br>
+ * or<br>
+ * Get{Integer,Boolean}Indexedv(<u></u>GL_TRANSFORM_FEEDBACK_BUFFER_<u></u>BINDING).<br>
+ *<br>
+ * In addition, there are a few tests which verify that errors do not<br>
+ * occur during normal operation ("interleaved_ok_*", "separate_ok_*",<br>
+ * and "link_other_active"). These tests help to verify that the<br>
+ * implementation is not overly aggressive in flagging errors.<br>
+ */<br>
+<br>
+#include "piglit-util.h"<br>
+<br>
+int piglit_width = 16;<br>
+int piglit_height = 16;<br>
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;<br>
+<br>
+#define XFB_BUFFER_SIZE 12<br>
+#define NUM_BUFFERS 2<br>
+<br>
+enum test_mode {<br>
+ NORMAL,<br>
+ NO_VARYINGS,<br>
+ UNBOUND_BUFFER,<br>
+ SKIP_USE_PROGRAM,<br>
+ BEGIN_ACTIVE,<br>
+ USEPROG_ACTIVE,<br>
+ LINK_CURRENT_ACTIVE,<br>
+ LINK_OTHER_ACTIVE,<br>
+ BIND_ACTIVE,<br>
+ END_INACTIVE,<br>
+ BIND_MAX,<br>
+ BIND_BAD_SIZE,<br>
+ BIND_BAD_OFFSET,<br>
+ NOT_A_PROGRAM,<br>
+};<br>
+<br>
+enum bind_mode {<br>
+ BASE,<br>
+ RANGE,<br>
+ OFFSET,<br>
+};<br>
+<br>
+static const char *vstext =<br>
+ "varying vec4 foo;\n"<br>
+ "varying vec4 bar;\n"<br>
+ "\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " foo = vec4(1.0);\n"<br>
+ " bar = vec4(1.0);\n"<br>
+ " gl_Position = vec4(1.0);\n"<br>
+ "}\n";<br>
+<br>
+static const char *varyings[] = { "foo", "bar" };<br>
+<br>
+static struct test_desc<br>
+{<br>
+ const char *name;<br>
+ enum test_mode mode;<br>
+ int param;<br>
+ enum bind_mode bind_mode;<br>
+ GLenum buffer_mode;<br>
+ int num_buffers;<br>
+ GLboolean skip_use_program;<br>
+} tests[] = {<br>
+ /* name mode param num_buffers<br>
+ * bind_mode<br>
+ * buffer_mode<br>
+ */<br>
+ { "interleaved_ok_base", NORMAL, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "interleaved_ok_range", NORMAL, 0, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "interleaved_ok_offset", NORMAL, 0, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "interleaved_unbound", UNBOUND_BUFFER, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "interleaved_no_varyings", NO_VARYINGS, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "separate_ok_1", NORMAL, 0, BASE, GL_SEPARATE_ATTRIBS, 1 },<br>
+ { "separate_unbound_0_1", UNBOUND_BUFFER, 0, BASE, GL_SEPARATE_ATTRIBS, 1 },<br>
+ { "separate_ok_2", NORMAL, 0, BASE, GL_SEPARATE_ATTRIBS, 2 },<br>
+ { "separate_unbound_0_2", UNBOUND_BUFFER, 0, BASE, GL_SEPARATE_ATTRIBS, 2 },<br>
+ { "separate_unbound_1_2", UNBOUND_BUFFER, 1, BASE, GL_SEPARATE_ATTRIBS, 2 },<br>
+ { "separate_no_varyings", NO_VARYINGS, 0, BASE, GL_SEPARATE_ATTRIBS, 1 },<br>
+ { "no_prog_active", SKIP_USE_PROGRAM, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "begin_active", BEGIN_ACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "useprog_active", USEPROG_ACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "link_current_active", LINK_CURRENT_ACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "link_other_active", LINK_OTHER_ACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_base_active", BIND_ACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_active", BIND_ACTIVE, 0, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_active", BIND_ACTIVE, 0, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "end_inactive", END_INACTIVE, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_base_max", BIND_MAX, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_max", BIND_MAX, 0, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_max", BIND_MAX, 0, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_m4", BIND_BAD_SIZE, -4, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_0", BIND_BAD_SIZE, 0, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_1", BIND_BAD_SIZE, 1, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_2", BIND_BAD_SIZE, 2, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_3", BIND_BAD_SIZE, 3, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_size_5", BIND_BAD_SIZE, 5, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_offset_1", BIND_BAD_OFFSET, 1, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_offset_2", BIND_BAD_OFFSET, 2, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_offset_3", BIND_BAD_OFFSET, 3, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_range_offset_5", BIND_BAD_OFFSET, 5, RANGE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_offset_1", BIND_BAD_OFFSET, 1, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_offset_2", BIND_BAD_OFFSET, 2, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_offset_3", BIND_BAD_OFFSET, 3, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "bind_offset_offset_5", BIND_BAD_OFFSET, 5, OFFSET, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+ { "not_a_program", NOT_A_PROGRAM, 0, BASE, GL_INTERLEAVED_ATTRIBS, 1 },<br>
+};<br>
+<br>
+static void<br>
+do_bind(const struct test_desc *test, GLuint buf, int i)<br>
+{<br>
+ int size = test->mode == BIND_BAD_SIZE<br>
+ ? test->param : sizeof(float[XFB_BUFFER_SIZE])<u></u>;<br>
+ int offset = test->mode == BIND_BAD_OFFSET<br>
+ ? test->param : 0;<br>
+<br>
+ switch (test->bind_mode) {<br>
+ case BASE:<br>
+ printf("BindBufferBase(buffer %i)\n", i);<br>
+ piglit_BindBufferBase(GL_<u></u>TRANSFORM_FEEDBACK_BUFFER, i, buf);<br>
+ break;<br>
+ case RANGE:<br>
+ printf("BindBufferRange(buffer %i, offset=%i, size=%i)\n", i,<br>
+ offset, size);<br>
+ piglit_BindBufferRange(GL_<u></u>TRANSFORM_FEEDBACK_BUFFER, i, buf,<br>
+ offset, size);<br>
+ break;<br>
+ case OFFSET:<br>
+ printf("BindBufferOffsetEXT(<u></u>buffer %i, offset=%i)\n", i,<br>
+ offset);<br>
+ glBindBufferOffsetEXT(GL_<u></u>TRANSFORM_FEEDBACK_BUFFER, i, buf,<br>
+ offset);<br>
+ break;<br>
+ }<br>
+}<br>
+<br>
+static GLboolean<br>
+do_test(const struct test_desc *test)<br>
+{<br>
+ GLuint vs;<br>
+ GLuint progs[2];<br>
+ GLuint bufs[NUM_BUFFERS];<br>
+ float initial_xfb_buffer_contents[<u></u>XFB_BUFFER_SIZE];<br>
+ GLboolean pass = GL_TRUE;<br>
+ int i;<br>
+ int num_varyings = test->mode == NO_VARYINGS ? 0 : test->num_buffers;<br>
+ GLint max_separate_attribs;<br>
+<br>
+ glGetIntegerv(GL_MAX_<u></u>TRANSFORM_FEEDBACK_SEPARATE_<u></u>ATTRIBS,<br>
+ &max_separate_attribs);<br>
+ printf("MAX_TRANSFORM_<u></u>FEEDBACK_SEPARATE_ATTIBS=%i\n"<u></u>,<br>
+ max_separate_attribs);<br>
+<br>
+ printf("Compile vertex shader\n");<br>
+ vs = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER, vstext);<br>
+ if (test->mode == NOT_A_PROGRAM) {<br>
+ printf("Create a buffer to use instead of a program\n");<br>
+ glGenBuffers(1, progs);<br>
+ } else {<br>
+ progs[0] = piglit_CreateProgram();<br>
+ piglit_AttachShader(progs[0], vs);<br>
+ }<br>
</blockquote>
<br></div></div>
This may work, but it's a bit sketchy. Each kind of object from a Gen function or Create function is in a separate namespace. It is conceivable that the name from GenBuffers and the handle from CreateProgram could have the same value. It should work in this case because no program has ever been created.<br>
<br>
A better approach is to create a program and immediately delete it. Since the program was never used, the delete will take effect immediately. As long as there are no intervening CreateProgram calls, you can be sure the deleted program will be invalid.<br>
</blockquote><div><br>Ah, I didn't realize that. I'll make the fix and retest on both Mesa and nVidia before pushing the patch.<br></div></div>