[Mesa-dev] [PATCH 3/4] ARB_Uniform_Buffer_Object: Types test

Vincent Lejeune vljn at ovi.com
Sun Dec 25 09:35:49 PST 2011


---
 tests/all.tests                                    |    1 +
 .../arb_uniform_buffer_object/CMakeLists.gl.txt    |    1 +
 tests/spec/arb_uniform_buffer_object/types.c       |  168 ++++++++++++++++++++
 3 files changed, 170 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_uniform_buffer_object/types.c

diff --git a/tests/all.tests b/tests/all.tests
index de138be..8ad3d89 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1390,6 +1390,7 @@ arb_transform_feedback2['draw-auto'] = PlainExecTest(['arb_transform_feedback2-d
 arb_uniform_buffer_object = Group()
 spec['ARB_uniform_buffer_object'] = arb_uniform_buffer_object
 arb_uniform_buffer_object['standard_layout'] = concurrent_test('arb_uniform_buffer_object_standard_layout')
+arb_uniform_buffer_object['types'] = concurrent_test('arb_uniform_buffer_object_types')
 arb_uniform_buffer_object['draw_test'] = PlainExecTest('arb_uniform_buffer_object_draw_test')
 
 ati_draw_buffers = Group()
diff --git a/tests/spec/arb_uniform_buffer_object/CMakeLists.gl.txt b/tests/spec/arb_uniform_buffer_object/CMakeLists.gl.txt
index 8f46101..f2bf52b 100644
--- a/tests/spec/arb_uniform_buffer_object/CMakeLists.gl.txt
+++ b/tests/spec/arb_uniform_buffer_object/CMakeLists.gl.txt
@@ -13,6 +13,7 @@ link_libraries (
 )
 
 add_executable (arb_uniform_buffer_object_standard_layout standard-layout.c)
+add_executable (arb_uniform_buffer_object_types types.c)
 add_executable (arb_uniform_buffer_object_draw_test draw_test.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_uniform_buffer_object/types.c b/tests/spec/arb_uniform_buffer_object/types.c
new file mode 100644
index 0000000..6c9725d
--- /dev/null
+++ b/tests/spec/arb_uniform_buffer_object/types.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ * Copyright © 2011 Vincent Lejeune
+ *
+ * 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.
+ */
+
+/**
+ * ARB_uniform_buffer_object test
+ *
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100;
+int piglit_height = 100;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+static GLuint prog;
+
+static const struct result {
+	const char* name;
+	GLenum type;
+} expected_result[] =
+	{
+		{ "a", GL_FLOAT },
+		{ "b", GL_FLOAT_VEC2 },
+		{ "c", GL_FLOAT_VEC3 },
+		{ "d", GL_FLOAT_VEC4 },
+		{ "e", GL_INT },
+		{ "f", GL_INT_VEC2 },
+		{ "g", GL_INT_VEC3 },
+		{ "h", GL_INT_VEC4 },
+		{ "i", GL_UNSIGNED_INT },
+		{ "j", GL_UNSIGNED_INT_VEC2 },
+		{ "k", GL_UNSIGNED_INT_VEC3 },
+		{ "l", GL_UNSIGNED_INT_VEC4 },
+		{ "m", GL_BOOL },
+		{ "n", GL_BOOL_VEC2 },
+		{ "o", GL_BOOL_VEC3 },
+		{ "p", GL_BOOL_VEC4 },
+		{ "q", GL_FLOAT_MAT2 },
+		{ "r", GL_FLOAT_MAT3 },
+		{ "s", GL_FLOAT_MAT4 },
+		{ "t", GL_FLOAT_MAT2x3 },
+		{ "u", GL_FLOAT_MAT2x4 },
+		{ "v", GL_FLOAT_MAT3x2 },
+		{ "w", GL_FLOAT_MAT3x4 },
+		{ "x", GL_FLOAT_MAT4x2 },
+		{ "y", GL_FLOAT_MAT4x3 },
+	};
+
+
+
+static const char frag_shader_text[] =
+	"#version 130\n"
+	"#extension GL_ARB_uniform_buffer_object : enable \n"
+	"\n"
+	"layout(std140) uniform test_ubo { \n"
+	"   float a;\n"
+	"   vec2 b;\n"
+	"   vec3 c;\n"
+	"   vec4 d;\n"
+	"   int e;\n"
+	"   ivec2 f;\n"
+	"   ivec3 g;\n"
+	"   ivec4 h;\n"
+	"   uint i;\n"
+	"   uvec2 j;\n"
+	"   uvec3 k;\n"
+	"   uvec4 l;\n"
+	"   bool m;\n"
+	"   bvec2 n;\n"
+	"   bvec3 o;\n"
+	"   bvec4 p;\n"
+	"   mat2 q;\n"
+	"   mat3 r;\n"
+	"   mat4 s;\n"
+	"   mat2x3 t;\n"
+	"   mat2x4 u;\n"
+	"   mat3x2 v;\n"
+	"   mat3x4 w;\n"
+	"   mat4x2 x;\n"
+	"   mat4x3 y;\n"
+	"};\n"
+	"\n"
+	"void main() {}";
+
+static void
+init(void)
+{
+	GLuint fs;
+
+	piglit_require_GLSL_version(130);
+
+	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag_shader_text);
+	prog = piglit_CreateProgram();
+	piglit_AttachShader(prog, fs);
+
+	piglit_LinkProgram(prog);
+	if (!piglit_link_check_status(prog)) {
+		piglit_DeleteProgram(prog);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	piglit_UseProgram(prog);
+	piglit_check_gl_error(0, PIGLIT_FAIL);
+}
+
+static bool
+validate_type()
+{
+	unsigned i, index;
+	GLint type;
+
+	for(i = 0; i < ARRAY_SIZE(expected_result); i++) {
+		const char * temp_name = expected_result[i].name;
+		glGetUniformIndices(prog, 1, &temp_name, &index);
+		if (index == GL_INVALID_INDEX) {
+			printf("%s not found\n",temp_name);
+			return false;
+		}
+		glGetActiveUniformsiv(prog, 1, &index, GL_UNIFORM_TYPE, &type);
+		if (type != expected_result[i].type) {
+			printf("For %s : type is %d, should be %d\n",temp_name,
+				type,expected_result[i].type);
+			return false;
+		}
+	}
+	return true;
+
+}
+
+static void
+check_results_and_exit(void)
+{
+	GLboolean pass = GL_TRUE;
+	pass = validate_type();
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	init();
+	check_results_and_exit();
+}
+
+enum piglit_result piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
-- 
1.7.7



More information about the mesa-dev mailing list