[Piglit] [PATCH] Add test to validate maximum supported texture size
Anuj Phogat
anuj.phogat at gmail.com
Thu Feb 2 11:12:35 PST 2012
This test case reproduces the errors reported in:
https://bugs.freedesktop.org/show_bug.cgi?id=44970
Driver throws assertion failure or segfaults/BUS ERROR with large textures.
Even the textures much smaller than maximum supported texture size shows
similar errors.
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
tests/all.tests | 1 +
tests/bugs/CMakeLists.gl.txt | 1 +
tests/bugs/validate-texture-size.c | 179 ++++++++++++++++++++++++++++++++++++
3 files changed, 181 insertions(+), 0 deletions(-)
create mode 100644 tests/bugs/validate-texture-size.c
diff --git a/tests/all.tests b/tests/all.tests
index aabd5ee..8e3ab61 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -569,6 +569,7 @@ add_plain_test(bugs, 'point-sprite')
add_plain_test(bugs, 'r300-readcache')
add_plain_test(bugs, 'tex1d-2dborder')
add_plain_test(bugs, 'tri-tex-crash')
+add_plain_test(bugs, 'validate-texture-size')
add_plain_test(bugs, 'vbo-buffer-unmap')
glx = Group()
diff --git a/tests/bugs/CMakeLists.gl.txt b/tests/bugs/CMakeLists.gl.txt
index 5c1864e..481bc84 100644
--- a/tests/bugs/CMakeLists.gl.txt
+++ b/tests/bugs/CMakeLists.gl.txt
@@ -33,6 +33,7 @@ add_executable (fdo25614-genmipmap fdo25614-genmipmap.c)
add_executable (fdo28551 fdo28551.c)
add_executable (fdo31934 fdo31934.c)
add_executable (tri-tex-crash tri-tex-crash.c)
+add_executable (validate-texture-size validate-texture-size.c)
add_executable (vbo-buffer-unmap vbo-buffer-unmap.c)
# vim: ft=cmake:
diff --git a/tests/bugs/validate-texture-size.c b/tests/bugs/validate-texture-size.c
new file mode 100644
index 0000000..c85bf2e
--- /dev/null
+++ b/tests/bugs/validate-texture-size.c
@@ -0,0 +1,179 @@
+/* Copyright © 2012 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 validate-texture-size.c
+ * Verify the maximum supported texture size for different texture targets
+ *
+ * This test works by calling glTexImage2D function with different texture
+ * targets. Each texture target is tested with the sizes greater than and equal
+ * to the maximum supported texture size. All the calls to glTexImage2D() and
+ * glTexSubImage2D() should ensure no segmentation faults in mesa driver.
+ *
+ * This test case reproduces the errors reported in:
+ * https://bugs.freedesktop.org/show_bug.cgi?id=44970
+ *
+ * \Author Anuj Phogat <anuj.phogat at gmail.com>
+ */
+#include "piglit-util.h"
+#define MAX_2D_TEXTURE 8192
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGBA | GLUT_DOUBLE;
+
+char *target_string[4] = {
+ "GL_TEXTURE_1D",
+ "GL_TEXTURE_CUBE_MAP",
+ "GL_TEXTURE_2D",
+ "GL_TEXTURE_3D",
+ };
+
+GLenum target[] = {
+ GL_TEXTURE_1D,
+ GL_TEXTURE_CUBE_MAP,
+ GL_TEXTURE_2D,
+ GL_TEXTURE_3D,
+ };
+
+GLenum maxTargetEnum(GLenum target) {
+ switch(target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ return GL_MAX_TEXTURE_SIZE;
+ case GL_TEXTURE_3D:
+ return GL_MAX_3D_TEXTURE_SIZE;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ return GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB;
+ case GL_TEXTURE_RECTANGLE:
+ return GL_MAX_RECTANGLE_TEXTURE_SIZE;
+ case GL_RENDERBUFFER_EXT:
+ return GL_MAX_RENDERBUFFER_SIZE_EXT;
+ default:
+ printf ("Invalid texture target used");
+ return 0;
+ }
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLuint tex;
+ GLint maxSide;
+ int i, j, k;
+ /* Allocate the data array for maximum texture size used in this test */
+ GLfloat *pixels = (GLfloat *)
+ calloc((MAX_2D_TEXTURE + 3) * (MAX_2D_TEXTURE + 3) * 4,
+ sizeof(float));
+
+ for ( i = 0; i < ARRAY_SIZE(target); i++) {
+ /* Query the maximum supported texture size */
+ glGetIntegerv(maxTargetEnum(target[i]), &maxSide);
+ printf("\nMaximum allowable texture size = %d\n", maxSide);
+
+ glGenTextures(1, &tex);
+ glBindTexture(target[i], tex);
+ glTexParameteri(target[i], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(target[i], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(target[i], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(target[i], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ for ( j = 0; j < 4; j ++) {
+ switch (target[i]) {
+ case GL_TEXTURE_1D:
+ printf("Testing %s, texture size = %d\n",
+ target_string[i], maxSide + j);
+ /* border = 0 */
+ glTexImage1D(target[i], 0, GL_RGBA16,
+ maxSide + j, 0,
+ GL_RGBA, GL_FLOAT, NULL);
+ glTexSubImage1D(target[i], 0, 0,
+ maxSide/2, GL_RGBA,
+ GL_FLOAT, pixels);
+ break;
+
+ case GL_TEXTURE_2D:
+ printf("Testing %s, texture size = %d\n",
+ target_string[i], maxSide + j);
+ /* border = 0 */
+ glTexImage2D(target[i], 0, GL_RGBA16 /*or GL_RGBA32F or GL_RGBA8*/,
+ maxSide + j, maxSide + j, 0,
+ GL_RGBA, GL_FLOAT, NULL);
+ glTexSubImage2D(target[i], 0, 0, 0,
+ maxSide/2, maxSide/2,
+ GL_RGBA, GL_FLOAT, pixels);
+ break;
+
+ case GL_TEXTURE_3D:
+ printf("Testing %s, texture size = %d\n",
+ target_string[i], maxSide + j);
+
+ glTexParameteri(target[i], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
+ /* border = 0 */
+ glTexImage3D(target[i], 0, GL_RGBA16,
+ maxSide + j, maxSide + j,
+ maxSide + j, 0, GL_RGBA,
+ GL_FLOAT, NULL);
+
+ glTexSubImage3D(target[i], 0, 0, 0, 0,
+ maxSide/2, maxSide/2, maxSide/2,
+ GL_RGBA, GL_FLOAT, pixels);
+
+ break;
+
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ printf("Testing %s, texture size = %d\n",
+ target_string[i], maxSide + j);
+ /* border = 0 */
+ for (k = 0; k < 6; k++) {
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k,
+ 0, GL_RGBA16 /*or GL_RGBA32F*/,
+ maxSide + j, maxSide + j, 0,
+ GL_RGBA, GL_FLOAT, NULL);
+ }
+ for (k = 0; k < 6; k++) {
+ glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k,
+ 0, 0, 0,
+ maxSide/2, maxSide/2,
+ GL_RGBA, GL_FLOAT, pixels);
+ }
+ break;
+ }
+ }
+ }
+ /* If execution reaches this point, return PIGLIT_PASS */
+ piglit_report_result(PIGLIT_PASS);
+ return (PIGLIT_PASS);
+}
+
+void piglit_init(int argc, char **argv)
+{
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho(0, piglit_width, 0, piglit_height, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glClearColor(0.2, 0.2, 0.2, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+}
--
1.7.7.4
More information about the Piglit
mailing list