[Piglit] [PATCH] max-texture-size: allow INVALID_VALUE if first TexImage fails with OUT_OF_MEMORY
Brian Paul
brianp at vmware.com
Mon Jun 18 12:01:05 PDT 2012
On 06/14/2012 08:28 PM, Marek Olšák wrote:
> The GL spec says that the behavior of a command returning OUT_OF_MEMORY is
> undefined, therefore the following call to TexSubImage may return INVALID_VALUE.
> (e.g. if TexWidth is 0 because the call to TexImage had no effect because
> of OUT_OF_MEMORY, then the check "xoffset+width> TexWidth" in TexSubImage will
> always set INVALID_VALUE)
> ---
> tests/texturing/max-texture-size.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/tests/texturing/max-texture-size.c b/tests/texturing/max-texture-size.c
> index 92316d4..0767d30 100644
> --- a/tests/texturing/max-texture-size.c
> +++ b/tests/texturing/max-texture-size.c
> @@ -157,6 +157,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> int maxSide, k;
> GLfloat *pixels = NULL;
> GLenum err = GL_NO_ERROR;
> + GLboolean first_oom;
>
> /* Query the largest supported texture size */
> glGetIntegerv(getMaxTarget(target),&maxSide);
> @@ -198,6 +199,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> 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) {
> free(pixels);
> @@ -209,8 +211,10 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> GL_FLOAT, pixels);
>
> err = glGetError();
> - /* Report a GL error other than GL_OUT_OF_MEMORY */
> - if (err != GL_NO_ERROR&& err != GL_OUT_OF_MEMORY) {
> + /* 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)) {
> free(pixels);
> printf("Unexpected GL error: 0x%x\n", err);
> return false;
> @@ -235,6 +239,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> 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) {
> free(pixels);
> @@ -246,8 +251,10 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> GL_RGBA, GL_FLOAT, pixels);
>
> err = glGetError();
> - /* Report a GL error other than GL_OUT_OF_MEMORY */
> - if (err != GL_NO_ERROR&& err != GL_OUT_OF_MEMORY) {
> + /* 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)) {
> free(pixels);
> printf("Unexpected GL error: 0x%x\n", err);
> return false;
> @@ -289,6 +296,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> 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) {
> printf("Unexpected GL error: 0x%x\n", err);
> @@ -300,8 +308,10 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> maxSide/2, maxSide/2, GL_RGBA,
> GL_FLOAT, pixels);
> err = glGetError();
> - /* Report a GL error other than GL_OUT_OF_MEMORY */
> - if (err != GL_NO_ERROR&& err != GL_OUT_OF_MEMORY) {
> + /* 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)) {
> free(pixels);
> printf("Unexpected GL error: 0x%x\n", err);
> return false;
> @@ -326,6 +336,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
>
> case GL_TEXTURE_CUBE_MAP_ARB:
> if (!useProxy) {
> + first_oom = GL_FALSE;
> for (k = 0; k< 6; k++) {
> glTexImage2D(
> GL_TEXTURE_CUBE_MAP_POSITIVE_X + k,
> @@ -333,6 +344,7 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> 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) {
> printf("Unexpected GL error: 0x%x\n", err);
> @@ -353,8 +365,10 @@ ValidateTexSize (GLenum target, GLenum internalformat, bool useProxy)
> return true;
> }
>
> - /* Report a GL error other than GL_OUT_OF_MEMORY */
> - if (err != GL_NO_ERROR&& err != GL_OUT_OF_MEMORY) {
> + /* 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)) {
I think this is a little more readable as:
!(first_oom && err == GL_INVALID_VALUE)
but that might just be me.
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the Piglit
mailing list