Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / framework / common / tcuCompressedTexture.hpp
1 #ifndef _TCUCOMPRESSEDTEXTURE_HPP
2 #define _TCUCOMPRESSEDTEXTURE_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  *//*!
22  * \file
23  * \brief Compressed Texture Utilities.
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "tcuTexture.hpp"
28
29 #include <vector>
30
31 namespace tcu
32 {
33
34 enum CompressedTexFormat
35 {
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,
47
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,
76
77         COMPRESSEDTEXFORMAT_BC1_RGB_UNORM_BLOCK,
78         COMPRESSEDTEXFORMAT_BC1_RGB_SRGB_BLOCK,
79         COMPRESSEDTEXFORMAT_BC1_RGBA_UNORM_BLOCK,
80         COMPRESSEDTEXFORMAT_BC1_RGBA_SRGB_BLOCK,
81         COMPRESSEDTEXFORMAT_BC2_UNORM_BLOCK,
82         COMPRESSEDTEXFORMAT_BC2_SRGB_BLOCK,
83         COMPRESSEDTEXFORMAT_BC3_UNORM_BLOCK,
84         COMPRESSEDTEXFORMAT_BC3_SRGB_BLOCK,
85         COMPRESSEDTEXFORMAT_BC4_UNORM_BLOCK,
86         COMPRESSEDTEXFORMAT_BC4_SNORM_BLOCK,
87         COMPRESSEDTEXFORMAT_BC5_UNORM_BLOCK,
88         COMPRESSEDTEXFORMAT_BC5_SNORM_BLOCK,
89         COMPRESSEDTEXFORMAT_BC6H_UFLOAT_BLOCK,
90         COMPRESSEDTEXFORMAT_BC6H_SFLOAT_BLOCK,
91         COMPRESSEDTEXFORMAT_BC7_UNORM_BLOCK,
92         COMPRESSEDTEXFORMAT_BC7_SRGB_BLOCK,
93
94         COMPRESSEDTEXFORMAT_LAST
95 };
96
97 int                                     getBlockSize                            (CompressedTexFormat format);
98 IVec3                           getBlockPixelSize                       (CompressedTexFormat format);
99
100 bool                            isEtcFormat                                     (CompressedTexFormat format);
101 bool                            isAstcFormat                            (CompressedTexFormat format);
102 bool                            isAstcSRGBFormat                        (CompressedTexFormat format);
103 bool                            isBcFormat                                      (CompressedTexFormat format);
104 bool                            isBcBitExactFormat                      (CompressedTexFormat format);
105 bool                            isBcSRGBFormat                          (CompressedTexFormat format);
106
107 TextureFormat           getUncompressedFormat           (CompressedTexFormat format);
108 CompressedTexFormat getAstcFormatByBlockSize    (const IVec3& size, bool isSRGB);
109
110 struct TexDecompressionParams
111 {
112         enum AstcMode
113         {
114                 ASTCMODE_LDR = 0,
115                 ASTCMODE_HDR,
116                 ASTCMODE_LAST
117         };
118
119         TexDecompressionParams (AstcMode astcMode_ = ASTCMODE_LAST) : astcMode(astcMode_) {}
120
121         AstcMode astcMode;
122 };
123
124 /*--------------------------------------------------------------------*//*!
125  * \brief Compressed texture
126  *
127  * This class implements container for common compressed texture formats.
128  * Reference decoding to uncompressed formats is supported.
129  *//*--------------------------------------------------------------------*/
130 class CompressedTexture
131 {
132 public:
133
134                                                         CompressedTexture                       (CompressedTexFormat format, int width, int height, int depth = 1);
135                                                         CompressedTexture                       (void);
136                                                         ~CompressedTexture                      (void);
137
138         void                                    setStorage                                      (CompressedTexFormat format, int width, int height, int depth = 1);
139
140         int                                             getWidth                                        (void) const    { return m_width;                               }
141         int                                             getHeight                                       (void) const    { return m_height;                              }
142         int                                             getDepth                                        (void) const    { return m_depth;                               }
143         CompressedTexFormat             getFormat                                       (void) const    { return m_format;                              }
144         int                                             getDataSize                                     (void) const    { return (int)m_data.size();    }
145         const void*                             getData                                         (void) const    { return &m_data[0];                    }
146         void*                                   getData                                         (void)                  { return &m_data[0];                    }
147
148         void                                    decompress                                      (const PixelBufferAccess& dst, const TexDecompressionParams& params = TexDecompressionParams()) const;
149
150 private:
151         CompressedTexFormat             m_format;
152         int                                             m_width;
153         int                                             m_height;
154         int                                             m_depth;
155         std::vector<deUint8>    m_data;
156 } DE_WARN_UNUSED_TYPE;
157
158 void decompress (const PixelBufferAccess& dst, CompressedTexFormat fmt, const deUint8* src, const TexDecompressionParams& params = TexDecompressionParams());
159
160 } // tcu
161
162 #endif // _TCUCOMPRESSEDTEXTURE_HPP