All other tests except invalid_enum_check pass on Nvidia binary driver (version 346.35).
Signed-off-by: Tapani Pälli <[email protected]> --- tests/all.py | 1 + .../CMakeLists.gl.txt | 1 + tests/spec/arb_framebuffer_no_attachments/params.c | 297 +++++++++++++++++++++ 3 files changed, 299 insertions(+) create mode 100755 tests/spec/arb_framebuffer_no_attachments/params.c diff --git a/tests/all.py b/tests/all.py index 18124b7..018b37d 100755 --- a/tests/all.py +++ b/tests/all.py @@ -2295,6 +2295,7 @@ with profile.group_manager( PiglitGLTest, grouptools.join('spec', 'ARB_framebuffer_no_attachments')) as g: g(['arb_framebuffer_no_attachments-minmax'], run_concurrent=False) + g(['arb_framebuffer_no_attachments-params'], run_concurrent=False) # Group ARB_explicit_uniform_location with profile.group_manager( diff --git a/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt index 894b95e..53aba8c 100755 --- a/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt +++ b/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt @@ -10,3 +10,4 @@ link_libraries ( ) piglit_add_executable (arb_framebuffer_no_attachments-minmax minmax.c) +piglit_add_executable (arb_framebuffer_no_attachments-params params.c) diff --git a/tests/spec/arb_framebuffer_no_attachments/params.c b/tests/spec/arb_framebuffer_no_attachments/params.c new file mode 100755 index 0000000..79ae668 --- /dev/null +++ b/tests/spec/arb_framebuffer_no_attachments/params.c @@ -0,0 +1,297 @@ +/* + * 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 params.c + * + * Test for set and get functions of framebuffer parameters defined by the + * GL_ARB_framebuffer_no_attachments specification. + * + * There is interaction with following extensions: + * - EXT_texture_array + * - EXT_direct_state_access + */ + +#include "piglit-util-gl.h" + +struct test_t { + GLenum param; + GLint default_value; + GLint value; + GLint max_value; + const char *extension; +} tests[] = { + { GL_FRAMEBUFFER_DEFAULT_WIDTH, + 0, 0, GL_MAX_FRAMEBUFFER_WIDTH, NULL }, + { GL_FRAMEBUFFER_DEFAULT_HEIGHT, + 0, 0, GL_MAX_FRAMEBUFFER_HEIGHT, NULL }, + { GL_FRAMEBUFFER_DEFAULT_LAYERS, + 0, 0, GL_MAX_FRAMEBUFFER_LAYERS, "EXT_texture_array" }, + { GL_FRAMEBUFFER_DEFAULT_SAMPLES, + 0, 0, GL_MAX_FRAMEBUFFER_SAMPLES, NULL }, + { GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, + 0, 0, 0, NULL } +}; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 20; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +static bool +set_value(GLenum par, GLint val, GLenum target, GLenum error, GLuint fbo) +{ + if (fbo) + glNamedFramebufferParameteriEXT(fbo, par, val); + else + glFramebufferParameteri(target, par, val); + if (!piglit_check_gl_error(error)) + return false; + return true; +} + +static bool +get_value(GLenum par, GLint *val, GLenum target, GLenum error, GLuint fbo) +{ + if (fbo) + glGetNamedFramebufferParameterivEXT(fbo, par, val); + else + glGetFramebufferParameteriv(target, par, val); + if (!piglit_check_gl_error(error)) + return false; + return true; +} + +static bool +test_values(struct test_t *test, GLenum target, GLuint fbo) +{ + GLint max = -1; + GLint value; + + /* If has a max value, do range test. */ + if (test->max_value != 0) + glGetIntegerv(test->max_value, &max); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + return false; + + /* If parameter has no max, it is a boolean type. */ + if (max == -1) { + if (!set_value(test->param, GL_TRUE, target, GL_NO_ERROR, fbo)) + return false; + + if (!get_value(test->param, &value, target, GL_NO_ERROR, fbo)) + return false; + + if (value != GL_TRUE) + return false; + return true; + } + + /* Parameter has a max, test that values max + 1 and -1 give error */ + if (!set_value(test->param, max + 1, target, GL_INVALID_VALUE, fbo)) + return false; + if (!set_value(test->param, -1, target, GL_INVALID_VALUE, fbo)) + return false; + + /* Valid value (max - 1) for set and get. */ + if (!set_value(test->param, max - 1, target, GL_NO_ERROR, fbo)) + return false; + if (!get_value(test->param, &value, target, GL_NO_ERROR, fbo)) + return false; + + if (value != max - 1) + return false; + + return true; +} + +static bool +invalid_enum_check() +{ + bool pass = true; + GLint value; + + /* Test invalid enums for functions. */ + if (!set_value(GL_NO_ERROR, 0, GL_FRAMEBUFFER, GL_INVALID_ENUM, 0)) + pass = false; + if (!get_value(GL_NO_ERROR, &value, GL_FRAMEBUFFER, GL_INVALID_ENUM, 0)) + pass = false; + + if (!piglit_is_extension_supported("GL_ARB_direct_state_access")) + return pass; + + /* Test INVALID_VALUE error when fbo given does not exist. */ + if (!set_value(GL_FRAMEBUFFER_DEFAULT_WIDTH, 42, GL_FRAMEBUFFER, + GL_INVALID_VALUE, 666)) + pass = false; + if (!get_value(GL_FRAMEBUFFER_DEFAULT_WIDTH, &value, GL_FRAMEBUFFER, + GL_INVALID_VALUE, 666)) + pass = false; + + piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, + "invalid enums"); + + return pass; +} + +static bool +dsa_subtest(GLuint fbo) +{ + unsigned i; + bool pass = true; + + if (!piglit_is_extension_supported("GL_ARB_direct_state_access")) + piglit_report_subtest_result(PIGLIT_SKIP, "dsa"); + + for (i = 0; i < sizeof(tests)/sizeof(struct test_t); i++) { + /* If extension required, see that it is supported. */ + if (tests[i].extension && + !piglit_is_extension_supported(tests[i].extension)) + continue; + + pass = pass && test_values(&tests[i], GL_DRAW_FRAMEBUFFER, fbo); + pass = pass && test_values(&tests[i], GL_READ_FRAMEBUFFER, fbo); + pass = pass && test_values(&tests[i], GL_FRAMEBUFFER, fbo); + } + + piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, "dsa"); + return pass; +} + + +static bool +default_fbo_errors() +{ + bool pass = true; + unsigned i; + GLint value; + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + /* Error cases with default fbo. */ + for (i = 0; i < sizeof(tests)/sizeof(struct test_t); i++) { + /* If extension required, see that it is supported. */ + if (tests[i].extension && + !piglit_is_extension_supported(tests[i].extension)) + continue; + if (!set_value(tests[i].param, tests[i].default_value, GL_FRAMEBUFFER, + GL_INVALID_OPERATION, 0)) + pass = false; + if (!get_value(tests[i].param, &value, GL_FRAMEBUFFER, + GL_INVALID_OPERATION, 0)) + pass = false; + } + piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, + "default fbo bound"); + return pass; +} + +/* Idea copied from arb_direct_state_access/dsa-utils.h */ +#define SUBTEST(subtest, global, ...) \ +do { \ + piglit_report_subtest_result(subtest ? PIGLIT_PASS : PIGLIT_FAIL, \ + __VA_ARGS__); \ + global = global && subtest; \ + subtest = true; \ +} while (0) + +void +piglit_init(int argc, char **argv) +{ + GLuint fbo, i; + bool pass = true; + bool sub = true; + + if (piglit_get_gl_version() < 30 || + !piglit_is_extension_supported("GL_ARB_framebuffer_object")) + piglit_report_result(PIGLIT_SKIP); + + piglit_require_extension("GL_ARB_framebuffer_no_attachments"); + + pass = default_fbo_errors(); + + /* Create fbo with no attachments. */ + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + /* Check that fbo is marked initially not complete. */ + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == + GL_FRAMEBUFFER_COMPLETE) + sub = false; + + SUBTEST(sub, pass, "initially incomplete"); + + pass = pass && invalid_enum_check(); + + /* Verify initial values. */ + for (i = 0; i < sizeof(tests)/sizeof(struct test_t); i++) { + /* If extension required, see that it is supported. */ + if (tests[i].extension && + !piglit_is_extension_supported(tests[i].extension)) + continue; + + glGetFramebufferParameteriv(GL_FRAMEBUFFER, tests[i].param, + &tests[i].value); + if (tests[i].value != tests[i].default_value) + sub = false; + } + + SUBTEST(sub, pass, "default values"); + + /* Check that there are no errors. */ + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + /* Set some values and verify them (for bound fbo). */ + for (i = 0; i < sizeof(tests)/sizeof(struct test_t); i++) { + /* If extension required, see that it is supported. */ + if (tests[i].extension && + !piglit_is_extension_supported(tests[i].extension)) + continue; + + sub = sub && test_values(&tests[i], GL_DRAW_FRAMEBUFFER, 0); + sub = sub && test_values(&tests[i], GL_READ_FRAMEBUFFER, 0); + sub = sub && test_values(&tests[i], GL_FRAMEBUFFER, 0); + } + + SUBTEST(sub, pass, "value setting"); + + /* Check that fbo is marked complete now. */ + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != + GL_FRAMEBUFFER_COMPLETE) + sub = false; + + SUBTEST(sub, pass, "fbo complete"); + + pass = pass && dsa_subtest(fbo); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + -- 2.1.0 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
