From: Bruce Merry <bme...@gmail.com> Cc: Brian Paul <bri...@vmware.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73096 ---
I came across this test when cleaning up bugzilla. Seems we fixed Mesa but never pushed the piglit test. tests/all.py | 1 + tests/spec/ext_packed_float/CMakeLists.gl.txt | 1 + .../query-rgba-signed-components.c | 167 ++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 tests/spec/ext_packed_float/query-rgba-signed-components.c diff --git a/tests/all.py b/tests/all.py index 26638cd82..db85f172e 100644 --- a/tests/all.py +++ b/tests/all.py @@ -3331,6 +3331,7 @@ with profile.test_list.group_manager( PiglitGLTest, grouptools.join('spec', 'ext_packed_float')) as g: g(['ext_packed_float-pack'], 'pack') + g(['query-rgba-signed-components'], 'query-rgba-signed-components') g(['getteximage-invalid-format-for-packed-type'], 'getteximage-invalid-format-for-packed-type') add_msaa_formats_tests(g, 'GL_EXT_packed_float') diff --git a/tests/spec/ext_packed_float/CMakeLists.gl.txt b/tests/spec/ext_packed_float/CMakeLists.gl.txt index 44a8818c8..b061cb6b2 100644 --- a/tests/spec/ext_packed_float/CMakeLists.gl.txt +++ b/tests/spec/ext_packed_float/CMakeLists.gl.txt @@ -10,5 +10,6 @@ link_libraries ( piglit_add_executable (ext_packed_float-pack pack.c) piglit_add_executable (getteximage-invalid-format-for-packed-type getteximage-invalid-format-for-packed-type.c) +piglit_add_executable (query-rgba-signed-components query-rgba-signed-components.c) # vim: ft=cmake: diff --git a/tests/spec/ext_packed_float/query-rgba-signed-components.c b/tests/spec/ext_packed_float/query-rgba-signed-components.c new file mode 100644 index 000000000..635d5bc5a --- /dev/null +++ b/tests/spec/ext_packed_float/query-rgba-signed-components.c @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2013 Bruce Merry + * + * 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 + * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COYPRIGTH + * HOLDERS AND/OR THEIR SUPPLIERS 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. + */ + +#include "piglit-util-gl.h" + +#define MAKE_FORMAT_STR(x) x, #x + +typedef struct { + GLenum format; + const char *format_str; + const char *extension; + int expected[4]; + int buffer; /* Draw buffer to attach the renderbuffer to */ +} format_info; + +static const format_info formats[] = { + { MAKE_FORMAT_STR(GL_RGBA8), NULL, { 0, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_R8I), "GL_ARB_texture_rg", { 1, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_RG8I), "GL_ARB_texture_rg", { 1, 1, 0, 0 } }, + { MAKE_FORMAT_STR(GL_R8_SNORM), "GL_EXT_texture_snorm", { 1, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_LUMINANCE8_SNORM), "GL_EXT_texture_snorm", { 1, 1, 1, 0 } }, + { MAKE_FORMAT_STR(GL_RGBA8UI_EXT), "GL_EXT_texture_integer", { 0, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_RGBA16F_ARB), "GL_ARB_texture_float", { 1, 1, 1, 1 } }, + { MAKE_FORMAT_STR(GL_LUMINANCE16F_ARB), "GL_ARB_texture_float", { 1, 1, 1, 0 } }, + { MAKE_FORMAT_STR(GL_RGB9_E5_EXT), "GL_EXT_texture_shared_exponent", { 0, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_R11F_G11F_B10F_EXT), "GL_EXT_packed_float", { 0, 0, 0, 0 } }, + { MAKE_FORMAT_STR(GL_RGBA16F_ARB), "GL_ARB_texture_float", { 0, 0, 0, 0 }, 1 } +}; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + + config.window_visual = PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + /* Should never be reached */ + return PIGLIT_FAIL; +} + +/* Queries GL_RGBA_SIGNED_COMPONENTS_EXT and compares to expected. + * If they do not match, prints an error. Returns true on match. + */ +static bool check_rgba_signed(const int *expected) +{ + int i; + /* Start with nonsense values, to ensure they are written */ + GLint actual[4] = {2, 2, 2, 2}; + + glGetIntegerv(GL_RGBA_SIGNED_COMPONENTS_EXT, actual); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + return false; + } + + for (i = 0; i < 4; i++) { + if (expected[i] != actual[i]) { + printf("Expected: (%d, %d, %d, %d)\n", + expected[0], + expected[1], + expected[2], + expected[3]); + printf("Actual: (%d, %d, %d, %d)\n", + actual[0], + actual[1], + actual[2], + actual[3]); + return false; + } + } + return true; +} + +static bool test_format(const format_info *f) +{ + GLuint rbo = 0; + bool pass = true; + + if (f->extension != NULL + && !piglit_is_extension_supported(f->extension)) { + printf("Skipping %s since %s not present\n", + f->format_str, f->extension); + return pass; + } + + glGenRenderbuffers(1, &rbo); + glBindRenderbuffer(GL_RENDERBUFFER, rbo); + glRenderbufferStorage( + GL_RENDERBUFFER, + f->format, 16, 16); + glFramebufferRenderbuffer( + GL_DRAW_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0 + f->buffer, + GL_RENDERBUFFER, rbo); + if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) + != GL_FRAMEBUFFER_COMPLETE) { + printf("Skipping %s: framebuffer not complete\n", + f->format_str); + } else { + printf("Testing %s\n", f->format_str); + if (!check_rgba_signed(f->expected)) + pass = false; + } + + glFramebufferRenderbuffer( + GL_DRAW_FRAMEBUFFER, + GL_COLOR_ATTACHMENT0 + f->buffer, + GL_RENDERBUFFER, 0); + glDeleteRenderbuffers(1, &rbo); + return pass; +} + +void +piglit_init(int argc, char **argv) +{ + int expected[4] = {0, 0, 0, 0}; + bool pass = true; + unsigned int i; + const GLenum buffers[2] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; + + piglit_require_extension("GL_EXT_packed_float"); + + /* With a normal window, all channels should be unsigned */ + printf("Testing window\n"); + if (!check_rgba_signed(expected)) + pass = false; + + if (piglit_is_extension_supported("GL_ARB_framebuffer_object")) { + GLuint fbo = 0; + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); + glDrawBuffers(2, buffers); + /* Test a variety of FBO formats */ + for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) { + pass = test_format(formats + i) && pass; + } + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fbo); + } + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} -- 2.17.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit