[Piglit] [PATCH] Add tests for GL_ARB_shader_draw_parameters

Kristian Høgsberg hoegsberg at gmail.com
Wed Dec 16 10:18:13 PST 2015


From: Kristian Høgsberg Kristensen <kristian.h.kristensen at intel.com>

---
 tests/spec/CMakeLists.txt                          |   1 +
 .../arb_shader_draw_parameters/CMakeLists.gl.txt   |  15 ++
 .../spec/arb_shader_draw_parameters/CMakeLists.txt |   1 +
 .../spec/arb_shader_draw_parameters/baseinstance.c | 164 +++++++++++++++++++++
 tests/spec/arb_shader_draw_parameters/basevertex.c | 128 ++++++++++++++++
 .../arb_shader_draw_parameters/drawid-vertexid.c   | 164 +++++++++++++++++++++
 tests/spec/arb_shader_draw_parameters/drawid.c     | 161 ++++++++++++++++++++
 7 files changed, 634 insertions(+)
 create mode 100644 tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_shader_draw_parameters/CMakeLists.txt
 create mode 100644 tests/spec/arb_shader_draw_parameters/baseinstance.c
 create mode 100644 tests/spec/arb_shader_draw_parameters/basevertex.c
 create mode 100644 tests/spec/arb_shader_draw_parameters/drawid-vertexid.c
 create mode 100644 tests/spec/arb_shader_draw_parameters/drawid.c

diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 57b6878..4c519b1 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -138,3 +138,4 @@ add_subdirectory (mesa_pack_invert)
 add_subdirectory (ext_texture_format_bgra8888)
 add_subdirectory (oes_draw_elements_base_vertex)
 add_subdirectory (arb_query_buffer_object)
