Touch watchdog before freeing objs in max_concurrent am: 815781b777 am: 6cbc014cfb
[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_LAST
78 };
79
80 int                                     getBlockSize                            (CompressedTexFormat format);
81 IVec3                           getBlockPixelSize                       (CompressedTexFormat format);
82
83 bool                            isEtcFormat                                     (CompressedTexFormat format);
84 bool                            isAstcFormat                            (CompressedTexFormat format);
85 bool                            isAstcSRGBFormat                        (CompressedTexFormat format);
86
87 TextureFormat           getUncompressedFormat           (CompressedTexFormat format);
88 CompressedTexFormat getAstcFormatByBlockSize    (const IVec3& size, bool isSRGB);
89
90 struct TexDecompressionParams
91 {
92         enum AstcMode
93         {
94                 ASTCMODE_LDR = 0,
95                 ASTCMODE_HDR,
96                 ASTCMODE_LAST
97         };
98
99         TexDecompressionParams (AstcMode astcMode_ = ASTCMODE_LAST) : astcMode(astcMode_) {}
100
101         AstcMode astcMode;
102 };
103
104 /*--------------------------------------------------------------------*//*!
105  * \brief Compressed texture
106  *
107  * This class implements container for common compressed texture formats.
108  * Reference decoding to uncompressed formats is supported.
109  *//*--------------------------------------------------------------------*/
110 class CompressedTexture
111 {
112 public:
113
114                                                         CompressedTexture                       (CompressedTexFormat format, int width, int height, int depth = 1);
115                                                         CompressedTexture                       (void);
116                                                         ~CompressedTexture                      (void);
117
118         void                                    setStorage                                      (CompressedTexFormat format, int width, int height, int depth = 1);
119
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];                    }
127
128         void                                    decompress                                      (const PixelBufferAccess& dst, const TexDecompressionParams& params = TexDecompressionParams()) const;
129
130 private:
131         CompressedTexFormat             m_format;
132         int                                             m_width;
133         int                                             m_height;
134         int                                             m_depth;
135         std::vector<deUint8>    m_data;
136 } DE_WARN_UNUSED_TYPE;
137
138 void decompress (const PixelBufferAccess& dst, CompressedTexFormat fmt, const deUint8* src, const TexDecompressionParams& params = TexDecompressionParams());
139
140 } // tcu
141
142 #endif // _TCUCOMPRESSEDTEXTURE_HPP