From d45dee6924d4174cef4c54120a061fd76ccfb05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Thu, 21 Jan 2016 08:37:38 +0200 Subject: [PATCH] test for bug #93796 --- .../arb_shader_atomic_counters/CMakeLists.gl.txt | 1 + tests/spec/arb_shader_atomic_counters/simple.c | 101 +++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 tests/spec/arb_shader_atomic_counters/simple.c diff --git a/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt b/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt index 40ea057..be55c1b 100644 --- a/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt +++ b/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt @@ -22,5 +22,6 @@ piglit_add_executable (arb_shader_atomic_counters-semantics semantics.c common.c piglit_add_executable (arb_shader_atomic_counters-unique-id unique-id.c common.c) piglit_add_executable (arb_shader_atomic_counters-unused-result unused-result.c common.c) piglit_add_executable (arb_shader_atomic_counters-respecify-buffer respecify-buffer.c) +piglit_add_executable (arb_shader_atomic_counters-simple simple.c common.c) # vim: ft=cmake: diff --git a/tests/spec/arb_shader_atomic_counters/simple.c b/tests/spec/arb_shader_atomic_counters/simple.c new file mode 100644 index 0000000..f3d65c6 --- /dev/null +++ b/tests/spec/arb_shader_atomic_counters/simple.c @@ -0,0 +1,101 @@ +/* + * Copyright © 2016 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 simple.c + */ + +#include "common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_core_version = 31; + + config.window_width = 1; + config.window_height = 1; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +const char *fs_source = "#version 150\n" +"#extension GL_ARB_shader_atomic_counters : require\n" +"out vec4 fragColor;\n" +"layout(binding=0, offset=0) uniform atomic_uint ac;\n" +"layout(binding=1, offset=0) uniform atomic_uint ac2;\n" +"void main()\n" +"{\n" +" float counter = float(atomicCounterIncrement(ac));\n" +" float counter2 = float(atomicCounterIncrement(ac2));\n" +" float r = (counter/ 255.f) / 255.f;\n" +" float b = (counter2/ 255.f) / 255.f;\n" +" fragColor = vec4(r, 0, b, 1);\n" +"}\n"; + +void +piglit_init(int argc, char **argv) +{ + GLuint prog = glCreateProgram(); + int i, j, n, ret; + + piglit_require_gl_version(31); + piglit_require_extension("GL_ARB_shader_atomic_counters"); + + if (!atomic_counters_compile(prog, GL_FRAGMENT_SHADER, fs_source)) { + fprintf(stderr, "Program failed to compile.\n"); + piglit_report_result(PIGLIT_FAIL); + } + + if (!atomic_counters_link(prog)) { + fprintf(stderr, "Program failed to link.\n"); + piglit_report_result(PIGLIT_FAIL); + } + + GLint binding, size, counters; + + glGetActiveAtomicCounterBufferiv(prog, 0, GL_ATOMIC_COUNTER_BUFFER_BINDING, &binding); + fprintf(stderr, "binding 0: %d\n", binding); + + glGetActiveAtomicCounterBufferiv(prog, 1, GL_ATOMIC_COUNTER_BUFFER_BINDING, &binding); + fprintf(stderr, "binding 1: %d\n", binding); + + glGetActiveAtomicCounterBufferiv(prog, 0, GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE, &size); + fprintf(stderr, "data size 0 : %d\n", size); + + glGetActiveAtomicCounterBufferiv(prog, 1, GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE, &size); + fprintf(stderr, "data size 1: %d\n", size); + + glGetActiveAtomicCounterBufferiv(prog, 0, GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS, &counters); + fprintf(stderr, "counters 0: %d\n", counters); + + glGetActiveAtomicCounterBufferiv(prog, 1, GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS, &counters); + fprintf(stderr, "counters 1: %d\n", counters); + + glDeleteProgram(prog); + + piglit_report_result(PIGLIT_PASS); +} + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_PASS; +} -- 2.5.0