[Mesa-dev] [PATCH v2 08/13] mesa/format_utils: Add a general format conversion function
Jason Ekstrand
jason at jlekstrand.net
Mon Aug 4 11:20:07 PDT 2014
On Mon, Aug 4, 2014 at 7:55 AM, Brian Paul <brianp at vmware.com> wrote:
> On 08/02/2014 02:11 PM, Jason Ekstrand wrote:
>
>> Most format conversion operations required by GL can be performed by
>> converting one channel at a time, shuffling the channels around, and
>> optionally filling missing channels with zeros and ones. This adds a
>> function to do just that in a general, yet efficient, way.
>>
>> v2:
>> * Add better comments including full docs for functions
>> * Don't use __typeof__
>> * Use inline helpers instead of writing out conversions by hand,
>> * Force full loop unrolling for better performance
>>
>> Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
>> ---
>> src/mesa/main/format_utils.c | 844 ++++++++++++++++++++++++++++++
>> +++++++++++++
>> src/mesa/main/format_utils.h | 5 +
>> 2 files changed, 849 insertions(+)
>>
>> diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
>> index 241c158..d60aeb3 100644
>> --- a/src/mesa/main/format_utils.c
>> +++ b/src/mesa/main/format_utils.c
>> @@ -54,3 +54,847 @@ _mesa_srgb_ubyte_to_linear_float(uint8_t cl)
>>
>> return lut[cl];
>> }
>> +
>> +/* A bunch of format conversion macros and helper functions used below */
>> +
>> +/* Only guaranteed to work for BITS <= 32 */
>> +#define MAX_UINT(BITS) ((BITS) == 32 ? UINT32_MAX : ((1u << (BITS)) - 1))
>> +#define MAX_INT(BITS) (int)MAX_UINT((BITS) - 1)
>>
>
> I'd probably put one more set of parens around the whole macro body, just
> to be safe.
>
Yup, fixed.
--Jason
>
> -Brian
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140804/053a2c82/attachment.html>
More information about the mesa-dev
mailing list