[Mesa-dev] [PATCH 30/37] mesa: Convert depth glGetTexImage() to using MapTextureImage().

Eric Anholt eric at anholt.net
Mon Aug 15 11:54:00 PDT 2011


From: Brian Paul <brianp at vmware.com>

---
 src/mesa/main/texgetimage.c            |   22 +++++++++++++++-------
 src/mesa/state_tracker/st_cb_texture.c |    3 ++-
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index f5278e8..36a3f42 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -34,6 +34,7 @@
 #include "enums.h"
 #include "context.h"
 #include "formats.h"
+#include "format_unpack.h"
 #include "image.h"
 #include "mfeatures.h"
 #include "mtypes.h"
@@ -128,12 +129,12 @@ get_tex_color_index(struct gl_context *ctx, GLuint dimensions,
 static void
 get_tex_depth(struct gl_context *ctx, GLuint dimensions,
               GLenum format, GLenum type, GLvoid *pixels,
-              const struct gl_texture_image *texImage)
+              struct gl_texture_image *texImage)
 {
    const GLint width = texImage->Width;
    const GLint height = texImage->Height;
    const GLint depth = texImage->Depth;
-   GLint img, row, col;
+   GLint img, row;
    GLfloat *depthRow = (GLfloat *) malloc(width * sizeof(GLfloat));
 
    if (!depthRow) {
@@ -142,17 +143,24 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
    }
 
    for (img = 0; img < depth; img++) {
+      GLubyte *srcMap;
+      GLint srcRowStride;
+
+      /* map src texture buffer */
+      ctx->Driver.MapTextureImage(ctx, texImage, img,
+                                  0, 0, width, height, GL_MAP_READ_BIT,
+                                  &srcMap, &srcRowStride);
+
       for (row = 0; row < height; row++) {
          void *dest = _mesa_image_address(dimensions, &ctx->Pack, pixels,
                                           width, height, format, type,
                                           img, row, 0);
-         assert(dest);
-
-         for (col = 0; col < width; col++) {
-            texImage->FetchTexelf(texImage, col, row, img, depthRow + col);
-         }
+         GLubyte *src = srcMap + row * srcRowStride;
+         _mesa_unpack_float_z_row(texImage->TexFormat, width, src, depthRow);
          _mesa_pack_depth_span(ctx, width, dest, type, depthRow, &ctx->Pack);
       }
+
+      ctx->Driver.UnmapTextureImage(ctx, texImage, img);
    }
 
    free(depthRow);
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index bdd90c7..feb4691 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -943,7 +943,8 @@ st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level,
       return;
    }
 
-   if (format == GL_DEPTH_STENCIL_EXT) {
+   if (format == GL_DEPTH_STENCIL ||
+       format == GL_DEPTH_COMPONENT) {
       do_map = GL_FALSE;
    }
 
-- 
1.7.5.4



More information about the mesa-dev mailing list