[Piglit] [PATCH] intel: Add test case to reproduce assertion failure in intel-miptree-release()

Anuj Phogat anuj.phogat at gmail.com
Tue Feb 21 14:43:04 PST 2012


Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46303

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 tests/all.tests                    |    1 +
 tests/bugs/CMakeLists.gl.txt       |    1 +
 tests/bugs/intel-miptree-release.c |  145 ++++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+), 0 deletions(-)
 create mode 100644 tests/bugs/intel-miptree-release.c

diff --git a/tests/all.tests b/tests/all.tests
index e4d56b8..f96c267 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -569,6 +569,7 @@ add_plain_test(bugs, 'fdo24066')
 add_plain_test(bugs, 'fdo25614-genmipmap')
 add_plain_test(bugs, 'fdo28551')
 add_plain_test(bugs, 'fdo31934')
+add_plain_test(bugs, 'intel-miptree-release')
 add_plain_test(bugs, 'point-sprite')
 add_plain_test(bugs, 'r300-readcache')
 add_plain_test(bugs, 'tex1d-2dborder')
diff --git a/tests/bugs/CMakeLists.gl.txt b/tests/bugs/CMakeLists.gl.txt
index 5c1864e..7c71c24 100644
--- a/tests/bugs/CMakeLists.gl.txt
+++ b/tests/bugs/CMakeLists.gl.txt
@@ -20,6 +20,7 @@ add_executable (drawbuffer-modes drawbuffer-modes.c)
 add_executable (fdo9833 fdo9833.c)
 add_executable (fdo10370 fdo10370.c)
 add_executable (fdo14575 fdo14575.c)
+add_executable (intel-miptree-release intel-miptree-release.c)
 add_executable (r300-readcache r300-readcache.c)
 add_executable (tex1d-2dborder tex1d-2dborder.c)
 add_executable (fdo20701 fdo20701.c)
diff --git a/tests/bugs/intel-miptree-release.c b/tests/bugs/intel-miptree-release.c
new file mode 100644
index 0000000..339b1e2
--- /dev/null
+++ b/tests/bugs/intel-miptree-release.c
@@ -0,0 +1,145 @@
+/* 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 intel-miptree-release.c
+ * Reproduce the assertion failure in intel_region_release() function
+ *
+ * This test works by calling glTexImage2D function with texture target
+ * = GL_TEXTURE_2D and increasing texture sizes
+ * All the calls to glTexImage2D() should ensure no assertion failure
+ * in mesa driver.
+ *
+ * This test case reproduces the errors reported in:
+ * https://bugs.freedesktop.org/show_bug.cgi?id=46303
+ *
+ * \Author Anuj Phogat <anuj.phogat at gmail.com>
+ */
+#include "piglit-util.h"
+#define MAX_2D_TEXTURE 8192
+#define COLOR_COMPONENTS 4
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGBA | GLUT_DOUBLE;
+
+char *target_string[] = {
+	"GL_TEXTURE_2D",
+	};
+
+char *format_string[] = {
+	"GL_RGBA8",
+	};
+
+GLenum target[] = {
+	GL_TEXTURE_2D,
+	};
+
+GLenum internalformat[] = {
+	GL_RGBA8,
+	};
+
+
+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, side;
+	const uint64_t nPixels = (uint64_t)(MAX_2D_TEXTURE + 3) *
+				 (uint64_t)(MAX_2D_TEXTURE + 3);
+	/* Allocate the data array for maximum texture size used in this test */
+	GLfloat *pixels = (GLfloat *) calloc(nPixels * COLOR_COMPONENTS, sizeof(float));
+	if ( pixels == NULL) {
+	   printf("\nUnable to allocate texture data array");
+	   return (PIGLIT_FAIL);
+	}
+
+	for ( i = 0; i < ARRAY_SIZE(target); i++) {
+		/* Query the maximum supported texture size */
+		glGetIntegerv(maxTargetEnum(target[i]), &maxSide);
+		printf("\n%s, Maximum allowable texture size = %d\n",
+		       target_string[i], 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 < ARRAY_SIZE(internalformat); j++) {
+			for ( side = maxSide/2; side < maxSide + 2; side++) {
+					glTexImage2D(target[i], 0, internalformat[j],
+						     side, side, 0,
+						     GL_RGBA, GL_FLOAT, NULL);
+					glTexSubImage2D(target[i], 0, 0, 0,
+							side/2, side/2,
+							GL_RGBA, GL_FLOAT, pixels);
+					if (glGetError() == GL_OUT_OF_MEMORY)
+					{
+					   printf("GL error while testing %s,"
+						  " texture size = %d, internal"
+						  " format = %s\n",
+						  target_string[i], side,
+						  format_string[j]);
+					   piglit_reset_gl_error();
+					}
+			}
+
+		}
+		glDeleteTextures(1, &tex);
+	}
+	/* 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.6



More information about the Piglit mailing list