[Piglit] [PATCH] Add test case to verify ERROR generated using transform feedback with incompatibile type.

Yi Sun yi.sun at intel.com
Thu Mar 1 00:23:31 PST 2012


Test error generated in transform feedback mode. Test renders a primitive while in transform feedback mode that is expecting primitives of different type.

Signed-off-by: Yi Sun <yi.sun at intel.com>

diff --git a/tests/bugs/CMakeLists.gl.txt b/tests/bugs/CMakeLists.gl.txt
index 3a8a9c5..132b9d0 100644
--- a/tests/bugs/CMakeLists.gl.txt
+++ b/tests/bugs/CMakeLists.gl.txt
@@ -35,5 +35,6 @@ add_executable (fdo31934 fdo31934.c)
 add_executable (tri-tex-crash tri-tex-crash.c)
 add_executable (vbo-buffer-unmap vbo-buffer-unmap.c)
 add_executable (swapbuffers-no-context swapbuffers-no-context.c)
+add_executable (transform_feedback_incompatibile_primitive transform_feedback_incompatibile_primitive.c)
 
 # vim: ft=cmake:
diff --git a/tests/bugs/transform_feedback_incompatibile_primitive.c b/tests/bugs/transform_feedback_incompatibile_primitive.c
new file mode 100644
index 0000000..17d893d
--- /dev/null
+++ b/tests/bugs/transform_feedback_incompatibile_primitive.c
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ *
+ * Authors:
+ *	  Sun Yi <yi.sun at intel.com>
+ *
+ */
+
+/** @file tests/bugs/transform_transform.c
+ *
+ * Negative case, to verify the error generated by using transform feedback and feeding back primitives of incompatibile type.
+ * Test renders a primitive while in transform feedback mode that is expecting primitives of different type.
+ * 
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_SINGLE | GLUT_RGB;
+
+static GLint prog;
+
+static const char vs_source[] =
+		"void main() \n"
+		"{ \n"
+		"	 gl_Position =  gl_Vertex; \n"
+		"} \n";
+
+static const char fs_source[] =
+		"void main() \n"
+		"{ \n"
+		"	gl_FragColor = vec4(1); \n"
+		"} \n";
+
+enum piglit_result
+piglit_display(void)
+{
+	/* unreached */
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+
+	GLint vs, fs;
+	GLuint name;
+	GLenum glError = GL_NO_ERROR;
+	const char* var = "gl_Position";
+
+	glGenBuffers(1, &name);
+	glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, name);
+	glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, 0, GL_STREAM_COPY);
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, name);
+
+	if (!GLEW_VERSION_3_0) {
+		printf("Requires OpenGL 3.0\n");
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+
+	prog = piglit_link_simple_program(vs, fs);
+	glUseProgram(prog);
+
+	glError = glGetError();
+
+	if (glError != GL_NO_ERROR)
+	{
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	glTransformFeedbackVaryings(prog, 1, &var, GL_INTERLEAVED_ATTRIBS);
+	glLinkProgram(prog);
+
+	glBeginTransformFeedback( GL_POINTS );
+	glBegin( GL_LINES );
+		glVertexAttrib2f(0, 0, 0);
+		glVertexAttrib2f(0, 1, 1);
+	glEnd();
+
+	glError = glGetError();
+	glEndTransformFeedback();
+
+	if ( glError == GL_INVALID_OPERATION )
+		piglit_report_result(PIGLIT_PASS);
+	else 
+		piglit_report_result(PIGLIT_FAIL);
+}
-- 
1.7.6.4



More information about the Piglit mailing list