[Piglit] [PATCH 7/8] arb_texture_view-texsubimage-levels: add PBO upload

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


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

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

diff --git a/tests/all.py b/tests/all.py
index a632e4c..f9ceef2 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2496,6 +2496,7 @@ with profile.group_manager(
     g(['arb_texture_view-lifetime-format'], 'lifetime-format')
     g(['arb_texture_view-getteximage-srgb'], 'getteximage-srgb')
     g(['arb_texture_view-texsubimage-levels'], 'texsubimage-levels')
+    g(['arb_texture_view-texsubimage-levels', 'pbo'], 'texsubimage-levels pbo')
     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')
diff --git a/tests/spec/arb_texture_view/texsubimage-levels.c b/tests/spec/arb_texture_view/texsubimage-levels.c
index 85986ca..20d956f 100644
--- a/tests/spec/arb_texture_view/texsubimage-levels.c
+++ b/tests/spec/arb_texture_view/texsubimage-levels.c
@@ -55,17 +55,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 texture with full miptree */
 	glGenTextures(1, &tex);
 	glBindTexture(GL_TEXTURE_2D, tex);
 	glTexStorage2D(GL_TEXTURE_2D, NUM_LEVELS,
 		       GL_RGBA8, TEX_SIZE, TEX_SIZE);
 
+	if (use_pbo) {
+		glGenBuffers(1, &buffer);
+		glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
+	}
+
 	for (i=0; i < NUM_LEVELS; i++) {
 		int dim = TEX_SIZE >> i;
 		GLubyte *pixels = create_solid_image(dim, dim, 1, 4, i);
@@ -73,9 +87,14 @@ piglit_init(int argc, char **argv)
 			printf("Failed to allocate image for level %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);
+		}
 		glTexSubImage2D(GL_TEXTURE_2D,
 				i, 0, 0, dim, dim,
-				GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+				GL_RGBA, GL_UNSIGNED_BYTE, use_pbo ? NULL : pixels);
 		free(pixels);
 	}
 
@@ -97,8 +116,13 @@ piglit_init(int argc, char **argv)
 			printf("Failed to allocate image for view level %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);
+		}
 		glTexSubImage2D(GL_TEXTURE_2D, i, 0, 0, dim, dim,
-				GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+				GL_RGBA, GL_UNSIGNED_BYTE, use_pbo ? NULL : pixels);
 		free(pixels);
 	}
 
@@ -130,5 +154,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