[Piglit] [PATCH] oes_fixed_point: Add ES1 test for fixed-point attribute arrays

Chad Versace chad.versace at linux.intel.com
Mon Jun 3 15:10:28 PDT 2013


Test GL_FIXED with glColorPointer and glVertexPointer. Verifies Mesa
commit 7a9f4d3e.

CC: Kenneth Graunke <kenneth at whitecape.org>
CC: Eric Anholt <eric at anholt.net>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 tests/all.tests                                    |   4 +
 tests/spec/CMakeLists.txt                          |   1 +
 tests/spec/oes_fixed_point/CMakeLists.gles1.txt    |   7 ++
 tests/spec/oes_fixed_point/CMakeLists.txt          |   1 +
 .../oes_fixed_point-attribute-arrays.c             | 128 +++++++++++++++++++++
 5 files changed, 141 insertions(+)
 create mode 100644 tests/spec/oes_fixed_point/CMakeLists.gles1.txt
 create mode 100644 tests/spec/oes_fixed_point/CMakeLists.txt
 create mode 100644 tests/spec/oes_fixed_point/oes_fixed_point-attribute-arrays.c

diff --git a/tests/all.tests b/tests/all.tests
index 417ca08..c8f3bd9 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2200,6 +2200,10 @@ spec['OES_compressed_paletted_texture'] = oes_compressed_paletted_texture
 oes_compressed_paletted_texture['invalid formats'] = PlainExecTest(['arb_texture_compression-invalid-formats', 'paletted'])
 oes_compressed_paletted_texture['invalid formats'].runConcurrent = True
 
+oes_fixed_point = Group()
+spec['OES_fixed_point'] = oes_fixed_point
+oes_fixed_point['attribute-arrays'] = concurrent_test('oes_fixed_point-attribute-arrays')
+
 spec['OES_standard_derivatives'] = Group()
 import_glsl_parser_tests(spec['OES_standard_derivatives'],
 			 os.path.join(testsDir, 'spec', 'oes_standard_derivatives'),
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index df7f6c2..690f463 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -70,6 +70,7 @@ add_subdirectory (ext_texture_array)
 add_subdirectory (ext_texture_integer)
 add_subdirectory (arb_draw_buffers)
 add_subdirectory (oes_draw_texture)
+add_subdirectory (oes_fixed_point)
 add_subdirectory (arb_blend_func_extended)
 add_subdirectory (ext_unpack_subimage)
 add_subdirectory (arb_vertex_array_object)
diff --git a/tests/spec/oes_fixed_point/CMakeLists.gles1.txt b/tests/spec/oes_fixed_point/CMakeLists.gles1.txt
new file mode 100644
index 0000000..df6f08f
--- /dev/null
+++ b/tests/spec/oes_fixed_point/CMakeLists.gles1.txt
@@ -0,0 +1,7 @@
+link_libraries(
+	piglitutil_${piglit_target_api}
+	)
+
+piglit_add_executable(oes_fixed_point-attribute-arrays oes_fixed_point-attribute-arrays.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/oes_fixed_point/CMakeLists.txt b/tests/spec/oes_fixed_point/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/oes_fixed_point/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/oes_fixed_point/oes_fixed_point-attribute-arrays.c b/tests/spec/oes_fixed_point/oes_fixed_point-attribute-arrays.c
new file mode 100644
index 0000000..ea96902
--- /dev/null
+++ b/tests/spec/oes_fixed_point/oes_fixed_point-attribute-arrays.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2013 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
+ * @brief Test GL_FIXED with attribute arrays in OpenGL ES 1.1.
+ *
+ * This test paints the window's left half green and window's right half dark
+ * blue. It uses the GL_FIXED data type for glVertexPointer and
+ * glColorPointer.
+ *
+ * This tests Mesa commit 7a9f4d3e for Intel gen4+.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_es_version = 11;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/* From the GL_OES_fixed_point spec, GL_FIXED represents a
+ * "signed 2's complement S15.16 scaled integer".
+ */
+#define ONE  0x00010000
+#define HALF 0x00008000
+
+/* Vertices for the window's left half. */
+static const GLfixed left_vertices[] = {
+	-ONE, -ONE,
+	   0, -ONE,
+	   0, +ONE,
+	-ONE, +ONE,
+};
+
+/* Vertices for the window's right half. */
+static const GLfixed right_vertices[] = {
+	   0, -ONE,
+	+ONE, -ONE,
+	+ONE, +ONE,
+	   0, +ONE,
+};
+
+/* Green, color of the window's left half. */
+static const GLfloat left_color_float[4] = {0, 1, 0, 1};
+static const GLfixed left_colors_fixed[] = {
+	0, ONE, 0, ONE,
+	0, ONE, 0, ONE,
+	0, ONE, 0, ONE,
+	0, ONE, 0, ONE,
+};
+
+/* Dark blue, color of the window's right half. */
+static const GLfloat right_color_float[4] = {0, 0, 0.5, 1};
+static const GLfixed right_colors_fixed[] = {
+	0, 0, HALF, ONE,
+	0, 0, HALF, ONE,
+	0, 0, HALF, ONE,
+	0, 0, HALF, ONE,
+};
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+
+	glClearColor(0, 0, 0, 1);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glEnableClientState(GL_VERTEX_ARRAY);
+	glEnableClientState(GL_COLOR_ARRAY);
+
+	/* Paint the window's left half. */
+	glVertexPointer(2, GL_FIXED, 0, left_vertices);
+	glColorPointer(4, GL_FIXED, 0, left_colors_fixed);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+	/* Paint the window's right half.*/
+	glVertexPointer(2, GL_FIXED, 0, right_vertices);
+	glColorPointer(4, GL_FIXED, 0, right_colors_fixed);
+	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+	/* Probe the window's left half. */
+	pass &= piglit_probe_rect_rgba(
+			0, 0,
+			piglit_width / 2, piglit_height / 2,
+			left_color_float);
+
+	/* Probe the window's right half. */
+	pass &= piglit_probe_rect_rgba(
+			(piglit_width + 1) / 2, (piglit_height + 1) / 2,
+			(piglit_width - 1) / 2,  (piglit_height - 1) / 2,
+			right_color_float);
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_OES_fixed_point");
+
+	piglit_gen_ortho_projection(-1, 1, -1, 1, -1, 1, false);
+	glViewport(0, 0, piglit_width, piglit_height);
+}
-- 
1.8.1.4



More information about the Piglit mailing list