[Piglit] [PATCH] V2. Add a case to valid gl_VertexID for bug 87611

Wang Shuo shuo.wang at intel.com
Sun Jan 4 05:01:44 PST 2015


V2: This case is failed by master, and passed by the patch of
vcelestialragev at gmail.com
(https://bugs.freedesktop.org/attachment.cgi?id=110839)
which is agree by Kenneth Graunke,
Below is the test point of this case:
1. Use user-allocated vertex arrays (NOT vertex buffer objects).
2. Use a glDrawArrays with a non-zero 'first'.
3. Use primitive restart to trigger multiple _mesa_prim without an
   intervening state change.
     For primitive restart test:
     In OpenGL ES, primitive restart do not support glDrawArrays.
     Below is the spec of OpenGLR ES Version 3.0.1(January 10, 2013)
     page26:
       When DrawElements,DrawElementsInstanced, or DrawRangeElements
       transfers a set of generic attribute array elements to the GL,
       if the index within the vertex arrays corresponding to that
       set is equal to 2^N - 1, where N is 8, 16 or 32 if the type is
       UNSIGNED_-BYTE, UNSIGNED_SHORT, or UNSIGNED_INT, respectively,
       then the GL does not process those elements as a vertex.
     In OpenGL, primitive restarting to work with all rendering
     commands, including the non-indexed commands. However,
     implementations did not implement this, and the rule itself
     makes no sense.(https://www.opengl.org/wiki/Vertex_Rendering)
     So I used glDrawElements to test primitive restart
4. Validate the value of gl_VertexID in the vertex shader.
     Both glDrawArrays testing and glDrawElements testing test the
     value of gl_VertexID

Signed-off-by: Wang Shuo <shuo.wang at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87611
---
 tests/all.py                    |   1 +
 tests/shaders/CMakeLists.gl.txt |   1 +
 tests/shaders/glsl-bug-87611.c  | 158 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)
 create mode 100644 tests/shaders/glsl-bug-87611.c

diff --git a/tests/all.py b/tests/all.py
index 051b157..c884567 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -386,6 +386,7 @@ add_concurrent_test(shaders, 'createshaderprogram-attached-shaders')
 add_concurrent_test(shaders, 'glsl-arb-fragment-coord-conventions')
 add_concurrent_test(shaders, 'glsl-arb-fragment-coord-conventions-define')
 add_concurrent_test(shaders, 'glsl-bug-22603')
+add_concurrent_test(shaders, 'glsl-bug-87611')
 add_concurrent_test(shaders, 'glsl-bindattriblocation')
 add_concurrent_test(shaders, 'glsl-dlist-getattriblocation')
 add_concurrent_test(shaders, 'glsl-getactiveuniform-array-size')
diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl.txt
index c827256..501cad3 100644
--- a/tests/shaders/CMakeLists.gl.txt
+++ b/tests/shaders/CMakeLists.gl.txt
@@ -47,6 +47,7 @@ piglit_add_executable (glsl-arb-fragment-coord-conventions glsl-arb-fragment-coo
 piglit_add_executable (glsl-arb-fragment-coord-conventions-define glsl-arb-fragment-coord-conventions-define.c)
 piglit_add_executable (glsl-bindattriblocation glsl-bindattriblocation.c)
 piglit_add_executable (glsl-bug-22603 glsl-bug-22603.c)
+piglit_add_executable (glsl-bug-87611 glsl-bug-87611.c)
 piglit_add_executable (glsl-dlist-getattriblocation glsl-dlist-getattriblocation.c)
 piglit_add_executable (glsl-explicit-location-01 glsl-explicit-location-01.c)
 piglit_add_executable (glsl-explicit-location-02 glsl-explicit-location-02.c)
diff --git a/tests/shaders/glsl-bug-87611.c b/tests/shaders/glsl-bug-87611.c
new file mode 100644
index 0000000..fbac245
--- /dev/null
+++ b/tests/shaders/glsl-bug-87611.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright © 2015 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 glsl-bug-87611.c
+ *
+ * Check gl_VertexID
+ * This case is added for *Bug 87611 - Exercise gl_VertexID corner
+ * cases in i965 driver*, and used to watch the status of *Bug 85529
+ * - Surfaces not drawn in Unvanquished* This case is failed by master,
+ * and passed by the patch of vcelestialragev at gmail.com
+ * (https://bugs.freedesktop.org/attachment.cgi?id=110839) 
+ * which is agree by Kenneth Graunke.
+ *
+ *
+ * \author Wang Shuo <shuo.wang at intel.com> */
+
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 20;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+//	Validate the value of gl_VertexID in the vertex shader.
+static const GLchar *vertShaderText =
+	"#version 130\n"
+	"in vec4 piglit_vertex;\n"
+	"void main()\n"
+	"{\n"
+	"    gl_Position = piglit_vertex;\n"
+	"    if (gl_VertexID >= 2 && gl_VertexID <= 5 ) {\n"
+	"        gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
+	"    } else {\n"
+	"        gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+	"    }\n"
+	"}\n";
+
+
+//	Validate the value of gl_VertexID in the vertex shader.
+static const GLchar *vertShaderTextIndex =
+	"#version 130\n"
+	"in vec4 piglit_vertex;\n"
+	"void main()\n"
+	"{\n"
+	"    gl_Position = piglit_vertex;\n"
+	"    if (gl_VertexID >= 2 && gl_VertexID <= 5 ) {\n"
+	"        gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
+	"    } else {\n"
+	"        gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+	"    }\n"
+	"}\n";
+
+static GLint prog, progIndex;
+
+static const GLfloat Vcoords[6][2] = { {-1, -1}, {-1, -1}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}};
+
+static const unsigned short indiceTriangleFan[] = 
+	{
+		2, 0xFFFF, 2, 3, 0xFFFF, 0xFFFF, 2, 3, 4, 5, 0xFFFF, 0xFFFF, 0xFFFF,5
+	};
+
+
+enum piglit_result
+piglit_display(void)
+{
+	static const GLfloat expColor[4] = {0, 1, 0, 1};
+	GLboolean pass = GL_TRUE;
+	enum piglit_result result;
+
+	glUseProgram(prog);
+
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	//	Use user-allocated vertex arrays (NOT vertex buffer objects).
+	glVertexAttribPointer(PIGLIT_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, Vcoords);
+	glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
+
+	//	Use a glDrawArrays with a non-zero 'first'.
+	glDrawArrays(GL_TRIANGLE_STRIP, 2, 4);
+
+	pass = piglit_probe_pixel_rgba(20, 20, expColor);
+
+	glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);
+
+	/*	Use primitive restart to trigger multiple _mesa_prim without an
+	 *  intervening state change. 
+	 *  Because for OpenGL ES PRIMITIVE_RESTART testing, only support
+	 *  DrawElements, DrawElementsInstanced, or DrawRangeElements.
+	 *  And for OpenGL, PRIMITIVE_RESTART work with all
+	 *  rendering commands, including the non-indexed commands. However,
+	 *  implementations did not implement this, and the rule itself makes
+	 *  no sense (https://www.opengl.org/wiki/Vertex_Rendering)
+	 *	So for testing PRIMITIVE_RESTART I used glDrawElements
+	 *	OpenGL ES spec:When DrawElements,DrawElementsInstanced, 
+	 *	or DrawRangeElements transfers a set of generic attribute array
+	 *	elements to the GL, if the index within the vertex arrays 
+	 *	corresponding to that set is equal to 2N 􀀀 1, where N is 8, 16
+	 *	or 32 if the type is UNSIGNED_-BYTE, UNSIGNED_SHORT, or 
+	 *	UNSIGNED_INT, respectively, then the GL does not process those
+	 *	elements as a vertex.
+	 */
+	glUseProgram(progIndex);
+
+	glClear(GL_COLOR_BUFFER_BIT);
+	
+	glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+
+	glVertexAttribPointer(PIGLIT_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, Vcoords);
+	glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);
+
+	glDrawElements(GL_TRIANGLE_STRIP, sizeof(indiceTriangleFan) / sizeof(indiceTriangleFan[0]), GL_UNSIGNED_SHORT, indiceTriangleFan);
+
+	pass = piglit_probe_pixel_rgba(20, 20, expColor) && pass;
+
+	glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);
+
+	glDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_GLSL_version(130);
+
+	prog = piglit_build_simple_program(vertShaderText, NULL);
+
+	progIndex = piglit_build_simple_program(vertShaderTextIndex, NULL);
+}
-- 
1.8.3.2



More information about the Piglit mailing list