This tests that a restored SSO doesn't fail validation once restored. This was happening in Mesa because we weren't storing the state of the program parameter PROGRAM_SEPARABLE. --- tests/opengl.py | 2 + .../arb_get_program_binary/CMakeLists.gl.txt | 2 + .../spec/arb_get_program_binary/gpb-common.c | 39 ++++++++ .../spec/arb_get_program_binary/gpb-common.h | 3 + .../restore-sso-program.c | 94 +++++++++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 tests/spec/arb_get_program_binary/restore-sso-program.c
diff --git a/tests/opengl.py b/tests/opengl.py index 6dd27e9d4..adf5a5312 100644 --- a/tests/opengl.py +++ b/tests/opengl.py @@ -1715,6 +1715,8 @@ with profile.test_list.group_manager( 'xfb-varyings') g(['arb_get_program_binary-restore-implicit-use-program'], 'restore-implicit-use-program') + g(['arb_get_program_binary-restore-sso-program'], + 'restore-sso-program') g(['arb_get_program_binary-reset-uniform'], 'reset-uniform') diff --git a/tests/spec/arb_get_program_binary/CMakeLists.gl.txt b/tests/spec/arb_get_program_binary/CMakeLists.gl.txt index ea43ba9ae..3ef48dbe0 100644 --- a/tests/spec/arb_get_program_binary/CMakeLists.gl.txt +++ b/tests/spec/arb_get_program_binary/CMakeLists.gl.txt @@ -14,6 +14,8 @@ piglit_add_executable (arb_get_program_binary-retrievable_hint retrievable_hint. piglit_add_executable (arb_get_program_binary-reset-uniform reset-uniform.c gpb-common.c) piglit_add_executable (arb_get_program_binary-restore-implicit-use-program restore-implicit-use-program.c gpb-common.c) +piglit_add_executable (arb_get_program_binary-restore-sso-program + restore-sso-program.c gpb-common.c) piglit_add_executable (arb_get_program_binary-xfb-varyings xfb-varyings.c gpb-common.c) # vim: ft=cmake: diff --git a/tests/spec/arb_get_program_binary/gpb-common.c b/tests/spec/arb_get_program_binary/gpb-common.c index 425b93673..438e4992d 100644 --- a/tests/spec/arb_get_program_binary/gpb-common.c +++ b/tests/spec/arb_get_program_binary/gpb-common.c @@ -127,3 +127,42 @@ gpb_save_restore(GLuint *prog) return true; } + +bool +gpb_save_restore_sso(GLuint *prog, GLuint pipeline, GLbitfield stage) +{ + GLsizei bin_length; + void *binary; + GLenum bin_format; + GLuint new_prog; + + if (!gpb_save_program(*prog, &binary, &bin_length, &bin_format)) { + fprintf(stderr, + "failed to save program with GetProgramBinary\n"); + piglit_report_result(PIGLIT_FAIL); + } + + new_prog = glCreateProgram(); + if (!piglit_check_gl_error(GL_NO_ERROR)) { + free(binary); + piglit_report_result(PIGLIT_FAIL); + } + + if (!gpb_restore_program(new_prog, binary, bin_length, bin_format)) { + free(binary); + fprintf(stderr, "failed to restore binary program\n"); + piglit_report_result(PIGLIT_FAIL); + } + free(binary); + + glUseProgramStages(pipeline, stage, new_prog); + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + glDeleteProgram(*prog); + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + *prog = new_prog; + + return true; +} diff --git a/tests/spec/arb_get_program_binary/gpb-common.h b/tests/spec/arb_get_program_binary/gpb-common.h index f471241aa..ae10f9e3a 100644 --- a/tests/spec/arb_get_program_binary/gpb-common.h +++ b/tests/spec/arb_get_program_binary/gpb-common.h @@ -34,4 +34,7 @@ gpb_restore_program(GLuint prog, void *binary, GLsizei length, GLenum format); bool gpb_save_restore(GLuint *prog); +bool +gpb_save_restore_sso(GLuint *prog, GLuint pipeline, GLbitfield stage); + #endif diff --git a/tests/spec/arb_get_program_binary/restore-sso-program.c b/tests/spec/arb_get_program_binary/restore-sso-program.c new file mode 100644 index 000000000..23d9998c1 --- /dev/null +++ b/tests/spec/arb_get_program_binary/restore-sso-program.c @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019 Timothy Arceri + * + * 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. + */ + +/** + * Verify that a binary program that was originally linked with the + * GL_PROGRAM_SEPARABLE parameter set does not trigger GL pipeline validation + * errors when calling UseProgramStages(). In other word this test makes sure + * we store/restore the state of the program parameter GL_PROGRAM_SEPARABLE. + */ + +#include "piglit-util-gl.h" +#include "gpb-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_RGB; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + +PIGLIT_GL_TEST_CONFIG_END + +void +piglit_init(int argc, char **argv) +{ + GLuint vs_prog, fs_prog; + GLint ok; + static GLuint pipeline; + + static const char *vs_code = + "void main()\n" + "{\n" + " gl_Position = gl_Vertex;\n" + "}\n"; + static const char *fs_code = + "#version 120\n" + "uniform vec4 color = vec4(0.0, 1.0, 0.0, 1.0);\n" + "\n" + "void main()\n" + "{\n" + " gl_FragColor = color;\n" + "}\n"; + + piglit_require_extension("GL_ARB_get_program_binary"); + piglit_require_extension("GL_ARB_separate_shader_objects"); + + vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1, &vs_code); + piglit_link_check_status(vs_prog); + + fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &fs_code); + piglit_link_check_status(fs_prog); + + + glGenProgramPipelines(1, &pipeline); + glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog); + glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog); + piglit_program_pipeline_check_status(pipeline); + + gpb_save_restore_sso(&vs_prog, pipeline, GL_VERTEX_SHADER_BIT); + gpb_save_restore_sso(&fs_prog, pipeline, GL_FRAGMENT_SHADER_BIT); + + glValidateProgramPipeline(pipeline); + glGetProgramPipelineiv(pipeline, GL_VALIDATE_STATUS, &ok); + + if (!ok) + piglit_report_result(PIGLIT_FAIL); + + piglit_report_result(PIGLIT_PASS); +} + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} -- 2.21.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit