gl-2.0: Add test for interaction between pointsprites and const attribs

Submitted by Chris Forbes on Nov. 25, 2014, 7:37 a.m.

Details

Message ID 1416901045-15878-1-git-send-email-chrisf@ijw.co.nz
State New
Headers show

Not browsing as part of any series.

Commit Message

Chris Forbes Nov. 25, 2014, 7:37 a.m.
Demonstrates an i965 bug, which wined3d hits in many apps.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
---
 tests/all.py                                     |   1 +
 tests/spec/gl-2.0/CMakeLists.gl.txt              |   1 +
 tests/spec/gl-2.0/const-attrib-pointsprite-bug.c | 119 +++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 tests/spec/gl-2.0/const-attrib-pointsprite-bug.c

Patch hide | download patch | download mbox

diff --git a/tests/all.py b/tests/all.py
index b3417a9..d9e7fbc 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -864,6 +864,7 @@  add_concurrent_test(gl20, 'attribs')
 add_concurrent_test(gl20, 'gl-2.0-edgeflag')
 add_concurrent_test(gl20, 'gl-2.0-edgeflag-immediate')
 add_concurrent_test(gl20, 'gl-2.0-vertexattribpointer')
+add_concurrent_test(gl20, 'gl-2.0-const-attrib-pointsprite-bug')
 add_plain_test(gl20, 'attrib-assignments')
 add_plain_test(gl20, 'getattriblocation-conventional')
 add_plain_test(gl20, 'clip-flag-behavior')
diff --git a/tests/spec/gl-2.0/CMakeLists.gl.txt b/tests/spec/gl-2.0/CMakeLists.gl.txt
index 3ac0d68..8f1b709 100644
--- a/tests/spec/gl-2.0/CMakeLists.gl.txt
+++ b/tests/spec/gl-2.0/CMakeLists.gl.txt
@@ -14,3 +14,4 @@  piglit_add_executable (vertex-program-two-side vertex-program-two-side.c)
 piglit_add_executable (gl-2.0-edgeflag edgeflag.c)
 piglit_add_executable (gl-2.0-edgeflag-immediate edgeflag-immediate.c)
 piglit_add_executable (gl-2.0-vertexattribpointer vertexattribpointer.c)
+piglit_add_executable (gl-2.0-const-attrib-pointsprite-bug const-attrib-pointsprite-bug.c)
diff --git a/tests/spec/gl-2.0/const-attrib-pointsprite-bug.c b/tests/spec/gl-2.0/const-attrib-pointsprite-bug.c
new file mode 100644
index 0000000..24b154c
--- /dev/null
+++ b/tests/spec/gl-2.0/const-attrib-pointsprite-bug.c
@@ -0,0 +1,119 @@ 
+/*
+ * Copyright 2014 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.
+ */
+
+/**
+ * With point sprites enabled, and texcoord replacement enabled for
+ * the first set of texcoords, test DrawArrays with the following
+ * vertex attribute layout:
+ * - vertex position, from a VBO
+ * - gl_SecondaryColor, from current state (array not enabled)
+ * - texcoords, from the same VBO as position
+ *
+ * This demonstrates a bug in i965, which is hit by wined3d in many
+ * apps.
+ */
+
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+	config.supports_gl_compat_version = 20;
+	config.window_visual = (PIGLIT_GL_VISUAL_RGBA |
+				PIGLIT_GL_VISUAL_DOUBLE);
+PIGLIT_GL_TEST_CONFIG_END
+
+
+static const char *vs_text =
+	"void main() {\n"
+	"   gl_FrontColor = gl_Color;\n"
+	"   gl_Position = gl_Vertex;\n"
+	"   gl_TexCoord[0] = gl_MultiTexCoord0;\n"
+	"}\n";
+static const char *fs_text =
+	"void main() { \n"
+	"   if (gl_Color.xyz == vec3(1,0,0))\n"
+	"	gl_FragColor = gl_TexCoord[0];\n"
+	"   else\n"
+	"	gl_FragColor = vec4(0,0,1,0);\n"
+	"}\n";
+
+static GLuint program;
+
+GLuint vbo;
+float verts[] = {
+	-1, -1,		0, 0,
+	1, -1,		1, 0,
+	1, 1,		1, 1,
+	-1, 1,		0, 1
+};
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	int x, y;
+
+	glViewport(0, 0, piglit_width, piglit_height);
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	glColor3f(1, 0, 0);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+	for (x = 0; x < 3; x++) {
+		for (y = 0; y < 3; y++) {
+			float expected[] = { (x+1)/4.0f, (y+1)/4.0f, 0 };
+			pass = piglit_probe_pixel_rgb(
+				expected[0] * piglit_width,
+				expected[1] * piglit_height,
+				expected) && pass;
+		}
+	}
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_GLSL();
+
+	program = piglit_build_simple_program(vs_text, fs_text);
+	glUseProgram(program);
+
+	glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
+
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STREAM_DRAW);
+	glVertexPointer(2, GL_FLOAT, 16, (GLvoid *)0);
+	glTexCoordPointer(2, GL_FLOAT, 16, (GLvoid *)8);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+	glEnable(GL_POINT_SPRITE);
+
+	glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
+}
+