diff options
author | Roland Scheidegger <[email protected]> | 2010-02-17 16:41:30 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2010-02-17 16:41:30 +0100 |
commit | c2ad9e380121d43f8ac066b590f9929a56bd1b0f (patch) | |
tree | a9ad9400766eb4cb01c276b85d233b47b7a08d60 /src/gallium | |
parent | b0f9717105301ee85afee0d03ee7e62e3e883326 (diff) |
util: new util_format_get_nr_components helper
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 2fbbb83d4ba..6345a11a8cf 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -404,6 +404,23 @@ util_format_has_alpha(enum pipe_format format) } } +/** + * Return the number of components stored. + * Formats with block size != 1x1 will always have 1 component (the block). + */ +static INLINE unsigned +util_format_get_nr_components(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + unsigned chan; + unsigned nr_comp = 0; + for (chan = 0; chan < 4; chan++) { + if (desc->channel[chan].size != 0) { + nr_comp++; + } + } + return nr_comp; +} /* * Format access functions. |