[Piglit] =?y?q?=5BPATCH=5D=20fbo-copyteximage-depth-max=3A=20New=20test=20for=20i965=20driver=20bug?=

Shuang He shuang.he at intel.com
Tue Jan 3 22:30:34 PST 2012


Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44436
Signed-off-by: Shuang He <shuang.he at intel.com>
---
 tests/all.tests                        |    1 +
 tests/fbo/CMakeLists.gl.txt            |    1 +
 tests/fbo/fbo-copyteximage-depth-max.c |  102 ++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 tests/fbo/fbo-copyteximage-depth-max.c

diff --git a/tests/all.tests b/tests/all.tests
index 1b1c848..9b87f35 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -164,6 +164,7 @@ add_plain_test(fbo, 'fbo-clear-formats')
 add_plain_test(fbo, 'fbo-copypix')
 add_plain_test(fbo, 'fbo-copyteximage')
 add_plain_test(fbo, 'fbo-copyteximage-simple')
+add_plain_test(fbo, 'fbo-copyteximage-depth-max')
 add_plain_test(fbo, 'fbo-depth-array')
 add_plain_test(fbo, 'fbo-depthtex')
 add_plain_test(fbo, 'fbo-depth-sample-compare')
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
index 6b5e32c..7152d9f 100644
--- a/tests/fbo/CMakeLists.gl.txt
+++ b/tests/fbo/CMakeLists.gl.txt
@@ -84,6 +84,7 @@ add_executable (fbo-sys-sub-blit fbo-sys-sub-blit.c)
 add_executable (fbo-pbo-readpixels-small fbo-pbo-readpixels-small.c)
 add_executable (fbo-copyteximage fbo-copyteximage.c)
 add_executable (fbo-copyteximage-simple fbo-copyteximage-simple.c)
+add_executable (fbo-copyteximage-depth-max fbo-copyteximage-depth-max.c)
 add_executable (fbo-cubemap fbo-cubemap.c)
 add_executable (fbo-scissor-bitmap fbo-scissor-bitmap.c)
 
diff --git a/tests/fbo/fbo-copyteximage-depth-max.c b/tests/fbo/fbo-copyteximage-depth-max.c
new file mode 100644
index 0000000..036debf
--- /dev/null
+++ b/tests/fbo/fbo-copyteximage-depth-max.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright © 20011Intel 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.
+ *
+ * Authors:
+ *    Shuang He <shuang.he at intel.com>
+ *
+ */
+
+/** @file fbo-copytex-depth-max.c
+ *
+ * Tests that glCopyTexImage2D can be used to copy from fbo with max supported size
+ * into depth texture.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100;
+int piglit_height = 100;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
+
+enum piglit_result
+piglit_display(void)
+{
+	GLboolean pass = GL_TRUE;
+	GLuint tex, fb, rb;
+	GLint maxTextureSize, maxRenderbufferSize, textureSize;
+	GLenum status;
+	GLubyte *depth = NULL;
+
+	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
+	glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxRenderbufferSize);
+	textureSize = (maxTextureSize > maxRenderbufferSize) ? maxRenderbufferSize:maxTextureSize;
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_2D, tex);
+
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
+		     textureSize, textureSize,
+		     0,
+		     GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+
+	assert(glGetError() == 0);
+
+	glGenFramebuffersEXT(1, &fb);
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
+	glGenRenderbuffersEXT(1, &rb);
+	glBindRenderbufferEXT(GL_RENDERBUFFER, rb);
+	glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, textureSize, textureSize);
+	glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
+	glDrawBuffer(GL_NONE);
+	glReadBuffer(GL_NONE);
+
+	assert(glGetError() == 0);
+
+	status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+		fprintf(stderr, "FBO incomplete\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	glClearDepth(0.5);
+	glClear(GL_DEPTH_BUFFER_BIT);
+
+	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, 100, 100, 0);
+
+	depth = malloc(sizeof(GLubyte) * textureSize * textureSize);
+	glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, depth);
+	if (depth[0] != 127)
+		pass = GL_FALSE;
+
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+	free(depth);
+	glDeleteRenderbuffersEXT(1, &rb);
+	glDeleteFramebuffersEXT(1, &fb);
+	glDeleteTextures(1, &tex);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_EXT_framebuffer_object");
+}
-- 
1.7.3.2.432.gad1a9.dirty



More information about the Piglit mailing list