diff --git a/tests/all.py b/tests/all.py index f0a7c05..d1091ee 100644 --- a/tests/all.py +++ b/tests/all.py @@ -2614,6 +2614,7 @@ with profile.test_list.group_manager( g(['arb_texture_view-rendering-layers'], 'rendering-layers') g(['arb_texture_view-rendering-formats'], 'rendering-formats') g(['arb_texture_view-rendering-r32ui'], 'rendering-r32ui') + g(['arb_texture_view-clear-srgb'], 'clear-srgb') g(['arb_texture_view-lifetime-format'], 'lifetime-format') g(['arb_texture_view-getteximage-srgb'], 'getteximage-srgb') g(['arb_texture_view-texsubimage-levels'], 'texsubimage-levels') diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt index 39330da..946eef8 100644 --- a/tests/spec/arb_texture_view/CMakeLists.gl.txt +++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt @@ -24,6 +24,7 @@ piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c) piglit_add_executable(arb_texture_view-rendering-layers rendering_layers.c common.c) piglit_add_executable(arb_texture_view-rendering-levels rendering_levels.c common.c) piglit_add_executable(arb_texture_view-rendering-r32ui rendering-r32ui.c) +piglit_add_executable(arb_texture_view-clear-srgb clear-srgb.c) piglit_add_executable(arb_texture_view-rendering-target rendering_target.c common.c) piglit_add_executable(arb_texture_view-sampling-2d-array-as-2d-layer sampling-2d-array-as-2d-layer.c) piglit_add_executable(arb_texture_view-sampling-2d-array-as-cubemap-array sampling-2d-array-as-cubemap-array.c) diff --git a/tests/spec/arb_texture_view/clear-srgb.c b/tests/spec/arb_texture_view/clear-srgb.c new file mode 100644 index 0000000..38e6780 --- /dev/null +++ b/tests/spec/arb_texture_view/clear-srgb.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 Józef Kucia + * + * 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 clear-srgb.c + * Tests that sRGB clears work properly for texture views. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + +config.supports_gl_compat_version = 30; + +PIGLIT_GL_TEST_CONFIG_END + +#define TEX_SIZE 64 + +static const float color[4] = {0.2f, 0.3f, 0.6f, 0.2f}; +static const float srgb_color[4] = {0.48, 0.58, 0.79f, 0.2f}; + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + GLuint tex, view, framebuffer; + bool pass = true; + + piglit_require_gl_version(30); + piglit_require_extension("GL_ARB_texture_view"); + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, TEX_SIZE, TEX_SIZE); + + glGenTextures(1, &view); + glTextureView(view, GL_TEXTURE_2D, tex, GL_SRGB8_ALPHA8, 0, 1, 0, 1); + + glGenFramebuffers(1, &framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D, view, 0); + + glClearColor(color[0], color[1], color[2], color[3]); + glClear(GL_COLOR_BUFFER_BIT); + pass = piglit_probe_rect_rgba(0, 0, TEX_SIZE, TEX_SIZE, + color) && pass; + + glEnable(GL_FRAMEBUFFER_SRGB); + glClearColor(color[0], color[1], color[2], color[3]); + glClear(GL_COLOR_BUFFER_BIT); + pass = piglit_probe_rect_rgba(0, 0, TEX_SIZE, TEX_SIZE, + srgb_color) && pass; + + glDeleteTextures(1, &view); + glDeleteTextures(1, &tex); + glDeleteFramebuffers(1, &framebuffer); + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +}