1e5c31af7Sopenharmony_ci#ifndef _TCUCOMPRESSEDTEXTURE_HPP
2e5c31af7Sopenharmony_ci#define _TCUCOMPRESSEDTEXTURE_HPP
3e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci * drawElements Quality Program Tester Core
5e5c31af7Sopenharmony_ci * ----------------------------------------
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project
8e5c31af7Sopenharmony_ci *
9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
14e5c31af7Sopenharmony_ci *
15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
19e5c31af7Sopenharmony_ci * limitations under the License.
20e5c31af7Sopenharmony_ci *
21e5c31af7Sopenharmony_ci *//*!
22e5c31af7Sopenharmony_ci * \file
23e5c31af7Sopenharmony_ci * \brief Compressed Texture Utilities.
24e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
25e5c31af7Sopenharmony_ci
26e5c31af7Sopenharmony_ci#include "tcuDefs.hpp"
27e5c31af7Sopenharmony_ci#include "tcuTexture.hpp"
28e5c31af7Sopenharmony_ci
29e5c31af7Sopenharmony_ci#include <vector>
30e5c31af7Sopenharmony_ci
31e5c31af7Sopenharmony_cinamespace tcu
32e5c31af7Sopenharmony_ci{
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_cienum CompressedTexFormat
35e5c31af7Sopenharmony_ci{
36e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC1_RGB8 = 0,
37e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_EAC_R11,
38e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_EAC_SIGNED_R11,
39e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_EAC_RG11,
40e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11,
41e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_RGB8,
42e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_SRGB8,
43e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
44e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
45e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8,
46e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8,
47e5c31af7Sopenharmony_ci
48e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_4x4_RGBA,
49e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_5x4_RGBA,
50e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_5x5_RGBA,
51e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_6x5_RGBA,
52e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_6x6_RGBA,
53e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x5_RGBA,
54e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x6_RGBA,
55e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x8_RGBA,
56e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x5_RGBA,
57e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x6_RGBA,
58e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x8_RGBA,
59e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x10_RGBA,
60e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_12x10_RGBA,
61e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_12x12_RGBA,
62e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_4x4_SRGB8_ALPHA8,
63e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_5x4_SRGB8_ALPHA8,
64e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8,
65e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_6x5_SRGB8_ALPHA8,
66e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_6x6_SRGB8_ALPHA8,
67e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x5_SRGB8_ALPHA8,
68e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8,
69e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_8x8_SRGB8_ALPHA8,
70e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x5_SRGB8_ALPHA8,
71e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x6_SRGB8_ALPHA8,
72e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x8_SRGB8_ALPHA8,
73e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_10x10_SRGB8_ALPHA8,
74e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_12x10_SRGB8_ALPHA8,
75e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_ASTC_12x12_SRGB8_ALPHA8,
76e5c31af7Sopenharmony_ci
77e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC1_RGB_UNORM_BLOCK,
78e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC1_RGB_SRGB_BLOCK,
79e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC1_RGBA_UNORM_BLOCK,
80e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC1_RGBA_SRGB_BLOCK,
81e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC2_UNORM_BLOCK,
82e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC2_SRGB_BLOCK,
83e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC3_UNORM_BLOCK,
84e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC3_SRGB_BLOCK,
85e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC4_UNORM_BLOCK,
86e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC4_SNORM_BLOCK,
87e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC5_UNORM_BLOCK,
88e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC5_SNORM_BLOCK,
89e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC6H_UFLOAT_BLOCK,
90e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC6H_SFLOAT_BLOCK,
91e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC7_UNORM_BLOCK,
92e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_BC7_SRGB_BLOCK,
93e5c31af7Sopenharmony_ci
94e5c31af7Sopenharmony_ci	COMPRESSEDTEXFORMAT_LAST
95e5c31af7Sopenharmony_ci};
96e5c31af7Sopenharmony_ci
97e5c31af7Sopenharmony_ciint					getBlockSize				(CompressedTexFormat format);
98e5c31af7Sopenharmony_ciIVec3				getBlockPixelSize			(CompressedTexFormat format);
99e5c31af7Sopenharmony_ci
100e5c31af7Sopenharmony_cibool				isEtcFormat					(CompressedTexFormat format);
101e5c31af7Sopenharmony_cibool				isAstcFormat				(CompressedTexFormat format);
102e5c31af7Sopenharmony_cibool				isAstcSRGBFormat			(CompressedTexFormat format);
103e5c31af7Sopenharmony_cibool				isBcFormat					(CompressedTexFormat format);
104e5c31af7Sopenharmony_cibool				isBcBitExactFormat			(CompressedTexFormat format);
105e5c31af7Sopenharmony_cibool				isBcSRGBFormat				(CompressedTexFormat format);
106e5c31af7Sopenharmony_ci
107e5c31af7Sopenharmony_ciTextureFormat		getUncompressedFormat		(CompressedTexFormat format);
108e5c31af7Sopenharmony_ciCompressedTexFormat getAstcFormatByBlockSize	(const IVec3& size, bool isSRGB);
109e5c31af7Sopenharmony_ci
110e5c31af7Sopenharmony_cistruct TexDecompressionParams
111e5c31af7Sopenharmony_ci{
112e5c31af7Sopenharmony_ci	enum AstcMode
113e5c31af7Sopenharmony_ci	{
114e5c31af7Sopenharmony_ci		ASTCMODE_LDR = 0,
115e5c31af7Sopenharmony_ci		ASTCMODE_HDR,
116e5c31af7Sopenharmony_ci		ASTCMODE_LAST
117e5c31af7Sopenharmony_ci	};
118e5c31af7Sopenharmony_ci
119e5c31af7Sopenharmony_ci	TexDecompressionParams (AstcMode astcMode_ = ASTCMODE_LAST) : astcMode(astcMode_) {}
120e5c31af7Sopenharmony_ci
121e5c31af7Sopenharmony_ci	AstcMode astcMode;
122e5c31af7Sopenharmony_ci};
123e5c31af7Sopenharmony_ci
124e5c31af7Sopenharmony_ci/*--------------------------------------------------------------------*//*!
125e5c31af7Sopenharmony_ci * \brief Compressed texture
126e5c31af7Sopenharmony_ci *
127e5c31af7Sopenharmony_ci * This class implements container for common compressed texture formats.
128e5c31af7Sopenharmony_ci * Reference decoding to uncompressed formats is supported.
129e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
130e5c31af7Sopenharmony_ciclass CompressedTexture
131e5c31af7Sopenharmony_ci{
132e5c31af7Sopenharmony_cipublic:
133e5c31af7Sopenharmony_ci
134e5c31af7Sopenharmony_ci							CompressedTexture			(CompressedTexFormat format, int width, int height, int depth = 1);
135e5c31af7Sopenharmony_ci							CompressedTexture			(void);
136e5c31af7Sopenharmony_ci							~CompressedTexture			(void);
137e5c31af7Sopenharmony_ci
138e5c31af7Sopenharmony_ci	void					setStorage					(CompressedTexFormat format, int width, int height, int depth = 1);
139e5c31af7Sopenharmony_ci
140e5c31af7Sopenharmony_ci	int						getWidth					(void) const	{ return m_width;				}
141e5c31af7Sopenharmony_ci	int						getHeight					(void) const	{ return m_height;				}
142e5c31af7Sopenharmony_ci	int						getDepth					(void) const	{ return m_depth;				}
143e5c31af7Sopenharmony_ci	CompressedTexFormat		getFormat					(void) const	{ return m_format;				}
144e5c31af7Sopenharmony_ci	int						getDataSize					(void) const	{ return (int)m_data.size();	}
145e5c31af7Sopenharmony_ci	const void*				getData						(void) const	{ return &m_data[0];			}
146e5c31af7Sopenharmony_ci	void*					getData						(void)			{ return &m_data[0];			}
147e5c31af7Sopenharmony_ci
148e5c31af7Sopenharmony_ci	void					decompress					(const PixelBufferAccess& dst, const TexDecompressionParams& params = TexDecompressionParams()) const;
149e5c31af7Sopenharmony_ci
150e5c31af7Sopenharmony_ciprivate:
151e5c31af7Sopenharmony_ci	CompressedTexFormat		m_format;
152e5c31af7Sopenharmony_ci	int						m_width;
153e5c31af7Sopenharmony_ci	int						m_height;
154e5c31af7Sopenharmony_ci	int						m_depth;
155e5c31af7Sopenharmony_ci	std::vector<deUint8>	m_data;
156e5c31af7Sopenharmony_ci} DE_WARN_UNUSED_TYPE;
157e5c31af7Sopenharmony_ci
158e5c31af7Sopenharmony_civoid decompress (const PixelBufferAccess& dst, CompressedTexFormat fmt, const deUint8* src, const TexDecompressionParams& params = TexDecompressionParams());
159e5c31af7Sopenharmony_ci
160e5c31af7Sopenharmony_ci} // tcu
161e5c31af7Sopenharmony_ci
162e5c31af7Sopenharmony_ci#endif // _TCUCOMPRESSEDTEXTURE_HPP
163