[Piglit] [PATCH] max-texture-size: use width=height=2 for glTexSubImage calls

Brian Paul brianp at vmware.com
Sat Mar 1 11:20:59 PST 2014


Before, we used maxSide/2 which could be very large, causing us to
allocate large amounts of memory with calloc().  This could sometimes
fail.
---
 tests/texturing/max-texture-size.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tests/texturing/max-texture-size.c b/tests/texturing/max-texture-size.c
index 5696337..ef56778 100644
--- a/tests/texturing/max-texture-size.c
+++ b/tests/texturing/max-texture-size.c
@@ -52,6 +52,8 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
+#define SUBTEX_SIZE 2
+
 static const GLenum targets[] = {
 	GL_TEXTURE_1D,
 	GL_TEXTURE_2D,
@@ -322,7 +324,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 	       piglit_get_gl_enum_name(internalformat),
 	       maxSide);
 	/* Allocate and initialize texture data array */
-	pixels = initTexData(target, maxSide/2);
+	pixels = initTexData(target, SUBTEX_SIZE);
 
 	if (pixels == NULL) {
 		printf("Error allocating texture data array for target %s, size %d\n",
@@ -337,7 +339,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 			     0, GL_RGBA, GL_FLOAT, NULL);
 		STOP_ON_ERRORS;
 
-		glTexSubImage1D(target, 0, 0, maxSide/2, GL_RGBA,
+		glTexSubImage1D(target, 0, 0, SUBTEX_SIZE, GL_RGBA,
 				GL_FLOAT, pixels);
 		break;
 
@@ -346,7 +348,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 			     maxSide, 0, GL_RGBA, GL_FLOAT, NULL);
 		STOP_ON_ERRORS;
 
-		glTexSubImage2D(target, 0, 0, 0, maxSide/2, maxSide/2,
+		glTexSubImage2D(target, 0, 0, 0, SUBTEX_SIZE, SUBTEX_SIZE,
 				GL_RGBA, GL_FLOAT, pixels);
 		break;
 
@@ -355,7 +357,7 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 			     maxSide, 0, GL_RGBA, GL_FLOAT, NULL);
 		STOP_ON_ERRORS;
 
-		glTexSubImage2D(target, 0, 0, 0, maxSide/2, maxSide/2,
+		glTexSubImage2D(target, 0, 0, 0, SUBTEX_SIZE, SUBTEX_SIZE,
 				GL_RGBA, GL_FLOAT, pixels);
 		break;
 
@@ -365,9 +367,9 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 			     NULL);
 		STOP_ON_ERRORS;
 
-		glTexSubImage3D(target, 0, 0, 0, 0, maxSide/2,
-				maxSide/2, maxSide/2, GL_RGBA,
-				GL_FLOAT, pixels);
+		glTexSubImage3D(target, 0, 0, 0, 0,
+                                SUBTEX_SIZE, SUBTEX_SIZE, SUBTEX_SIZE,
+                                GL_RGBA, GL_FLOAT, pixels);
 		break;
 
 	case GL_TEXTURE_CUBE_MAP_ARB:
@@ -381,8 +383,8 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 
 		for (k = 0; k < 6; k++) {
 			glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + k,
-					0, 0, 0, maxSide/2, maxSide/2, GL_RGBA,
-					GL_FLOAT, pixels);
+					0, 0, 0, SUBTEX_SIZE, SUBTEX_SIZE,
+					GL_RGBA, GL_FLOAT, pixels);
 
 			STOP_ON_ERRORS;
 		}
-- 
1.7.10.4



More information about the Piglit mailing list