diff options
author | Neil Roberts <[email protected]> | 2014-07-17 14:18:27 +0100 |
---|---|---|
committer | Neil Roberts <[email protected]> | 2014-08-12 18:23:50 +0100 |
commit | 7e78033c11858b34e274be91586fdfa750c1db11 (patch) | |
tree | ea5788bd36a172b27d040f6073aa63344827a650 /src/mesa | |
parent | cc9c30b8a746691316ae7757b68cea1b1cd3ea84 (diff) |
mesa: Add the format enums for BPTC-compressed images
This adds the following four Mesa image format enums which correspond to the
four BPTC compressed texture formats:
MESA_FORMAT_BPTC_RGBA_UNORM
MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
It also updates the format information functions to handle these and the
corresponding GL enums.
v2: Also modify _mesa_get_format_color_encoding, _mesa_get_srgb_format_linear
and _mesa_get_uncompressed_format
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/formats.c | 20 | ||||
-rw-r--r-- | src/mesa/main/formats.csv | 6 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 6 | ||||
-rw-r--r-- | src/mesa/main/glformats.c | 10 | ||||
-rw-r--r-- | src/mesa/main/texcompress.c | 24 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 8 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 14 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 24 |
8 files changed, 112 insertions, 0 deletions
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index a4ddbd66963..db22a45c46d 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -369,6 +369,7 @@ _mesa_get_format_color_encoding(mesa_format format) case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: case MESA_FORMAT_B8G8R8X8_SRGB: + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: return GL_SRGB; default: return GL_LINEAR; @@ -451,6 +452,9 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: format = MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1; break; + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: + format = MESA_FORMAT_BPTC_RGBA_UNORM; + break; case MESA_FORMAT_B8G8R8X8_SRGB: format = MESA_FORMAT_B8G8R8X8_UNORM; break; @@ -516,6 +520,12 @@ _mesa_get_uncompressed_format(mesa_format format) case MESA_FORMAT_ETC2_RG11_EAC: case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: return MESA_FORMAT_R16G16_UNORM; + case MESA_FORMAT_BPTC_RGBA_UNORM: + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: + return MESA_FORMAT_A8B8G8R8_UNORM; + case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: + case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: + return MESA_FORMAT_RGB_FLOAT32; default: #ifdef DEBUG assert(!_mesa_is_format_compressed(format)); @@ -993,6 +1003,10 @@ _mesa_format_to_type_and_comps(mesa_format format, case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1: case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: + case MESA_FORMAT_BPTC_RGBA_UNORM: + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: + case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: + case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: /* XXX generate error instead? */ *datatype = GL_UNSIGNED_BYTE; *comps = 0; @@ -1549,6 +1563,12 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format, case MESA_FORMAT_RGBA_DXT5: return GL_FALSE; + case MESA_FORMAT_BPTC_RGBA_UNORM: + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: + case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: + case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: + return GL_FALSE; + case MESA_FORMAT_RGBA_FLOAT32: return format == GL_RGBA && type == GL_FLOAT && !swapBytes; case MESA_FORMAT_RGBA_FLOAT16: diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv index eade6facd60..4d542b7c6eb 100644 --- a/src/mesa/main/formats.csv +++ b/src/mesa/main/formats.csv @@ -280,3 +280,9 @@ MESA_FORMAT_ETC2_SIGNED_R11_EAC , etc2 , 4, 4, x64 , , , MESA_FORMAT_ETC2_SIGNED_RG11_EAC , etc2 , 4, 4, x128, , , , xy01, rgb MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1 , etc2 , 4, 4, x64 , , , , xyzw, rgb MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1, etc2 , 4, 4, x64 , , , , xyzw, srgb + +# BPTC compressed formats +MESA_FORMAT_BPTC_RGBA_UNORM , bptc , 4, 4, x128, , , , xyzw, rgb +MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM , bptc , 4, 4, x128, , , , xyzw, srgb +MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT , bptc , 4, 4, x128, , , , xyz1, rgb +MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT , bptc , 4, 4, x128, , , , xyz1, rgb diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 8166b964c7f..d6253bf862f 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -427,6 +427,12 @@ typedef enum MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1, MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1, + /* BPTC compressed formats */ + MESA_FORMAT_BPTC_RGBA_UNORM, + MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM, + MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT, + MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT, + MESA_FORMAT_COUNT } mesa_format; diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 0fb25ba0ff3..00478f989a6 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -787,6 +787,10 @@ _mesa_is_color_format(GLenum format) case GL_COMPRESSED_SIGNED_RG11_EAC: case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + case GL_COMPRESSED_RGBA_BPTC_UNORM: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: /* generic integer formats */ case GL_RED_INTEGER_EXT: case GL_GREEN_INTEGER_EXT: @@ -1040,6 +1044,12 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility; + case GL_COMPRESSED_RGBA_BPTC_UNORM: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return _mesa_is_desktop_gl(ctx) && + ctx->Extensions.ARB_texture_compression_bptc; case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: case GL_PALETTE4_R5_G6_B5_OES: diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index fb3ea025b39..53c0ea02206 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -235,6 +235,12 @@ _mesa_gl_compressed_format_base_format(GLenum format) * GL_EXT_texture_compression_latc. At the very least, Catalyst 11.6 does not * expose the 3dc formats through this mechanism. * + * The spec for GL_ARB_texture_compression_bptc doesn't mention whether it + * should be included in GL_COMPRESSED_TEXTURE_FORMATS. However as it takes a + * very long time to compress the textures in this format it's probably not + * very useful as a general format where the GL will have to compress it on + * the fly. + * * \param ctx the GL context * \param formats the resulting format list (may be NULL). * @@ -434,6 +440,15 @@ _mesa_glenum_to_compressed_format(GLenum format) case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1; + case GL_COMPRESSED_RGBA_BPTC_UNORM: + return MESA_FORMAT_BPTC_RGBA_UNORM; + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM; + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + return MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT; + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT; + default: return MESA_FORMAT_NONE; } @@ -515,6 +530,15 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, mesa_format mesaFormat case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case MESA_FORMAT_BPTC_RGBA_UNORM: + return GL_COMPRESSED_RGBA_BPTC_UNORM; + case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: + return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM; + case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: + return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT; + case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: + return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; + default: _mesa_problem(ctx, "Unexpected mesa texture format in" " _mesa_compressed_format_to_glenum()"); diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index c61a74859aa..6d3b8055661 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -345,6 +345,14 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, return MESA_FORMAT_SRGBA_DXT3; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return MESA_FORMAT_SRGBA_DXT5; + case GL_COMPRESSED_RGBA_BPTC_UNORM: + return MESA_FORMAT_BPTC_RGBA_UNORM; + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM; + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + return MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT; + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT; case GL_ALPHA16F_ARB: RETURN_IF_SUPPORTED(MESA_FORMAT_A_FLOAT16); diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index bb050b1882a..5f8edff87c6 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -520,6 +520,20 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) } } + if (_mesa_is_desktop_gl(ctx) && + ctx->Extensions.ARB_texture_compression_bptc) { + switch (internalFormat) { + case GL_COMPRESSED_RGBA_BPTC_UNORM: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return GL_RGBA; + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return GL_RGB; + default: + ; /* fallthrough */ + } + } + if (ctx->API == API_OPENGLES) { switch (internalFormat) { case GL_PALETTE4_RGB8_OES: diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index aef02321764..38d71caa38b 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -512,6 +512,30 @@ texfetch_funcs[] = fetch_compressed, fetch_compressed, fetch_compressed + }, + { + MESA_FORMAT_BPTC_RGBA_UNORM, + fetch_compressed, + fetch_compressed, + fetch_compressed + }, + { + MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM, + fetch_compressed, + fetch_compressed, + fetch_compressed + }, + { + MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT, + fetch_compressed, + fetch_compressed, + fetch_compressed + }, + { + MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT, + fetch_compressed, + fetch_compressed, + fetch_compressed } }; |