[Mesa-dev] [PATCH 1/2] mesa: Move TextureView layer error checks before dimension checking.

Kenneth Graunke kenneth at whitecape.org
Thu Mar 20 02:18:34 PDT 2014


If the number of layers is invalid, we're supposed to return
INVALID_VALUE.  _mesa_legal_texture_dimensions detects some of these
cases (i.e. number of layers not being divisible by 6 for cubes), but
results in an INVALID_OPERATION error (which appears to be correct for
more general dimension problems).

Fixes oglconform's texture_view/negative.apiErrors test.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/main/textureview.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

Applies to the 'texture_view_ext' branch of:
git://github.com/chrisforbes/mesa.git

diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c
index 99ccafd..c7756f5 100644
--- a/src/mesa/main/textureview.c
+++ b/src/mesa/main/textureview.c
@@ -560,27 +560,6 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
       break;
    }
 
-   /* If the dimensions of the original texture are larger than the maximum
-    * supported dimensions of the new target, the error INVALID_OPERATION is
-    * generated. For example, if the original texture has a TEXTURE_2D_ARRAY
-    * target and its width is greater than MAX_CUBE_MAP_TEXTURE_SIZE, an error
-    * will be generated if TextureView is called to create a TEXTURE_CUBE_MAP
-    * view.
-    */
-   dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
-                                                 width, height, depth, 0);
-   if (!dimensionsOK) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid width or height or depth)");
-      return;
-   }
-
-   sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
-                                          width, height, depth, 0);
-   if (!sizeOK) {
-      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid texture size)");
-      return;
-   }
-
    /* If <target> is TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_RECTANGLE,
     * or TEXTURE_2D_MULTISAMPLE and <numlayers> does not equal 1, the error
     * INVALID_VALUE is generated.
@@ -623,6 +602,27 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
       break;
    }
 
+   /* If the dimensions of the original texture are larger than the maximum
+    * supported dimensions of the new target, the error INVALID_OPERATION is
+    * generated. For example, if the original texture has a TEXTURE_2D_ARRAY
+    * target and its width is greater than MAX_CUBE_MAP_TEXTURE_SIZE, an error
+    * will be generated if TextureView is called to create a TEXTURE_CUBE_MAP
+    * view.
+    */
+   dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
+                                                 width, height, depth, 0);
+   if (!dimensionsOK) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid width or height or depth)");
+      return;
+   }
+
+   sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
+                                          width, height, depth, 0);
+   if (!sizeOK) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureView(invalid texture size)");
+      return;
+   }
+
    /* If the new texture's target is TEXTURE_CUBE_MAP or
     * TEXTURE_CUBE_MAP_ARRAY, the width and height of the original texture's
     * levels must be equal otherwise the error INVALID_OPERATION is generated.
-- 
1.9.0



More information about the mesa-dev mailing list