[Mesa-dev] [PATCH 08/13] mesa: overhaul the glGetTexImage code

Brian Paul brianp at vmware.com
Mon Jul 13 18:21:08 PDT 2015


1. Reorganize the error checking code.
2. Lay groundwork for getting sub images.
3. Implement _mesa_GetnTexImageARB(), _mesa_GetTexImage() and
   _mesa_GetTextureImage() all in terms of get_texture_image().
---
 src/mesa/main/texgetimage.c | 539 +++++++++++++++++++++++++++++---------------
 1 file changed, 352 insertions(+), 187 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index e180a4c..b74517a 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -49,6 +49,13 @@
 #include "format_utils.h"
 #include "pixeltransfer.h"
 
+
+/** Some magic numbers used when getting whole texture image */
+#define WHOLE_WIDTH -123
+#define WHOLE_HEIGHT -123
+#define WHOLE_DEPTH -123
+
+
 /**
  * Can the given type represent negative values?
  */
@@ -891,27 +898,59 @@ legal_getteximage_target(struct gl_context *ctx, GLenum target, bool dsa)
 
 
 /**
- * Do error checking for a glGetTex(ture)Image() call.
- * \return GL_TRUE if any error, GL_FALSE if no errors.
+ * Do error checking for all (non-compressed) get-texture-image functions.
+ * \param target  user-provided texture target, or 0 if called from DSA function
+ * \return true if any error, false if no errors.
  */
-static GLboolean
+static bool
 getteximage_error_check(struct gl_context *ctx,
-                        struct gl_texture_image *texImage,
+                        struct gl_texture_object *texObj,
                         GLenum target, GLint level,
                         GLenum format, GLenum type, GLsizei clientMemSize,
-                        GLvoid *pixels, bool dsa)
+                        GLvoid *pixels, const char *caller)
 {
-   const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
-   const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
-   GLenum baseFormat;
-   const char *suffix = dsa ? "ture" : "";
+   struct gl_texture_image *texImage;
+   GLenum baseFormat, err;
+   GLint maxLevels;
+   const bool dsa = (target == 0);
 
-   assert(texImage);
-   assert(maxLevels != 0);
+   if (!texObj || texObj->Target == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture)", caller);
+      return true;
+   }
+
+   if (dsa) {
+      target = texObj->Target;
+   }
+
+   if (!legal_getteximage_target(ctx, target, dsa)) {
+      _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%s)", caller,
+                  _mesa_lookup_enum_by_nr(texObj->Target));
+      return true;
+   }
+
+   err = _mesa_error_check_format_and_type(ctx, format, type);
+   if (err != GL_NO_ERROR) {
+      _mesa_error(ctx, err, "%s(format/type)", caller);
+      return true;
+   }
+
+   maxLevels = _mesa_max_texture_levels(ctx, target);
    if (level < 0 || level >= maxLevels) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glGetTex%sImage(level out of range)", suffix);
