[Piglit] [PATCH 16/16] namespace-pollution: Add Apple vertex array as an object to test

Ian Romanick idr at freedesktop.org
Wed Jan 6 16:53:16 PST 2016


From: Ian Romanick <ian.d.romanick at intel.com>

Almost all subtests fail because ARB and Apple VAOs share the same
namespace.  See the ARB_vertex_array_object spec "Interactions with
APPLE_vertex_array_object" section for more details.

NOTE: The following tests fail on i965 (and presumably other drivers
that use meta) on Mesa master and 11.1:

    vertex-array with glbitmap
    vertex-array with glblitframebuffer
    vertex-array with glclear
    vertex-array with glcleartexsubimage
    vertex-array with glcopyimagesubdata
    vertex-array with glcopypixels
    vertex-array with gldrawpixels
    vertex-array with glgeneratemipmap
    vertex-array with glgetteximage
    vertex-array with glgetteximage-compressed
    vertex-array with gltexsubimage2d

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92363
---
 tests/all.py                               |   2 +-
 tests/general/object-namespace-pollution.c | 200 +++++++++++++++++++++++++++++
 2 files changed, 201 insertions(+), 1 deletion(-)

diff --git a/tests/all.py b/tests/all.py
index 9169699..844f433 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4608,7 +4608,7 @@ with profile.group_manager(
 with profile.group_manager(
         PiglitGLTest,
         grouptools.join('object namespace pollution')) as g:
-    for object_type in ("buffer", "framebuffer", "program", "renderbuffer", "texture"):
+    for object_type in ("buffer", "framebuffer", "program", "renderbuffer", "texture", "vertex-array"):
         for operation in ("glBitmap", "glBlitFramebuffer", "glClear", "glClearTexSubImage", "glCopyImageSubData", "glCopyPixels", "glCopyTexSubImage2D", "glDrawPixels", "glGenerateMipmap", "glGetTexImage", "glGetTexImage-compressed", "glTexSubImage2D"):
             g(['object-namespace-pollution', operation, object_type],
               '{} with {}'.format(object_type, operation))
diff --git a/tests/general/object-namespace-pollution.c b/tests/general/object-namespace-pollution.c
index 0fc10bc..a76080f 100644
--- a/tests/general/object-namespace-pollution.c
+++ b/tests/general/object-namespace-pollution.c
@@ -819,6 +819,205 @@ validate_texture(unsigned name)
 }
 /*@}*/
 
