diff options
author | Brian Paul <[email protected]> | 2012-08-24 08:43:42 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-08-24 14:09:03 -0600 |
commit | a3af27e99362c0da9f467a39427d32d1270a720f (patch) | |
tree | 5cae6275923047fd48ecab6e743162adadc4ccc6 /src | |
parent | 13d0bb21a9ba04424019df25d6757e77304a1f9a (diff) |
mesa: add generic compressed -> uncompressed format helper
_mesa_generic_compressed_format_to_uncompressed_format() probably wins the
prize for longest function name in Mesa.
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/glformats.c | 39 | ||||
-rw-r--r-- | src/mesa/main/glformats.h | 3 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index b6f9e94f5f5..2d06cb7151b 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -971,6 +971,45 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname) /** + * If format is a generic compressed format, return the corresponding + * non-compressed format. For other formats, return the format as-is. + */ +GLenum +_mesa_generic_compressed_format_to_uncompressed_format(GLenum format) +{ + switch (format) { + case GL_COMPRESSED_RED: + return GL_RED; + case GL_COMPRESSED_RG: + return GL_RG; + case GL_COMPRESSED_RGB: + return GL_RGB; + case GL_COMPRESSED_RGBA: + return GL_RGBA; + case GL_COMPRESSED_ALPHA: + return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE: + return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA: + return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY: + return GL_INTENSITY; + /* sRGB formats */ + case GL_COMPRESSED_SRGB: + return GL_SRGB; + case GL_COMPRESSED_SRGB_ALPHA: + return GL_SRGB_ALPHA; + case GL_COMPRESSED_SLUMINANCE: + return GL_SLUMINANCE; + case GL_COMPRESSED_SLUMINANCE_ALPHA: + return GL_SLUMINANCE_ALPHA; + default: + return format; + } +} + + +/** * Do error checking of format/type combinations for glReadPixels, * glDrawPixels and glTex[Sub]Image. Note that depending on the format * and type values, we may either generate GL_INVALID_OPERATION or diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h index d553eae0a0a..24fbda99137 100644 --- a/src/mesa/main/glformats.h +++ b/src/mesa/main/glformats.h @@ -92,6 +92,9 @@ extern GLboolean _mesa_base_format_has_channel(GLenum base_format, GLenum pname); extern GLenum +_mesa_generic_compressed_format_to_uncompressed_format(GLenum format); + +extern GLenum _mesa_error_check_format_and_type(const struct gl_context *ctx, GLenum format, GLenum type); |