[Piglit] [PATCH 08/11] max-texture-size: Report SKIP and stop on GL_OUT_OF_MEMORY errors.

Kenneth Graunke kenneth at whitecape.org
Sun Feb 2 03:13:56 PST 2014


Previously, the test would call TexImage to create the texture image.
If it received a GL_OUT_OF_MEMORY error, it would continue on and call
TexSubImage to try and overwrite a part of the image...which doesn't
exist, because the GL ran out of memory when trying to create it.

Marek tried to work around this by making it accept INVALID_VALUE for
the TexSubImage calls, but Mesa can also report INVALID_OPERATION in
some cases.  Rather than quibbling about error codes, we should step
back and take a sensible action: if a texture image doesn't exist,
don't try and write to it.

When we receive a GL_OUT_OF_MEMORY error, we now report a subtest
result of "skip" and move on.  We can't realistically claim "pass" or
"fail", since we have no idea whether the implementation works or not.

For other errors, we report "fail" and stop.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/texturing/max-texture-size.c | 102 ++++++++++---------------------------
 1 file changed, 26 insertions(+), 76 deletions(-)

diff --git a/tests/texturing/max-texture-size.c b/tests/texturing/max-texture-size.c
index c8fcc41..3c95ffb 100644
--- a/tests/texturing/max-texture-size.c
+++ b/tests/texturing/max-texture-size.c
@@ -229,15 +229,31 @@ test_proxy_texture_size(GLenum target, GLenum internalformat)
 				     piglit_get_gl_enum_name(internalformat));
 }
 
+/* If there were any errors, abort the current test in progress.
+ * For a GL_OUT_OF_MEMORY object, report "skip" - without sufficient memory,
+ * we have no idea if the implementation works or not.  For other errors,
+ * report "fail".
+ */
+#define STOP_ON_ERRORS                                              \
+	do {                                                        \
+		GLenum err = glGetError();                          \
+		if (err == GL_OUT_OF_MEMORY) {                      \
+			result = PIGLIT_SKIP;                       \
+			goto out;                                   \
+		} else if (err != GL_NO_ERROR) {                    \
+			printf("Unexpected GL error: 0x%x\n", err); \
+			result = PIGLIT_FAIL;                       \
+			goto out;                                   \
+		}                                                   \
+	} while (0);
+
 static void
 test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 {
 	GLuint tex;
 	int maxSide, k;
 	GLfloat *pixels = NULL;
-	GLenum err = GL_NO_ERROR;
-	GLboolean first_oom;
-	enum piglit_result result = PIGLIT_FAIL;
+	enum piglit_result result = PIGLIT_PASS;
 
 	glGenTextures(1, &tex);
 	glBindTexture(target, tex);
@@ -265,97 +281,46 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 	case GL_TEXTURE_1D:
 		glTexImage1D(target, 0, internalformat, maxSide,
 			     0, GL_RGBA, GL_FLOAT, NULL);
-
-		err = glGetError();
-		first_oom = err == GL_OUT_OF_MEMORY;
-		/* Report a GL error other than GL_OUT_OF_MEMORY */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
-			goto out;
-		}
+		STOP_ON_ERRORS;
 
 		glTexSubImage1D(target, 0, 0, maxSide/2, GL_RGBA,
 				GL_FLOAT, pixels);
-
-		err = glGetError();
-		/* Report a GL error other than GL_OUT_OF_MEMORY and
-		 * INVALID_VALUE */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
-		    (!first_oom || err != GL_INVALID_VALUE)) {
-			goto out;
-		}
 		break;
 
 	case GL_TEXTURE_2D:
 		glTexImage2D(target, 0, internalformat, maxSide,
 			     maxSide, 0, GL_RGBA, GL_FLOAT, NULL);
-
-		err = glGetError();
-		first_oom = err == GL_OUT_OF_MEMORY;
-		/* Report a GL error other than GL_OUT_OF_MEMORY */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
-			goto out;
-		}
+		STOP_ON_ERRORS;
 
 		glTexSubImage2D(target, 0, 0, 0, maxSide/2, maxSide/2,
 				GL_RGBA, GL_FLOAT, pixels);
-
-		err = glGetError();
-		/* Report a GL error other than GL_OUT_OF_MEMORY and
-		 * INVALID_VALUE */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
-		    (!first_oom || err != GL_INVALID_VALUE)) {
-			goto out;
-		}
 		break;
 
 	case GL_TEXTURE_RECTANGLE:
 		glTexImage2D(target, 0, internalformat, maxSide,
 			     maxSide, 0, GL_RGBA, GL_FLOAT, NULL);
-
-		err = glGetError();
-		/* Report a GL error other than GL_OUT_OF_MEMORY */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
-			goto out;
-		}
+		STOP_ON_ERRORS;
 		break;
 
 	case GL_TEXTURE_3D:
 		glTexImage3D(target, 0, internalformat, maxSide,
 			     maxSide, maxSide, 0, GL_RGBA, GL_FLOAT,
 			     NULL);
-
-		err = glGetError();
-		first_oom = err == GL_OUT_OF_MEMORY;
-		/* Report a GL error other than GL_OUT_OF_MEMORY */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY) {
-			goto out;
-		}
+		STOP_ON_ERRORS;
 
 		glTexSubImage3D(target, 0, 0, 0, 0, maxSide/2,
 				maxSide/2, maxSide/2, GL_RGBA,
 				GL_FLOAT, pixels);
-		err = glGetError();
-		/* Report a GL error other than GL_OUT_OF_MEMORY and
-		 * INVALID_VALUE */
-		if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
-		    (!first_oom || err != GL_INVALID_VALUE)) {
-			goto out;
-		}
 		break;
 
 	case GL_TEXTURE_CUBE_MAP_ARB:
-		first_oom = GL_FALSE;
 		for (k = 0; k < 6; k++) {
 			glTexImage2D(
 			GL_TEXTURE_CUBE_MAP_POSITIVE_X + k,
 			0, internalformat, maxSide, maxSide, 0,
 			GL_RGBA, GL_FLOAT, NULL);
 
-			err = glGetError();
-			first_oom = first_oom || err == GL_OUT_OF_MEMORY;
-			/* Report a GL error other than GL_OUT_OF_MEMORY */
-			if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY)
-				goto out;
+			STOP_ON_ERRORS;
 		}
 
 		for (k = 0; k < 6; k++) {
@@ -364,29 +329,14 @@ test_non_proxy_texture_size(GLenum target, GLenum internalformat)
 			0, 0, 0, maxSide/2, maxSide/2, GL_RGBA,
 			GL_FLOAT, pixels);
 
-			err = glGetError();
-			if (err == GL_OUT_OF_MEMORY) {
-				result = PIGLIT_PASS;
-				goto out;
-			}
-
-			/* Report a GL error other than GL_OUT_OF_MEMORY and
-			 * INVALID_VALUE */
-			if (err != GL_NO_ERROR && err != GL_OUT_OF_MEMORY &&
-			    (!first_oom || err != GL_INVALID_VALUE)) {
-				goto out;
-			}
+			STOP_ON_ERRORS;
 		}
 		break;
 	}
 
-	/* Apparently we succeeded. */
-	result = PIGLIT_PASS;
+	STOP_ON_ERRORS;
 
 out:
-	if (result == PIGLIT_FAIL)
-		printf("Unexpected GL error: 0x%x\n", err);
-
 	glDeleteTextures(1, &tex);
 	free(pixels);
 
-- 
1.8.5.2



More information about the Piglit mailing list