1 #ifndef _TCUCOMPRESSEDTEXTURE_HPP
2 #define _TCUCOMPRESSEDTEXTURE_HPP
3 /*-------------------------------------------------------------------------
4 * drawElements Quality Program Tester Core
5 * ----------------------------------------
7 * Copyright 2014 The Android Open Source Project
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Compressed Texture Utilities.
24 *//*--------------------------------------------------------------------*/
26 #include "tcuDefs.hpp"
27 #include "tcuTexture.hpp"
34 enum CompressedTexFormat
36 COMPRESSEDTEXFORMAT_ETC1_RGB8 = 0,
37 COMPRESSEDTEXFORMAT_EAC_R11,
38 COMPRESSEDTEXFORMAT_EAC_SIGNED_R11,
39 COMPRESSEDTEXFORMAT_EAC_RG11,
40 COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11,
41 COMPRESSEDTEXFORMAT_ETC2_RGB8,
42 COMPRESSEDTEXFORMAT_ETC2_SRGB8,
43 COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
44 COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
45 COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8,
46 COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8,
48 COMPRESSEDTEXFORMAT_ASTC_4x4_RGBA,
49 COMPRESSEDTEXFORMAT_ASTC_5x4_RGBA,
50 COMPRESSEDTEXFORMAT_ASTC_5x5_RGBA,
51 COMPRESSEDTEXFORMAT_ASTC_6x5_RGBA,
52 COMPRESSEDTEXFORMAT_ASTC_6x6_RGBA,
53 COMPRESSEDTEXFORMAT_ASTC_8x5_RGBA,
54 COMPRESSEDTEXFORMAT_ASTC_8x6_RGBA,
55 COMPRESSEDTEXFORMAT_ASTC_8x8_RGBA,
56 COMPRESSEDTEXFORMAT_ASTC_10x5_RGBA,
57 COMPRESSEDTEXFORMAT_ASTC_10x6_RGBA,
58 COMPRESSEDTEXFORMAT_ASTC_10x8_RGBA,
59 COMPRESSEDTEXFORMAT_ASTC_10x10_RGBA,
60 COMPRESSEDTEXFORMAT_ASTC_12x10_RGBA,
61 COMPRESSEDTEXFORMAT_ASTC_12x12_RGBA,
62 COMPRESSEDTEXFORMAT_ASTC_4x4_SRGB8_ALPHA8,
63 COMPRESSEDTEXFORMAT_ASTC_5x4_SRGB8_ALPHA8,
64 COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8,
65 COMPRESSEDTEXFORMAT_ASTC_6x5_SRGB8_ALPHA8,
66 COMPRESSEDTEXFORMAT_ASTC_6x6_SRGB8_ALPHA8,
67 COMPRESSEDTEXFORMAT_ASTC_8x5_SRGB8_ALPHA8,
68 COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8,
69 COMPRESSEDTEXFORMAT_ASTC_8x8_SRGB8_ALPHA8,
70 COMPRESSEDTEXFORMAT_ASTC_10x5_SRGB8_ALPHA8,
71 COMPRESSEDTEXFORMAT_ASTC_10x6_SRGB8_ALPHA8,
72 COMPRESSEDTEXFORMAT_ASTC_10x8_SRGB8_ALPHA8,
73 COMPRESSEDTEXFORMAT_ASTC_10x10_SRGB8_ALPHA8,
74 COMPRESSEDTEXFORMAT_ASTC_12x10_SRGB8_ALPHA8,
75 COMPRESSEDTEXFORMAT_ASTC_12x12_SRGB8_ALPHA8,
77 COMPRESSEDTEXFORMAT_LAST
80 int getBlockSize (CompressedTexFormat format);
81 IVec3 getBlockPixelSize (CompressedTexFormat format);
83 bool isEtcFormat (CompressedTexFormat format);
84 bool isAstcFormat (CompressedTexFormat format);
85 bool isAstcSRGBFormat (CompressedTexFormat format);
87 TextureFormat getUncompressedFormat (CompressedTexFormat format);
88 CompressedTexFormat getAstcFormatByBlockSize (const IVec3& size, bool isSRGB);
90 struct TexDecompressionParams
99 TexDecompressionParams (AstcMode astcMode_ = ASTCMODE_LAST) : astcMode(astcMode_) {}
104 /*--------------------------------------------------------------------*//*!
105 * \brief Compressed texture
107 * This class implements container for common compressed texture formats.
108 * Reference decoding to uncompressed formats is supported.
109 *//*--------------------------------------------------------------------*/
110 class CompressedTexture
114 CompressedTexture (CompressedTexFormat format, int width, int height, int depth = 1);
115 CompressedTexture (void);
116 ~CompressedTexture (void);
118 void setStorage (CompressedTexFormat format, int width, int height, int depth = 1);
120 int getWidth (void) const { return m_width; }
121 int getHeight (void) const { return m_height; }
122 int getDepth (void) const { return m_depth; }
123 CompressedTexFormat getFormat (void) const { return m_format; }
124 int getDataSize (void) const { return (int)m_data.size(); }
125 const void* getData (void) const { return &m_data[0]; }
126 void* getData (void) { return &m_data[0]; }
128 void decompress (const PixelBufferAccess& dst, const TexDecompressionParams& params = TexDecompressionParams()) const;
131 CompressedTexFormat m_format;
135 std::vector<deUint8> m_data;
136 } DE_WARN_UNUSED_TYPE;
138 void decompress (const PixelBufferAccess& dst, CompressedTexFormat fmt, const deUint8* src, const TexDecompressionParams& params = TexDecompressionParams());
142 #endif // _TCUCOMPRESSEDTEXTURE_HPP