-      return GL_TRUE;
+                  "%s(level = %d)", caller, level);
+      return true;
+   }
+
+   if (target == GL_TEXTURE_CUBE_MAP) {
+      target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+   }
+
+   texImage = _mesa_select_tex_image(texObj, target, level);
+   if (!texImage) {
+      /* non-existant texture image */
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+      return true;
    }
 
    /*
@@ -927,247 +966,325 @@ getteximage_error_check(struct gl_context *ctx,
    if (_mesa_is_color_format(format)
        && !_mesa_is_color_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTex%sImage(format mismatch)", suffix);
-      return GL_TRUE;
+                  "%s(format mismatch)", caller);
+      return true;
    }
    else if (_mesa_is_depth_format(format)
             && !_mesa_is_depth_format(baseFormat)
             && !_mesa_is_depthstencil_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTex%sImage(format mismatch)", suffix);
-      return GL_TRUE;
+                  "%s(format mismatch)", caller);
+      return true;
    }
    else if (_mesa_is_stencil_format(format)
             && !ctx->Extensions.ARB_texture_stencil8) {
       _mesa_error(ctx, GL_INVALID_ENUM,
-                  "glGetTex%sImage(format=GL_STENCIL_INDEX)", suffix);
-      return GL_TRUE;
+                  "%s(format=GL_STENCIL_INDEX)", caller);
+      return true;
    }
    else if (_mesa_is_ycbcr_format(format)
             && !_mesa_is_ycbcr_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTex%sImage(format mismatch)", suffix);
-      return GL_TRUE;
+                  "%s(format mismatch)", caller);
+      return true;
    }
    else if (_mesa_is_depthstencil_format(format)
             && !_mesa_is_depthstencil_format(baseFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTex%sImage(format mismatch)", suffix);
-      return GL_TRUE;
+                  "%s(format mismatch)", caller);
+      return true;
    }
    else if (!_mesa_is_stencil_format(format) &&
             _mesa_is_enum_format_integer(format) !=
             _mesa_is_format_integer(texImage->TexFormat)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGetTex%sImage(format mismatch)", suffix);
-      return GL_TRUE;
+                  "%s(format mismatch)", caller);
+      return true;
    }
 
-   if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
-                                  texImage->Height, texImage->Depth,
+   return false;
+}
+
+
+/**
+ * Do PBO-related error checking.
+ * \return true if there was an error (or the GetTexImage is to be a no-op)
+ */
+static bool
+pbo_error_check(struct gl_context *ctx, GLenum target,
+                GLsizei width, GLsizei height, GLsizei depth,
+                GLenum format, GLenum type, GLsizei clientMemSize,
+                GLvoid *pixels,
+                const char *caller)
+{
+   const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+
+   if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, width, height, depth,
                                   format, type, clientMemSize, pixels)) {
       if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetTex%sImage(out of bounds PBO access)", suffix);
+                     "%s(out of bounds PBO access)", caller);
       } else {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "%s(out of bounds access:"
-                     " bufSize (%d) is too small)",
-                     dsa ? "glGetTextureImage" : "glGetnTexImageARB",
-                     clientMemSize);
+                     "%s(out of bounds access: bufSize (%d) is too small)",
+                     caller, clientMemSize);
       }
-      return GL_TRUE;
+      return true;
    }
 
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
       /* PBO should not be mapped */
       if (_mesa_check_disallowed_mapping(ctx->Pack.BufferObj)) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glGetTex%sImage(PBO is mapped)", suffix);
-         return GL_TRUE;
+                     "%s(PBO is mapped)", caller);
+         return true;
       }
    }
 
-   return GL_FALSE;
+   if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {
+      /* not an error, do nothing */
+      return true;
+   }
+
+   return false;
 }
 
 
 /**
- * This is the implementation for glGetnTexImageARB, glGetTextureImage,
- * and glGetTexImage.
- *
- * Requires caller to pass in texImage object because _mesa_GetTextureImage
- * must handle the GL_TEXTURE_CUBE_MAP target.
- *
- * \param target texture target.
- * \param level image level.
- * \param format pixel data format for returned image.
- * \param type pixel data type for returned image.
- * \param bufSize size of the pixels data buffer.
- * \param pixels returned pixel data.
- * \param dsa True when the caller is an ARB_direct_state_access function,
- *            false otherwise
+ * Error-check the offset and size arguments to
+ * glGet[Compressed]TextureSubImage().
+ * \return true if error, false if no error.
  */
-static void
-get_texture_image(struct gl_context *ctx,
-                  struct gl_texture_object *texObj,
-                  struct gl_texture_image *texImage, GLenum target,
-                  GLint level, GLenum format, GLenum type,
-                  GLsizei bufSize, GLvoid *pixels, bool dsa)
+static bool
+dimensions_error_check(struct gl_context *ctx,
+                       const struct gl_texture_image *texImage,
+                       GLint xoffset, GLint yoffset, GLint zoffset,
+                       GLsizei width, GLsizei height, GLsizei depth,
+                       const char *caller)
 {
-   assert(texObj);
-   assert(texImage);
+   const GLenum target = texImage->TexObject->Target;
 
-   FLUSH_VERTICES(ctx, 0);
+   switch (target) {
+   case GL_TEXTURE_1D:
+      if (yoffset != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(1D, yoffset = %d)", caller, yoffset);
+         return true;
+      }
+      if (height != 1) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(1D, height = %d)", caller, height);
+         return true;
+      }
+      /* fall-through */
+   case GL_TEXTURE_1D_ARRAY:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE:
+      if (zoffset != 0) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(zoffset = %d)", caller, zoffset);
+         return true;
+      }
+      if (depth != 1) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(depth = %d)", caller, depth);
+         return true;
+      }
+      break;
 
-   /*
-    * Legal target checking has been moved up to GetnTexImage and
-    * GetTextureImage so that it can be caught before receiving a NULL
-    * texImage object and exiting.
-    */
+   case GL_TEXTURE_CUBE_MAP:
+      /* we'll return the faces indicated by the zoffset and depth */
+      /* XXX */
 
