main: Checking for cube completeness in GetCompressedTextureImage.
authorLaura Ekstrand <laura@jlekstrand.net>
Tue, 6 Jan 2015 22:05:41 +0000 (14:05 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Mon, 9 Mar 2015 20:33:53 +0000 (13:33 -0700)
v2: Review from Anuj Phogat
   - Remove redundant copies of the cube map block comment
   - Replace redundant "if (!texImage) return;" statements with
     assert(texImage)

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/texgetimage.c

index 9411db81614db9d6446bd955d70580c88211c8f8..255d365599af1caf5a25705cefca3528993c0e10 100644 (file)
@@ -1303,7 +1303,16 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level,
 
    /* Must handle special case GL_TEXTURE_CUBE_MAP. */
    if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
 
    /* Must handle special case GL_TEXTURE_CUBE_MAP. */
    if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
-      assert(texObj->NumLayers >= 6);
+
+      /* Make sure the texture object is a proper cube.
+       * (See texturesubimage in teximage.c for details on why this check is
+       * performed.)
+       */
+      if (!_mesa_cube_level_complete(texObj, level)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glGetCompressedTextureImage(cube map incomplete)");
+         return;
+      }
 
       /* Copy each face. */
       for (i = 0; i < 6; ++i) {
 
       /* Copy each face. */
       for (i = 0; i < 6; ++i) {