Merge branch 'mesa_7_5_branch'
authorBrian Paul <brianp@vmware.com>
Fri, 14 Aug 2009 17:27:51 +0000 (11:27 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 14 Aug 2009 17:27:51 +0000 (11:27 -0600)
1  2 
src/mesa/main/dlist.c
src/mesa/main/light.c
src/mesa/shader/shader_api.c

index 4133f15dc7290b5a75fde33b8514ae012f810d8f,74537d79e9baf9e56b8bc253d43b305cc748da02..9b68b3e116260745d75eaca13d3bbfdc1c5a6d9a
@@@ -690,17 -688,40 +691,40 @@@ unpack_image(GLcontext *ctx, GLuint dim
               GLenum format, GLenum type, const GLvoid * pixels,
               const struct gl_pixelstore_attrib *unpack)
  {
 -   if (unpack->BufferObj->Name == 0) {
 +   if (!_mesa_is_bufferobj(unpack->BufferObj)) {
        /* no PBO */
-       return _mesa_unpack_image(dimensions, width, height, depth, format,
-                                 type, pixels, unpack);
+       GLvoid *image = _mesa_unpack_image(dimensions, width, height, depth,
+                                          format, type, pixels, unpack);
+       if (pixels && !image) {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
+       }
+       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);
-       return _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");
+       }
+       return image;
     }
     /* bad access! */
     return NULL;
Simple merge
Simple merge