[Piglit] [PATCH 4/6] ARB_pipeline_statistics_query (frag): basic test
Ben Widawsky
benjamin.widawsky at intel.com
Mon Nov 17 16:00:23 PST 2014
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
.../spec/arb_pipeline_statistics/CMakeLists.gl.txt | 2 +
.../arb_pipeline_statistics/pipeline_stats_frag.c | 105 +++++++++++++++++++++
tests/spec/arb_pipeline_statistics/pipestat_help.c | 4 +-
tests/spec/arb_pipeline_statistics/pipestat_help.h | 1 +
4 files changed, 111 insertions(+), 1 deletion(-)
create mode 100644 tests/spec/arb_pipeline_statistics/pipeline_stats_frag.c
diff --git a/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
index f9726e0..45da290 100644
--- a/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
+++ b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
@@ -22,5 +22,7 @@ piglit_add_executable (arb_pipeline_stats_vert_adj pipeline_stats_vert_adj.c)
target_link_libraries (arb_pipeline_stats_vert_adj 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/pipeline_stats_frag.c b/tests/spec/arb_pipeline_statistics/pipeline_stats_frag.c
new file mode 100644
index 0000000..890048f
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/pipeline_stats_frag.c
@@ -0,0 +1,105 @@
+/*
+ * 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;
+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",
+ .expected = TEST_WIDTH * TEST_WIDTH,
+ .upper_bound = TEST_WIDTH * TEST_WIDTH / 2}, /* 50% fudge */
+};
+
+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);
+}
diff --git a/tests/spec/arb_pipeline_statistics/pipestat_help.c b/tests/spec/arb_pipeline_statistics/pipestat_help.c
index 298765c..8763c18 100644
--- a/tests/spec/arb_pipeline_statistics/pipestat_help.c
+++ b/tests/spec/arb_pipeline_statistics/pipestat_help.c
@@ -70,9 +70,11 @@ do_query_func(const struct query *queries, const int count,
end_query(&queries[i]);
for (i = 0; i < count; i++) {
+ const struct query *q = &queries[i];
GLuint params;
+
glGetQueryObjectuiv(queries[i].obj, GL_QUERY_RESULT, ¶ms);
- if (params != queries[i].expected) {
+ if (q->expected > params + q->upper_bound) {
fprintf(stderr, "%s was %d. Expected %d\n",
queries[i].name, params, queries[i].expected);
piglit_report_result(PIGLIT_FAIL);
diff --git a/tests/spec/arb_pipeline_statistics/pipestat_help.h b/tests/spec/arb_pipeline_statistics/pipestat_help.h
index 1831b01..6abd250 100644
--- a/tests/spec/arb_pipeline_statistics/pipestat_help.h
+++ b/tests/spec/arb_pipeline_statistics/pipestat_help.h
@@ -11,6 +11,7 @@ struct query {
GLuint query;
const char *name;
GLuint expected;
+ GLuint upper_bound;
};
static inline void
--
2.1.3
More information about the Piglit
mailing list