diff options
author | José Fonseca <[email protected]> | 2011-09-21 11:15:10 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-09-22 08:26:36 -0600 |
commit | ffb1996f614679553ef1d029306d0194b3161113 (patch) | |
tree | 4f19458e7d21473123ba9783d643b33687c496fb /src/gallium | |
parent | c40c1599bb7782808a1387663d69cc9f99f4c68f (diff) |
util: Allow to make the depth/stencil format queries without repeatedly looking up the format description.
All functions here should take struct util_format_description * IMO, to
incentive efficient code.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 2eb3e1b80a2..964f19c3a2e 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -410,7 +410,21 @@ util_format_is_s3tc(enum pipe_format format) return desc->layout == UTIL_FORMAT_LAYOUT_S3TC ? TRUE : FALSE; } -static INLINE boolean +static INLINE boolean +util_format_has_depth(const struct util_format_description *desc) +{ + return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS && + desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE; +} + +static INLINE boolean +util_format_has_stencil(const struct util_format_description *desc) +{ + return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS && + desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE; +} + +static INLINE boolean util_format_is_depth_or_stencil(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); @@ -420,10 +434,11 @@ util_format_is_depth_or_stencil(enum pipe_format format) return FALSE; } - return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE; + return util_format_has_depth(desc) || + util_format_has_stencil(desc); } -static INLINE boolean +static INLINE boolean util_format_is_depth_and_stencil(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); @@ -433,12 +448,8 @@ util_format_is_depth_and_stencil(enum pipe_format format) return FALSE; } - if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) { - return FALSE; - } - - return (desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE && - desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE; + return util_format_has_depth(desc) && + util_format_has_stencil(desc); } |