[Piglit] [PATCH 4/4] arb_direct_state_access: Added glGetTransformFeedback* tests

Martin Peres martin.peres at linux.intel.com
Thu Jan 29 04:51:29 PST 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../arb_direct_state_access/gettransformfeedback.c | 235 +++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/gettransformfeedback.c

diff --git a/tests/all.py b/tests/all.py
index 3a187bb..3e23081 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4404,6 +4404,7 @@ spec['ARB_direct_state_access'] = {}
 spec['ARB_direct_state_access']['create-transformfeedbacks'] = PiglitGLTest(['arb_direct_state_access-create-transformfeedbacks'], run_concurrent=True)
 spec['ARB_direct_state_access']['transformfeedback-bufferbase'] = PiglitGLTest(['arb_direct_state_access-transformfeedback-bufferbase'], run_concurrent=True)
 spec['ARB_direct_state_access']['transformfeedback-bufferrange'] = PiglitGLTest(['arb_direct_state_access-transformfeedback-bufferrange'], run_concurrent=True)
+spec['ARB_direct_state_access']['gettransformfeedback'] = PiglitGLTest(['arb_direct_state_access-gettransformfeedback'], run_concurrent=True)
 spec['ARB_direct_state_access']['dsa-textures'] = PiglitGLTest(['arb_direct_state_access-dsa-textures'], run_concurrent=True)
 spec['ARB_direct_state_access']['texturesubimage'] = PiglitGLTest(['arb_direct_state_access-texturesubimage'], run_concurrent=True)
 spec['ARB_direct_state_access']['bind-texture-unit'] = PiglitGLTest(['arb_direct_state_access-bind-texture-unit'], run_concurrent=True)
diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
index 8ae8275..a6232e3 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -12,6 +12,7 @@ link_libraries (
 piglit_add_executable (arb_direct_state_access-create-transformfeedbacks create-transformfeedbacks.c)
 piglit_add_executable (arb_direct_state_access-transformfeedback-bufferbase transformfeedback-bufferbase.c)
 piglit_add_executable (arb_direct_state_access-transformfeedback-bufferrange transformfeedback-bufferrange.c)
+piglit_add_executable (arb_direct_state_access-gettransformfeedback gettransformfeedback.c)
 piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c)
 piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c)
 piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c)
