1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Utility functions to make assertions about formats.
32 * This module centralizes most of logic used when determining what algorithm
33 * is most suitable (i.e., most efficient yet correct) for a given format.
35 * It might be possible to move some of these functions to u_format module,
36 * but since tiny differences in the format my render it more/less
37 * appropriate to a given algorithm it is impossible to make any long term
38 * guarantee about the semantics of these functions.
40 * @author Jose Fonseca <jfonseca@vmware.com>
44 #include "util/u_format.h"
46 #include "lp_bld_format.h"
50 * Whether this format is a 4 rgba8 variant
53 lp_format_is_rgba8(const struct util_format_description
*desc
)
57 if(desc
->block
.width
!= 1 ||
58 desc
->block
.height
!= 1 ||
59 desc
->block
.bits
!= 32)
62 for(chan
= 0; chan
< 4; ++chan
) {
63 if(desc
->channel
[chan
].type
!= UTIL_FORMAT_TYPE_UNSIGNED
&&
64 desc
->channel
[chan
].type
!= UTIL_FORMAT_TYPE_SIGNED
&&
65 desc
->channel
[chan
].type
!= UTIL_FORMAT_TYPE_VOID
)
67 if(desc
->channel
[chan
].size
!= 8)