[Piglit] [PATCH piglit] texsubimage: Optionally use a PBO for the subimage upload

Neil Roberts neil at linux.intel.com
Mon Dec 22 10:15:49 PST 2014


If the pbo option is given on the command line then the image sub-data
will instead be uploaded from a PBO rather than directly from the
malloc'd array. This is worth testing because the drivers often have
different code-paths for PBO uploads.
---
 tests/all.py                  |  3 +++
 tests/texturing/texsubimage.c | 48 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index 1449551..70cb49f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2082,6 +2082,9 @@ add_plain_test(arb_pixel_buffer_object, 'pbo-readpixels-small')
 add_plain_test(arb_pixel_buffer_object, 'pbo-teximage')
 add_plain_test(arb_pixel_buffer_object, 'pbo-teximage-tiling')
 add_plain_test(arb_pixel_buffer_object, 'pbo-teximage-tiling-2')
+add_concurrent_test(arb_pixel_buffer_object, 'texsubimage pbo')
+add_concurrent_test(arb_pixel_buffer_object, 'texsubimage array pbo')
+add_concurrent_test(arb_pixel_buffer_object, 'texsubimage cube_map_array pbo')
 
 # Group ARB_provoking_vertex
 arb_provoking_vertex = {}
diff --git a/tests/texturing/texsubimage.c b/tests/texturing/texsubimage.c
index 615502f..8739f49 100644
--- a/tests/texturing/texsubimage.c
+++ b/tests/texturing/texsubimage.c
@@ -92,6 +92,10 @@ static const struct test_desc texsubimage_test_sets[] = {
 /* List of texture targets to test, terminated by GL_NONE */
 static const GLenum *test_targets;
 
+/* If set to GL_TRUE then the texture sub image upload will be read
+ * from a PBO */
+static GLboolean use_pbo = GL_FALSE;
+
 static const char fragment_1d_array[] =
 	"#extension GL_EXT_texture_array : require\n"
 	"uniform sampler1DArray tex;\n"
@@ -383,6 +387,7 @@ test_format(GLenum target, GLenum intFormat)
 	GLubyte *testImg;
 	GLboolean pass = GL_TRUE;
 	GLuint bw, bh, wMask, hMask, dMask;
+	GLuint pbo = 0;
 	get_format_block_size(intFormat, &bw, &bh);
 	wMask = ~(bw-1);
 	hMask = ~(bh-1);
@@ -427,6 +432,16 @@ test_format(GLenum target, GLenum intFormat)
 		}
 	}
 
+	if (use_pbo) {
+		glGenBuffers(1, &pbo);
+		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
+		glBufferData(GL_PIXEL_UNPACK_BUFFER,
+			     w * h * d * 4,
+			     updated_img,
+			     GL_STATIC_DRAW);
+		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+	}
+
 	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
 
@@ -464,6 +479,9 @@ test_format(GLenum target, GLenum intFormat)
 		assert(ty + th <= h);
 		assert(tz + td <= d);
 
+		if (use_pbo)
+			glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
+
 		/* replace texture region with data from updated image */
 		glPixelStorei(GL_UNPACK_SKIP_PIXELS, tx);
 		glPixelStorei(GL_UNPACK_SKIP_ROWS, ty);
@@ -471,19 +489,22 @@ test_format(GLenum target, GLenum intFormat)
 		if (d > 1) {
 			glTexSubImage3D(target, 0, tx, ty, tz, tw, th, td,
 					srcFormat, GL_UNSIGNED_BYTE,
-					updated_img);
+					use_pbo ? NULL : updated_img);
 		} else if (h > 1) {
 			glTexSubImage2D(target, 0, tx, ty, tw, th,
 					srcFormat, GL_UNSIGNED_BYTE,
-					updated_img);
+					use_pbo ? NULL : updated_img);
 		} else if (w > 1) {
 			glTexSubImage1D(target, 0, tx, tw,
 					srcFormat, GL_UNSIGNED_BYTE,
-					updated_img);
+					use_pbo ? NULL : updated_img);
 		} else {
 			assert(!"Unknown image dimensions");
 		}
 
+		if (use_pbo)
+			glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+
 		/* draw test image */
 		glClear(GL_COLOR_BUFFER_BIT);
 		draw_and_read_texture(w, h, d, testImg);
@@ -510,6 +531,8 @@ test_format(GLenum target, GLenum intFormat)
 	free(updated_img);
 	free(updated_ref);
 	free(testImg);
+	if (use_pbo)
+		glDeleteBuffers(1, &pbo);
 
 	return pass;
 }
@@ -624,29 +647,30 @@ piglit_init(int argc, char **argv)
 		GL_TEXTURE_CUBE_MAP_ARRAY_ARB,
 		GL_NONE
 	};
+	int remaining_argc = 1;
+	int i;
 
 	test_targets = core_targets;
 
-	if (argc > 1) {
-		if (!strcmp(argv[1], "array")) {
+	for (i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "array")) {
 			piglit_require_extension("GL_EXT_texture_array");
 			piglit_require_GLSL();
 			test_targets = array_targets;
-		} else if (!strcmp(argv[1], "cube_map_array")) {
+		} else if (!strcmp(argv[i], "cube_map_array")) {
 			piglit_require_extension
 				("GL_ARB_texture_cube_map_array");
 			piglit_require_GLSL();
 			test_targets = cube_map_array_targets;
+		} else if (!strcmp(argv[i], "pbo")) {
+			piglit_require_extension("GL_ARB_pixel_buffer_object");
+			use_pbo = GL_TRUE;
 		} else {
-			goto handled_targets;
+			argv[remaining_argc++] = argv[i];
 		}
-
-		argc--;
-		argv++;
 	}
- handled_targets:
 
-	fbo_formats_init(argc, argv, 0);
+	fbo_formats_init(remaining_argc, argv, 0);
 	(void) fbo_formats_display;
 
 	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
-- 
1.9.3



More information about the Piglit mailing list