diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2015-02-06 14:23:19 -0800 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2015-03-09 16:20:45 -0700 |
commit | 88e4f1bf789f7c4da71c2f5354847855f748c2a3 (patch) | |
tree | ec07c83f7d7f0b83d962cebaebd1bbcba07b5b85 | |
parent | 7242c8dc133ee4c214d4a2d41ca73184138fe435 (diff) |
arb_direct_state_access: Add test for glDrawBuffer/glReadBuffer.
This lays the groundwork for testing NamedFramebufferDrawBuffer,
NamedFramebufferDrawBuffers, and NamedFramebufferReadBuffer.
-rw-r--r-- | tests/all.py | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/drawbuffers.c | 110 |
3 files changed, 112 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 1dd2a2693..2779c175f 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4247,6 +4247,7 @@ with profile.group_manager( g(['arb_direct_state_access-fbattachmentparam-errors'], 'fbattachmentparam-errors') g(['arb_direct_state_access-invalidateframebuffer'], 'invalidateframebuffer') g(['arb_direct_state_access-clearnamedframebuffer'], 'clearnamedframebuffer') + g(['arb_direct_state_access-drawbuffers'], 'drawbuffers') 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 847c5fcac..72900c8ac 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -31,6 +31,7 @@ piglit_add_executable (arb_direct_state_access-checkfbstatus-errors checkfbstatu 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-drawbuffers drawbuffers.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/drawbuffers.c b/tests/spec/arb_direct_state_access/drawbuffers.c new file mode 100644 index 000000000..6e7ecf555 --- /dev/null +++ b/tests/spec/arb_direct_state_access/drawbuffers.c @@ -0,0 +1,110 @@ +/* + * 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 drawbuffers.c + * + * Tests explicitly setting the read and draw framebuffers. + * + * Somewhat inspired by tests/general/read-front.c. + */ + +#include "piglit-util-gl.h" +#include "dsa-utils.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | + PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +static bool pass = true; + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_direct_state_access"); +} + +static GLuint fbo; + +static void +clear_to_color(float color[4], int att) +{ + glClearColor(color[0], color[1], color[2], color[3]); + glDrawBuffer(GL_COLOR_ATTACHMENT0 + att); + glClear(GL_COLOR_BUFFER_BIT); +} + +static void +clear_subtest(float color[4], int att, const char *test_name) +{ + glReadBuffer(GL_COLOR_ATTACHMENT0 + att); + piglit_check_gl_error(GL_NO_ERROR); + SUBTESTCONDITION(piglit_probe_rect_rgb(0, 0, piglit_width, + piglit_height, color), pass, test_name); +} + +enum piglit_result +piglit_display(void) +{ + float red[] = {1.0, 0.0, 0.0, 0.0}; + float green[] = {0.0, 1.0, 0.0, 0.0}; + float blue[] = {0.0, 0.0, 1.0, 0.0}; + GLuint textures[3]; + int i; + + /* Make a custom framebuffer with three color attachments */ + glCreateFramebuffers(1, &fbo); + glCreateTextures(GL_TEXTURE_2D, 3, textures); + for (i = 0; i < 3; ++i) { + glTextureStorage2D(textures[i], 1, GL_RGBA8, + piglit_width, piglit_height); + glNamedFramebufferTexture(fbo, GL_COLOR_ATTACHMENT0 + i, + textures[i], 0); + } + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); + glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); + piglit_check_gl_error(GL_NO_ERROR); + + /* The clearing steps and the testing steps are separate and in a + * different order to make sure that GL_COLOR_ATTACHMENT0 + att is + * selecting the correct attachment. + */ + clear_to_color(green, 1); + clear_to_color(blue, 2); + clear_to_color(red, 0); + + clear_subtest(blue, 2, "Clear 2 to blue"); + clear_subtest(red, 0, "Clear 0 to red"); + clear_subtest(green, 1, "Clear 1 to green"); + + + glDeleteTextures(3, textures); + glDeleteFramebuffers(1, &fbo); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} |