summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2011-07-19 21:15:31 -0600
committerBrian Paul <brianp@vmware.com>2011-07-19 21:15:31 -0600
commit141bf377f154461392a1784e821ccb99d8548766 (patch)
tree5adc8a791fce383c4b7db6f79bf727c63bc5a326 /tests
parent0e028841f4a54890011bbc3b3349502744d93a3b (diff)
copyteximage-clipping: test clipping of glCopyTexImage2D()
Diffstat (limited to 'tests')
-rw-r--r--tests/all.tests1
-rw-r--r--tests/texturing/CMakeLists.gl.txt2
-rw-r--r--tests/texturing/copyteximage-clipping.c74
3 files changed, 77 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index f11db7fb9..cc6c684db 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -566,6 +566,7 @@ glx['glx-pixmap-crosscheck'].runConcurrent = True
texturing = Group()
add_plain_test(texturing, 'array-texture')
add_plain_test(texturing, 'copytexsubimage')
+add_plain_test(texturing, 'copyteximage-clipping')
add_plain_test(texturing, 'cubemap')
add_plain_test(texturing, 'depth-level-clamp')
add_plain_test(texturing, 'depth-tex-modes')
diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt
index 360c1c863..7c67ed441 100644
--- a/tests/texturing/CMakeLists.gl.txt
+++ b/tests/texturing/CMakeLists.gl.txt
@@ -15,6 +15,7 @@ link_libraries (
add_executable (array-texture array-texture.c)
add_executable (copytexsubimage copytexsubimage.c)
+add_executable (copyteximage-clipping copyteximage-clipping.c)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_executable (crossbar crossbar.c)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@@ -56,6 +57,7 @@ add_executable (teximage-errors teximage-errors.c)
add_executable (texrect-many texrect-many.c)
add_executable (texredefine texredefine.c)
add_executable (texture-packed-formats texture-packed-formats.c)
+add_executable (texture-buffer-object texture-buffer-object.c)
add_executable (texture-integer texture-integer.c)
add_executable (depth-tex-modes depth-tex-modes.c depth-tex-modes-common.c)
add_executable (depth-tex-modes-rg depth-tex-modes-rg.c depth-tex-modes-common.c)
diff --git a/tests/texturing/copyteximage-clipping.c b/tests/texturing/copyteximage-clipping.c
new file mode 100644
index 000000000..3e7b3bce1
--- /dev/null
+++ b/tests/texturing/copyteximage-clipping.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2011 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.
+ */
+
+/**
+ * Try copying a large texture image from a small window. The driver will
+ * have to do some clipping to avoid reading out of bounds.
+ * XXX we should also do some rendering with the texture and check the results.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
+
+
+static GLboolean
+test(void)
+{
+ const int texWidth = 512, texHeight = 512;
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ int x = rand() % 300 - 100;
+ int y = rand() % 300 - 100;
+ int w, h;
+
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y,
+ texWidth, texHeight, 0);
+
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
+ if (w != texWidth || h != texHeight)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+ if (test())
+ return PIGLIT_PASS;
+ else
+ return PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+
+}