[Piglit] [PATCH 10/15] arb_direct_state_access: Testing glClearNamedFramebuffer*.
Laura Ekstrand
laura at jlekstrand.net
Thu Mar 5 18:01:20 PST 2015
---
tests/all.py | 1 +
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +
.../clearnamedframebuffer.c | 115 +++++++++++++++++++++
3 files changed, 117 insertions(+)
create mode 100644 tests/spec/arb_direct_state_access/clearnamedframebuffer.c
diff --git a/tests/all.py b/tests/all.py
index d03f661..ffa5b2e 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4033,6 +4033,7 @@ spec['ARB_direct_state_access']['framebufferblit'] = PiglitGLTest(['arb_direct_s
spec['ARB_direct_state_access']['checkfbstatus-errors'] = PiglitGLTest(['arb_direct_state_access-checkfbstatus-errors'], run_concurrent=True)
spec['ARB_direct_state_access']['fbattachmentparam-errors'] = PiglitGLTest(['arb_direct_state_access-fbattachmentparam-errors'], run_concurrent=True)
spec['ARB_direct_state_access']['invalidateframebuffer'] = PiglitGLTest(['arb_direct_state_access-invalidateframebuffer'], run_concurrent=True)
+spec['ARB_direct_state_access']['clearnamedframebuffer'] = PiglitGLTest(['arb_direct_state_access-clearnamedframebuffer'], 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 3c09c21..f83dc01 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -30,6 +30,7 @@ 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-fbattachmentparam-errors fbattachmentparam-errors.c)
piglit_add_executable (arb_direct_state_access-invalidateframebuffer invalidateframebuffer.c)
+piglit_add_executable (arb_direct_state_access-clearnamedframebuffer clearnamedframebuffer.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/clearnamedframebuffer.c b/tests/spec/arb_direct_state_access/clearnamedframebuffer.c
new file mode 100644
index 0000000..25d705e
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/clearnamedframebuffer.c
@@ -0,0 +1,115 @@
+/*
+ * 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 clearnamedframebuffer.c
+ *
+ * Fairly trivial tests for glClearNamedFramebuffer* functions.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_core_version = 32;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA |
+ PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_require_extension("GL_ARB_direct_state_access");
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ GLint darkbrown[4] = {128, 102, 76, 255};
+ GLuint almostblack[4] = {128, 102, 76, 255};
+ GLfloat brown[4] = {0.5f, 0.4f, 0.3f, 1.0f};
+ GLfloat black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ GLfloat cyan[4] = {0.0f, 0.9f, 0.8f, 1.0f};
+ GLfloat clearcolor[4];
+ int i;
+ GLuint fbo, texture;
+
+ /* Non-generated names */
+ glClearNamedFramebufferiv(1337, GL_COLOR, 0, darkbrown);
+ SUBTEST(GL_INVALID_OPERATION, pass, "bad name: iv");
+
+ glClearNamedFramebufferuiv(1337, GL_COLOR, 0, almostblack);
+ SUBTEST(GL_INVALID_OPERATION, pass, "bad name: uiv");
+
+ glClearNamedFramebufferfv(1337, GL_COLOR, 0, brown);
+ SUBTEST(GL_INVALID_OPERATION, pass, "bad name: fv");
+
+ glClearNamedFramebufferfi(1337, GL_DEPTH_STENCIL, 1.0f, 25);
+ SUBTEST(GL_INVALID_OPERATION, pass, "bad name: fi");
+
+ /* Clear default framebuffer to brown. */
+ glClearNamedFramebufferfv(0, GL_COLOR, 0, brown);
+ SUBTESTCONDITION(piglit_probe_rect_rgba(0, 0, piglit_width,
+ piglit_height, brown), pass, "default fb clear");
+ piglit_present_results();
+
+ /* Check to see if clear color was modified. */
+ glGetFloatv(GL_COLOR_CLEAR_VALUE, clearcolor);
+ for (i = 0; i < 4; ++i) {
+ if (clearcolor[i] != black[i]) {
+ printf("glClearNamedFramebufferfv modified the clear"
+ " color. For i=%u, got %f, expected %f.\n",
+ i, clearcolor[i], black[i]);
+ pass = false;
+ }
+ }
+
+ /* Make a custom framebuffer and clear it to cyan. */
+ glCreateFramebuffers(1, &fbo);
+ glCreateTextures(GL_TEXTURE_2D, 1, &texture);
+ glTextureStorage2D(texture, 1, GL_RGBA8, piglit_width, piglit_height);
+ glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0, texture, 0);
+ piglit_check_gl_error(GL_NO_ERROR);
+ glClearNamedFramebufferfv(fbo, GL_COLOR, 0, cyan);
+ piglit_check_gl_error(GL_NO_ERROR);
+
+ /* Send the contents of fbo to the screen */
+ glBlitNamedFramebuffer(fbo, piglit_winsys_fbo,
+ 0, 0, piglit_width, piglit_height,
+ 0, 0, piglit_width, piglit_height,
+ GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ piglit_check_gl_error(GL_NO_ERROR);
+ SUBTESTCONDITION(piglit_probe_rect_rgba(0, 0, piglit_width,
+ piglit_height, cyan), pass, "clear and blit");
+ piglit_present_results();
+
+
+ glDeleteTextures(1, &texture);
+ glDeleteFramebuffers(1, &fbo);
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
--
2.1.0
More information about the Piglit
mailing list