[Piglit] [PATCH 06/15] arb_direct_state_access: Testing CheckNamedFramebufferStatus errors.

Laura Ekstrand laura at jlekstrand.net
Thu Mar 5 18:01:16 PST 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../arb_direct_state_access/checkfbstatus-errors.c | 117 +++++++++++++++++++++
 3 files changed, 119 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/checkfbstatus-errors.c

diff --git a/tests/all.py b/tests/all.py
index 71b4498..3015857 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4030,6 +4030,7 @@ spec['ARB_direct_state_access']['getnamedbufferparameter'] = PiglitGLTest(['arb_
 spec['ARB_direct_state_access']['getnamedbuffersubdata'] = PiglitGLTest(['arb_direct_state_access-getnamedbuffersubdata'], run_concurrent=True)
 spec['ARB_direct_state_access']['namedframebufferrenderbuffer'] = PiglitGLTest(['arb_direct_state_access-namedframebufferrenderbuffer'], run_concurrent=True)
 spec['ARB_direct_state_access']['framebufferblit'] = PiglitGLTest(['arb_direct_state_access-framebufferblit'], run_concurrent=True)
+spec['ARB_direct_state_access']['checkfbstatus-errors'] = PiglitGLTest(['arb_direct_state_access-checkfbstatus-errors'], run_concurrent=True)
 
 arb_shader_image_load_store = spec['ARB_shader_image_load_store']
 arb_shader_image_load_store['atomicity'] = PiglitGLTest(['arb_shader_image_load_store-atomicity'], run_concurrent=True)
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index 727acc2..744735a 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -27,6 +27,7 @@ piglit_add_executable (arb_direct_state_access-getnamedbufferparameter getnamedb
 piglit_add_executable (arb_direct_state_access-getnamedbuffersubdata getnamedbuffersubdata.c)
 piglit_add_executable (arb_direct_state_access-namedframebufferrenderbuffer namedframebufferrenderbuffer.c)
 piglit_add_executable (arb_direct_state_access-framebufferblit framebufferblit.c)
+piglit_add_executable (arb_direct_state_access-checkfbstatus-errors checkfbstatus-errors.c)
 piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
 piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
 piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
diff --git a/tests/spec/arb_direct_state_access/checkfbstatus-errors.c b/tests/spec/arb_direct_state_access/checkfbstatus-errors.c
new file mode 100644
index 0000000..e8a8323
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/checkfbstatus-errors.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 2015 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 checkfbstatus-errors.c
+ *
+ * Make sure that glCheckNamedFramebufferStatus behaves according to the
+ * OpenGL 4.5 spec (30.10.2014).
+ *
+ * Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
+ * (30.10.2014, PDF page 336) says:
+ *    "If framebuffer is zero, then the status of the default read or
+ *    draw framebuffer (as determined by target) is returned."
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_direct_state_access");
+}
+
+static bool
+check_fbo_status(GLuint fbo, GLenum target, GLenum expected_status)
+{
+	GLenum fbstatus;
+	fbstatus = glCheckNamedFramebufferStatus(fbo, target);
+	if (fbstatus != expected_status) {
+		printf("fbo=%u, target=%s status: got %s, expected %s\n",
+		       fbo, piglit_get_gl_enum_name(target),
+		       piglit_get_gl_enum_name(fbstatus),
+		       piglit_get_gl_enum_name(expected_status));
+	    return false;
+	}
+
+	return true;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	GLuint fbo, texture;
+
+	/* Uninitialized fbo */
+	glCreateFramebuffers(1, &fbo);
+	SUBTESTCONDITION(check_fbo_status(fbo, GL_FRAMEBUFFER,
+			 GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), pass,
+			 "uninitialized fbo");
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	/* This should be complete */
+	glCreateTextures(GL_TEXTURE_2D, 1, &texture);
+	glTextureStorage2D(texture, 1, GL_RGB8, 30, 30);
+	glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, texture, 0);
+	SUBTESTCONDITION(check_fbo_status(fbo, GL_FRAMEBUFFER,
+			 GL_FRAMEBUFFER_COMPLETE), pass, "initialized fbo");
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	/* Default draw fbo */
+	SUBTESTCONDITION(check_fbo_status(0, GL_DRAW_FRAMEBUFFER,
+			 GL_FRAMEBUFFER_COMPLETE), pass, "default draw fbo");
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	/* Default read fbo */
+	SUBTESTCONDITION(check_fbo_status(0, GL_READ_FRAMEBUFFER,
+			 GL_FRAMEBUFFER_COMPLETE), pass, "default read fbo");
+	piglit_check_gl_error(GL_NO_ERROR);
+
+
+	/* The OpenGL 4.5 core spec (02.02.2015, PDF page 336) says: "If
+	 * CheckFramebufferStatus generates an error, zero is returned."
+	 */
+
+	/* Good fbo, bad target */
+	SUBTESTCONDITION(check_fbo_status(fbo, GL_NONE, 0), pass,
+			 "target error returns 0");
+	SUBTEST(GL_INVALID_ENUM, pass, "good fbo, bad target");
+
+	/* Non-genned fbo name */
+	SUBTESTCONDITION(check_fbo_status(1337, GL_FRAMEBUFFER, 0), pass,
+			 "name error returns 0");
+	SUBTEST(GL_INVALID_OPERATION, pass, "fbo with bad name");
+
+
+	glDeleteTextures(1, &texture);
+	glDeleteFramebuffers(1, &fbo);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
2.1.0



More information about the Piglit mailing list