diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-04-11 06:23:00 +0200 |
---|---|---|
committer | Marek Olšák <maraeo@gmail.com> | 2011-04-15 05:08:00 +0200 |
commit | 75fa5c99a86c1ae0f8a4fecc016a5f82da9ae80a (patch) | |
tree | d36da8703a01b177d52df997d8af515c40e7de13 /src/gallium/auxiliary/util | |
parent | 848f7d368d97f02eeb0c6546548784d639e3c3bf (diff) | |
download | external_mesa3d-75fa5c99a86c1ae0f8a4fecc016a5f82da9ae80a.zip external_mesa3d-75fa5c99a86c1ae0f8a4fecc016a5f82da9ae80a.tar.gz external_mesa3d-75fa5c99a86c1ae0f8a4fecc016a5f82da9ae80a.tar.bz2 |
gallium: add and use generic function for querying patented format support (v2)
v2: Unsigned floats are allowed regardless of the configure switch.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_format.c | 49 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format.h | 10 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 4896faa..9cbdd0a 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -36,6 +36,55 @@ #include "u_memory.h" #include "u_rect.h" #include "u_format.h" +#include "u_format_s3tc.h" + +#include "pipe/p_defines.h" + + +boolean +util_format_is_float(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + unsigned i; + + assert(desc); + if (!desc) { + return FALSE; + } + + /* Find the first non-void channel. */ + for (i = 0; i < 4; i++) { + if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) { + break; + } + } + + if (i == 4) { + return FALSE; + } + + return desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT ? TRUE : FALSE; +} + + +boolean +util_format_is_supported(enum pipe_format format, unsigned bind) +{ + if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) { + return FALSE; + } + +#ifndef TEXTURE_FLOAT_ENABLED + if ((bind & PIPE_BIND_RENDER_TARGET) && + format != PIPE_FORMAT_R9G9B9E5_FLOAT && + format != PIPE_FORMAT_R11G11B10_FLOAT && + util_format_is_float(format)) { + return FALSE; + } +#endif + + return TRUE; +} void diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 7659a80..bb3ed72 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -473,6 +473,10 @@ util_format_colormask(const struct util_format_description *desc) } +boolean +util_format_is_float(enum pipe_format format); + + /** * Whether the src format can be blitted to destation format with a simple * memcpy. @@ -481,6 +485,12 @@ boolean util_is_format_compatible(const struct util_format_description *src_desc, const struct util_format_description *dst_desc); +/** + * Whether the format is supported by Gallium for the given bindings. + * This covers S3TC textures and floating-point render targets. + */ +boolean +util_format_is_supported(enum pipe_format format, unsigned bind); /** * Whether this format is a rgab8 variant. |