[Piglit] [PATCH 6/7] ARB_pipeline_statistics_query (frag): basic test
Ben Widawsky
benjamin.widawsky at intel.com
Fri Feb 13 22:54:37 PST 2015
This patch was accidentally squashed into the clipper patch
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
tests/all.py | 1 +
.../spec/arb_pipeline_statistics/CMakeLists.gl.txt | 2 +
.../CMakeLists.gl.txt | 2 +
.../pipeline_stats_frag.c | 113 +++++++++++++++++++++
4 files changed, 118 insertions(+)
create mode 100644 tests/spec/arb_pipeline_statistics_query/pipeline_stats_frag.c
diff --git a/tests/all.py b/tests/all.py
index e7cdbed..4128287 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3770,6 +3770,7 @@ add_concurrent_test(arb_pipeline_statistics_query, ['arb_pipeline_statistics_que
add_concurrent_test(arb_pipeline_statistics_query, ['arb_pipeline_statistics_query-vert_adj'])
add_concurrent_test(arb_pipeline_statistics_query, ['arb_pipeline_statistics_query-clip'])
add_concurrent_test(arb_pipeline_statistics_query, ['arb_pipeline_statistics_query-geom'])
+add_concurrent_test(arb_pipeline_statistics_query, ['arb_pipeline_statistics_query-frag'])
# group glslparsertest ------------------------------------------------------
glslparsertest = {}
diff --git a/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
index efc8f7d..0c80a31 100644
--- a/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
+++ b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
@@ -24,5 +24,7 @@ piglit_add_executable (arb_pipeline_stats_geom pipeline_stats_geom.c)
target_link_libraries (arb_pipeline_stats_geom pipestat_help)
piglit_add_executable (arb_pipeline_stats_clip pipeline_stats_clip.c)
target_link_libraries (arb_pipeline_stats_clip pipestat_help)
+piglit_add_executable (arb_pipeline_stats_frag pipeline_stats_frag.c)
+target_link_libraries (arb_pipeline_stats_frag pipestat_help)
# vim: ft=cmake
diff --git a/tests/spec/arb_pipeline_statistics_query/CMakeLists.gl.txt b/tests/spec/arb_pipeline_statistics_query/CMakeLists.gl.txt
index f637f7d..d0128d1 100644
--- a/tests/spec/arb_pipeline_statistics_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_pipeline_statistics_query/CMakeLists.gl.txt
@@ -24,5 +24,7 @@ piglit_add_executable (arb_pipeline_statistics_query-clip pipeline_stats_clip.c)
target_link_libraries (arb_pipeline_statistics_query-clip pipestat_help)
piglit_add_executable (arb_pipeline_statistics_query-geom pipeline_stats_geom.c)
target_link_libraries (arb_pipeline_statistics_query-geom pipestat_help)
+piglit_add_executable (arb_pipeline_statistics_query-frag pipeline_stats_frag.c)
+target_link_libraries (arb_pipeline_statistics_query-frag pipestat_help)
# vim: ft=cmake
diff --git a/tests/spec/arb_pipeline_statistics_query/pipeline_stats_frag.c b/tests/spec/arb_pipeline_statistics_query/pipeline_stats_frag.c
new file mode 100644
index 0000000..1fa86f8
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics_query/pipeline_stats_frag.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 2014 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 pipeline_stats_frag.c
+ *
+ * This test verifies that the fragment shader related tokens of
+ * ARB_pipeline_statistics_query() work as expected. I believe these values
+ * are safe to use on all hardware but I am not certain. One again we get the
+ * beloved, "can't rely on values clause." For the most part this makes senes
+ * since implementations can very well process too many vertices - but the
+ * clause also allows too few. The former case is accounted for within this code.
+ *
+ * 15.2 (Another chicken clause)
+ * Implementations are allowed to skip the execution of certain fragment
+ * shader invocations, and to execute additional fragment shader invocations
+ * during programmable fragment processing due to implementation dependent
+ * reasons, including the execution of fragment shader invocations when there
+ * isn't an active program object present for the fragment shader stage, as
+ * long as the results of rendering otherwise remain unchanged.
+ *
+ * 15.3
+ * When BeginQuery is called with a target of FRAGMENT_SHADER_INVOCATIONS_ARB,
+ * the fragment shader invocations count maintained by the GL is set to zero.
+ * When a fragment shader invocations query is active, the counter is
+ * incremented every time the fragment shader is invoked (see section 15.2).
+ * The result of fragment shader queries may be implementation dependent due
+ * to reasons described in section 15.2.
+ */
+
+#include "piglit-util-gl.h"
+#include "pipestat_help.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+ config.supports_gl_compat_version = 30;
+ config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+ config.window_width = TEST_WIDTH;
+ config.window_width = TEST_HEIGHT;
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vs_src =
+ "#version 110 \n"
+ " \n"
+ "void main() \n"
+ "{ \n"
+ " gl_Position = gl_Vertex; \n"
+ "} \n";
+
+static const char *fs_src =
+ "#version 110 \n"
+ " \n"
+ "void main() \n"
+ "{ \n"
+ " gl_FragColor = vec4(0, 1, 0, 1); \n"
+ "} \n";
+
+static struct query queries[] = {
+ {
+ .query = GL_FRAGMENT_SHADER_INVOCATIONS_ARB,
+ .name = "GL_FRAGMENT_SHADER_INVOCATIONS_ARB",
+ .min = TEST_WIDTH * TEST_HEIGHT / 2,
+ .max = 0xffffffff},
+ /* XXX:
+ * Intel hardware has some very unpredictable results for fragment
+ * shader invocations. After a day of head scratching, I've given up.
+ * Generating a real min, or max is not possible. The spec allows this.
+ * This will also help variance across vendors.
+ */
+};
+
+enum piglit_result
+piglit_display(void)
+{
+ enum piglit_result ret = do_query(queries, ARRAY_SIZE(queries));
+#ifdef DISPLAY
+ piglit_present_results();
+#endif
+ return ret;
+}
+
+void
+piglit_init(int argc, char *argv[])
+{
+ GLuint prog;
+
+ piglit_require_gl_version(11);
+ piglit_require_GLSL();
+
+ do_query_init(queries, ARRAY_SIZE(queries));
+
+ prog = piglit_build_simple_program(vs_src, fs_src);
+
+ glUseProgram(prog);
+}
--
2.3.0
More information about the Piglit
mailing list