[Piglit] [PATCH 6/8] arb_texture_view-texsubimage-layers: add PBO upload

Nicolai Hähnle nhaehnle at gmail.com
Mon Jan 18 13:40:26 PST 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 tests/all.py                                     |  1 +
 tests/spec/arb_texture_view/texsubimage-layers.c | 31 ++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index 049ffc0..a632e4c 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2497,6 +2497,7 @@ with profile.group_manager(
     g(['arb_texture_view-getteximage-srgb'], 'getteximage-srgb')
     g(['arb_texture_view-texsubimage-levels'], 'texsubimage-levels')
     g(['arb_texture_view-texsubimage-layers'], 'texsubimage-layers')
+    g(['arb_texture_view-texsubimage-layers', 'pbo'], 'texsubimage-layers pbo')
     g(['arb_texture_view-clear-into-view-2d'], 'clear-into-view-2d')
     g(['arb_texture_view-clear-into-view-2d-array'],
       'clear-into-view-2d-array')
diff --git a/tests/spec/arb_texture_view/texsubimage-layers.c b/tests/spec/arb_texture_view/texsubimage-layers.c
index c2b250b..b1601be 100644
--- a/tests/spec/arb_texture_view/texsubimage-layers.c
+++ b/tests/spec/arb_texture_view/texsubimage-layers.c
@@ -54,17 +54,31 @@ void
 piglit_init(int argc, char **argv)
 {
 	GLuint tex, view;
+	GLuint buffer;
 	int i, j;
+	bool use_pbo = false;
 	bool pass = true;
 
 	piglit_require_extension("GL_ARB_texture_view");
 
+	for (i = 1; i < argc; ++i) {
+		if (strcmp(argv[i], "pbo") == 0) {
+			piglit_require_extension("GL_ARB_pixel_buffer_object");
+			use_pbo = true;
+		}
+	}
+
 	/* build a 2d array texture; no mip levels */
 	glGenTextures(1, &tex);
 	glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
 	glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1,
 		GL_RGBA8, TEX_SIZE, TEX_SIZE, NUM_LAYERS);
 
+	if (use_pbo) {
+		glGenBuffers(1, &buffer);
+		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
+	}
+
 	for (i=0; i < NUM_LAYERS; i++) {
 		GLubyte *pixels = create_solid_image(TEX_SIZE, TEX_SIZE,
 						     1, 4, i);
@@ -72,9 +86,14 @@ piglit_init(int argc, char **argv)
 			printf("Allocation failure for layer %d\n", i);
 			piglit_report_result(PIGLIT_FAIL);
 		}
+
+		if (use_pbo) {
+			glBufferData(GL_PIXEL_UNPACK_BUFFER, TEX_SIZE * TEX_SIZE * 4,
+				     pixels, GL_STREAM_DRAW);
+		}
 		glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0,
 				0, 0, i, TEX_SIZE, TEX_SIZE, 1,
-				GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+				GL_RGBA, GL_UNSIGNED_BYTE, use_pbo ? NULL : pixels);
 		free(pixels);
 	}
 
@@ -95,9 +114,14 @@ piglit_init(int argc, char **argv)
 			printf("Allocation failure for view layer %d\n", i);
 			piglit_report_result(PIGLIT_FAIL);
 		}
+
+		if (use_pbo) {
+			glBufferData(GL_PIXEL_UNPACK_BUFFER, TEX_SIZE * TEX_SIZE * 4,
+				     pixels, GL_STREAM_DRAW);
+		}
 		glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0,
 				0, 0, i, TEX_SIZE, TEX_SIZE, 1,
-				GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+				GL_RGBA, GL_UNSIGNED_BYTE, use_pbo ? NULL : pixels);
 		free(pixels);
 	}
 
@@ -128,5 +152,8 @@ piglit_init(int argc, char **argv)
 						      expected_color) && pass;
 	}
 
+	if (use_pbo)
+		glDeleteBuffers(1, &buffer);
+
 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
 }
-- 
2.5.0



More information about the Piglit mailing list