summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2013-10-07 17:15:50 -0700
committerFrancisco Jerez <currojerez@riseup.net>2013-10-07 18:16:03 -0700
commit48a32ecb67bb0690f9d23cf2c3fee8f8de588dff (patch)
treed035273b77c4abf529e029818dcd011ec65f2db6
parent6250689e96c03e9c8675baa2ef80c34fa3e31bd8 (diff)
arb_shader_atomic_counters: Test that atomic ops aren't executed for discarded fragments.
-rw-r--r--tests/all.tests1
-rw-r--r--tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_shader_atomic_counters/fragment-discard.c113
3 files changed, 115 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests
index 91d4e6fbc..4aba9331f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -3174,6 +3174,7 @@ arb_shader_atomic_counters['active-counters'] = concurrent_test('arb_shader_atom
arb_shader_atomic_counters['array-indexing'] = concurrent_test('arb_shader_atomic_counters-array-indexing')
arb_shader_atomic_counters['buffer-binding'] = concurrent_test('arb_shader_atomic_counters-buffer-binding')
arb_shader_atomic_counters['default-partition'] = concurrent_test('arb_shader_atomic_counters-default-partition')
+arb_shader_atomic_counters['fragment-discard'] = concurrent_test('arb_shader_atomic_counters-fragment-discard')
profile.tests['hiz'] = hiz
profile.tests['fast_color_clear'] = fast_color_clear
diff --git a/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt b/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt
index f9479de74..5526fbfaf 100644
--- a/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_atomic_counters/CMakeLists.gl.txt
@@ -14,5 +14,6 @@ add_executable (arb_shader_atomic_counters-active-counters active-counters.c com
add_executable (arb_shader_atomic_counters-array-indexing array-indexing.c common.c)
add_executable (arb_shader_atomic_counters-buffer-binding buffer-binding.c common.c)
add_executable (arb_shader_atomic_counters-default-partition default-partition.c common.c)
+add_executable (arb_shader_atomic_counters-fragment-discard fragment-discard.c common.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_shader_atomic_counters/fragment-discard.c b/tests/spec/arb_shader_atomic_counters/fragment-discard.c
new file mode 100644
index 000000000..e3b75cd32
--- /dev/null
+++ b/tests/spec/arb_shader_atomic_counters/fragment-discard.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 2013 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 fragment-discard.c
+ *
+ * Check that atomic counter operations from discarded fragments have
+ * no effect.
+ */
+
+#include "common.h"
+
+#define L 256
+#define N (L * L)
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_core_version = 31;
+
+ config.window_width = L;
+ config.window_height = L;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool
+run_test(void)
+{
+ const char *fs_source = "#version 140\n"
+ "#extension GL_ARB_shader_atomic_counters : enable\n"
+ "\n"
+ "layout(binding = 0, offset = 0) uniform atomic_uint x;\n"
+ "layout(binding = 0, offset = 4) uniform atomic_uint y;\n"
+ "out ivec4 fcolor;\n"
+ "\n"
+ "void main() {\n"
+ " if ((atomicCounterIncrement(x) & 0x3u) == 0u)\n"
+ " discard;\n"
+ "\n"
+ " fcolor.x = int(atomicCounterIncrement(y));\n"
+ "}\n";
+ const char *vs_source = "#version 140\n"
+ "in vec4 piglit_vertex;\n"
+ "\n"
+ "void main() {\n"
+ " gl_Position = piglit_vertex;\n"
+ "}\n";
+ const uint32_t start_value[] = { 0, 0 };
+ const uint32_t expected_value[] = { N, N * 3/4 };
+ GLuint prog = glCreateProgram();
+ bool ret = atomic_counters_compile(prog, GL_FRAGMENT_SHADER, fs_source) &&
+ atomic_counters_compile(prog, GL_VERTEX_SHADER, vs_source) &&
+ atomic_counters_draw_rect(prog, 2, start_value) &&
+ atomic_counters_probe_buffer(0, 2, expected_value);
+
+ glDeleteProgram(prog);
+ return ret;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint fb, rb, buffer;
+
+ piglit_require_gl_version(31);
+ piglit_require_extension("GL_ARB_shader_atomic_counters");
+
+ glGenFramebuffers(1, &fb);
+ glGenRenderbuffers(1, &rb);
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+ glBindRenderbuffer(GL_RENDERBUFFER, rb);
+
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_R32UI, L, L);
+ glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_RENDERBUFFER, rb);
+
+ glGenBuffers(1, &buffer);
+ glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, buffer);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ enum piglit_result status = PIGLIT_PASS;
+
+ atomic_counters_subtest(&status, GL_FRAGMENT_SHADER,
+ "Fragment discard",
+ run_test);
+
+ piglit_report_result(status);
+ return status;
+}