summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2011-08-21 09:55:27 +0100
committerDave Airlie <airlied@redhat.com>2011-08-21 10:02:16 +0100
commite7db67810b87d56817daefd8ff98c7eb69919d6c (patch)
tree663e3b4686623dc863f04c8cfd80ba34a78dc8b4
parentd1696bb83ff89dfdc7b6aff4c62fd01e767de4e3 (diff)
arb_vertex_type_2_10_10_10_rev: add vertex/color drawing test.
This is a clone of the general draw-vertices test but adapted to test the ARB_vertex_type_2_10_10_10_rev VBO api.
-rw-r--r--tests/all.tests4
-rw-r--r--tests/spec/CMakeLists.txt1
-rw-r--r--tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.gl.txt17
-rw-r--r--tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.txt1
-rw-r--r--tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c190
5 files changed, 213 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 406d23f1d..b38db53bc 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1203,6 +1203,10 @@ arb_copy_buffer = Group()
spec['ARB_copy_buffer'] = arb_copy_buffer
add_plain_test(arb_copy_buffer, 'copy_buffer_coherency')
+arb_vertex_type_2_10_10_10_rev = Group()
+spec['ARB_vertex_type_2_10_10_10_rev'] = arb_vertex_type_2_10_10_10_rev
+add_plain_test(arb_vertex_type_2_10_10_10_rev, 'draw-vertices-2101010')
+
# group glslparsertest ------------------------------------------------------
glslparsertest = Group()
# Add all shader source files in the directories below.
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index bb7b6a11e..b4e77070b 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -20,3 +20,4 @@ add_subdirectory (arb_vertex_program)
add_subdirectory (arb_copy_buffer)
add_subdirectory (glsl-1.20)
add_subdirectory (glsl-1.30)
+add_subdirectory (arb_vertex_type_2_10_10_10_rev)
diff --git a/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.gl.txt b/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.gl.txt
new file mode 100644
index 000000000..3bb8b9572
--- /dev/null
+++ b/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.gl.txt
@@ -0,0 +1,17 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${GLUT_INCLUDE_DIR}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ ${GLUT_glut_LIBRARY}
+)
+
+add_executable (draw-vertices-2101010 draw-vertices-2101010.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.txt b/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.txt
new file mode 100644
index 000000000..144a306f4
--- /dev/null
+++ b/tests/spec/arb_vertex_type_2_10_10_10_rev/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c b/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c
new file mode 100644
index 000000000..f7b64d270
--- /dev/null
+++ b/tests/spec/arb_vertex_type_2_10_10_10_rev/draw-vertices-2101010.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright © 2011 Dave Airlie <airlied@redhat.com>
+ * Based on draw-vertices © Marek Olšák <maraeo@gmail.com>
+ *
+ * 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.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ */
+
+/* this test does some basic tests of ARB_vertex_type_2_10_10_10 vbos */
+
+#include "piglit-util.h"
+
+int piglit_width = 320, piglit_height = 60;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+#define i32to10(x) ((x) >= 0 ? (x & 0x1ff) : 1024-(abs((x))& 0x1ff))
+#define i32to2(x) ((x) >= 0 ? (x & 0x1) : 1-abs((x)))
+
+static unsigned iconv(int x, int y, int z, int w)
+{
+ unsigned val;
+
+ val = i32to10(x);
+ val |= i32to10(y) << 10;
+ val |= i32to10(z) << 20;
+ val |= i32to2(w) << 30;
+ return val;
+}
+#define conv(x,y,z,w) (((unsigned)(x) & 0x3ff) | ((unsigned)(y) & 0x3ff) << 10 | ((unsigned)(z) & 0x3ff)<< 20 | ((unsigned)(w) & 0x3) << 30)
+
+void piglit_init(int argc, char **argv)
+{
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ if (!GLEW_VERSION_1_5) {
+ printf("Requires OpenGL 1.5\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ piglit_require_extension("GL_ARB_vertex_type_2_10_10_10_rev");
+ glShadeModel(GL_FLAT);
+ glClearColor(0.2, 0.2, 0.2, 1.0);
+}
+
+static GLuint vboVertexPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *buf, GLsizei bufSize, intptr_t bufOffset)
+{
+ GLuint id;
+ glGenBuffers(1, &id);
+ glBindBuffer(GL_ARRAY_BUFFER, id);
+ glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
+ glVertexPointer(size, type, stride, (void*)bufOffset);
+ return id;
+}
+
+static GLuint vboColorPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *buf, GLsizei bufSize, intptr_t bufOffset)
+{
+ GLuint id;
+ glGenBuffers(1, &id);
+ glBindBuffer(GL_ARRAY_BUFFER, id);
+ glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
+ glColorPointer(size, type, stride, (void*)bufOffset);
+ return id;
+}
+
+static void test_packed_int_color_vertices(float x1, float y1, float x2, float y2, int index)
+{
+ unsigned int v[3];
+ unsigned int c[3];
+ GLuint vbo;
+
+ v[0] = iconv(x1, y1, 0, 1);
+ v[1] = iconv(x1, y2, 0, 1);
+ v[2] = iconv(x2, y1, 0, 1);
+
+ if (index == 0) {
+ c[0] = iconv(511, 0, 0, 0);
+ c[1] = iconv(511, 0, 0, 0);
+ c[2] = iconv(511, 0, 0, 0);
+ } else {
+ c[0] = conv(1023, 0, 0, 0);
+ c[1] = conv(1023, 0, 0, 0);
+ c[2] = conv(1023, 0, 0, 0);
+ }
+
+ glVertexPointer(4, GL_INT_2_10_10_10_REV, 4, v);
+
+ glEnableClientState(GL_COLOR_ARRAY);
+ switch (index) {
+ case 0: vbo = vboColorPointer(4, GL_INT_2_10_10_10_REV, 4, c, sizeof(c), 0); break;
+ case 1: vbo = vboColorPointer(4, GL_UNSIGNED_INT_2_10_10_10_REV, 4, c, sizeof(c), 0); break;
+ }
+
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDeleteBuffers(1, &vbo);
+}
+
+static void test_packed_int_vertices(float x1, float y1, float x2, float y2, int index)
+{
+ unsigned int v[3];
+ GLuint vbo;
+
+ if (index == 0) {
+ v[0] = iconv(x1, y1, 0, 1);
+ v[1] = iconv(x1, y2, 0, 1);
+ v[2] = iconv(x2, y1, 0, 1);
+ } else {
+ v[0] = conv(x1, y1, 0, 1);
+ v[1] = conv(x1, y2, 0, 1);
+ v[2] = conv(x2, y1, 0, 1);
+ }
+
+ switch (index) {
+ case 0: vbo = vboVertexPointer(4, GL_INT_2_10_10_10_REV, 4, v, sizeof(v), 0); break;
+ case 1: vbo = vboVertexPointer(4, GL_UNSIGNED_INT_2_10_10_10_REV, 4, v, sizeof(v), 0); break;
+ }
+
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ glDeleteBuffers(1, &vbo);
+}
+
+struct test {
+ void (*test)(float x1, float y1, float x2, float y2, int index);
+ int index;
+ float expected_color[3];
+ const char *name;
+};
+
+struct test tests[] = {
+ {test_packed_int_vertices, 0, {1, 1, 1}, "Int vertices - 2/10/10/10"},
+ {test_packed_int_vertices, 1, {1, 1, 1}, "Unsigned Int vertices - 2/10/10/10"},
+ {test_packed_int_color_vertices, 0, {1, 0, 0}, "Int Color - 2/10/10/10"},
+ {test_packed_int_color_vertices, 1, {1, 0, 0}, "Unsigned Int Color - 2/10/10/10"},
+
+ {0}
+};
+
+enum piglit_result
+piglit_display(void)
+{
+ GLboolean pass = GL_TRUE;
+ unsigned i;
+ float x = 0, y = 0;
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ for (i = 0; tests[i].test; i++) {
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ printf("%s\n", tests[i].name);
+ tests[i].test(x, y, x+20, y+20, tests[i].index);
+ assert(glGetError() == 0);
+ pass = piglit_probe_pixel_rgb(x+5, y+5, tests[i].expected_color) && pass;
+
+ x += 20;
+ if (x > 300) {
+ x = 0;
+ y += 20;
+ }
+ }
+
+ glFinish();
+ glutSwapBuffers();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}