On Fri, Feb 27, 2015 at 4:07 PM, Laura Ekstrand <la...@jlekstrand.net> wrote:
> ---
>  src/mesa/main/texgetimage.c | 51 
> ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 50 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 24df5b6..327a397 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -1339,7 +1339,56 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint 
> level,
>
>     /* Must handle special case GL_TEXTURE_CUBE_MAP. */
>     if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
> -      assert(texObj->NumLayers >= 6);
> +
> +      /* Error checking */
> +      if (texObj->NumLayers < 6) {
> +         /* Not enough image planes for a cube map.  The spec does not say
> +          * what should happen in this case because the user has always
> +          * specified each cube face separately (using
> +          * GL_TEXTURE_CUBE_MAP_POSITIVE_X+i) in previous GL versions.
> +          * This is addressed in Khronos Bug 13223.
> +          */
> +         _mesa_error(ctx, GL_INVALID_OPERATION,
> +                     "glGetCompressedTextureImage("
> +                     "insufficient cube map storage)");
> +         return;
> +      }
> +
> +      /*
> +       * What do we do if the user created a texture with the following code
> +       * and then called this function with its handle?
> +       *
> +       *    GLuint tex;
> +       *    glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &tex);
> +       *    glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
> +       *    glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, ...);
> +       *    glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, ...);
> +       *    glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, ...);
> +       *    // Note: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y not set, or given the
> +       *    // wrong format, or given the wrong size, etc.
> +       *    glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, ...);
> +       *    glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, ...);
> +       *
> +       * A bug has been filed against the spec for this case.  In the
> +       * meantime, we will check for cube completeness.
> +       *
> +       * According to Section 8.17 Texture Completeness in the OpenGL 4.5
> +       * Core Profile spec (30.10.2014):
> +       *    "[A] cube map texture is cube complete if the
> +       *    following conditions all hold true: The [base level] texture
> +       *    images of each of the six cube map faces have identical, 
> positive,
> +       *    and square dimensions. The [base level] images were each 
> specified
> +       *    with the same internal format."
> +       *
> +       * It seems reasonable to check for cube completeness of an arbitrary
> +       * level here so that the returned data has a consistent format and 
> size
> +       * and therefore fits in the user's buffer.
> +       */
Above comment already exist in two files teximage.c and texgetimage.c.  Point to
the existing one instead of duplicating at more places. Better would be to move
the existing comments to above _mesa_cube_level_complete() definition. This
comment also applies to Patch 2/6.

> +      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) {
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to