[Piglit] [PATCH 07/16] namespace-pollution: Add glTexSubImage2D as an operation to test

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


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

This test currently passes on i965 even though the
_mesa_meta_pbo_TexSubImage calls _mesa_GenTextures.  Before finishing,
the TexSubImage destroys any object that it created.  This prevents it
from polluting the namespace.

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 | 69 ++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/tests/all.py b/tests/all.py
index cb6deab..8cf5af6 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4609,7 +4609,7 @@ with profile.group_manager(
         PiglitGLTest,
         grouptools.join('object namespace pollution')) as g:
     for object_type in ("buffer", "texture"):
-        for operation in ("glBitmap", "glClear", "glClearTexSubImage", "glCopyPixels", "glCopyTexSubImage2D", "glDrawPixels", "glGenerateMipmap"):
+        for operation in ("glBitmap", "glClear", "glClearTexSubImage", "glCopyPixels", "glCopyTexSubImage2D", "glDrawPixels", "glGenerateMipmap", "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 05d6c83..6c70b33 100644
--- a/tests/general/object-namespace-pollution.c
+++ b/tests/general/object-namespace-pollution.c
@@ -113,6 +113,8 @@ struct enum_value_pair {
 	GLint expected;
 };
 
+#define BUFFER_OFFSET(i) ((char *)NULL + (i))
+
 /**
  * Spare objects used by test cases.
  *
@@ -580,6 +582,72 @@ do_GenerateMipmap(bool silent_skip)
 
 	return piglit_check_gl_error(GL_NO_ERROR) && pass;
 }
+
+static bool
+do_TexSubImage2D(bool silent_skip)
+{
+	const GLuint tex = FIRST_SPARE_OBJECT;
+	const GLuint pbo = FIRST_SPARE_OBJECT;
+	uint8_t data[TEXTURE_DATA_SIZE];
+	bool pass = true;
+
+	if (!piglit_is_extension_supported("GL_EXT_pixel_buffer_object") &&
+	    piglit_get_gl_version() < 30) {
+		if (silent_skip)
+			return true;
+
+		printf("%s requires pixel buffer objects.\n", __func__);
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	if (glIsTexture(tex)) {
+		printf("\t%s,%d: %u is already a texture\n",
+		       __func__, __LINE__, tex);
+		pass = false;
+	}
+
+	if (glIsBuffer(pbo)) {
+		printf("\t%s,%d: %u is already a buffer object\n",
+		       __func__, __LINE__, pbo);
+		pass = false;
+	}
+
+	/* Generate the initial texture object.
+	 *
+	 * NOTE: This must occur before binding the PBO.  Otherwise
+	 * the NULL texel pointer will be interpreted as a zero offset
+	 * in the buffer, and glTexImage2D will upload data from the
+	 * PBO.  This is not the intent of this test.
+	 */
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 16, 16, 0, GL_RGBA,
+		     GL_UNSIGNED_INT_8_8_8_8, NULL);
+
+
+	/* Generate the buffer object that will be used for the PBO upload
+	 * to the texture.
+	 */
+	generate_random_data(data, sizeof(data), GL_PIXEL_UNPACK_BUFFER, pbo);
+
+	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
+	glBufferData(GL_PIXEL_UNPACK_BUFFER, sizeof(data), data,
+		     GL_STATIC_DRAW);
+
+	/* Do the "real" test. */
+	glTexSubImage2D(GL_TEXTURE_2D, 0 /* level */,
+			0 /* xoffset */, 0 /* yoffset */,
+			16 /* width */, 16 /* height */,
+			GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, BUFFER_OFFSET(0));
+
+	/* Final clean up. */
+	glBindTexture(GL_TEXTURE_2D, 0);
+	glDeleteTextures(1, &tex);
+
+	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+	glDeleteBuffers(1, &pbo);
+
+	return piglit_check_gl_error(GL_NO_ERROR) && pass;
+}
 /*@}*/
 
 static const struct {
@@ -593,6 +661,7 @@ static const struct {
 	{ "glCopyTexSubImage2D", do_CopyTexSubImage2D },
 	{ "glDrawPixels", do_DrawPixels },
 	{ "glGenerateMipmap", do_GenerateMipmap },
+	{ "glTexSubImage2D", do_TexSubImage2D },
 };
 
 static const struct {
-- 
2.5.0



More information about the Piglit mailing list