+/** \name Methods for operating on Apple vertex array objects */
+/*@{*/
+static float dummy_vao_data[257];
+
+static const int vao_vertex_size[] = { 2, 3, 4 };
+static const int vao_color_size[] = { 3, 4 };
+static const int vao_texture_size[] = { 1, 2, 3, 4 };
+static const GLenum vao_vertex_type[] = { GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE };
+static const GLenum vao_normal_type[] = { GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, GL_DOUBLE };
+static const GLenum vao_color_type[] = {
+	GL_BYTE, GL_UNSIGNED_BYTE,
+	GL_SHORT, GL_UNSIGNED_SHORT,
+	GL_INT,	GL_UNSIGNED_INT,
+	GL_FLOAT,
+	GL_DOUBLE
+};
+
+#define PICK(a, i) a[i % ARRAY_SIZE(a)]
+#define STRIDE(x) (((x) % 16) * sizeof(int))
+
+/* 4 arrays, and each has at most 4 values. */
+#define VAO_DATA_SIZE (4 * 4)
+
+static bool
+create_vertex_array(unsigned name, bool silent_skip)
+{
+	uint8_t data[VAO_DATA_SIZE];
+
+	if (!piglit_is_extension_supported("GL_APPLE_vertex_array_object")) {
+		if (silent_skip)
+			return true;
+
+		printf("%s requires GL_APPLE_vertex_array_object.\n", __func__);
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	if (glIsVertexArrayAPPLE(name)) {
+		printf("\t%s,%d: %u is already a vertex array\n",
+		       __func__, __LINE__, name);
+		return false;
+	}
+
+	glBindVertexArrayAPPLE(name);
+
+	generate_random_data(data,
+			     sizeof(data),
+			     GL_VERTEX_ARRAY_BINDING_APPLE,
+			     name);
+
+	glVertexPointer(PICK(vao_vertex_size, data[0]),
+			PICK(vao_vertex_type, data[1]),
+			STRIDE(data[2]),
+			&dummy_vao_data[data[3]]);
+	glNormalPointer(PICK(vao_normal_type, data[4]),
+			STRIDE(data[5]),
+			&dummy_vao_data[data[6]]);
+	glColorPointer(PICK(vao_color_size, data[7]),
+		       PICK(vao_color_type, data[8]),
+		       STRIDE(data[9]),
+		       &dummy_vao_data[data[10]]);
+	glTexCoordPointer(PICK(vao_texture_size, data[11]),
+			  PICK(vao_vertex_type, data[12]),
+			  STRIDE(data[13]),
+			  &dummy_vao_data[data[14]]);
+
+	glBindVertexArrayAPPLE(0);
+
+	return piglit_check_gl_error(GL_NO_ERROR);
+}
+
+static bool
+check_integer_query(GLenum pname, int expected, unsigned name,
+		    const char *caller)
+{
+	int got;
+
+	glGetIntegerv(pname, &got);
+	if (got != expected) {
+		printf("\t%s,%d: %s of %u: got 0x%x, expected 0x%x\n",
+		       caller, __LINE__,
+		       piglit_get_gl_enum_name(pname),
+		       name,
+		       got, expected);
+		return false;
+	}
+
+	return true;
+}
+
+static bool
+check_pointer_query(GLenum pname, const void *expected, unsigned name,
+		    const char *caller)
+{
+	void *got;
+
+	glGetPointerv(pname, &got);
+	if (got != expected) {
+		printf("\t%s,%d: %s of %u: got %p, expected %p\n",
+		       caller, __LINE__,
+		       piglit_get_gl_enum_name(pname),
+		       name,
+		       got, expected);
+		return false;
+	}
+
+	return true;
+}
+
+static bool
+validate_vertex_array(unsigned name)
+{
+	uint8_t data[VAO_DATA_SIZE];
+	bool pass = true;
+
+	if (!piglit_is_extension_supported("GL_APPLE_vertex_array_object"))
+		return true;
+
+	if (!glIsVertexArrayAPPLE(name)) {
+		printf("\t%s,%d: %u is not a vertex array\n",
+		       __func__, __LINE__, name);
+		return false;
+	}
+
+	glBindVertexArrayAPPLE(name);
+
+	generate_random_data(data,
+			     sizeof(data),
+			     GL_VERTEX_ARRAY_BINDING_APPLE,
+			     name);
+
+	pass = check_integer_query(GL_VERTEX_ARRAY_SIZE,
+				   PICK(vao_vertex_size, data[0]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_VERTEX_ARRAY_TYPE,
+				   PICK(vao_vertex_type, data[1]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_VERTEX_ARRAY_STRIDE,
+				   STRIDE(data[2]),
+				   name,
+				   __func__) && pass;
+	pass = check_pointer_query(GL_VERTEX_ARRAY_POINTER,
+				   &dummy_vao_data[data[3]],
+				   name,
+				   __func__) && pass;
+
+	pass = check_integer_query(GL_NORMAL_ARRAY_TYPE,
+				   PICK(vao_normal_type, data[4]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_NORMAL_ARRAY_STRIDE,
+				   STRIDE(data[5]),
+				   name,
+				   __func__) && pass;
+	pass = check_pointer_query(GL_NORMAL_ARRAY_POINTER,
+				   &dummy_vao_data[data[6]],
+				   name,
+				   __func__) && pass;
+
+	pass = check_integer_query(GL_COLOR_ARRAY_SIZE,
+				   PICK(vao_color_size, data[7]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_COLOR_ARRAY_TYPE,
+				   PICK(vao_color_type, data[8]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_COLOR_ARRAY_STRIDE,
+				   STRIDE(data[9]),
+				   name,
+				   __func__) && pass;
+	pass = check_pointer_query(GL_COLOR_ARRAY_POINTER,
+				   &dummy_vao_data[data[10]],
+				   name,
+				   __func__) && pass;
+
+	pass = check_integer_query(GL_TEXTURE_COORD_ARRAY_SIZE,
+				   PICK(vao_texture_size, data[11]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_TEXTURE_COORD_ARRAY_TYPE,
+				   PICK(vao_vertex_type, data[12]),
+				   name,
+				   __func__) && pass;
+	pass = check_integer_query(GL_TEXTURE_COORD_ARRAY_STRIDE,
+				   STRIDE(data[13]),
+				   name,
+				   __func__) && pass;
+	pass = check_pointer_query(GL_TEXTURE_COORD_ARRAY_POINTER,
+				   &dummy_vao_data[data[14]],
+				   name,
+				   __func__) && pass;
+
+	glBindVertexArrayAPPLE(0);
+	return piglit_check_gl_error(GL_NO_ERROR) && pass;
+}
+/*@}*/
+
 /** \name GL operation wrapper functions. */
 /*@{*/
 static bool
@@ -1320,6 +1519,7 @@ static const struct {
 	{ "program", create_program, validate_program },
 	{ "renderbuffer", create_renderbuffer, validate_renderbuffer },
 	{ "texture", create_texture, validate_texture },
+	{ "vertex-array", create_vertex_array, validate_vertex_array },
 };
 
 static NORETURN void
-- 
2.5.0



More information about the Piglit mailing list