+add_subdirectory (arb_shader_draw_parameters)
diff --git a/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt b/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
new file mode 100644
index 0000000..5396484
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/CMakeLists.gl.txt
@@ -0,0 +1,15 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+	${piglit_SOURCE_DIR}/tests/mesa/util
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (basevertex basevertex.c)
+piglit_add_executable (baseinstance baseinstance.c)
+piglit_add_executable (drawid drawid.c)
+piglit_add_executable (drawid-vertexid drawid-vertexid.c)
diff --git a/tests/spec/arb_shader_draw_parameters/CMakeLists.txt b/tests/spec/arb_shader_draw_parameters/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_shader_draw_parameters/baseinstance.c b/tests/spec/arb_shader_draw_parameters/baseinstance.c
new file mode 100644
index 0000000..17ccc36
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/baseinstance.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright © 2011 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 baseinstance.c
+ *
+ * Test that gl_BaseInstanceARB has the correct values. Draw left side
+ * of window with a non-instanced draw call to verify
+ * gl_BaseInstanceARB is 0 in that case, then draw other half with
+ * base instance 7 and verifies that that works.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 31;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_text[] =
+	"#version 330\n"
+	"#extension GL_ARB_shader_draw_parameters: require\n"
+	"\n"
+	"/* This is floating point so we can use immediate mode */\n"
+	"layout(location = 0) in vec2 pos;\n"
+	"layout(location = 1) in vec4 in_color;\n"
+	"out vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = vec4(pos, 0.0, 1.0);\n"
+	"  color = vec4(equal(vec4(gl_BaseInstanceARB), in_color));\n"
+	"}\n";
+
+static const char fs_text[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = color;\n"
+	"}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+
+	piglit_require_GLSL_version(130);
+
+	piglit_require_extension("GL_ARB_shader_draw_parameters");
+	piglit_require_extension("GL_ARB_base_instance");
+
+	prog = piglit_build_simple_program(vs_text, fs_text);
+
+	glUseProgram(prog);
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass;
+
+	struct {
+		float vertex_array[16];
+		float color_array[32];
+		int indices[6];
+	} geometry = {
+		.vertex_array = {
+			-1, -1,
+			0, -1,
+			0, 1,
+			-1, 1,
+
+			0, -1,
+			1, -1,
+			1, 1,
+			0, 1,
+		},
+		.color_array = {
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+
+			0.5, 7.0, 0.5, 0.5,
+			0.5, 7.0, 0.5, 0.5,
+			0.5, 7.0, 0.5, 0.5,
+			0.5, 7.0, 0.5, 0.5,
+		}
+	};
+
+	const int indices[6] = {
+		0, 1, 2,
+		0, 2, 3,
+	};
+
+	float green[] = {0, 1, 0, 0};
+
+	GLuint vao, vbo;
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(geometry), &geometry, GL_STATIC_DRAW);
+
+	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
+			      2 * sizeof(GLfloat),
+			      (void *) ((char *) &geometry.vertex_array - (char *) &geometry));
+
+	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE,
+			      4 * sizeof(GLfloat),
+			      (void *) ((char *) &geometry.color_array - (char *) &geometry));
+
+	/* Enable the attributes */
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
+
+	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, indices);
+
+	/* We use this monster to draw the right half of the
+	 * window. Base vertex so that we can reuse the indices to
+	 * draw with vertices and colors 4-7, base instance so that we
+	 * can verify that the value presented in the shader is
+	 * correct. We only draw one instance so the only effect of
+	 * instancing is that gl_BaseInstanceARB is 7.
+	 */
+	glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, 6,
+						      GL_UNSIGNED_INT,
+						      indices, 1,
+						      4, /* basevertex */
+						      7 /* baseinstance */);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
diff --git a/tests/spec/arb_shader_draw_parameters/basevertex.c b/tests/spec/arb_shader_draw_parameters/basevertex.c
new file mode 100644
index 0000000..c60788a
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/basevertex.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2011 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 basevertex.c
+ *
+ * Test that gl_BaseVertexARB has the correct values.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_text[] =
+	"#version 130\n"
+	"#extension GL_ARB_shader_draw_parameters: require\n"
+	"\n"
+	"/* This is floating point so we can use immediate mode */\n"
+	"out vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = gl_Vertex;\n"
+	"  color = vec4(equal(vec4(gl_BaseVertexARB), gl_Color));\n"
+	"}\n";
+
+static const char fs_text[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = color;\n"
+	"}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+
+	piglit_require_GLSL_version(130);
+
+	piglit_require_extension("GL_ARB_shader_draw_parameters");
+
+	prog = piglit_build_simple_program(vs_text, fs_text);
+
+	glUseProgram(prog);
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass;
+	float vertex_array[] = {
+		-1, -1,
+		0, -1,
+		0, 1,
+		-1, 1,
+
+		0, -1,
+		1, -1,
+		1, 1,
+		0, 1,
+	};
+	float color_array[] = {
+		0.5, 0.0, 0.5, 0.5,
+		0.5, 0.0, 0.5, 0.5,
+		0.5, 0.0, 0.5, 0.5,
+		0.5, 0.0, 0.5, 0.5,
+
+		0.5, 4.0, 0.5, 0.5,
+		0.5, 4.0, 0.5, 0.5,
+		0.5, 4.0, 0.5, 0.5,
+		0.5, 4.0, 0.5, 0.5,
+
+	};
+	int indices[] = {
+		0, 1, 2,
+		0, 2, 3,
+	};
+	float green[] = {0, 1, 0, 0};
+
+	glVertexPointer(2, GL_FLOAT, 0, vertex_array);
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glColorPointer(4, GL_FLOAT, 0, color_array);
+	glEnableClientState(GL_COLOR_ARRAY);
+
+	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, indices);
+
+	glDrawElementsBaseVertex(GL_TRIANGLES, 6,
+				 GL_UNSIGNED_INT, indices, 4);
+
+	glDisableClientState(GL_COLOR_ARRAY);
+	glDisableClientState(GL_VERTEX_ARRAY);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
diff --git a/tests/spec/arb_shader_draw_parameters/drawid-vertexid.c b/tests/spec/arb_shader_draw_parameters/drawid-vertexid.c
new file mode 100644
index 0000000..4d6649d
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/drawid-vertexid.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright © 2011 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 baseinstance.c
+ *
+ * Test that gl_BaseInstanceARB has the correct values. Draw left side
+ * of window with a non-instanced draw call to verify
+ * gl_BaseInstanceARB is 0 in that case, then draw other half with
+ * base instance 7 and verifies that that works.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 31;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_text[] =
+	"#version 330\n"
+	"#extension GL_ARB_shader_draw_parameters: require\n"
+	"\n"
+	"layout(location = 0) in vec2 pos;\n"
+	"layout(location = 1) in ivec2 reference;\n"
+	"out vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = vec4(pos, 0.0, 1.0);\n"
+	"  if (reference.x == gl_DrawIDARB &&\n"
+	"      reference.y == gl_VertexID)\n"
+	"    color = vec4(0, 1, 0, 1);\n"
+	"  else\n"
+	"    color = vec4(1, 0, 0, 1);\n"
+	"}\n";
+
+static const char fs_text[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = color;\n"
+	"}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+
+	piglit_require_GLSL_version(130);
+
+	piglit_require_extension("GL_ARB_shader_draw_parameters");
+	piglit_require_extension("GL_ARB_base_instance");
+
+	prog = piglit_build_simple_program(vs_text, fs_text);
+
+	glUseProgram(prog);
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass;
+
+	struct {
+		float vertex_array[16];
+		int reference_array[16];
+		int indices[6];
+	} geometry = {
+		.vertex_array = {
+			-1, -1,
+			0, -1,
+			0, 1,
+			-1, 1,
+
+			0, -1,
+			1, -1,
+			1, 1,
+			0, 1,
+		},
+		.reference_array = {
+			0, 0,
+			0, 1,
+			0, 2,
+			0, 3,
+
+			1, 4,
+			1, 5,
+			1, 6,
+			1, 7,
+		}
+	};
+
+	const int indices[12] = {
+		0, 1, 2,
+		0, 2, 3,
+
+		4, 5, 6,
+		4, 6, 7,
+	};
+
+	float green[] = {0, 1, 0, 0};
+
+	GLuint vao, vbo;
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(geometry), &geometry, GL_STATIC_DRAW);
+
+	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
+			      2 * sizeof(GLfloat),
+			      (void *) ((char *) &geometry.vertex_array - (char *) &geometry));
+
+	glVertexAttribIPointer(1, 2, GL_UNSIGNED_INT,
+			       2 * sizeof(int),
+			       (void *) ((char *) &geometry.reference_array - (char *) &geometry));
+
+	/* Enable the attributes */
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
+
+	GLsizei counts[2] = { 6, 6 };
+	const int *indices_array[2] = { &indices[0], &indices[6] };
+
+	glMultiDrawElements(GL_TRIANGLES,
+			    counts,
+			    GL_UNSIGNED_INT,
+			    (const void **) indices_array,
+			    2);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
diff --git a/tests/spec/arb_shader_draw_parameters/drawid.c b/tests/spec/arb_shader_draw_parameters/drawid.c
new file mode 100644
index 0000000..6b65eac
--- /dev/null
+++ b/tests/spec/arb_shader_draw_parameters/drawid.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright © 2011 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 baseinstance.c
+ *
+ * Test that gl_BaseInstanceARB has the correct values. Draw left side
+ * of window with a non-instanced draw call to verify
+ * gl_BaseInstanceARB is 0 in that case, then draw other half with
+ * base instance 7 and verifies that that works.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 31;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_text[] =
+	"#version 330\n"
+	"#extension GL_ARB_shader_draw_parameters: require\n"
+	"\n"
+	"/* This is floating point so we can use immediate mode */\n"
+	"layout(location = 0) in vec2 pos;\n"
+	"layout(location = 1) in vec4 in_color;\n"
+	"out vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_Position = vec4(pos, 0.0, 1.0);\n"
+	"  color = vec4(equal(vec4(gl_DrawIDARB), in_color));\n"
+	"}\n";
+
+static const char fs_text[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"  gl_FragColor = color;\n"
+	"}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+
+	piglit_require_GLSL_version(130);
+
+	piglit_require_extension("GL_ARB_shader_draw_parameters");
+	piglit_require_extension("GL_ARB_base_instance");
+
+	prog = piglit_build_simple_program(vs_text, fs_text);
+
+	glUseProgram(prog);
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass;
+
+	struct {
+		float vertex_array[16];
+		float color_array[32];
+		int indices[6];
+	} geometry = {
+		.vertex_array = {
+			-1, -1,
+			0, -1,
+			0, 1,
+			-1, 1,
+
+			0, -1,
+			1, -1,
+			1, 1,
+			0, 1,
+		},
+		.color_array = {
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+			0.5, 0.0, 0.5, 0.5,
+
+			0.5, 1.0, 0.5, 0.5,
+			0.5, 1.0, 0.5, 0.5,
+			0.5, 1.0, 0.5, 0.5,
+			0.5, 1.0, 0.5, 0.5,
+		}
+	};
+
+	const int indices[12] = {
+		0, 1, 2,
+		0, 2, 3,
+
+		4, 5, 6,
+		4, 6, 7,
+	};
+
+	float green[] = {0, 1, 0, 0};
+
+	GLuint vao, vbo;
+	glGenVertexArrays(1, &vao);
+	glBindVertexArray(vao);
+
+	glGenBuffers(1, &vbo);
+	glBindBuffer(GL_ARRAY_BUFFER, vbo);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(geometry), &geometry, GL_STATIC_DRAW);
+
+	glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
+			      2 * sizeof(GLfloat),
+			      (void *) ((char *) &geometry.vertex_array - (char *) &geometry));
+
+	glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE,
+			      4 * sizeof(GLfloat),
+			      (void *) ((char *) &geometry.color_array - (char *) &geometry));
+
+	/* Enable the attributes */
+	glEnableVertexAttribArray(0);
+	glEnableVertexAttribArray(1);
+
+	GLsizei counts[2] = { 6, 6 };
+	const int *indices_array[2] = { &indices[0], &indices[6] };
+
+	glMultiDrawElements(GL_TRIANGLES,
+			    counts,
+			    GL_UNSIGNED_INT,
+			    (const void **) indices_array,
+			    2);
+
+	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
+				      green);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
2.6.4



More information about the Piglit mailing list