-   if (getteximage_error_check(ctx, texImage, target, level, format,
-                               type, bufSize, pixels, dsa)) {
-      return;
+   default:
+      ; /* nothing */
    }
 
-   if (!_mesa_is_bufferobj(ctx->Pack.BufferObj) && !pixels) {
-      /* not an error, do nothing */
-      return;
+   if (xoffset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(xoffset = %d)", caller, xoffset);
+      return true;
    }
 
-   if (_mesa_is_zero_size_texture(texImage))
-      return;
-
-   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
-      _mesa_debug(ctx, "glGetTex%sImage(tex %u) format = %s, w=%d, h=%d,"
-                  " dstFmt=0x%x, dstType=0x%x\n",
-                  dsa ? "ture": "",
-                  texObj->Name,
-                  _mesa_get_format_name(texImage->TexFormat),
-                  texImage->Width, texImage->Height,
-                  format, type);
+   if (yoffset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(yoffset = %d)", caller, yoffset);
+      return true;
    }
 
-   _mesa_lock_texture(ctx, texObj);
-   {
-      ctx->Driver.GetTexSubImage(ctx, 0, 0, 0,
-                                 texImage->Width, texImage->Height,
-                                 texImage->Depth,
-                                 format, type, pixels, texImage);
+   if (zoffset < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(zoffset = %d)", caller, zoffset);
+      return true;
    }
-   _mesa_unlock_texture(ctx, texObj);
-}
 
-/**
- * Get texture image.  Called by glGetTexImage.
- *
- * \param target texture target.
- * \param level image level.
- * \param format pixel data format for returned image.
- * \param type pixel data type for returned image.
- * \param bufSize size of the pixels data buffer.
- * \param pixels returned pixel data.
- */
-void GLAPIENTRY
-_mesa_GetnTexImageARB(GLenum target, GLint level, GLenum format,
-                      GLenum type, GLsizei bufSize, GLvoid *pixels)
-{
-   struct gl_texture_object *texObj;
-   struct gl_texture_image *texImage;
-   GLenum err;
-   GET_CURRENT_CONTEXT(ctx);
+   if (xoffset + width > texImage->Width) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(xoffset %d + width %d > %u)",
+                  caller, xoffset, width, texImage->Width);
+      return true;
+   }
 
-   /*
-    * This has been moved here because a format/type mismatch can cause a NULL
-    * texImage object, which in turn causes the mismatch error to be
-    * ignored.
-    */
-   err = _mesa_error_check_format_and_type(ctx, format, type);
-   if (err != GL_NO_ERROR) {
-      _mesa_error(ctx, err, "glGetnTexImage(format/type)");
-      return;
+   if (yoffset + height > texImage->Height) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+                  "%s(yoffset %d + height %d > %u)",
+                  caller, yoffset, height, texImage->Height);
+      return true;
    }
 
-   /*
-    * Legal target checking has been moved here to prevent exiting with a NULL
-    * texImage object.
-    */
-   if (!legal_getteximage_target(ctx, target, false)) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetnTexImage(target=0x%x)",
-                  target);
-      return;
+   if (target == GL_TEXTURE_CUBE_MAP) {
+      if (zoffset + depth > 6) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(zoffset %d + depth %d > 6(cube))",
+                     caller, zoffset, depth);
+         return true;
+      }
+   }
+   else if (target == GL_TEXTURE_CUBE_MAP_ARRAY) {
+      const GLuint level = texImage->Level;
+      const struct gl_texture_image *face0 =
+         _mesa_select_tex_image(texImage->TexObject,
+                                GL_TEXTURE_CUBE_MAP_ARRAY, level);
+      if (!face0 || zoffset + depth > face0->Depth) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(zoffset %d + depth %d > %d)",
+                     caller, zoffset, depth,
+                     face0 ? face0->Depth : 0);
+         return true;
+      }
+   }
+   else {
+      /* 2D array or 3D texture */
+      if (zoffset + depth > texImage->Depth) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "%s(zoffset %d + depth %d > %u)",
+                     caller, zoffset, depth, texImage->Depth);
+         return true;
+      }
    }
 
