[Mesa-dev] [PATCH] util: replace format equality test with compatibility test in blit code

Brian Paul brianp at vmware.com
Tue Feb 28 07:51:43 PST 2012


I can at least fix formats_compatible() to be smarter when 
src_format==dst_format.  I'll post a v2.

-Brian

On 02/28/2012 08:11 AM, Jose Fonseca wrote:
> Looks good. Thanks for using util_format_description.
>
> If cpu usage in u_format becomes an issue in the future I'd suggest obtaining util_format_description only once per format, as currently util_format_description() ends up being called a few times per format.
>
> At any rate, I think that cpu should rarely be a bottleneck on blit functions. And if it is, then we should probably consider adding support for multiple rectangles per call, as opposed of only one.
>
> Jose
>
>
> ----- Original Message -----
>> This lets us use the resource_copy_region() path when blitting from
>> R8G8B8A8 to R8G8B8x8, for example.
>> ---
>>   src/gallium/auxiliary/util/u_blit.c |   17 ++++++++++++++++-
>>   1 files changed, 16 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_blit.c
>> b/src/gallium/auxiliary/util/u_blit.c
>> index a10fd17..8865823 100644
>> --- a/src/gallium/auxiliary/util/u_blit.c
>> +++ b/src/gallium/auxiliary/util/u_blit.c
>> @@ -321,6 +321,21 @@ regions_overlap(int srcX0, int srcY0,
>>
>>
>>   /**
>> + * Can we blit from src format to dest format with a simple copy?
>> + */
>> +static boolean
>> +formats_compatible(enum pipe_format src_format,
>> +                   enum pipe_format dst_format)
>> +{
>> +   const struct util_format_description *src_desc =
>> +      util_format_description(src_format);
>> +   const struct util_format_description *dst_desc =
>> +      util_format_description(dst_format);
>> +   return util_is_format_compatible(src_desc, dst_desc);
>> +}
>> +
>> +
>> +/**
>>    * Copy pixel block from src surface to dst surface.
>>    * Overlapping regions are acceptable.
>>    * Flipping and stretching are supported.
>> @@ -377,7 +392,7 @@ util_blit_pixels_writemask(struct blit_state
>> *ctx,
>>       * no overlapping.
>>       * Filter mode should not matter since there's no stretching.
>>       */
>> -   if (dst_format == src_format&&
>> +   if (formats_compatible(src_format, dst_format)&&
>>          srcX0<  srcX1&&
>>          dstX0<  dstX1&&
>>          srcY0<  srcY1&&
>> --
>> 1.7.3.4
>>
>> _______________________________________________
>> 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