Mesa (master): mesa: add missing PBO mapping code in unpack_image()

Brian Paul brianp at kemper.freedesktop.org
Fri Aug 14 17:31:37 UTC 2009


Module: Mesa
Branch: master
Commit: 36df6a6e91988590900a879b88eac7c7acc0a86d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=36df6a6e91988590900a879b88eac7c7acc0a86d

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Aug 13 14:00:21 2009 -0600

mesa: add missing PBO mapping code in unpack_image()

---

 src/mesa/main/dlist.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9d0a2dc..2e36eee 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -681,7 +681,6 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list)
 /**
  * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
  * If we run out of memory, GL_OUT_OF_MEMORY will be recorded.
- * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
  */
 static GLvoid *
 unpack_image(GLcontext *ctx, GLuint dimensions,
@@ -698,12 +697,27 @@ unpack_image(GLcontext *ctx, GLuint dimensions,
       }
       return image;
    }
-   else
-      if (_mesa_validate_pbo_access
-          (dimensions, unpack, width, height, depth, format, type, pixels)) {
-      const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
-      GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth,
-                                         format, type, src, unpack);
+   else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+                                      format, type, pixels)) {
+      const GLubyte *map, *src;
+      GLvoid *image;
+
+      map = (GLubyte *)
+         ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+                               GL_READ_ONLY_ARB, unpack->BufferObj);
+      if (!map) {
+         /* unable to map src buffer! */
+         _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
+         return NULL;
+      }
+
+      src = ADD_POINTERS(map, pixels);
+      image = _mesa_unpack_image(dimensions, width, height, depth,
+                                 format, type, src, unpack);
+
+      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+                              unpack->BufferObj);
+
       if (!image) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
       }




More information about the mesa-commit mailing list