-   texObj = _mesa_get_current_tex_object(ctx, target);
-   if (!texObj)
-      return;
+   /* Extra checks for compressed textures */
+   {
+      GLuint bw, bh;
+      _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
+      if (bw > 1 || bh > 1) {
+         /* offset must be multiple of block size */
+         if (xoffset % bw != 0) {
+            _mesa_error(ctx, GL_INVALID_VALUE,
+                        "%s(xoffset = %d)", caller, xoffset);
+            return true;
+         }
+         if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) {
+            if (yoffset % bh != 0) {
+               _mesa_error(ctx, GL_INVALID_VALUE,
+                           "%s(yoffset = %d)", caller, yoffset);
+               return true;
+            }
+         }
 
-   texImage = _mesa_select_tex_image(texObj, target, level);
-   if (!texImage)
-      return;
+         /* The size must be a multiple of bw x bh, or we must be using a
+          * offset+size that exactly hits the edge of the image.
+          */
+         if ((width % bw != 0) &&
+             (xoffset + width != (GLint) texImage->Width)) {
+            _mesa_error(ctx, GL_INVALID_VALUE,
+                        "%s(width = %d)", caller, width);
+            return true;
+         }
 
-   get_texture_image(ctx, texObj, texImage, target, level, format, type,
-                     bufSize, pixels, false);
-}
+         if ((height % bh != 0) &&
+             (yoffset + height != (GLint) texImage->Height)) {
+            _mesa_error(ctx, GL_INVALID_VALUE,
+                        "%s(height = %d)", caller, height);
+            return true;
+         }
+      }
+   }
 
+   if (width == 0 || height == 0 || depth == 0) {
+      /* Not an error, but nothing to do.  Return 'true' so that the
+       * caller simply returns.
+       */
+      return true;
+   }
 
-void GLAPIENTRY
-_mesa_GetTexImage( GLenum target, GLint level, GLenum format,
-                   GLenum type, GLvoid *pixels )
-{
-   _mesa_GetnTexImageARB(target, level, format, type, INT_MAX, pixels);
+   return false;
 }
 
+
 /**
- * Get texture image.
- *
- * \param texture texture name.
+ * Common code for all (uncompressed) get-texture-image functions.
+ * \param texObj  the texture object (should not be null)
+ * \param target  user-provided target, or 0 for DSA
  * \param level image level.
  * \param format pixel data format for returned image.
  * \param type pixel data type for returned image.
  * \param bufSize size of the pixels data buffer.
  * \param pixels returned pixel data.
+ * \param caller  name of calling function
  */
-void GLAPIENTRY
-_mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
-                      GLenum type, GLsizei bufSize, GLvoid *pixels)
+static void
+get_texture_image(struct gl_context *ctx,
+                  struct gl_texture_object *texObj,
+                  GLenum target, GLint level,
+                  GLint xoffset, GLint yoffset, GLint zoffset,
+                  GLsizei width, GLsizei height, GLint depth,
+                  GLenum format, GLenum type,
+                  GLsizei bufSize, GLvoid *pixels, const char *caller)
 {
-   struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
-   int i;
-   GLint image_stride;
-   GLenum err;
-   GET_CURRENT_CONTEXT(ctx);
+   unsigned firstFace, numFaces, i;
+   GLint imageStride;
 
-   /*
-    * This has been moved here because a format/type mismatch can cause a NULL
-    * texImage object, which in turn causes the mismatch error to be
-    * ignored.
-    */
-   err = _mesa_error_check_format_and_type(ctx, format, type);
-   if (err != GL_NO_ERROR) {
-      _mesa_error(ctx, err, "glGetTextureImage(format/type)");
+   FLUSH_VERTICES(ctx, 0);
+
+   if (getteximage_error_check(ctx, texObj, target, level,
+                               format, type, bufSize, pixels, caller)) {
       return;
    }
 
-   texObj = _mesa_lookup_texture_err(ctx, texture, "glGetTextureImage");
-   if (!texObj)
+   texImage = _mesa_select_tex_image(texObj, target, level);
+   assert(texImage);  /* should have been error checked already */
+
+   /* check sub-image dimensions */
+   if (width == WHOLE_WIDTH && height == WHOLE_HEIGHT && depth == WHOLE_DEPTH) {
+      /* getting whole image */
+      width = texImage->Width;
+      height = texImage->Height;
+      depth = texImage->Depth;
+   }
+   else {
+      /* getting sub image */
+      if (dimensions_error_check(ctx, texImage, xoffset, yoffset, zoffset,
+                                 width, height, depth, caller)) {
+         return;
+      }
+   }
+
+   if (pbo_error_check(ctx, target, width, height, depth,
+                       format, type, bufSize, pixels, caller)) {
       return;
+   }
 
-   /*
-    * Legal target checking has been moved here to prevent exiting with a NULL
-    * texImage object.
-    */
-   if (!legal_getteximage_target(ctx, texObj->Target, true)) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetTextureImage(target=%s)",
-                  _mesa_lookup_enum_by_nr(texObj->Target));
+   if (_mesa_is_zero_size_texture(texImage)) {
+      /* no image data to return */
       return;
    }
 
-   /* Must handle special case GL_TEXTURE_CUBE_MAP. */
-   if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
+   if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
+      _mesa_debug(ctx, "%s(tex %u) format = %s, w=%d, h=%d,"
+                  " dstFmt=0x%x, dstType=0x%x\n",
+                  caller, texObj->Name,
+                  _mesa_get_format_name(texImage->TexFormat),
+                  texImage->Width, texImage->Height,
+                  format, type);
+   }
 
