Has someone reached out to the Flockers devs and let them know what they are doing is bogus? I would, but don't have a contact.
- Chris On Tue, Jun 23, 2015 at 11:51 PM, Jose Fonseca <[email protected]> wrote: > On 22/06/15 15:45, Brian Paul wrote: >> >> The draw-vertices tests exercises unusual vertex sizes and strides, >> but not with interleaved arrays. >> >> This test creates a VBO with interleaved vertex positions and colors. >> The colors are positioned at offsets like 9, 10 and 11 bytes from the >> start of the vertex. Unusual strides between vertices are tested too. >> >> Exercises a bug in Gallium's u_vbuf code where the driver was passed >> pipe_vertex_element::src_offset values which weren't a multiple of >> four, even when PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY >> returned 1. >> >> v2: add more comments, specifically describing Flockers. Return "warn" >> if a test fails, not "fail". >> >> Reviewed-by: Marek Olšák <[email protected]> >> --- >> tests/all.py | 1 + >> tests/spec/gl-1.5/CMakeLists.gl.txt | 1 + >> tests/spec/gl-1.5/vertex-buffer-offsets.c | 149 >> ++++++++++++++++++++++++++++++ >> 3 files changed, 151 insertions(+) >> create mode 100644 tests/spec/gl-1.5/vertex-buffer-offsets.c >> >> diff --git a/tests/all.py b/tests/all.py >> index 3e91055..6c4fb41 100644 >> --- a/tests/all.py >> +++ b/tests/all.py >> @@ -1049,6 +1049,7 @@ with profile.group_manager( >> 'normal3b3s-invariance-byte', run_concurrent=False) >> g(['gl-1.5-normal3b3s-invariance', 'GL_SHORT'], >> 'normal3b3s-invariance-short', run_concurrent=False) >> + g(['gl-1.5-vertex-buffer-offsets'], 'vertex-buffer-offsets') >> >> with profile.group_manager( >> PiglitGLTest, >> diff --git a/tests/spec/gl-1.5/CMakeLists.gl.txt >> b/tests/spec/gl-1.5/CMakeLists.gl.txt >> index 8dcd95d..f10c6cb 100644 >> --- a/tests/spec/gl-1.5/CMakeLists.gl.txt >> +++ b/tests/spec/gl-1.5/CMakeLists.gl.txt >> @@ -10,5 +10,6 @@ link_libraries ( >> ) >> >> piglit_add_executable (gl-1.5-normal3b3s-invariance >> normal3b3s-invariance.c) >> +piglit_add_executable (gl-1.5-vertex-buffer-offsets >> vertex-buffer-offsets.c) >> >> # vim: ft=cmake: >> diff --git a/tests/spec/gl-1.5/vertex-buffer-offsets.c >> b/tests/spec/gl-1.5/vertex-buffer-offsets.c >> new file mode 100644 >> index 0000000..1b9580d >> --- /dev/null >> +++ b/tests/spec/gl-1.5/vertex-buffer-offsets.c >> @@ -0,0 +1,149 @@ >> +/* >> + * Copyright 2015 VMware, Inc. >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining >> a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without >> limitation >> + * the rights to use, copy, modify, merge, publish, distribute, >> sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice (including the >> next >> + * paragraph) shall be included in all copies or substantial portions of >> the >> + * Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> EXPRESS OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT >> SHALL >> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR >> OTHER >> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> ARISING >> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >> + * DEALINGS IN THE SOFTWARE. >> + */ >> + >> +/* >> + * Test interleaved vertex arrays with unusual element offsets and >> strides. >> + * >> + * The game Flockers (from Steam) uses some unusual vertex arrays. >> + * For example: glVertexAttribPointerARB(index = 1, size = 3, type = >> GL_FLOAT, >> + * normalized = GL_FALSE, stride = 87, pointer = 0x4b). Note that the >> + * offset to the float[3] attribute is 75 (0x4b) bytes and the stride >> between >> + * vertices is 87 bytes. >> + * >> + * According to the OpenGL specification, OpenGL 1.5, page 33: >> + * "Clients must align data elements consistent with the requirements of >> the >> + * client platform, with an additional base-level requirement that an >> offset >> + * within a buffer to a datum comprising N basic machine units be a >> multiple >> + * of N." >> + * >> + * However, the spec does not say what might happen if that requirement >> is >> + * not met. There is no language about raising a GL error or undefined >> + * behavior. >> + * >> + * This test exercises float[3] attributes at unusual offsets/strides. >> + * If a failure is detected we generate "warn" instead of "fail" since >> + * according to the spec, the failure is allowed, but there are apps >> (such >> + * as Flockers) that will hit this issue. >> + * >> + * If a failure/warning is reported, the OpenGL implementor will have to >> + * decide if conformance or app support is more important. >> + * >> + * Brian Paul >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + config.supports_gl_compat_version = 15; >> + config.window_visual = PIGLIT_GL_VISUAL_RGBA | >> PIGLIT_GL_VISUAL_DOUBLE; >> +PIGLIT_GL_TEST_CONFIG_END >> + >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + /* nothing */ >> +} >> + >> + >> +static bool >> +test_offset_stride(int color_offset, int stride) >> +{ >> + static const GLfloat vertex[4][2] = { >> + { -1, -1 }, >> + { 1, -1 }, >> + { 1, 1 }, >> + { -1, 1 } >> + }; >> + static const GLfloat color[4] = { 0.0, 1.0, 0.5, 1.0 }; >> + GLubyte buffer[1000]; >> + GLuint buf; >> + int i, pos; >> + bool p; >> + >> + assert(color_offset >= sizeof(vertex[0])); >> + assert(stride >= color_offset + sizeof(color)); >> + >> + pos = 0; >> + for (i = 0; i < 4; i++) { >> + /* copy vertex position into buffer */ >> + memcpy(buffer + pos, vertex[i], sizeof(vertex[i])); >> + >> + /* copy vertex color into buffer at unusual offset */ >> + memcpy(buffer + pos + color_offset, color, sizeof(color)); >> + >> + pos += stride; >> + } >> + assert(pos <= sizeof(buffer)); >> + >> + glGenBuffers(1, &buf); >> + glBindBuffer(GL_ARRAY_BUFFER, buf); >> + glBufferData(GL_ARRAY_BUFFER, sizeof(buffer), >> + buffer, GL_STATIC_DRAW); >> + >> + glVertexPointer(2, GL_FLOAT, stride, (void *) 0); >> + glColorPointer(4, GL_FLOAT, stride, (void *) (size_t) >> color_offset); >> + glEnable(GL_VERTEX_ARRAY); >> + glEnable(GL_COLOR_ARRAY); >> + >> + glClear(GL_COLOR_BUFFER_BIT); >> + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); >> + >> + p = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, >> color); >> + >> + if (!p) { >> + printf("Failure for color_offset %d, stride %d\n", >> + color_offset, stride); >> + } >> + >> + piglit_present_results(); >> + >> + glDeleteBuffers(1, &buf); >> + >> + return p; >> +} >> + >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + bool pass = true; >> + >> + /* test nice values */ >> + pass = test_offset_stride(8, 24) && pass; >> + pass = test_offset_stride(12, 28) && pass; >> + > > > The unusual cases should probably be restricted to x86, as it might crash > elsewhere (no the test, since it uses mempcy, but inside the OpenGL > implementation). At least, a /* FIXME: skip on platforms that don't support > unaligned floats */ so that somebody working on those platforms knows what > needs to be done. > >> + /* test unusual offset */ >> + pass = test_offset_stride(9, 32) && pass; >> + >> + /* test unusual stride */ >> + pass = test_offset_stride(8, 27) && pass; >> + >> + /* test unusual offset, unusual stride */ >> + pass = test_offset_stride(9, 25) && pass; >> + pass = test_offset_stride(10, 26) && pass; >> + pass = test_offset_stride(11, 27) && pass; >> + >> + /* Report warn, not fail (see comments above) */ >> + return pass ? PIGLIT_PASS : PIGLIT_WARN; >> +} > > > I also wonder if we should fail instead of just warn on x86, or whatever > platform (Windows or Linux) that Flockers runs. > > Either way > > Reviewed-by: Jose Fonseca <[email protected]> > > Jose > > > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
