[Piglit] [PATCH 1/6] ARB_pipeline_statistics_query (vertex): basic test
Ben Widawsky
benjamin.widawsky at intel.com
Mon Nov 17 16:00:20 PST 2014
Add very rudimentary tests for the 3 vertex related queries in
ARB_pipeline_statistics_query. This can be accomplished easily with 1
shader, and 1 draw call - and is sort of required to work before testing
the other stages.
The library introduced here will be reused on other tests.
Note about the library: I attempted to use the existing piglit_add_library,
however I was getting cmake warnings (cmake --help-policy CMP0038). Since the
library won't grow large, I simply went with a static library using standard
CMAKE directives.
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
tests/spec/CMakeLists.txt | 1 +
.../spec/arb_pipeline_statistics/CMakeLists.gl.txt | 22 ++++
tests/spec/arb_pipeline_statistics/CMakeLists.txt | 1 +
.../arb_pipeline_statistics/pipeline_stats_vert.c | 132 +++++++++++++++++++++
tests/spec/arb_pipeline_statistics/pipestat_help.c | 82 +++++++++++++
tests/spec/arb_pipeline_statistics/pipestat_help.h | 29 +++++
6 files changed, 267 insertions(+)
create mode 100644 tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
create mode 100644 tests/spec/arb_pipeline_statistics/CMakeLists.txt
create mode 100644 tests/spec/arb_pipeline_statistics/pipeline_stats_vert.c
create mode 100644 tests/spec/arb_pipeline_statistics/pipestat_help.c
create mode 100644 tests/spec/arb_pipeline_statistics/pipestat_help.h
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index b2da115..c68e630 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -112,3 +112,4 @@ add_subdirectory (ext_image_dma_buf_import)
add_subdirectory (arb_blend_func_extended)
add_subdirectory (ext_unpack_subimage)
add_subdirectory (arb_vertex_array_object)
+add_subdirectory (arb_pipeline_statistics)
diff --git a/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
new file mode 100644
index 0000000..bec5918
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/CMakeLists.gl.txt
@@ -0,0 +1,22 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+)
+
+# Display stuff in the tests
+#add_definitions (-DDISPLAY)
+
+# Don't bother with the piglit helper functions since we just need a simple
+# static link that won't be installed. (We'll actually anger newer cmake if we
+# use piglit helpers).
+add_library (pipestat_help STATIC pipestat_help.c)
+
+piglit_add_executable (arb_pipeline_stats_vert pipeline_stats_vert.c)
+target_link_libraries (arb_pipeline_stats_vert pipestat_help)
+
+# vim: ft=cmake
diff --git a/tests/spec/arb_pipeline_statistics/CMakeLists.txt b/tests/spec/arb_pipeline_statistics/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_pipeline_statistics/pipeline_stats_vert.c b/tests/spec/arb_pipeline_statistics/pipeline_stats_vert.c
new file mode 100644
index 0000000..7072b4e
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/pipeline_stats_vert.c
@@ -0,0 +1,132 @@
+/*
+ * 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_vert.c
+ *
+ * This test verifies that the vertex shader related tokens of
+ * ARB_pipeline_statistics_query() work as expected. OpenGL 4.4 Specification,
+ * Core Profile.
+ *
+ * Section 11.1.3 as quoted below makes it sound like we can't actually
+ * reliably count on any of these values. Consider that information when
+ * investigating failures.
+ *
+ * 10.1
+ * When BeginQuery is called with a target of VERTICES_SUBMITTED_ARB, the
+ * submitted vertices count maintained by the GL is set to zero. When a
+ * vertices submitted query is active, the submitted vertices count is
+ * incremented every time a vertex is transferred to the GL (see sections
+ * 10.3.4, and 10.5). In case of primitive types with adjacency information
+ * (see sections 10.1.11 through 10.1.14) only the vertices belonging to the
+ * main primitive are counted but not the adjacent vertices. In case of line
+ * loop primitives implementations are allowed to count the first vertex
+ * twice for the purposes of VERTICES_SUBMITTED_ARB queries. Additionally,
+ * vertices corresponding to incomplete primitives may or may not be
+ * counted.
+ *
+ * When BeginQuery is called with a target of PRIMITIVES_SUBMITTED_ARB, the
+ * submitted primitives count maintained by the GL is set to zero. When a
+ * primitives submitted query is active, the submitted primitives count is
+ * incremented every time a point, line, triangle, or patch primitive is
+ * transferred to the GL (see sections 10.1, 10.3.5, and 10.5). Restarting a
+ * primitive topology using the primitive restart index has no effect on the
+ * issued primitives count. Incomplete primitives may or may not be counted.
+ *
+ * 11.1.3 (the chicken clause)
+ * Implementations are allowed to skip the execution of certain shader
+ * invocations, and to execute additional shader invocations for any shader
+ * type during programmable vertex processing due to implementation dependent
+ * reasons, including the execution of shader invocations that don't have an
+ * active program object present for the particular shader stage, as long as
+ * the results of rendering otherwise remain unchanged.
+ */
+
+#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 struct query queries[] = {
+ {
+ .query = GL_PRIMITIVES_SUBMITTED_ARB,
+ .name = "GL_PRIMITIVES_SUBMITTED_ARB",
+ .expected = NUM_PRIMS},
+ {
+ .query = GL_VERTICES_SUBMITTED_ARB,
+ .name = "GL_VERTICES_SUBMITTED_ARB",
+ .expected = NUM_VERTS},
+ {
+ .query = GL_VERTEX_SHADER_INVOCATIONS_ARB,
+ .name = "GL_VERTEX_SHADER_INVOCATIONS_ARB",
+ .expected = NUM_VERTS}
+};
+
+/* Use DISPLAY for debug */
+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 vs, prog;
+
+ piglit_require_gl_version(11);
+ piglit_require_GLSL();
+
+#ifndef DISPLAY
+ glEnable(GL_RASTERIZER_DISCARD);
+#endif
+ do_query_init(queries, ARRAY_SIZE(queries));
+
+ /* Emit a very simply vertex shader just to make sure we actually go
+ * through the part of the pipeline we're trying to test. */
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_src);
+ prog = glCreateProgram();
+ glAttachShader(prog, vs);
+ glLinkProgram(prog);
+
+ if (!piglit_link_check_status(prog)) {
+ glDeleteProgram(prog);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ glUseProgram(prog);
+}
diff --git a/tests/spec/arb_pipeline_statistics/pipestat_help.c b/tests/spec/arb_pipeline_statistics/pipestat_help.c
new file mode 100644
index 0000000..898beee
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/pipestat_help.c
@@ -0,0 +1,82 @@
+/*
+ * 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 pipestat_help.c
+ *
+ * Helper library for the pipeline statistics tests
+ */
+
+#include "piglit-util-gl.h"
+#include "pipestat_help.h"
+
+void
+do_query_init(struct query *queries, const int count)
+{
+ int i;
+
+ /* Some of the token require more than just having the extension, but
+ * all require at least having the extension.
+ */
+ if (!piglit_is_extension_supported
+ ("GL_ARB_pipeline_statistics_query")) {
+ printf("Pipeline statistics not supported.\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ for (i = 0; i < count; i++) {
+ glGenQueries(1, &queries[i].obj);
+ if (glGetError() != GL_NO_ERROR)
+ piglit_report_result(PIGLIT_FAIL);
+ }
+}
+
+enum piglit_result
+do_query(const struct query *queries, const int count)
+{
+ const float green[] = {0, 1, 0, 0};
+ int i;
+
+ glClearColor(1.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glColor4fv(green);
+
+ for (i = 0; i < count; i++)
+ begin_query(&queries[i]);
+
+ piglit_draw_rect(-1, -1, 2, 2);
+
+ for (i = 0; i < count; i++)
+ end_query(&queries[i]);
+
+ for (i = 0; i < count; i++) {
+ GLuint params;
+ glGetQueryObjectuiv(queries[i].obj, GL_QUERY_RESULT, ¶ms);
+ if (params != queries[i].expected) {
+ fprintf(stderr, "%s was %d. Expected %d\n",
+ queries[i].name, params, queries[i].expected);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ }
+
+ return PIGLIT_PASS;
+}
diff --git a/tests/spec/arb_pipeline_statistics/pipestat_help.h b/tests/spec/arb_pipeline_statistics/pipestat_help.h
new file mode 100644
index 0000000..26ab02f
--- /dev/null
+++ b/tests/spec/arb_pipeline_statistics/pipestat_help.h
@@ -0,0 +1,29 @@
+#define TEST_HEIGHT 10
+#define TEST_WIDTH 10
+
+/* We're going to be emitting a TRISTRIP to form a square (after doing a
+ * clear). This makes our pipeline quite predictable. */
+#define NUM_VERTS 4
+#define NUM_PRIMS 2
+
+struct query {
+ GLuint obj;
+ GLuint query;
+ const char *name;
+ GLuint expected;
+};
+
+static inline void
+begin_query(const struct query *q)
+{
+ glBeginQuery(q->query, q->obj);
+}
+
+static inline void
+end_query(const struct query *q)
+{
+ glEndQuery(q->query);
+}
+
+void do_query_init(struct query *queries, const int count);
+enum piglit_result do_query(const struct query *queries, const int count);
--
2.1.3
More information about the Piglit
mailing list