summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2015-02-05 15:50:52 -0800
committerLaura Ekstrand <laura@jlekstrand.net>2015-03-09 16:20:45 -0700
commit7242c8dc133ee4c214d4a2d41ca73184138fe435 (patch)
treea115307e6e868ad3e424b0d732daf1dd010cb5c4
parent31c7c5607a912764542df0cefe42c9eb4e21f7d7 (diff)
arb_direct_state_access: Testing glClearNamedFramebuffer*.
-rw-r--r--tests/all.py1
-rw-r--r--tests/spec/arb_direct_state_access/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_direct_state_access/clearnamedframebuffer.c115
3 files changed, 117 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index 904583c7a..1dd2a2693 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4246,6 +4246,7 @@ with profile.group_manager(
g(['arb_direct_state_access-checkfbstatus-errors'], 'checkfbstatus-errors')
g(['arb_direct_state_access-fbattachmentparam-errors'], 'fbattachmentparam-errors')
g(['arb_direct_state_access-invalidateframebuffer'], 'invalidateframebuffer')
+ g(['arb_direct_state_access-clearnamedframebuffer'], 'clearnamedframebuffer')
with profile.group_manager(
PiglitGLTest,
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index 406c3c128..847c5fcac 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 000000000..25d705ea1
--- /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;
+}
+