diff --git a/tests/spec/arb_direct_state_access/gettransformfeedback.c b/tests/spec/arb_direct_state_access/gettransformfeedback.c
new file mode 100644
index 0000000..cc3a056
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/gettransformfeedback.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright © 2014 VMware, Inc.
+ *
+ * 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 gettransformfeedback.c
+ * Simple transform feedback test drawing GL_POINTS and checking that all the
+ * state is well reported by the GetTransformFeedback*() functions.
+ *
+ * Greatly inspired from ext_transform_feedback/points.c.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static GLuint prog;
+static GLuint xfb_buf[3], vert_buf;
+static bool pass = true;
+
+static const char *vstext = {
+	"void main() {"
+	"   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
+	"   gl_FrontColor = vec4(0.9, 0.8, 0.7, 0.6);"
+	"}"
+};
+
+#define NUM_VERTS 3
+static const GLfloat verts[NUM_VERTS][3] =
+{
+	{-1.0, 0.2, 0},
+	{0, 0.2, 0},
+	{1, 0.2, 0}
+};
+
+struct context_t {
+	struct tbo_state_t {
+		GLuint binding;
+		GLint64 start;
+		GLint64 size;
+	} bo_state[3];
+	bool active;
+	bool paused;
+} ctx;
+
+void
+check_active_paused_state(const char *test_name)
+{
+	GLint param;
+
+	glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_PAUSED, &param);
+	piglit_check_gl_error(GL_NO_ERROR);
+	SUBTESTCONDITION(param == ctx.paused, pass, "%s: paused state valid",
+					 test_name);
+
+	glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_ACTIVE, &param);
+	piglit_check_gl_error(GL_NO_ERROR);
+	SUBTESTCONDITION(param == ctx.active, pass, "%s: active state valid",
+					 test_name);
+}
+
+void
+check_binding_state(const char *test_name)
+{
+	GLint64 param64;
+	GLint param;
+	int i;
+
+	for (i = 0; i < 3; i++) {
+		glGetTransformFeedbacki_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,
+								  i, &param);
+		piglit_check_gl_error(GL_NO_ERROR);
+		SUBTESTCONDITION(param == ctx.bo_state[i].binding, pass,
+						 "%s: bound buffer %i valid", test_name, i);
+
+		glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_START,
+									i, &param64);
+		piglit_check_gl_error(GL_NO_ERROR);
+		SUBTESTCONDITION(param64 ==  ctx.bo_state[i].start, pass,
+						 "%s: bound buffer %i start valid", test_name, i);
+
+		glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_SIZE,
+									i, &param64);
+		piglit_check_gl_error(GL_NO_ERROR);
+		SUBTESTCONDITION(param64 ==  ctx.bo_state[i].size, pass,
+						 "%s: bound buffer %i size valid", test_name, i);
+	}
+}
+
+void
+check_invalid_queries()
+{
+	GLint64 param64;
+	GLint param;
+
+	glGetTransformFeedbackiv(0, GL_TRANSFORM_FEEDBACK_BINDING, &param);
+	SUBTEST(GL_INVALID_ENUM, pass,
+			"glGetTransformFeedbackiv: fetch invalid attribute");
+
+	glGetTransformFeedbacki_v(0, GL_TRANSFORM_FEEDBACK_ACTIVE, 0, &param);
+	SUBTEST(GL_INVALID_ENUM, pass,
+			"glGetTransformFeedbacki_v: fetch invalid attribute");
+
+	glGetTransformFeedbacki64_v(0, GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,
+								0, &param64);
+	SUBTEST(GL_INVALID_ENUM, pass,
+			"glGetTransformFeedbacki64_v: fetch invalid attribute");
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	static const char *varyings[] = { "gl_Position", "gl_FrontColor" };
+	GLuint vs, size, start;
+	int i;
+
+	glMatrixMode(GL_MODELVIEW);
+	glLoadIdentity();
+	glScalef(0.5, 0.5, 1.0);
+
+	/* Check the driver. */
+	piglit_require_gl_version(15);
+	piglit_require_GLSL();
+	piglit_require_extension("GL_ARB_transform_feedback3");
+	piglit_require_extension("GL_ARB_direct_state_access");
+
+	/* Create shaders. */
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+	prog = glCreateProgram();
+	glAttachShader(prog, vs);
+	glTransformFeedbackVaryings(prog, 2, varyings,
+					GL_SEPARATE_ATTRIBS);
+	glLinkProgram(prog);
+	if (!piglit_link_check_status(prog)) {
+		glDeleteProgram(prog);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	glUseProgram(prog);
+
+	/* Set up the vertex data buffer */
+	glGenBuffers(1, &vert_buf);
+	glBindBuffer(GL_ARRAY_BUFFER, vert_buf);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
+
+	/* set the initial state */
+	ctx.active = false;
+	ctx.paused = false;
+	for (i = 0; i < 3; i++) {
+		ctx.bo_state[i].binding = 0;
+		ctx.bo_state[i].start = 0;
+		ctx.bo_state[i].size = 0;
+	}
+	check_active_paused_state("initial state");
+	check_binding_state("initial state");
+
+	/* Set up the transform feedback buffer */
+	glCreateTransformFeedbacks(3, xfb_buf);
+	for (i = 0; i < 2; i++) {
+		start = rand() & 0xFC;
+		size = 0x100 + (rand() & 0xFFC);
+
+		glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, xfb_buf[i]);
+		piglit_check_gl_error(GL_NO_ERROR);
+		glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
+				 size, NULL, GL_STREAM_READ);
+		piglit_check_gl_error(GL_NO_ERROR);
+		glTransformFeedbackBufferRange(0, i, xfb_buf[i], start, size);
+		piglit_check_gl_error(GL_NO_ERROR);
+
+		ctx.bo_state[i].binding = xfb_buf[i];
+		ctx.bo_state[i].start = start;
+		ctx.bo_state[i].size = size;
+	}
+
+	check_binding_state("post-binding state");
+
+	glClearColor(0.2, 0.2, 0.2, 1.0);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	check_invalid_queries();
+
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glBeginTransformFeedback(GL_POINTS);
+
+	ctx.active = true;
+	check_active_paused_state("TransformFeedback started");
+
+	glPauseTransformFeedback();
+
+	ctx.paused = true;
+	check_active_paused_state("TransformFeedback paused");
+
+	glResumeTransformFeedback();
+
+	ctx.paused = false;
+	check_active_paused_state("TransformFeedback resumed");
+
+	glBindBuffer(GL_ARRAY_BUFFER, vert_buf);
+	glVertexPointer(3, GL_FLOAT, 0, 0);
+	glEnable(GL_VERTEX_ARRAY);
+	glDrawArrays(GL_POINTS, 0, 3);
+	glEndTransformFeedback();
+
+	ctx.active = false;
+	check_active_paused_state("TransformFeedback ended");
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
2.2.2



More information about the Piglit mailing list