From 75ef110efe944a2c2d2533f04392686a232b0417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 1 Aug 2015 23:44:21 +0200 Subject: [PATCH] Compressed image support, part 10: support ETC2/EAC formats. --- doc/opengl-support.dox | 2 +- src/Magnum/AbstractTexture.cpp | 30 +++++++++++ src/Magnum/ColorFormat.cpp | 12 +++++ src/Magnum/ColorFormat.h | 94 ++++++++++++++++++++++++++++++++++ src/Magnum/TextureFormat.h | 94 ++++++++++++++++++++++++++++++++++ 5 files changed, 231 insertions(+), 1 deletion(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index c69aeabf6..d140b2734 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -172,7 +172,7 @@ Extension | Status ------------------------------------------- | ------ GLSL 4.30 | done @extension{ARB,arrays_of_arrays} | done (shading language only) -@extension{ARB,ES3_compatibility} | only conservative sample query +@extension{ARB,ES3_compatibility} | only conservative sample query and compression formats @extension{ARB,clear_buffer_object} | | @extension{ARB,compute_shader} | | @extension{ARB,copy_image} | | diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index b9ace1eb8..284986718 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -487,6 +487,10 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRed: case TextureFormat::CompressedRedRgtc1: case TextureFormat::CompressedSignedRedRgtc1: + #endif + #ifndef MAGNUM_TARGET_GLES2 + case TextureFormat::CompressedR11Eac: + case TextureFormat::CompressedSignedR11Eac: #endif return ColorFormat::Red; #endif @@ -519,6 +523,10 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRG: case TextureFormat::CompressedRGRgtc2: case TextureFormat::CompressedSignedRGRgtc2: + #endif + #ifndef MAGNUM_TARGET_GLES2 + case TextureFormat::CompressedRG11Eac: + case TextureFormat::CompressedSignedRG11Eac: #endif return ColorFormat::RG; #endif @@ -575,6 +583,10 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRGBBptcUnsignedFloat: case TextureFormat::CompressedRGBBptcSignedFloat: #endif + #ifndef MAGNUM_TARGET_GLES2 + case TextureFormat::CompressedRGB8Etc2: + case TextureFormat::CompressedSRGB8Etc2: + #endif case TextureFormat::CompressedRGBS3tcDxt1: return ColorFormat::RGB; @@ -625,6 +637,12 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm: #endif + #ifndef MAGNUM_TARGET_GLES2 + case TextureFormat::CompressedRGB8PunchthroughAlpha1Etc2: + case TextureFormat::CompressedSRGB8PunchthroughAlpha1Etc2: + case TextureFormat::CompressedRGBA8Etc2Eac: + case TextureFormat::CompressedSRGB8Alpha8Etc2Eac: + #endif case TextureFormat::CompressedRGBAS3tcDxt1: case TextureFormat::CompressedRGBAS3tcDxt3: case TextureFormat::CompressedRGBAS3tcDxt5: @@ -722,6 +740,18 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::CompressedRGBABptcUnorm: case TextureFormat::CompressedSRGBAlphaBptcUnorm: #endif + #ifndef MAGNUM_TARGET_GLES2 + case TextureFormat::CompressedRGB8Etc2: + case TextureFormat::CompressedSRGB8Etc2: + case TextureFormat::CompressedRGB8PunchthroughAlpha1Etc2: + case TextureFormat::CompressedSRGB8PunchthroughAlpha1Etc2: + case TextureFormat::CompressedRGBA8Etc2Eac: + case TextureFormat::CompressedSRGB8Alpha8Etc2Eac: + case TextureFormat::CompressedR11Eac: + case TextureFormat::CompressedSignedR11Eac: + case TextureFormat::CompressedRG11Eac: + case TextureFormat::CompressedSignedRG11Eac: + #endif case TextureFormat::CompressedRGBS3tcDxt1: case TextureFormat::CompressedRGBAS3tcDxt1: case TextureFormat::CompressedRGBAS3tcDxt3: diff --git a/src/Magnum/ColorFormat.cpp b/src/Magnum/ColorFormat.cpp index bc258c3ec..b53bca5bc 100644 --- a/src/Magnum/ColorFormat.cpp +++ b/src/Magnum/ColorFormat.cpp @@ -154,6 +154,18 @@ Debug operator<<(Debug debug, const CompressedColorFormat value) { _c(RGBABptcUnorm) _c(SRGBAlphaBptcUnorm) #endif + #ifndef MAGNUM_TARGET_GLES2 + _c(RGB8Etc2) + _c(SRGB8Etc2) + _c(RGB8PunchthroughAlpha1Etc2) + _c(SRGB8PunchthroughAlpha1Etc2) + _c(RGBA8Etc2Eac) + _c(SRGB8Alpha8Etc2Eac) + _c(R11Eac) + _c(SignedR11Eac) + _c(RG11Eac) + _c(SignedRG11Eac) + #endif _c(RGBS3tcDxt1) _c(RGBAS3tcDxt1) _c(RGBAS3tcDxt3) diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index 830b373e1..e6d5bd2c1 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -667,6 +667,100 @@ enum class CompressedColorFormat: GLenum { SRGBAlphaBptcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, #endif + #ifndef MAGNUM_TARGET_GLES2 + /** + * ETC2 compressed RGB, normalized unsigned. **Available only on 2D, 2D + * array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + RGB8Etc2 = GL_COMPRESSED_RGB8_ETC2, + + /** + * ETC2 compressed sRGB, normalized unsigned. **Available only on 2D, 2D + * array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + SRGB8Etc2 = GL_COMPRESSED_SRGB8_ETC2, + + /** + * ETC2 compressed RGB with punchthrough (single-bit) alpha, normalized + * unsigned. **Available only on 2D, 2D array, cube map and cube map array + * textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + RGB8PunchthroughAlpha1Etc2 = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + + /** + * ETC2 compressed sRGB with punchthrough (single-bit) alpha, normalized + * unsigned. **Available only on 2D, 2D array, cube map and cube map array + * textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + SRGB8PunchthroughAlpha1Etc2 = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + + /** + * ETC2/EAC compressed RGBA, normalized unsigned. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + RGBA8Etc2Eac = GL_COMPRESSED_RGBA8_ETC2_EAC, + + /** + * ETC2/EAC compressed sRGB with alpha, normalized unsigned. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + SRGB8Alpha8Etc2Eac = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + + /** + * EAC compressed red channel, normalized unsigned. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + R11Eac = GL_COMPRESSED_R11_EAC, + + /** + * EAC compressed red channel, normalized signed. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + SignedR11Eac = GL_COMPRESSED_SIGNED_R11_EAC, + + /** + * EAC compressed red and green channel, normalized unsigned. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + RG11Eac = GL_COMPRESSED_RG11_EAC, + + /** + * EAC compressed red and green channel, normalized signed. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + SignedRG11Eac = GL_COMPRESSED_SIGNED_RG11_EAC, + #endif + /** * S3TC DXT1 compressed RGB. **Available only for 2D, 3D, 2D array, cube * map and cube map array textures.** diff --git a/src/Magnum/TextureFormat.h b/src/Magnum/TextureFormat.h index a3cd5dd29..dba45efd6 100644 --- a/src/Magnum/TextureFormat.h +++ b/src/Magnum/TextureFormat.h @@ -926,6 +926,100 @@ enum class TextureFormat: GLenum { CompressedSRGBAlphaBptcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, #endif + #ifndef MAGNUM_TARGET_GLES2 + /** + * ETC2 compressed RGB, normalized unsigned. **Available only on 2D, 2D + * array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedRGB8Etc2 = GL_COMPRESSED_RGB8_ETC2, + + /** + * ETC2 compressed sRGB, normalized unsigned. **Available only on 2D, 2D + * array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedSRGB8Etc2 = GL_COMPRESSED_SRGB8_ETC2, + + /** + * ETC2 compressed RGB with punchthrough (single-bit) alpha, normalized + * unsigned. **Available only on 2D, 2D array, cube map and cube map array + * textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedRGB8PunchthroughAlpha1Etc2 = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + + /** + * ETC2 compressed sRGB with punchthrough (single-bit) alpha, normalized + * unsigned. **Available only on 2D, 2D array, cube map and cube map array + * textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedSRGB8PunchthroughAlpha1Etc2 = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + + /** + * ETC2/EAC compressed RGBA, normalized unsigned. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedRGBA8Etc2Eac = GL_COMPRESSED_RGBA8_ETC2_EAC, + + /** + * ETC2/EAC compressed sRGB with alpha, normalized unsigned. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedSRGB8Alpha8Etc2Eac = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + + /** + * EAC compressed red channel, normalized unsigned. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedR11Eac = GL_COMPRESSED_R11_EAC, + + /** + * EAC compressed red channel, normalized signed. **Available only on 2D, + * 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedSignedR11Eac = GL_COMPRESSED_SIGNED_R11_EAC, + + /** + * EAC compressed red and green channel, normalized unsigned. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedRG11Eac = GL_COMPRESSED_RG11_EAC, + + /** + * EAC compressed red and green channel, normalized signed. **Available + * only on 2D, 2D array, cube map and cube map array textures.** + * @requires_gl43 Extension @extension{ARB,ES3_compatibility} + * @requires_gles30 ETC2 texture compression is not available in OpenGL ES + * 2.0. + */ + CompressedSignedRG11Eac = GL_COMPRESSED_SIGNED_RG11_EAC, + #endif + /** * S3TC DXT1 compressed RGB. **Available only on 2D, 3D, 2D array, cube map * and cube map array textures.**