That one is, but the follow up isn't. And neither is version I checked in: http://cgit.freedesktop.org/piglit/commit/?id=d67090fbc549ed02d1a78765401492ad48dfc7c9
On Sun, Nov 1, 2015 at 11:38 PM, Dylan Baker <[email protected]> wrote: > This one is missing all.py, no? > > On Oct 30, 2015 12:23, "Ryan Houdek" <[email protected]> wrote: >> >> --- >> tests/spec/CMakeLists.txt | 1 + >> .../CMakeLists.gles2.txt | 14 ++ >> .../oes_draw_elements_base_vertex/CMakeLists.txt | 1 + >> .../drawelements-instanced.c | 190 >> +++++++++++++++++++++ >> .../oes_draw_elements_base_vertex/drawelements.c | 181 >> ++++++++++++++++++++ >> .../drawrangeelements.c | 143 ++++++++++++++++ >> .../multidrawelements.c | 175 >> +++++++++++++++++++ >> 7 files changed, 705 insertions(+) >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/CMakeLists.gles2.txt >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/CMakeLists.txt >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/drawelements-instanced.c >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/drawelements.c >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/drawrangeelements.c >> create mode 100644 >> tests/spec/oes_draw_elements_base_vertex/multidrawelements.c >> >> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt >> index 61f013a..eeedc4c 100644 >> --- a/tests/spec/CMakeLists.txt >> +++ b/tests/spec/CMakeLists.txt >> @@ -135,3 +135,4 @@ add_subdirectory (arb_vertex_attrib_64bit) >> add_subdirectory (ext_framebuffer_blit) >> add_subdirectory (mesa_pack_invert) >> add_subdirectory (ext_texture_format_bgra8888) >> +add_subdirectory (oes_draw_elements_base_vertex) >> diff --git a/tests/spec/oes_draw_elements_base_vertex/CMakeLists.gles2.txt >> b/tests/spec/oes_draw_elements_base_vertex/CMakeLists.gles2.txt >> new file mode 100644 >> index 0000000..bd50394 >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/CMakeLists.gles2.txt >> @@ -0,0 +1,14 @@ >> +include_directories( >> + ${GLEXT_INCLUDE_DIR} >> + ${OPENGL_INCLUDE_PATH} >> +) >> + >> +link_libraries ( >> + piglitutil_${piglit_target_api} >> + ${OPENGL_gl_LIBRARY} >> +) >> + >> +piglit_add_executable (oes_draw_elements_base_vertex-drawelements >> drawelements.c) >> +piglit_add_executable (oes_draw_elements_base_vertex-drawrangeelements >> drawrangeelements.c) >> +piglit_add_executable >> (oes_draw_elements_base_vertex-drawelements-instanced >> drawelements-instanced.c) >> +piglit_add_executable (oes_draw_elements_base_vertex-multidrawelements >> multidrawelements.c) >> diff --git a/tests/spec/oes_draw_elements_base_vertex/CMakeLists.txt >> b/tests/spec/oes_draw_elements_base_vertex/CMakeLists.txt >> new file mode 100644 >> index 0000000..144a306 >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/CMakeLists.txt >> @@ -0,0 +1 @@ >> +piglit_include_target_api() >> diff --git >> a/tests/spec/oes_draw_elements_base_vertex/drawelements-instanced.c >> b/tests/spec/oes_draw_elements_base_vertex/drawelements-instanced.c >> new file mode 100644 >> index 0000000..71cfc29 >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/drawelements-instanced.c >> @@ -0,0 +1,190 @@ >> +/* >> + * >> + * 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. >> + * >> + */ >> + >> +/* Tests OES_draw_elements_base_vertex functionality by drawing a >> checkerboard >> + * of quads using different base vertices using the same vertex and >> + * index buffers and instancing >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_es_version = 30; >> + >> + config.window_width = 300; >> + config.window_height = 300; >> + config.window_visual = PIGLIT_GL_VISUAL_RGB | >> PIGLIT_GL_VISUAL_DOUBLE; >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +#define NUM_QUADS 10 >> +const GLfloat inc_amount = 2.0 / NUM_QUADS; >> +const int window_width = 300; >> +const int window_height = 300; >> + >> +const char *vs_source = { >> + "#version 300 es\n" >> + "in vec2 vertex;\n" >> + "in float xOffsetPerInstance;\n" >> + "void main() {\n" >> + " vec2 p = vertex;\n" >> + " p.y -= 1.0 * float(gl_InstanceID);\n" >> + " p.x += xOffsetPerInstance * float(gl_InstanceID);\n" >> + " gl_Position = vec4(p, 0, 1);\n" >> + "}\n" >> +}; >> + >> +const char *fs_source = { >> + "#version 300 es\n" >> + "out highp vec4 ocol;\n" >> + "void main() {\n" >> + " ocol = vec4(1, 1, 1, 1);\n" >> + "}\n" >> +}; >> + >> +static GLushort indices[] = { >> + 0, 1, 2, 1, 2, 3 >> +}; >> +static GLsizei indices_size = sizeof(indices); >> + >> +static GLuint vao; >> +static GLuint vertexBuffer; >> +static GLuint indexBuffer; >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + piglit_require_extension("GL_OES_draw_elements_base_vertex"); >> + >> + GLuint program; >> + GLuint vertex_index; >> + GLuint xoffset_index; >> + >> + GLfloat* vertices = malloc(4 * 2 * NUM_QUADS * sizeof(GLfloat)); >> + GLsizei vertices_size = 4 * 2 * NUM_QUADS * sizeof(GLfloat); >> + >> + // Generate a checkerboard pattern >> + // |x x x x x | >> + // | x x x x x| >> + int i; >> + for (i = 0; i < NUM_QUADS; ++i) >> + { >> + GLfloat xoffset, yoffset; >> + GLfloat x[4], y[4]; >> + >> + xoffset = inc_amount * i - 1.0; >> + yoffset = 1.0; >> + >> + // Top-left >> + x[0] = xoffset; >> + y[0] = yoffset; >> + >> + // Top-right >> + x[1] = xoffset + inc_amount / 2.0; >> + y[1] = yoffset; >> + >> + // Bottom-left >> + x[2] = xoffset; >> + y[2] = yoffset - 1.0; >> + >> + // Bottom-right >> + x[3] = xoffset + inc_amount / 2.0; >> + y[3] = yoffset - 1.0; >> + >> + vertices[i * 8 + 0] = x[0]; >> + vertices[i * 8 + 1] = y[0]; >> + >> + vertices[i * 8 + 2] = x[1]; >> + vertices[i * 8 + 3] = y[1]; >> + >> + vertices[i * 8 + 4] = x[2]; >> + vertices[i * 8 + 5] = y[2]; >> + >> + vertices[i * 8 + 6] = x[3]; >> + vertices[i * 8 + 7] = y[3]; >> + } >> + >> + /* Create program */ >> + program = piglit_build_simple_program(vs_source, fs_source); >> + glUseProgram(program); >> + >> + /* Gen vertex array buffer */ >> + glGenBuffers(1, &vertexBuffer); >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, >> GL_STATIC_DRAW); >> + >> + /* Gen indices array buffer */ >> + glGenBuffers(1, &indexBuffer); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_size, >> + indices, GL_STATIC_DRAW); >> + >> + /* Gen VAO */ >> + glGenVertexArrays(1, &vao); >> + glBindVertexArray(vao); >> + >> + xoffset_index = glGetAttribLocation(program, >> "xOffsetPerInstance"); >> + glVertexAttrib1f(xoffset_index, inc_amount / 2.0); >> + >> + /* Retrieve indices from vs */ >> + vertex_index = glGetAttribLocation(program, "vertex"); >> + >> + /* Enable vertex attrib array */ >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glEnableVertexAttribArray(vertex_index); >> + glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + GLboolean pass = GL_TRUE; >> + float white[] = {1.0, 1.0, 1.0, 1.0}; >> + int i; >> + >> + glClear(GL_COLOR_BUFFER_BIT); >> + >> + glBindVertexArray(vao); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + >> + for (i = 0; i < NUM_QUADS; ++i) >> + glDrawElementsInstancedBaseVertexOES(GL_TRIANGLES, 6, >> GL_UNSIGNED_SHORT, NULL, 2, i * 4); >> + >> + for (i = 0; i < (NUM_QUADS * 2); ++i) >> + { >> + GLfloat xoffset[2], yoffset[2]; >> + >> + xoffset[0] = inc_amount * i / 4.0 * window_width; >> + xoffset[1] = inc_amount * (i + 1) / 4.0 * window_width; >> + yoffset[0] = (i % 2 ? 0.0 : 0.5) * window_height; >> + yoffset[1] = yoffset[0] + window_height / 2; >> + >> + pass = piglit_probe_rect_rgba(xoffset[0], yoffset[0], >> + xoffset[1] - xoffset[0], yoffset[1] - yoffset[0], >> white) && pass; >> + } >> + >> + piglit_present_results(); >> + >> + return pass ? PIGLIT_PASS : PIGLIT_FAIL; >> +} >> diff --git a/tests/spec/oes_draw_elements_base_vertex/drawelements.c >> b/tests/spec/oes_draw_elements_base_vertex/drawelements.c >> new file mode 100644 >> index 0000000..0333d8e >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/drawelements.c >> @@ -0,0 +1,181 @@ >> +/* >> + * >> + * 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. >> + * >> + */ >> + >> +/* Tests OES_draw_elements_base_vertex functionality by drawing a >> checkerboard >> + * of quads using different base vertices using the same vertex and >> + * index buffers >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_es_version = 20; >> + >> + config.window_width = 300; >> + config.window_height = 300; >> + config.window_visual = PIGLIT_GL_VISUAL_RGB | >> PIGLIT_GL_VISUAL_DOUBLE; >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +#define NUM_QUADS 10 >> +const GLfloat inc_amount = 2.0 / NUM_QUADS; >> +const int window_width = 300; >> +const int window_height = 300; >> + >> +const char *vs_source = { >> + "#version 100\n" >> + "attribute vec2 vertex;\n" >> + "void main() {\n" >> + " gl_Position = vec4(vertex.xy, 0, 1);\n" >> + "}\n" >> +}; >> + >> +const char *fs_source = { >> + "#version 100\n" >> + "void main() {\n" >> + " gl_FragColor = vec4(1, 1, 1, 1);\n" >> + "}\n" >> +}; >> + >> +static GLushort indices[] = { >> + 0, 1, 2, 1, 2, 3 >> +}; >> +static GLsizei indices_size = sizeof(indices); >> + >> +static GLuint vao; >> +static GLuint vertexBuffer; >> +static GLuint indexBuffer; >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + piglit_require_extension("GL_OES_draw_elements_base_vertex"); >> + >> + GLuint program; >> + GLuint vertex_index; >> + >> + GLfloat* vertices = malloc(4 * 2 * NUM_QUADS * sizeof(GLfloat)); >> + GLsizei vertices_size = 4 * 2 * NUM_QUADS * sizeof(GLfloat); >> + >> + // Generate a checkerboard pattern >> + // |x x x x x | >> + // | x x x x x| >> + int i; >> + for (i = 0; i < NUM_QUADS; ++i) >> + { >> + GLfloat xoffset, yoffset; >> + GLfloat x[4], y[4]; >> + >> + xoffset = inc_amount * i - 1.0; >> + yoffset = i % 2 ? 0.0 : 1.0; >> + >> + // Top-left >> + x[0] = xoffset; >> + y[0] = yoffset; >> + >> + // Top-right >> + x[1] = xoffset + inc_amount; >> + y[1] = yoffset; >> + >> + // Bottom-left >> + x[2] = xoffset; >> + y[2] = yoffset - 1.0; >> + >> + // Bottom-right >> + x[3] = xoffset + inc_amount; >> + y[3] = yoffset - 1.0; >> + >> + vertices[i * 8 + 0] = x[0]; >> + vertices[i * 8 + 1] = y[0]; >> + >> + vertices[i * 8 + 2] = x[1]; >> + vertices[i * 8 + 3] = y[1]; >> + >> + vertices[i * 8 + 4] = x[2]; >> + vertices[i * 8 + 5] = y[2]; >> + >> + vertices[i * 8 + 6] = x[3]; >> + vertices[i * 8 + 7] = y[3]; >> + } >> + >> + /* Create program */ >> + program = piglit_build_simple_program(vs_source, fs_source); >> + glUseProgram(program); >> + >> + /* Gen vertex array buffer */ >> + glGenBuffers(1, &vertexBuffer); >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, >> GL_STATIC_DRAW); >> + >> + /* Gen indices array buffer */ >> + glGenBuffers(1, &indexBuffer); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_size, >> + indices, GL_STATIC_DRAW); >> + >> + /* Gen VAO */ >> + glGenVertexArrays(1, &vao); >> + glBindVertexArray(vao); >> + >> + /* Retrieve indices from vs */ >> + vertex_index = glGetAttribLocation(program, "vertex"); >> + >> + /* Enable vertex attrib array */ >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glEnableVertexAttribArray(vertex_index); >> + glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + GLboolean pass = GL_TRUE; >> + float white[] = {1.0, 1.0, 1.0, 1.0}; >> + int i; >> + >> + glClear(GL_COLOR_BUFFER_BIT); >> + >> + glBindVertexArray(vao); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + >> + for (i = 0; i < NUM_QUADS; ++i) >> + glDrawElementsBaseVertexOES(GL_TRIANGLES, 6, >> GL_UNSIGNED_SHORT, NULL, i * 4); >> + >> + for (i = 0; i < NUM_QUADS; ++i) >> + { >> + GLfloat xoffset[2], yoffset[2]; >> + >> + xoffset[0] = inc_amount * i / 2.0 * window_width; >> + xoffset[1] = inc_amount * (i + 1) / 2.0 * window_width; >> + yoffset[0] = (i % 2 ? 0.0 : 0.5) * window_height; >> + yoffset[1] = yoffset[0] + window_height / 2; >> + >> + pass = piglit_probe_rect_rgba(xoffset[0], yoffset[0], >> + xoffset[1] - xoffset[0], yoffset[1] - yoffset[0], >> white) && pass; >> + } >> + >> + piglit_present_results(); >> + >> + return pass ? PIGLIT_PASS : PIGLIT_FAIL; >> +} >> diff --git a/tests/spec/oes_draw_elements_base_vertex/drawrangeelements.c >> b/tests/spec/oes_draw_elements_base_vertex/drawrangeelements.c >> new file mode 100644 >> index 0000000..6042c72 >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/drawrangeelements.c >> @@ -0,0 +1,143 @@ >> +/* >> + * >> + * 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. >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_es_version = 30; >> + >> + config.window_width = 200; >> + config.window_height = 200; >> + config.window_visual = PIGLIT_GL_VISUAL_RGB | >> PIGLIT_GL_VISUAL_DOUBLE; >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +const char *vs_source = { >> + "#version 300 es\n" >> + "in vec2 vertex;\n" >> + "void main() {\n" >> + " gl_Position = vec4(vertex.xy, 0, 1);\n" >> + "}\n" >> +}; >> + >> +const char *fs_source = { >> + "#version 300 es\n" >> + "out highp vec4 ocol;\n" >> + "void main() {\n" >> + " ocol = vec4(0, 1, 0, 1);\n" >> + "}\n" >> +}; >> + >> +static GLuint vao; >> +static GLuint vertexBuffer; >> +static GLuint indexBuffer; >> + >> +/* sets of two (x,y) */ >> +static GLfloat vertices[] = { >> + -1.0, 1.0, >> + 1.0, 1.0, >> + -1.0, 0.5, >> + 1.0, 0.5, >> + -1.0, 0.0, >> + 1.0, 0.0, >> + -1.0,-0.5, >> + 1.0,-0.5, >> + -1.0,-1.0, >> + 1.0,-1.0 >> +}; >> +static GLsizei vertices_size = sizeof(vertices); >> + >> +static GLushort indices[] = { >> + 0, 1, 2, 1, 2, 3, /* Top Quad */ >> + 4, 5, 6, 5, 6, 7, /* Bot Quad */ >> +}; >> +static GLsizei indices_size = sizeof(indices); >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + GLuint program; >> + GLuint vertex_index; >> + >> + piglit_require_extension("GL_OES_draw_elements_base_vertex"); >> + >> + /* Create program */ >> + program = piglit_build_simple_program(vs_source, fs_source); >> + glUseProgram(program); >> + >> + /* Gen vertex array buffer */ >> + glGenBuffers(1, &vertexBuffer); >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, >> GL_STATIC_DRAW); >> + >> + /* Gen indices array buffer */ >> + glGenBuffers(1, &indexBuffer); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_size, >> + indices, GL_STATIC_DRAW); >> + >> + /* Gen VAO */ >> + glGenVertexArrays(1, &vao); >> + glBindVertexArray(vao); >> + >> + /* Retrieve indices from vs */ >> + vertex_index = glGetAttribLocation(program, "vertex"); >> + >> + /* Enable vertex attrib array */ >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glEnableVertexAttribArray(vertex_index); >> + glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + bool pass = true; >> + >> + float green[] = {0, 1, 0, 1}; >> + float blue[] = {0, 0, 1, 1}; >> + >> + glClearColor(blue[0], blue[1], blue[2], 1.0); >> + glClear(GL_COLOR_BUFFER_BIT); >> + >> + glBindVertexArray(vao); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + >> + /* Top Quad */ >> + glDrawRangeElementsBaseVertexOES(GL_TRIANGLES, 0, 3, 6, >> GL_UNSIGNED_SHORT, >> + NULL, 0); >> + >> + /* Bot Quad */ >> + glDrawRangeElementsBaseVertexOES(GL_TRIANGLES, 4, 7, 6, >> GL_UNSIGNED_SHORT, >> + (GLvoid *)(sizeof(GLushort)*6), 2); >> + >> + /* Check for test pass */ >> + pass = piglit_probe_pixel_rgba(100, 175, green) && pass; >> + pass = piglit_probe_pixel_rgba(100, 125, blue) && pass; >> + pass = piglit_probe_pixel_rgba(100, 75, blue) && pass; >> + pass = piglit_probe_pixel_rgba(100, 25, green) && pass; >> + >> + piglit_present_results(); >> + >> + return pass ? PIGLIT_PASS : PIGLIT_FAIL; >> +} >> diff --git a/tests/spec/oes_draw_elements_base_vertex/multidrawelements.c >> b/tests/spec/oes_draw_elements_base_vertex/multidrawelements.c >> new file mode 100644 >> index 0000000..8b6d5c0 >> --- /dev/null >> +++ b/tests/spec/oes_draw_elements_base_vertex/multidrawelements.c >> @@ -0,0 +1,175 @@ >> +/* >> + * >> + * 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. >> + * >> + */ >> + >> +/** >> + * >> + * (0)-------(1) Set up indices for quad 1 and 3. >> + * | 1 | >> + * (2)-------(3) Use a basevertex of 2 to shift >> + * | 2 | indices from quad 1 to 2 and >> + * (4)-------(5) from quad 3 to 4 >> + * | 3 | >> + * (6)-------(7) End result 1 and 3 should be >> + * | 4 | blue while 2 and 4 are green. >> + * (8)-------(9) >> + * >> + * >> + * MultiDrawElementsBaseVertex behaves identically to >> + * DrawElementsBaseVertex, except that primcount separate >> + * lists of elements are specified instead. It has the >> + * same effect as: >> + * >> + * for (int i = 0; i < primcount ; i++) >> + * if (count[i] > 0) >> + * DrawElementsBaseVertex(mode, count[i], type, >> + * indices[i], basevertex[i]); >> + * >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_es_version = 20; >> + >> + config.window_width = 200; >> + config.window_height = 200; >> + config.window_visual = PIGLIT_GL_VISUAL_RGB | >> PIGLIT_GL_VISUAL_DOUBLE; >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +const char *vs_source = { >> + "#version 100\n" >> + "attribute vec2 vertex;\n" >> + "void main() {\n" >> + " gl_Position = vec4(vertex.xy, 0, 1);\n" >> + "}\n" >> +}; >> + >> +const char *fs_source = { >> + "#version 100\n" >> + "void main() {\n" >> + " gl_FragColor = vec4(0, 1, 0, 1);\n" >> + "}\n" >> +}; >> +static GLuint vao; >> +static GLuint vertexBuffer; >> +static GLuint indexBuffer; >> + >> +/* >> + * sets of two (x,y) >> + */ >> +static GLfloat vertices[] = { >> + -1.0, 1.0, >> + 1.0, 1.0, >> + -1.0, 0.5, >> + 1.0, 0.5, >> + -1.0, 0.0, >> + 1.0, 0.0, >> + -1.0,-0.5, >> + 1.0,-0.5, >> + -1.0,-1.0, >> + 1.0,-1.0 >> +}; >> +static GLsizei vertices_size = sizeof(vertices); >> + >> +static GLushort indices[] = { >> + 0, 1, 2, 1, 2, 3, /* top square */ >> + 4, 5, 6, 5, 6, 7, /* bot square */ >> +}; >> +static GLsizei indices_size = sizeof(indices); >> + >> +static const GLvoid * const indices_offset[] = { >> + (GLvoid*) 0, (GLvoid*)(6 * sizeof(GLushort)) >> +}; >> +static GLsizei indices_count[] = { >> + 6, 6 >> +}; >> + >> +static GLint basevertex[] = { 2, 2 }; >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + GLuint program; >> + GLuint vertex_index; >> + >> + piglit_require_extension("GL_OES_draw_elements_base_vertex"); >> + piglit_require_extension("GL_EXT_multi_draw_arrays"); >> + >> + /* Create program */ >> + program = piglit_build_simple_program(vs_source, fs_source); >> + glUseProgram(program); >> + >> + /* Gen vertex array buffer */ >> + glGenBuffers(1, &vertexBuffer); >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glBufferData(GL_ARRAY_BUFFER, vertices_size, vertices, >> GL_STATIC_DRAW); >> + >> + /* Gen indices array buffer */ >> + glGenBuffers(1, &indexBuffer); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices_size, >> + indices, GL_STATIC_DRAW); >> + >> + /* Gen VAO */ >> + glGenVertexArrays(1, &vao); >> + glBindVertexArray(vao); >> + >> + /* Retrieve indices from vs */ >> + vertex_index = glGetAttribLocation(program, "vertex"); >> + >> + /* Enable vertex attrib array */ >> + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); >> + glEnableVertexAttribArray(vertex_index); >> + glVertexAttribPointer(vertex_index, 2, GL_FLOAT, GL_FALSE, 0, 0); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + bool pass = true; >> + >> + float green[] = {0, 1, 0, 1}; >> + float blue[] = {0, 0, 1, 1}; >> + >> + glClearColor(blue[0], blue[1], blue[2], 1.0); >> + glClear(GL_COLOR_BUFFER_BIT); >> + >> + glBindVertexArray(vao); >> + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); >> + >> + glMultiDrawElementsBaseVertexEXT(GL_TRIANGLES, indices_count, >> + GL_UNSIGNED_SHORT, >> (GLvoid*)indices_offset, >> + 2, basevertex); >> + >> + /* Check for test pass */ >> + pass = piglit_probe_pixel_rgba(100, 175, blue) && pass; >> + pass = piglit_probe_pixel_rgba(100, 125, green) && pass; >> + pass = piglit_probe_pixel_rgba(100, 75, blue) && pass; >> + pass = piglit_probe_pixel_rgba(100, 25, green) && pass; >> + >> + piglit_present_results(); >> + >> + 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
