[Piglit] [PATCH 5/5] arb_transform_feedback2: Verify counting queries around pause and resume

Ian Romanick idr at freedesktop.org
Fri Jul 20 14:43:46 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

NVIDIA's closed-source driver passes this test.  AMD's closed-source
driver has not been tested.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/all.tests                                    |    1 +
 .../spec/arb_transform_feedback2/CMakeLists.gl.txt |    1 +
 .../spec/arb_transform_feedback2/pause-counting.c  |  155 ++++++++++++++++++++
 3 files changed, 157 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_transform_feedback2/pause-counting.c

diff --git a/tests/all.tests b/tests/all.tests
index 1614d95..ca92f8f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1866,6 +1866,7 @@ arb_transform_feedback2['glGenTransformFeedbacks names only'] = concurrent_test(
 arb_transform_feedback2['cannot bind when another object is active'] = concurrent_test('arb_transform_feedback2-cannot-bind-when-active')
 arb_transform_feedback2['misc. API error checks'] = concurrent_test('arb_transform_feedback2-api-errors')
 arb_transform_feedback2['misc. API queries'] = concurrent_test('arb_transform_feedback2-api-queries')
+arb_transform_feedback2['counting with pause'] = concurrent_test('arb_transform_feedback2-pause-counting')
 
 arb_transform_feedback_instanced = Group()
 spec['ARB_transform_feedback_instanced'] = arb_transform_feedback_instanced
diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
index 35b4913..42b5300 100644
--- a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
@@ -14,5 +14,6 @@ piglit_add_executable (arb_transform_feedback2-api-queries api-queries.c)
 piglit_add_executable (arb_transform_feedback2-cannot-bind-when-active cannot-bind-when-active.c)
 piglit_add_executable (arb_transform_feedback2-draw-auto draw-auto.c)
 piglit_add_executable (arb_transform_feedback2-gen-names-only gen-names-only.c)
+piglit_add_executable (arb_transform_feedback2-pause-counting pause-counting.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback2/pause-counting.c b/tests/spec/arb_transform_feedback2/pause-counting.c
new file mode 100644
index 0000000..349704e
--- /dev/null
+++ b/tests/spec/arb_transform_feedback2/pause-counting.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright © 2012 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 pause-counting.c
+ * Verify behavior of XFB "counting" queries when pause and resume are used.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_MAIN(
+    10 /*window_width*/,
+    10 /*window_height*/,
+    GLUT_RGB)
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+static const float data[] = {
+	-1.0, -1.0,
+	 1.0, -1.0,
+	 1.0,  1.0,
+	-1.0,  1.0,
+};
+
+static const char vstext[] =
+	"varying vec4 x; void main() { gl_Position = gl_Vertex; x = vec4(0); }";
+
+void piglit_init(int argc, char **argv)
+{
+	static const char *varyings[] = {"x"};
+	GLuint id;
+	GLuint buffers[2];
+	GLuint prog;
+	GLuint vs;
+	GLuint queries[2];
+	bool pass = true;
+	GLuint generated;
+	GLuint written;
+
+	piglit_require_transform_feedback();
+	piglit_require_GLSL();
+	piglit_require_extension("GL_ARB_transform_feedback2");
+
+	/* This is all just the boot-strap work for the test.
+	 */
+	glGenBuffers(2, buffers);
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buffers[0]);
+	glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL, GL_STREAM_READ);
+
+	glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
+	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 0);
+	glEnableVertexAttribArray(0);
+
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+	prog = piglit_CreateProgram();
+	piglit_AttachShader(prog, vs);
+
+	glTransformFeedbackVaryings(prog, 1, varyings, GL_INTERLEAVED_ATTRIBS);
+	piglit_LinkProgram(prog);
+	if (!piglit_link_check_status(prog)) {
+		pass = false;
+		goto done;
+	}
+
+	glUseProgram(prog);
+
+	glGenTransformFeedbacks(1, &id);
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffers[0]);
+
+	glGenQueries(2, queries);
+
+	/* Here's the actual test.  Start both kinds of query.  Pause and
+	 * resume transform feedback around some of the drawing.  This should
+	 * cause GL_PRIMITIVES_GENERATED to be larger than
+	 * GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN.
+	 */
+	glEnable(GL_RASTERIZER_DISCARD);
+	glBeginQuery(GL_PRIMITIVES_GENERATED, queries[0]);
+	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[1]);
+        glBeginTransformFeedback(GL_TRIANGLES);
+
+	glDrawArrays(GL_TRIANGLES, 0, 4);
+
+	glPauseTransformFeedback();
+
+	glDrawArrays(GL_TRIANGLES, 0, 4);
+
+	glResumeTransformFeedback();
+
+	glDrawArrays(GL_TRIANGLES, 0, 4);
+
+	glEndTransformFeedback();
+	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+	glEndQuery(GL_PRIMITIVES_GENERATED);
+
+	glGetQueryObjectuiv(queries[0], GL_QUERY_RESULT, &generated);
+	glGetQueryObjectuiv(queries[1], GL_QUERY_RESULT, &written);
+
+	if (generated != 3) {
+		fprintf(stderr,
+			"GL_PRIMITIVES_GENERATED: "
+			"Expected %d, got %d\n",
+			3, generated);
+		pass = false;
+	}
+
+	if (written != 2) {
+		fprintf(stderr,
+			"GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: "
+			"Expected %d, got %d\n",
+			2, written);
+		pass = false;
+	}
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
+
+done:
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
+	glDeleteBuffers(2, buffers);
+	glDeleteQueries(2, queries);
+	glDeleteTransformFeedbacks(1, &id);
+
+	glUseProgram(0);
+	glDeleteShader(vs);
+	glDeleteProgram(prog);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.7.6.5



More information about the Piglit mailing list