[Mesa-dev] [PATCH 02/22] swrast: do fast_copy_pixels() with Map/UnmapRenderbuffer()
Brian Paul
brian.e.paul at gmail.com
Thu Dec 22 08:25:39 PST 2011
On Wed, Dec 21, 2011 at 12:58 PM, Eric Anholt <eric at anholt.net> wrote:
>> - 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.
I'll fix that. Thanks.
-Brian
More information about the mesa-dev
mailing list