[Piglit] [PATCH v3] fbo: Verify attaching an invalid slice of a 3D texture
Ian Romanick
idr at freedesktop.org
Wed Jul 31 13:28:29 PDT 2013
From: Ian Romanick <ian.d.romanick at intel.com>
Create a texture with slices [0, N-1]. Try attaching slice N, N+1, and
N-1 to an FBO. The first two cases should result in
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. Do the same test with the layers
of an array texture. The i965 driver results in:
intel_mipmap_tree.h:554: intel_miptree_check_level_layer: Assertion `layer < mt->level[level].depth' failed.
v2: Also try attaching levels N and N-1 instead of just N+1. This
catches a bug in the first proposed fix for this issue.
v3: Also try 1D_ARRAY textures. There were still some problems there in
Mesa.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com> [v1]
---
tests/fbo/fbo-incomplete.cpp | 144 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
diff --git a/tests/fbo/fbo-incomplete.cpp b/tests/fbo/fbo-incomplete.cpp
index a13da89..95bea53 100644
--- a/tests/fbo/fbo-incomplete.cpp
+++ b/tests/fbo/fbo-incomplete.cpp
@@ -200,6 +200,147 @@ incomplete_0_by_0_renderbuffer(void)
return t.pass();
}
+/**
+ * Verify that attaching an invalid slice of a 3D texture results in
+ * incompleteness.
+ */
+bool
+invalid_3d_slice(void)
+{
+ incomplete_fbo_test t("invalid slice of 3D texture", GL_TEXTURE_3D);
+
+ /* Create a texture with only 8 slices (0 through 7), but try to
+ * attach slice 8 and slice 9 to the FBO.
+ */
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, 8, 8, 8, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, NULL);
+ glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_3D, t.tex, 0, 8);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
+ return t.fail();
+
+ glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_3D, t.tex, 0, 9);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
+ return t.fail();
+
+ /* Now try slice 7. This should work.
+ */
+ glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_3D, t.tex, 0, 7);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_COMPLETE))
+ return t.fail();
+
+ return t.pass();
+}
+
+/**
+ * Common code the verify attaching an invalid layer of an array texture
+ * results in incompleteness.
+ */
+bool
+invalid_array_layer_common(incomplete_fbo_test &t)
+{
+ /* The texture has only 8 layers (0 through 7), but try to attach
+ * layer 8 and layer 9 to the FBO.
+ */
+ glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ t.tex, 0, 8);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
+ return t.fail();
+
+ glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ t.tex, 0, 9);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT))
+ return t.fail();
+
+ /* Now try layer 7. This should work.
+ */
+ glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ t.tex, 0, 7);
+
+ if (!piglit_check_gl_error(GL_NO_ERROR))
+ return t.fail();
+
+ if (!t.check_fbo_status(GL_FRAMEBUFFER_COMPLETE))
+ return t.fail();
+ return t.pass();
+}
+
+/**
+ * Verify that attaching an invalid layer of a 1D array texture results in
+ * incompleteness.
+ */
+bool
+invalid_1d_array_layer(void)
+{
+ static const char subtest_name[] =
+ "invalid layer of a 1D-array texture";
+
+ if (!piglit_is_extension_supported("GL_EXT_texture_array")
+ && piglit_get_gl_version() < 30) {
+ piglit_report_subtest_result(PIGLIT_SKIP, subtest_name);
+ return true;
+ }
+
+ incomplete_fbo_test t(subtest_name, GL_TEXTURE_1D_ARRAY);
+
+ /* Create a texture with only 8 layers (0 through 7), but try to
+ * attach layer 8 and layer 9 to the FBO.
+ */
+ glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA, 8, 8, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, NULL);
+
+ return invalid_array_layer_common(t);
+}
+
+/**
+ * Verify that attaching an invalid layer of a 2D array texture results in
+ * incompleteness.
+ */
+bool
+invalid_2d_array_layer(void)
+{
+ static const char subtest_name[] =
+ "invalid layer of a 2D-array texture";
+
+ if (!piglit_is_extension_supported("GL_EXT_texture_array")
+ && piglit_get_gl_version() < 30) {
+ piglit_report_subtest_result(PIGLIT_SKIP, subtest_name);
+ return true;
+ }
+
+ incomplete_fbo_test t(subtest_name, GL_TEXTURE_2D_ARRAY);
+
+ /* Create a texture with only 8 layers (0 through 7), but try to
+ * attach layer 8 and layer 9 to the FBO.
+ */
+ glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 8, 8, 8, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, NULL);
+
+ return invalid_array_layer_common(t);
+}
+
enum piglit_result
piglit_display(void)
{
@@ -215,6 +356,9 @@ piglit_init(int argc, char **argv)
pass = incomplete_0_by_0_texture() && pass;
pass = incomplete_0_by_0_renderbuffer() && pass;
+ pass = invalid_3d_slice() && pass;
+ pass = invalid_1d_array_layer() && pass;
+ pass = invalid_2d_array_layer() && pass;
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
--
1.8.1.4
More information about the Piglit
mailing list