Jose, I believe that's exactly what it's saying, yes.
- Chris On Sun, Jun 21, 2015 at 8:00 PM, Jose Fonseca <[email protected]> wrote: > It depends on the platform. But x86 doesn't require floats to be 4-byte > aligned. https://en.wikipedia.org/wiki/Data_structure_alignment#x86 > > I don't know about other platforms though -- it might be indeed necessary to > skip or be less strict on non-x86 platforms. > > I'm having trouble interpreting the "additional base-level requirement" > means. Is it saying that a an offset to a float (4bytes), must be 4bytes > aligned, regardless the platform can deal with non- 4-byte aligned floats? > > Jose > > ________________________________________ > From: Piglit <[email protected]> on behalf of Chris Forbes > <[email protected]> > Sent: 20 June 2015 11:32 > To: Brian Paul > Cc: [email protected] > Subject: Re: [Piglit] [PATCH] gl-1.5-vertex-buffer-offsets: test unusual > vertex offsets/strides > > Brian, > > Doesn't this test run afoul of the alignment requirements? > > The OpenGL 1.5 specification, page 33 [first version in which this is > introduced; > equivalent language exists in later spec versions] says: > > "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." > > Non-naturally-aligned float attributes sourced from a buffer object would > appear > to violate this rule - or have I misunderstood? > > - Chris > > > > > On Sat, Jun 20, 2015 at 2:39 AM, Brian Paul <[email protected]> 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. >> --- >> tests/all.py | 1 + >> tests/spec/gl-1.5/CMakeLists.gl.txt | 1 + >> tests/spec/gl-1.5/vertex-buffer-offsets.c | 124 >> ++++++++++++++++++++++++++++++ >> 3 files changed, 126 insertions(+) >> create mode 100644 tests/spec/gl-1.5/vertex-buffer-offsets.c >> >> diff --git a/tests/all.py b/tests/all.py >> index ad4c494..ee11be6 100755 >> --- a/tests/all.py >> +++ b/tests/all.py >> @@ -1042,6 +1042,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..6d58331 >> --- /dev/null >> +++ b/tests/spec/gl-1.5/vertex-buffer-offsets.c >> @@ -0,0 +1,124 @@ >> +/* >> + * 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. >> + * 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; >> + >> + /* test unual offset */ >> + pass = test_offset_stride(9, 32) && pass; >> + >> + /* test unual 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; >> + >> + return pass ? PIGLIT_PASS : PIGLIT_FAIL; >> +} >> + >> -- >> 1.9.1 >> >> _______________________________________________ >> Piglit mailing list >> [email protected] >> http://lists.freedesktop.org/mailman/listinfo/piglit > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