+   if (target == 0) {
+      target = texObj->Target;
+   }
+
+   if (target == GL_TEXTURE_CUBE_MAP) {
       /* Make sure the texture object is a proper cube.
        * (See texturesubimage in teximage.c for details on why this check is
        * performed.)
@@ -1178,31 +1295,79 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
          return;
       }
 
-      /* Copy each face. */
-      for (i = 0; i < 6; ++i) {
-         texImage = texObj->Image[i][level];
-         assert(texImage);
-
-         get_texture_image(ctx, texObj, texImage, texObj->Target, level,
-                           format, type, bufSize, pixels, true);
-
-         image_stride = _mesa_image_image_stride(&ctx->Pack, texImage->Width,
-                                                 texImage->Height, format,
-                                                 type);
-         pixels = (GLubyte *) pixels + image_stride;
-         bufSize -= image_stride;
-      }
+      /* Compute stride between cube faces */
+      imageStride = _mesa_image_image_stride(&ctx->Pack, width, height,
+                                             format, type);
+      firstFace = zoffset;
+      numFaces = depth;
+      zoffset = 0;
+      depth = 1;
    }
    else {
-      texImage = _mesa_select_tex_image(texObj, texObj->Target, level);
-      if (!texImage)
-         return;
+      imageStride = 0;
+      firstFace = _mesa_tex_target_to_face(target);
+      numFaces = 1;
+   }
+
+   _mesa_lock_texture(ctx, texObj);
 
-      get_texture_image(ctx, texObj, texImage, texObj->Target, level,
-                        format, type, bufSize, pixels, true);
+   for (i = 0; i < numFaces; i++) {
+      texImage = texObj->Image[firstFace + i][level];
+      assert(texImage);
+
+      ctx->Driver.GetTexSubImage(ctx, xoffset, yoffset, zoffset,
+                                 width, height, depth,
+                                 format, type, pixels, texImage);
+
+      /* next cube face */
+      pixels = (GLubyte *) pixels + imageStride;
+      bufSize -= imageStride;
    }
+
+   _mesa_unlock_texture(ctx, texObj);
+}
+
+
+void GLAPIENTRY
+_mesa_GetnTexImageARB(GLenum target, GLint level, GLenum format, GLenum type,
+                      GLsizei bufSize, GLvoid *pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target);
+
+   get_texture_image(ctx, texObj, target, level,
+                     0, 0, 0, WHOLE_WIDTH, WHOLE_HEIGHT, WHOLE_DEPTH,
+                     format, type, bufSize, pixels, "glGetnTexImageARB");
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
+                  GLvoid *pixels )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target);
+
+   get_texture_image(ctx, texObj, target, level,
+                     0, 0, 0, WHOLE_WIDTH, WHOLE_HEIGHT, WHOLE_DEPTH,
+                     format, type, INT_MAX, pixels, "glGetTexImage");
+}
+
+
+void GLAPIENTRY
+_mesa_GetTextureImage(GLuint texture, GLint level, GLenum format, GLenum type,
+                      GLsizei bufSize, GLvoid *pixels)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture);
+
+   get_texture_image(ctx, texObj, 0, level,
+                     0, 0, 0, WHOLE_WIDTH, WHOLE_HEIGHT, WHOLE_DEPTH,
+                     format, type, bufSize, pixels, "glGetTextureImage");
 }
 
+
+
 /**
  * Do error checking for a glGetCompressedTexImage() call.
  * \return GL_TRUE if any error, GL_FALSE if no errors.
-- 
1.9.1



More information about the mesa-dev mailing list