[Mesa-dev] [PATCH 2/2] mesa: Speedup the xrgb -> argb special case in fast_read_rgba_pixels_memcpy
Martin Andersson
g02maran at gmail.com
Mon Mar 11 09:01:09 PDT 2013
On Mon, Mar 11, 2013 at 3:56 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> I'm surprised this is is faster.
>
> In particular, for big things we'll be touching memory twice.
>
> Did you measure the speed up?
I tested it with the previous patch, with GL_UNSIGNED_BYTE, and on
that case it was faster, but since that patch was incorrect (I did not
take endianness into account) this patch can also probably be
discarded.
>
> Jose
>
> ----- Original Message -----
>> ---
>> src/mesa/main/readpix.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
>> index 349b0bc..0f5c84c 100644
>> --- a/src/mesa/main/readpix.c
>> +++ b/src/mesa/main/readpix.c
>> @@ -285,11 +285,12 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
>> }
>> } else if (copy_xrgb) {
>> /* convert xrgb -> argb */
>> + int alphaOffset = texelBytes - 1;
>> for (j = 0; j < height; j++) {
>> - GLuint *dst4 = (GLuint *) dst, *map4 = (GLuint *) map;
>> + memcpy(dst, map, width * texelBytes);
>> int i;
>> for (i = 0; i < width; i++) {
>> - dst4[i] = map4[i] | 0xff000000; /* set A=0xff */
>> + dst[i * texelBytes + alphaOffset] = 0xff; /* set A=0xff */
>> }
>> dst += dstStride;
>> map += stride;
>> --
>> 1.8.1.5
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
More information about the mesa-dev
mailing list