diff options
-rw-r--r-- | tests/spec/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_shader_stencil_export/CMakeLists.gl.txt | 13 | ||||
-rw-r--r-- | tests/spec/arb_shader_stencil_export/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_shader_stencil_export/basic.c | 110 |
4 files changed, 125 insertions, 0 deletions
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 5dc37a10a..727728b7b 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -49,6 +49,7 @@ add_subdirectory (arb_shader_atomic_counters) add_subdirectory (arb_shader_objects) add_subdirectory (arb_shader_image_load_store) add_subdirectory (arb_shader_image_size) +add_subdirectory (arb_shader_stencil_export) add_subdirectory (arb_shading_language_420pack/execution) add_subdirectory (arb_stencil_texturing) add_subdirectory (arb_sync) diff --git a/tests/spec/arb_shader_stencil_export/CMakeLists.gl.txt b/tests/spec/arb_shader_stencil_export/CMakeLists.gl.txt new file mode 100644 index 000000000..48b7decf3 --- /dev/null +++ b/tests/spec/arb_shader_stencil_export/CMakeLists.gl.txt @@ -0,0 +1,13 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} +) + +piglit_add_executable (arb_shader_stencil_export basic.c) + +# vim: ft=cmake: diff --git a/tests/spec/arb_shader_stencil_export/CMakeLists.txt b/tests/spec/arb_shader_stencil_export/CMakeLists.txt new file mode 100644 index 000000000..144a306f4 --- /dev/null +++ b/tests/spec/arb_shader_stencil_export/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_shader_stencil_export/basic.c b/tests/spec/arb_shader_stencil_export/basic.c new file mode 100644 index 000000000..a1d6f1e4b --- /dev/null +++ b/tests/spec/arb_shader_stencil_export/basic.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. + * + */ + +#include "piglit-util-gl.h" + +#define width 32 +#define height 32 + +static const char *vs_text = + "#version 330 \n" + "layout(location = 0) in vec4 piglit_vertex; \n" + "void main() { \n" + " gl_Position = piglit_vertex; \n" + "}\n"; + +static const char *fs_stencil_output_text = + "#version 330 \n" + "#extension GL_ARB_shader_stencil_export : require \n" + "uniform int ref; \n" + "void main() \n" + "{ \n" + " gl_FragStencilRefARB = ref; \n" + "} \n"; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +static GLuint stc_prog; + +static void glReadStencil(uint8_t val) +{ + uint8_t data[width * height]; + + uint8_t expected_data[width * height]; + + memset(expected_data, val, sizeof(expected_data)); + + glReadPixels(0, 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, data); + + memcmp(data, expected_data, sizeof(expected_data)); +} + + +static void glWriteStencil(uint8_t val) +{ + + glUseProgram(stc_prog); + GLuint ref = glGetUniformLocation(stc_prog, "ref"); + glUniform1i(ref, val); + glEnable(GL_STENCIL_TEST); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_ALWAYS, 0, 0xff); + piglit_draw_rect(-1, -1, 2, 2); + glDisable(GL_STENCIL_TEST); +} + +enum piglit_result +piglit_display(void) +{ + glViewport(0, 0, width, height); + glClearStencil(0); + glClear(GL_STENCIL_BUFFER_BIT); + + glWriteStencil(5); + + glReadStencil(5); + + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + if (piglit_get_gl_version() < 33) + piglit_report_result(PIGLIT_SKIP); + + piglit_require_extension("GL_ARB_shader_stencil_export"); + stc_prog = piglit_build_simple_program(vs_text, fs_stencil_output_text); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + piglit_report_result(PIGLIT_PASS); +} |