summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2014-12-21 16:31:02 -0800
committerJordan Justen <jordan.l.justen@intel.com>2014-12-21 16:37:31 -0800
commitecb5d47806f2042c585d485902918cfabcb49f4b (patch)
tree4c2cf63034cce6bc107cdd70bd8eb3a1751417f2
parente8b33df1b6b5fec35bf1b71decfd36dd1202d1e9 (diff)
intel_rectlist_prim: Try reproducing diagonal tearing with triangle fanintel-rectlist
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r--tests/spec/CMakeLists.txt1
-rw-r--r--tests/spec/intel_rectlist_prim/CMakeLists.gl.txt13
-rw-r--r--tests/spec/intel_rectlist_prim/CMakeLists.txt2
-rw-r--r--tests/spec/intel_rectlist_prim/execution/CMakeLists.gl.txt15
-rw-r--r--tests/spec/intel_rectlist_prim/execution/CMakeLists.txt1
-rw-r--r--tests/spec/intel_rectlist_prim/execution/draw.c153
6 files changed, 185 insertions, 0 deletions
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index dfd822b41..2a65f3638 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -114,3 +114,4 @@ add_subdirectory (arb_blend_func_extended)
add_subdirectory (ext_unpack_subimage)
add_subdirectory (arb_vertex_array_object)
add_subdirectory (oes_texture_float)
+add_subdirectory (intel_rectlist_prim)
diff --git a/tests/spec/intel_rectlist_prim/CMakeLists.gl.txt b/tests/spec/intel_rectlist_prim/CMakeLists.gl.txt
new file mode 100644
index 000000000..b204c0247
--- /dev/null
+++ b/tests/spec/intel_rectlist_prim/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+# vim: ft=cmake:
diff --git a/tests/spec/intel_rectlist_prim/CMakeLists.txt b/tests/spec/intel_rectlist_prim/CMakeLists.txt
new file mode 100644
index 000000000..e4126fc2d
--- /dev/null
+++ b/tests/spec/intel_rectlist_prim/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (execution)
+piglit_include_target_api()
diff --git a/tests/spec/intel_rectlist_prim/execution/CMakeLists.gl.txt b/tests/spec/intel_rectlist_prim/execution/CMakeLists.gl.txt
new file mode 100644
index 000000000..9e1198a20
--- /dev/null
+++ b/tests/spec/intel_rectlist_prim/execution/CMakeLists.gl.txt
@@ -0,0 +1,15 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (intel_rectlist_prim-draw draw.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/intel_rectlist_prim/execution/CMakeLists.txt b/tests/spec/intel_rectlist_prim/execution/CMakeLists.txt
new file mode 100644
index 000000000..144a306f4
--- /dev/null
+++ b/tests/spec/intel_rectlist_prim/execution/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/intel_rectlist_prim/execution/draw.c b/tests/spec/intel_rectlist_prim/execution/draw.c
new file mode 100644
index 000000000..4b6311d16
--- /dev/null
+++ b/tests/spec/intel_rectlist_prim/execution/draw.c
@@ -0,0 +1,153 @@
+/* Copyright (c) 2014 Intel Corporation
+ *
+ * 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.
+ */
+
+/** @file draw.c
+ * Can we reproduce diagonal tearing with a triangle fan?
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_core_version = 32;
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+ config.window_width = 800;
+ config.window_height = 600;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define NUM_RECTS 10000
+#define COLORS 2
+
+struct bo_data {
+ float x, y;
+ char r, g, b;
+};
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ int i;
+
+ glViewport(0, 0, piglit_width, piglit_height);
+ glClearColor(0.2, 0.2, 0.2, 0.2);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ for (i = 0; i < NUM_RECTS; i++) {
+ unsigned offset = (i % COLORS) * 4;
+ glDrawArrays(GL_TRIANGLE_FAN, offset, 4);
+ glFlush();
+ }
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint prog = piglit_build_simple_program(
+ "#version 140\n"
+ "\n"
+ "in vec2 piglit_vertex;\n"
+ "in vec3 in_color;\n"
+ "out vec3 color_from_vs;\n"
+ "\n"
+ "void main() {\n"
+ " color_from_vs = in_color;\n"
+ " gl_Position = vec4(piglit_vertex, 0, 1);\n"
+ "}\n",
+
+ "#version 140\n"
+ "in vec3 color_from_vs;\n"
+ "out vec4 fragcolor;\n"
+ "\n"
+ "void main() {\n"
+ " fragcolor = vec4(color_from_vs, 1);\n"
+ "}\n");
+
+ GLuint vao;
+ GLuint bo;
+ GLint attrib;
+ struct bo_data *bo_data;
+ unsigned bo_size = sizeof(struct bo_data) * NUM_RECTS;
+ GLsizei stride = sizeof(struct bo_data);
+ void *pointer;
+ unsigned vertex;
+
+ glUseProgram(prog);
+
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+
+ bo_data = calloc(NUM_RECTS, sizeof(struct bo_data));
+
+ for (vertex = 0; vertex < 2 * 4; vertex++) {
+ switch(vertex % 4) {
+ case 0:
+ bo_data[vertex].x = 1.0;
+ bo_data[vertex].y = -1.0;
+ break;
+
+ case 1:
+ bo_data[vertex].x = -1.0;
+ bo_data[vertex].y = -1.0;
+ break;
+
+ case 2:
+ bo_data[vertex].x = -1.0;
+ bo_data[vertex].y = 1.0;
+ break;
+
+ case 3:
+ bo_data[vertex].x = 1.0;
+ bo_data[vertex].y = 1.0;
+ break;
+ }
+
+ switch(vertex / 4) {
+ case 0:
+ bo_data[vertex].r = 0xff;
+ break;
+ case 1:
+ bo_data[vertex].g = 0xff;
+ break;
+ }
+ }
+
+ glGenBuffers(1, &bo);
+ glBindBuffer(GL_ARRAY_BUFFER, bo);
+ glBufferData(GL_ARRAY_BUFFER, bo_size, bo_data,
+ GL_STATIC_DRAW);
+
+ free(bo_data);
+
+ attrib = glGetAttribLocation(prog, "piglit_vertex");
+ pointer = (void *) OFFSET_OF(struct bo_data, x);
+ glVertexAttribPointer(attrib, 2, GL_FLOAT, GL_FALSE, stride, pointer);
+ glEnableVertexAttribArray(attrib);
+
+ attrib = glGetAttribLocation(prog, "in_color");
+ pointer = (void *) OFFSET_OF(struct bo_data, r);
+ glVertexAttribPointer(attrib, 3, GL_UNSIGNED_BYTE, GL_TRUE, stride, pointer);
+ glEnableVertexAttribArray(attrib);
+}