summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2015-01-04 16:47:54 +0100
committerMarek Olšák <marek.olsak@amd.com>2015-01-15 13:31:21 +0100
commitb9445e07c317deed7e03e562bcf1d02f7f755bf9 (patch)
treee6a8f44b19bf9433645c6b0fbeba72e45515fe18
parentd66dd25487a65e16dfc2f4df826438e8298251b1 (diff)
arb_draw_indirect: test glDrawArraysIndirect with GL_PRIMITIVE_RESTART
-rw-r--r--tests/all.py1
-rw-r--r--tests/spec/arb_draw_indirect/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_draw_indirect/draw-arrays-prim-restart.c115
3 files changed, 117 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index f0bd17ac9..ccf4107d6 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1834,6 +1834,7 @@ arb_draw_indirect = {}
spec['ARB_draw_indirect'] = arb_draw_indirect
add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-api-errors'])
add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-draw-arrays'])
+add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-draw-arrays-prim-restart'])
add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-draw-elements'])
add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-draw-arrays-base-instance'])
add_concurrent_test(arb_draw_indirect, ['arb_draw_indirect-draw-elements-base-instance'])
diff --git a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt
index 4be3a8836..1d1b59825 100644
--- a/tests/spec/arb_draw_indirect/CMakeLists.gl.txt
+++ b/tests/spec/arb_draw_indirect/CMakeLists.gl.txt
@@ -11,6 +11,7 @@ link_libraries (
piglit_add_executable (arb_draw_indirect-api-errors api-errors.c)
piglit_add_executable (arb_draw_indirect-draw-arrays draw-arrays.c)
+piglit_add_executable (arb_draw_indirect-draw-arrays-prim-restart draw-arrays-prim-restart.c)
piglit_add_executable (arb_draw_indirect-draw-elements draw-elements.c)
piglit_add_executable (arb_draw_indirect-draw-arrays-base-instance draw-arrays-base-instance.c)
piglit_add_executable (arb_draw_indirect-draw-elements-base-instance draw-elements-base-instance.c)
diff --git a/tests/spec/arb_draw_indirect/draw-arrays-prim-restart.c b/tests/spec/arb_draw_indirect/draw-arrays-prim-restart.c
new file mode 100644
index 000000000..f1e2247f1
--- /dev/null
+++ b/tests/spec/arb_draw_indirect/draw-arrays-prim-restart.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright © 2014 Advanced Micro Devices, 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 if primitive restart works with glDrawArraysIndirect.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ config.supports_gl_compat_version = 33;
+ config.supports_gl_core_version = 33;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+PIGLIT_GL_TEST_CONFIG_END
+
+static const GLchar *vstext =
+ "#version 330\n"
+ "attribute vec2 piglit_vertex;\n"
+ "attribute int piglit_texcoord;\n"
+ "out vec4 color;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = vec4(piglit_vertex, 0.0, 1.0);\n"
+ " color = vec4(0.0, 1.0, 0.0, 1.0);\n"
+ "} \n";
+
+static const char *fstext =
+ "#version 330\n"
+ "in vec4 color;\n"
+ "void main() {\n"
+ " gl_FragColor = color;\n"
+ "}\n";
+
+static GLint prog;
+
+enum piglit_result
+piglit_display(void)
+{
+ static const float green[] = {0, 1, 0, 1};
+ enum piglit_result result;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDrawArraysIndirect(GL_TRIANGLES, NULL);
+
+ result = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+ green)
+ ? PIGLIT_PASS : PIGLIT_FAIL;
+
+ piglit_present_results();
+ return result;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ static const float pos[] = {
+ -1, -1,
+ -1, 1,
+ 1, -1,
+ 1, -1, /* restart index */
+ 1, 1,
+ 1, -1,
+ -1, 1,
+ };
+ static const int indices[] = {
+ 7, /* count */
+ 1, /* instance count */
+ 0, /* start */
+ 0, /* start instance */
+ };
+ GLuint vao, buf, indirect_buf;
+
+ piglit_require_gl_version(33);
+ piglit_require_extension("GL_ARB_draw_indirect");
+ prog = piglit_build_simple_program(vstext, fstext);
+ glUseProgram(prog);
+
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+
+ glGenBuffers(1, &buf);
+ glBindBuffer(GL_ARRAY_BUFFER, buf);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(pos), pos, GL_STATIC_DRAW);
+
+ glGenBuffers(1, &indirect_buf);
+ glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirect_buf);
+ glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(indices), indices,
+ GL_STATIC_DRAW);
+
+ glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
+ glVertexAttribPointer(PIGLIT_ATTRIB_POS, 2, GL_FLOAT, 0, 0, NULL);
+
+ glEnable(GL_PRIMITIVE_RESTART);
+ glPrimitiveRestartIndex(3);
+}