summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format.c
diff options
context:
space:
mode:
authorJames Benton <jbenton@vmware.com>2012-07-11 15:32:47 +0100
committerJosé Fonseca <jfonseca@vmware.com>2012-11-28 19:14:36 +0000
commitd03d29a0442e8c1bfb1567f33abc83373a203220 (patch)
tree5cf6b7e889fa14262ebe83ee2616cdc143f41249 /src/gallium/auxiliary/util/u_format.c
parente66ec7c46b310f6b309aa90c1e0e2edd53de3479 (diff)
util: Updated util_format_is_array to be more accurate.
Will allow formats with padding, e.g. RGBX. Will now allow swizzled formats as long as the alpha is channel 3. Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.c')
-rw-r--r--src/gallium/auxiliary/util/u_format.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index f572a612e24..ddce95601a6 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -147,9 +147,12 @@ util_format_is_array(const struct util_format_description *desc)
}
for (chan = 0; chan < desc->nr_channels; ++chan) {
- if (desc->swizzle[chan] != chan)
+ if (desc->channel[chan].size != desc->channel[0].size)
return FALSE;
+ if (desc->channel[chan].type == UTIL_FORMAT_TYPE_VOID && (chan + 1) == desc->nr_channels)
+ continue;
+
if (desc->channel[chan].type != desc->channel[0].type)
return FALSE;
@@ -158,9 +161,16 @@ util_format_is_array(const struct util_format_description *desc)
if (desc->channel[chan].pure_integer != desc->channel[0].pure_integer)
return FALSE;
+ }
- if (desc->channel[chan].size != desc->channel[0].size)
+ if (desc->nr_channels == 4) {
+ if (desc->swizzle[3] < 3)
return FALSE;
+ } else {
+ for (chan = 0; chan < desc->nr_channels; ++chan) {
+ if (desc->swizzle[chan] != chan)
+ return FALSE;
+ }
}
return TRUE;