[Piglit] [PATCH] arb_transform_feedback2: Check switching active XFB objects while paused

Ian Romanick idr at freedesktop.org
Thu Sep 5 18:18:05 PDT 2013


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

The test methodology is:

    - Bind an XFB object, start XFB, draw something, pause XFB.

    - Bind a different XFB object, start XFB, draw someting, pause XFB.

    - Rebind the first XFB object, resume XFB, draw something, end XFB.

    - Rebind the second XFB object, resume XFB, draw something, end XFB.

    - Verify that all the expected data has landed in the expected
      places.

NVIDIA (304.64 on GTX 260) passes this test.  AMD has not been tested.

Mesa (i965_dri.so) fails the GLES3 version of the test, and, when
GL_ARB_transform_feedback2 is force-enabled, it fails the desktop GL
version as well.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/all.tests                                    |   2 +
 .../spec/arb_transform_feedback2/CMakeLists.gl.txt |   1 +
 .../arb_transform_feedback2/CMakeLists.gles3.txt   |  13 +
 .../change-objects-while-paused.c                  | 303 +++++++++++++++++++++
 4 files changed, 319 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback2/CMakeLists.gles3.txt
 create mode 100644 tests/spec/arb_transform_feedback2/change-objects-while-paused.c

diff --git a/tests/all.tests b/tests/all.tests
index b68f187..4a19fdc 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2242,6 +2242,8 @@ ext_transform_feedback['geometry-shaders-basic'] = concurrent_test(
 
 arb_transform_feedback2 = Group()
 spec['ARB_transform_feedback2'] = arb_transform_feedback2
+arb_transform_feedback2['Change objects while paused'] = PlainExecTest(['arb_transform_feedback2-change-objects-while-paused', '-auto'])
+arb_transform_feedback2['Change objects while paused (GLES3)'] = PlainExecTest(['arb_transform_feedback2-change-objects-while-paused_gles3', '-auto'])
 arb_transform_feedback2['draw-auto'] = PlainExecTest(['arb_transform_feedback2-draw-auto', '-auto'])
 arb_transform_feedback2['istranformfeedback'] = PlainExecTest(['arb_transform_feedback2-istransformfeedback', '-auto'])
 arb_transform_feedback2['glGenTransformFeedbacks names only'] = concurrent_test('arb_transform_feedback2-gen-names-only')
diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
index fbd716b..3d74f91 100644
--- a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
@@ -12,6 +12,7 @@ link_libraries (
 piglit_add_executable (arb_transform_feedback2-api-errors api-errors.c)
 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-change-objects-while-paused change-objects-while-paused.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-istransformfeedback istransformfeedback.c)
diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.gles3.txt b/tests/spec/arb_transform_feedback2/CMakeLists.gles3.txt
new file mode 100644
index 0000000..cad25bd
--- /dev/null
+++ b/tests/spec/arb_transform_feedback2/CMakeLists.gles3.txt
@@ -0,0 +1,13 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gles2_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback2-change-objects-while-paused_${piglit_target_api} change-objects-while-paused.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback2/change-objects-while-paused.c b/tests/spec/arb_transform_feedback2/change-objects-while-paused.c
new file mode 100644
index 0000000..2d759de
--- /dev/null
+++ b/tests/spec/arb_transform_feedback2/change-objects-while-paused.c
@@ -0,0 +1,303 @@
+/*
+ * 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 change-objects-while-paused.c
+ * Verify behavior of changing XFB objects while XFB is paused.
+ *
+ * The test methodology is:
+ *
+ * - Bind an XFB object, start XFB, draw something, pause XFB.
+ *
+ * - Bind a different XFB object, start XFB, draw someting, pause XFB.
+ *
+ * - Rebind the first XFB object, resume XFB, draw something, end XFB.
+ *
+ * - Rebind the second XFB object, resume XFB, draw something, end XFB.
+ *
+ * - Verify that all the expected data has landed in the expected places.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+#ifdef PIGLIT_USE_OPENGL
+	config.supports_gl_compat_version = 10;
+#elif defined PIGLIT_USE_OPENGL_ES3
+	config.supports_gl_es_version = 30;
+#else
+#error "Cannot build this."
+#endif
+	config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+static const float data[] = {
+	1.0,
+	2.0,
+	3.0,
+	4.0,
+	5.0,
+	6.0,
+	7.0,
+	8.0,
+	9.0,
+	10.0,
+	11.0,
+	12.0,
+};
+
+static const char vstext[] =
+#if defined PIGLIT_USE_OPENGL_ES3
+	"#version 300 es\n"
+#else
+	"#version 130\n"
+#endif
+	"in vec4 piglit_vertex;\n"
+	"out float x;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"    gl_Position = piglit_vertex;\n"
+	"    x = piglit_vertex.x;\n"
+	"}\n"
+	;
+
+static const char fstext[] =
+#if defined PIGLIT_USE_OPENGL_ES3
+	"#version 300 es\n"
+#else
+	"#version 130\n"
+#endif
+	"out highp vec4 color;\n"
+	"void main() { color = vec4(0); }\n"
+	;
+
+bool
+check_results(unsigned test, unsigned expect_written, const float *expect_data,
+	      GLuint q0, GLuint q1)
+{
+	float *data;
+	bool pass = true;
+	GLuint written[2];
+	GLuint total;
+
+	glGetQueryObjectuiv(q0, GL_QUERY_RESULT, &written[0]);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glGetQueryObjectuiv(q0, GL_QUERY_RESULT, &written[1]);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	total = written[0] + written[1];
+	if (total != expect_written) {
+		fprintf(stderr,
+			"XFB %d GL_PRIMITIVES_WRITTEN: "
+			"Expected %d, got %d\n",
+			test, expect_written, total);
+		pass = false;
+	} 
+
+	data = glMapBufferRange(GL_ARRAY_BUFFER, 0, 512, GL_MAP_READ_BIT);
+	if (!piglit_check_gl_error(GL_NO_ERROR) || data == NULL) {
+		fprintf(stderr,	"XFB %d: Could not map results buffer.\n",
+			test);
+		pass = false;
+	} else {
+		unsigned i;
+
+		for (i = 0; i < expect_written; i++) {
+			if (data[i] != expect_data[i]) {
+				fprintf(stderr,
+					"XFB %d data %d: "
+					"Expected %f, got %f\n",
+					test, i, expect_data[i], data[i]);
+				pass = false;
+			}
+		}
+		
+		glUnmapBuffer(GL_ARRAY_BUFFER);
+	}
+
+	return pass;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	static const char *varyings[] = {"x"};
+	GLuint buffers[3];
+	GLuint vao;
+	GLuint prog;
+	GLuint queries[4];
+	GLuint xfb[2];
+	bool pass = true;
+
+#ifdef PIGLIT_USE_OPENGL
+	piglit_require_transform_feedback();
+	piglit_require_GLSL_version(130);
+	piglit_require_extension("GL_ARB_vertex_array_object");
+	piglit_require_extension("GL_ARB_transform_feedback2");
+#endif
+
+	/* This is all just the boot-strap work for the test.
+	 */
+	glGenTransformFeedbacks(ARRAY_SIZE(xfb), xfb);
+	glGenBuffers(ARRAY_SIZE(buffers), buffers);
+
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buffers[0]);
+	glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL, GL_STREAM_READ);
+
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buffers[1]);
+	glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL, GL_STREAM_READ);
+
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
+
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+	glBindBuffer(GL_ARRAY_BUFFER, buffers[2]);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
+	glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 1 * sizeof(GLfloat), 0);
+	glEnableVertexAttribArray(0);
+
+	glGenQueries(ARRAY_SIZE(queries), queries);
+
+	prog = piglit_build_simple_program_unlinked(vstext, fstext);
+
+	glTransformFeedbackVaryings(prog, 1, varyings, GL_INTERLEAVED_ATTRIBS);
+	glLinkProgram(prog);
+	if (!piglit_link_check_status(prog)) {
+		pass = false;
+		goto done;
+	}
+
+	glUseProgram(prog);
+	glEnable(GL_RASTERIZER_DISCARD);
+
+	/* Here's the actual test.
+	 */
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, xfb[0]);
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffers[0]);
+	glBeginTransformFeedback(GL_POINTS);
+
+	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[0]);
+	glDrawArrays(GL_POINTS, 0, 4);
+	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+
+	glPauseTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, xfb[1]);
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffers[1]);
+	glBeginTransformFeedback(GL_POINTS);
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[1]);
+	glDrawArrays(GL_POINTS, 4, 2);
+	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+
+	glPauseTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, xfb[0]);
+	glResumeTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[2]);
+	glDrawArrays(GL_POINTS, 6, 4);
+	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+
+	glEndTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, xfb[1]);
+	glResumeTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[3]);
+	glDrawArrays(GL_POINTS, 10, 2);
+	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
+
+	glEndTransformFeedback();
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
+	glBindVertexArray(0);
+
+	/* The first XFB should have 8 primitives generated, and the buffer
+	 * object should contain the values {1.0, 2.0, 3.0, 4.0, 7.0, 8.0,
+	 * 9.0, 10.0}.
+	 */
+	{
+		static const float expected_xfb_data[] = {
+			1.0, 2.0, 3.0, 4.0, 7.0, 8.0, 9.0, 10.0
+		};
+
+		glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+		pass = check_results(1, ARRAY_SIZE(expected_xfb_data),
+				     expected_xfb_data,
+				     queries[0], queries[2])
+			&& pass;
+	}
+
+	/* The second XFB should have 4 primitives generated, and the buffer
+	 * object should contain the values {5.0, 6.0, 11.0, 12.0}.
+	 */
+	{
+		static const float expected_xfb_data[] = {
+			5.0, 6.0, 11.0, 12.0
+		};
+
+		glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
+		pass = check_results(2, ARRAY_SIZE(expected_xfb_data),
+				     expected_xfb_data,
+				     queries[1], queries[3])
+			&& pass;
+	}
+
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+done:
+	glBindVertexArray(0);
+	glDeleteVertexArrays(1, &vao);
+	glDeleteBuffers(ARRAY_SIZE(buffers), buffers);
+	glDeleteQueries(ARRAY_SIZE(queries), queries);
+	glDeleteTransformFeedbacks(ARRAY_SIZE(xfb), xfb);
+
+	glUseProgram(0);
+	glDeleteProgram(prog);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.8.1.4



More information about the Piglit mailing list