[Mesa-dev] [PATCH 02/22] swrast: do fast_copy_pixels() with Map/UnmapRenderbuffer()

Eric Anholt eric at anholt.net
Wed Dec 21 11:58:15 PST 2011


> -   temp = malloc(width * MAX_PIXEL_BYTES);
> -   if (!temp) {
> -      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
> -      return GL_FALSE;
> +      /* different src/dst buffers */
> +      ctx->Driver.MapRenderbuffer(ctx, srcRb, srcX, srcY,
> +                                  width, height,
> +                                  GL_MAP_READ_BIT, &srcMap, &srcRowStride);
> +      if (!srcMap) {
> +         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
> +         return GL_TRUE; /* don't retry with slow path */
> +      }
> +      ctx->Driver.MapRenderbuffer(ctx, dstRb, dstX, dstY,
> +                                  width, height,
> +                                  GL_MAP_WRITE_BIT, &dstMap, &dstRowStride);
> +      if (!dstMap) {
> +         ctx->Driver.UnmapRenderbuffer(ctx, srcRb);
> +         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
> +         return GL_TRUE; /* don't retry with slow path */
> +      }
>     }
>  
>     for (row = 0; row < height; row++) {
> -      srcRb->GetRow(ctx, srcRb, width, srcX, srcY, temp);
> -      dstRb->PutRow(ctx, dstRb, width, dstX, dstY, temp, NULL);
> -      srcY += yStep;
> -      dstY += yStep;
> +      memcpy(dstMap, srcMap, widthInBytes);
> +      dstMap += dstRowStride;
> +      srcMap += srcRowStride;
>     }

So, previously we didn't have to worry about X direction for overlap
because we used a temp between the Get and Put.  Now, I think you need
to use memmove instead of memcpy.

Patch 1, and 3-7 are:
Reviewed-by: Eric Anholt <eric at anholt.net>

this one is too if memmove is the solution.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111221/cc5bedee/attachment.pgp>


More information about the mesa-dev mailing list