• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES Utilities
3  * ------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Texture format utilities.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "gluTextureUtil.hpp"
25 #include "gluRenderContext.hpp"
26 #include "gluContextInfo.hpp"
27 #include "tcuTextureUtil.hpp"
28 #include "tcuFormatUtil.hpp"
29 #include "glwEnums.hpp"
30 
31 namespace glu
32 {
33 
34 using std::string;
35 
36 /*--------------------------------------------------------------------*//*!
37  * \brief Map tcu::TextureFormat to GL pixel transfer format.
38  *
39  * Maps generic texture format description to GL pixel transfer format.
40  * If no mapping is found, throws tcu::InternalError.
41  *
42  * \param texFormat Generic texture format.
43  * \return GL pixel transfer format.
44  *//*--------------------------------------------------------------------*/
getTransferFormat(tcu::TextureFormat texFormat)45 TransferFormat getTransferFormat (tcu::TextureFormat texFormat)
46 {
47 	using tcu::TextureFormat;
48 
49 	deUint32	format	= GL_NONE;
50 	deUint32	type	= GL_NONE;
51 	bool		isInt	= false;
52 
53 	switch (texFormat.type)
54 	{
55 		case TextureFormat::SIGNED_INT8:
56 		case TextureFormat::SIGNED_INT16:
57 		case TextureFormat::SIGNED_INT32:
58 		case TextureFormat::UNSIGNED_INT8:
59 		case TextureFormat::UNSIGNED_INT16:
60 		case TextureFormat::UNSIGNED_INT32:
61 		case TextureFormat::UNSIGNED_INT_1010102_REV:
62 			isInt = true;
63 			break;
64 
65 		default:
66 			isInt = false;
67 			break;
68 	}
69 
70 	switch (texFormat.order)
71 	{
72 		case TextureFormat::A:		format = GL_ALPHA;								break;
73 		case TextureFormat::L:		format = GL_LUMINANCE;							break;
74 		case TextureFormat::LA:		format = GL_LUMINANCE_ALPHA;					break;
75 		case TextureFormat::R:		format = isInt ? GL_RED_INTEGER		: GL_RED;	break;
76 		case TextureFormat::RG:		format = isInt ? GL_RG_INTEGER		: GL_RG;	break;
77 		case TextureFormat::RGB:	format = isInt ? GL_RGB_INTEGER		: GL_RGB;	break;
78 		case TextureFormat::RGBA:	format = isInt ? GL_RGBA_INTEGER	: GL_RGBA;	break;
79 		case TextureFormat::sR:		format = GL_RED;								break;
80 		case TextureFormat::sRG:	format = GL_RG;									break;
81 		case TextureFormat::sRGB:	format = GL_RGB;								break;
82 		case TextureFormat::sRGBA:	format = GL_RGBA;								break;
83 		case TextureFormat::D:		format = GL_DEPTH_COMPONENT;					break;
84 		case TextureFormat::DS:		format = GL_DEPTH_STENCIL;						break;
85 		case TextureFormat::S:		format = GL_STENCIL_INDEX;						break;
86 
87 		case TextureFormat::BGRA:
88 			DE_ASSERT(!isInt);
89 			format = GL_BGRA;
90 			break;
91 
92 		default:
93 			DE_ASSERT(false);
94 	}
95 
96 	switch (texFormat.type)
97 	{
98 		case TextureFormat::SNORM_INT8:						type = GL_BYTE;								break;
99 		case TextureFormat::SNORM_INT16:					type = GL_SHORT;							break;
100 		case TextureFormat::UNORM_INT8:						type = GL_UNSIGNED_BYTE;					break;
101 		case TextureFormat::UNORM_INT16:					type = GL_UNSIGNED_SHORT;					break;
102 		case TextureFormat::UNORM_SHORT_565:				type = GL_UNSIGNED_SHORT_5_6_5;				break;
103 		case TextureFormat::UNORM_SHORT_4444:				type = GL_UNSIGNED_SHORT_4_4_4_4;			break;
104 		case TextureFormat::UNORM_SHORT_5551:				type = GL_UNSIGNED_SHORT_5_5_5_1;			break;
105 		case TextureFormat::SIGNED_INT8:					type = GL_BYTE;								break;
106 		case TextureFormat::SIGNED_INT16:					type = GL_SHORT;							break;
107 		case TextureFormat::SIGNED_INT32:					type = GL_INT;								break;
108 		case TextureFormat::UNSIGNED_INT8:					type = GL_UNSIGNED_BYTE;					break;
109 		case TextureFormat::UNSIGNED_INT16:					type = GL_UNSIGNED_SHORT;					break;
110 		case TextureFormat::UNSIGNED_INT32:					type = GL_UNSIGNED_INT;						break;
111 		case TextureFormat::FLOAT:							type = GL_FLOAT;							break;
112 		case TextureFormat::UNORM_INT_101010:				type = GL_UNSIGNED_INT_2_10_10_10_REV;		break;
113 		case TextureFormat::UNORM_INT_1010102_REV:			type = GL_UNSIGNED_INT_2_10_10_10_REV;		break;
114 		case TextureFormat::UNSIGNED_INT_1010102_REV:		type = GL_UNSIGNED_INT_2_10_10_10_REV;		break;
115 		case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV:	type = GL_UNSIGNED_INT_10F_11F_11F_REV;		break;
116 		case TextureFormat::UNSIGNED_INT_999_E5_REV:		type = GL_UNSIGNED_INT_5_9_9_9_REV;			break;
117 		case TextureFormat::HALF_FLOAT:						type = GL_HALF_FLOAT;						break;
118 		case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:	type = GL_FLOAT_32_UNSIGNED_INT_24_8_REV;	break;
119 		case TextureFormat::UNSIGNED_INT_24_8:				type = texFormat.order == TextureFormat::D
120 																 ? GL_UNSIGNED_INT
121 																 : GL_UNSIGNED_INT_24_8;				break;
122 
123 		default:
124 			throw tcu::InternalError("Can't map texture format to GL transfer format");
125 	}
126 
127 	return TransferFormat(format, type);
128 }
129 
130 /*--------------------------------------------------------------------*//*!
131  * \brief Map tcu::TextureFormat to GL internal sized format.
132  *
133  * Maps generic texture format description to GL internal format.
134  * If no mapping is found, throws tcu::InternalError.
135  *
136  * \param texFormat Generic texture format.
137  * \return GL sized internal format.
138  *//*--------------------------------------------------------------------*/
getInternalFormat(tcu::TextureFormat texFormat)139 deUint32 getInternalFormat (tcu::TextureFormat texFormat)
140 {
141 	DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST < (1<<16));
142 	DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELTYPE_LAST < (1<<16));
143 
144 #define PACK_FMT(ORDER, TYPE) ((int(ORDER) << 16) | int(TYPE))
145 #define FMT_CASE(ORDER, TYPE) PACK_FMT(tcu::TextureFormat::ORDER, tcu::TextureFormat::TYPE)
146 
147 	switch (PACK_FMT(texFormat.order, texFormat.type))
148 	{
149 		case FMT_CASE(RGBA,		UNORM_SHORT_5551):				return GL_RGB5_A1;
150 		case FMT_CASE(RGBA,		UNORM_SHORT_4444):				return GL_RGBA4;
151 		case FMT_CASE(RGB,		UNORM_SHORT_565):				return GL_RGB565;
152 		case FMT_CASE(D,		UNORM_INT16):					return GL_DEPTH_COMPONENT16;
153 		case FMT_CASE(S,		UNSIGNED_INT8):					return GL_STENCIL_INDEX8;
154 
155 		case FMT_CASE(RGBA,		FLOAT):							return GL_RGBA32F;
156 		case FMT_CASE(RGBA,		SIGNED_INT32):					return GL_RGBA32I;
157 		case FMT_CASE(RGBA,		UNSIGNED_INT32):				return GL_RGBA32UI;
158 		case FMT_CASE(RGBA,		UNORM_INT16):					return GL_RGBA16;
159 		case FMT_CASE(RGBA,		SNORM_INT16):					return GL_RGBA16_SNORM;
160 		case FMT_CASE(RGBA,		HALF_FLOAT):					return GL_RGBA16F;
161 		case FMT_CASE(RGBA,		SIGNED_INT16):					return GL_RGBA16I;
162 		case FMT_CASE(RGBA,		UNSIGNED_INT16):				return GL_RGBA16UI;
163 		case FMT_CASE(RGBA,		UNORM_INT8):					return GL_RGBA8;
164 		case FMT_CASE(RGBA,		SIGNED_INT8):					return GL_RGBA8I;
165 		case FMT_CASE(RGBA,		UNSIGNED_INT8):					return GL_RGBA8UI;
166 		case FMT_CASE(sRGBA,	UNORM_INT8):					return GL_SRGB8_ALPHA8;
167 		case FMT_CASE(RGBA,		UNORM_INT_1010102_REV):			return GL_RGB10_A2;
168 		case FMT_CASE(RGBA,		UNSIGNED_INT_1010102_REV):		return GL_RGB10_A2UI;
169 		case FMT_CASE(RGBA,		SNORM_INT8):					return GL_RGBA8_SNORM;
170 
171 		case FMT_CASE(RGB,		UNORM_INT8):					return GL_RGB8;
172 		case FMT_CASE(RGB,		UNSIGNED_INT_11F_11F_10F_REV):	return GL_R11F_G11F_B10F;
173 		case FMT_CASE(RGB,		FLOAT):							return GL_RGB32F;
174 		case FMT_CASE(RGB,		SIGNED_INT32):					return GL_RGB32I;
175 		case FMT_CASE(RGB,		UNSIGNED_INT32):				return GL_RGB32UI;
176 		case FMT_CASE(RGB,		UNORM_INT16):					return GL_RGB16;
177 		case FMT_CASE(RGB,		SNORM_INT16):					return GL_RGB16_SNORM;
178 		case FMT_CASE(RGB,		HALF_FLOAT):					return GL_RGB16F;
179 		case FMT_CASE(RGB,		SIGNED_INT16):					return GL_RGB16I;
180 		case FMT_CASE(RGB,		UNSIGNED_INT16):				return GL_RGB16UI;
181 		case FMT_CASE(RGB,		SNORM_INT8):					return GL_RGB8_SNORM;
182 		case FMT_CASE(RGB,		SIGNED_INT8):					return GL_RGB8I;
183 		case FMT_CASE(RGB,		UNSIGNED_INT8):					return GL_RGB8UI;
184 		case FMT_CASE(sRGB,		UNORM_INT8):					return GL_SRGB8;
185 		case FMT_CASE(RGB,		UNSIGNED_INT_999_E5_REV):		return GL_RGB9_E5;
186 		case FMT_CASE(RGB,		UNORM_INT_1010102_REV):			return GL_RGB10;
187 
188 		case FMT_CASE(RG,		FLOAT):							return GL_RG32F;
189 		case FMT_CASE(RG,		SIGNED_INT32):					return GL_RG32I;
190 		case FMT_CASE(RG,		UNSIGNED_INT32):				return GL_RG32UI;
191 		case FMT_CASE(RG,		UNORM_INT16):					return GL_RG16;
192 		case FMT_CASE(RG,		SNORM_INT16):					return GL_RG16_SNORM;
193 		case FMT_CASE(RG,		HALF_FLOAT):					return GL_RG16F;
194 		case FMT_CASE(RG,		SIGNED_INT16):					return GL_RG16I;
195 		case FMT_CASE(RG,		UNSIGNED_INT16):				return GL_RG16UI;
196 		case FMT_CASE(RG,		UNORM_INT8):					return GL_RG8;
197 		case FMT_CASE(RG,		SIGNED_INT8):					return GL_RG8I;
198 		case FMT_CASE(RG,		UNSIGNED_INT8):					return GL_RG8UI;
199 		case FMT_CASE(RG,		SNORM_INT8):					return GL_RG8_SNORM;
200 		case FMT_CASE(sRG,		UNORM_INT8):					return GL_SRG8_EXT;
201 
202 		case FMT_CASE(R,		FLOAT):							return GL_R32F;
203 		case FMT_CASE(R,		SIGNED_INT32):					return GL_R32I;
204 		case FMT_CASE(R,		UNSIGNED_INT32):				return GL_R32UI;
205 		case FMT_CASE(R,		UNORM_INT16):					return GL_R16;
206 		case FMT_CASE(R,		SNORM_INT16):					return GL_R16_SNORM;
207 		case FMT_CASE(R,		HALF_FLOAT):					return GL_R16F;
208 		case FMT_CASE(R,		SIGNED_INT16):					return GL_R16I;
209 		case FMT_CASE(R,		UNSIGNED_INT16):				return GL_R16UI;
210 		case FMT_CASE(R,		UNORM_INT8):					return GL_R8;
211 		case FMT_CASE(R,		SIGNED_INT8):					return GL_R8I;
212 		case FMT_CASE(R,		UNSIGNED_INT8):					return GL_R8UI;
213 		case FMT_CASE(R,		SNORM_INT8):					return GL_R8_SNORM;
214 		case FMT_CASE(sR,		UNORM_INT8):					return GL_SR8_EXT;
215 
216 		case FMT_CASE(D,		FLOAT):							return GL_DEPTH_COMPONENT32F;
217 		case FMT_CASE(D,		UNSIGNED_INT_24_8):				return GL_DEPTH_COMPONENT24;
218 		case FMT_CASE(D,		UNSIGNED_INT32):				return GL_DEPTH_COMPONENT32;
219 		case FMT_CASE(DS,		FLOAT_UNSIGNED_INT_24_8_REV):	return GL_DEPTH32F_STENCIL8;
220 		case FMT_CASE(DS,		UNSIGNED_INT_24_8):				return GL_DEPTH24_STENCIL8;
221 
222 		default:
223 			throw tcu::InternalError("Can't map texture format to GL internal format");
224 	}
225 }
226 
227 /*--------------------------------------------------------------------*//*!
228  * \brief Map generic compressed format to GL compressed format enum.
229  *
230  * Maps generic compressed format to GL compressed format enum value.
231  * If no mapping is found, throws tcu::InternalError.
232  *
233  * \param format Generic compressed format.
234  * \return GL compressed texture format.
235  *//*--------------------------------------------------------------------*/
getGLFormat(tcu::CompressedTexFormat format)236 deUint32 getGLFormat (tcu::CompressedTexFormat format)
237 {
238 	switch (format)
239 	{
240 		case tcu::COMPRESSEDTEXFORMAT_ETC1_RGB8:						return GL_ETC1_RGB8_OES;
241 		case tcu::COMPRESSEDTEXFORMAT_EAC_R11:							return GL_COMPRESSED_R11_EAC;
242 		case tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11:					return GL_COMPRESSED_SIGNED_R11_EAC;
243 		case tcu::COMPRESSEDTEXFORMAT_EAC_RG11:							return GL_COMPRESSED_RG11_EAC;
244 		case tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11:					return GL_COMPRESSED_SIGNED_RG11_EAC;
245 		case tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8:						return GL_COMPRESSED_RGB8_ETC2;
246 		case tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8:						return GL_COMPRESSED_SRGB8_ETC2;
247 		case tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:	return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
248 		case tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:	return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
249 		case tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8:					return GL_COMPRESSED_RGBA8_ETC2_EAC;
250 		case tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
251 
252 		case tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_RGBA:					return GL_COMPRESSED_RGBA_ASTC_4x4_KHR;
253 		case tcu::COMPRESSEDTEXFORMAT_ASTC_5x4_RGBA:					return GL_COMPRESSED_RGBA_ASTC_5x4_KHR;
254 		case tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_RGBA:					return GL_COMPRESSED_RGBA_ASTC_5x5_KHR;
255 		case tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_RGBA:					return GL_COMPRESSED_RGBA_ASTC_6x5_KHR;
256 		case tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_RGBA:					return GL_COMPRESSED_RGBA_ASTC_6x6_KHR;
257 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x5_RGBA:					return GL_COMPRESSED_RGBA_ASTC_8x5_KHR;
258 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_RGBA:					return GL_COMPRESSED_RGBA_ASTC_8x6_KHR;
259 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_RGBA:					return GL_COMPRESSED_RGBA_ASTC_8x8_KHR;
260 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_RGBA:					return GL_COMPRESSED_RGBA_ASTC_10x5_KHR;
261 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_RGBA:					return GL_COMPRESSED_RGBA_ASTC_10x6_KHR;
262 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_RGBA:					return GL_COMPRESSED_RGBA_ASTC_10x8_KHR;
263 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_RGBA:					return GL_COMPRESSED_RGBA_ASTC_10x10_KHR;
264 		case tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_RGBA:					return GL_COMPRESSED_RGBA_ASTC_12x10_KHR;
265 		case tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_RGBA:					return GL_COMPRESSED_RGBA_ASTC_12x12_KHR;
266 		case tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
267 		case tcu::COMPRESSEDTEXFORMAT_ASTC_5x4_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
268 		case tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
269 		case tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
270 		case tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
271 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x5_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
272 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
273 		case tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
274 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
275 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
276 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
277 		case tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
278 		case tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
279 		case tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_SRGB8_ALPHA8:			return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
280 
281 		default:
282 			throw tcu::InternalError("Can't map compressed format to GL format");
283 	}
284 }
285 
286 /*--------------------------------------------------------------------*//*!
287  * \brief Map compressed GL format to generic compressed format.
288  *
289  * Maps compressed GL format to generic compressed format.
290  * If no mapping is found, throws tcu::InternalError.
291  *
292  * \param GL compressed texture format.
293  * \return format Generic compressed format.
294  *//*--------------------------------------------------------------------*/
mapGLCompressedTexFormat(deUint32 format)295 tcu::CompressedTexFormat mapGLCompressedTexFormat (deUint32 format)
296 {
297 	switch (format)
298 	{
299 		case GL_ETC1_RGB8_OES:								return tcu::COMPRESSEDTEXFORMAT_ETC1_RGB8;
300 		case GL_COMPRESSED_R11_EAC:							return tcu::COMPRESSEDTEXFORMAT_EAC_R11;
301 		case GL_COMPRESSED_SIGNED_R11_EAC:					return tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11;
302 		case GL_COMPRESSED_RG11_EAC:						return tcu::COMPRESSEDTEXFORMAT_EAC_RG11;
303 		case GL_COMPRESSED_SIGNED_RG11_EAC:					return tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11;
304 		case GL_COMPRESSED_RGB8_ETC2:						return tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8;
305 		case GL_COMPRESSED_SRGB8_ETC2:						return tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8;
306 		case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:	return tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
307 		case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:	return tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
308 		case GL_COMPRESSED_RGBA8_ETC2_EAC:					return tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8;
309 		case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:			return tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8;
310 
311 		case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_RGBA;
312 		case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_5x4_RGBA;
313 		case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_RGBA;
314 		case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_RGBA;
315 		case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_RGBA;
316 		case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_8x5_RGBA;
317 		case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_RGBA;
318 		case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_RGBA;
319 		case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_RGBA;
320 		case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_RGBA;
321 		case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_RGBA;
322 		case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_RGBA;
323 		case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_RGBA;
324 		case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:				return tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_RGBA;
325 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_SRGB8_ALPHA8;
326 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_5x4_SRGB8_ALPHA8;
327 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8;
328 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_SRGB8_ALPHA8;
329 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_SRGB8_ALPHA8;
330 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_8x5_SRGB8_ALPHA8;
331 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8;
332 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_SRGB8_ALPHA8;
333 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_SRGB8_ALPHA8;
334 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_SRGB8_ALPHA8;
335 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_SRGB8_ALPHA8;
336 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_SRGB8_ALPHA8;
337 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_SRGB8_ALPHA8;
338 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:		return tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_SRGB8_ALPHA8;
339 
340 		default:
341 			throw tcu::InternalError("Can't map compressed GL format to compressed format");
342 	}
343 }
344 
isCompressedFormat(deUint32 internalFormat)345 bool isCompressedFormat (deUint32 internalFormat)
346 {
347 	switch (internalFormat)
348 	{
349 		case GL_ETC1_RGB8_OES:
350 		case GL_COMPRESSED_R11_EAC:
351 		case GL_COMPRESSED_SIGNED_R11_EAC:
352 		case GL_COMPRESSED_RG11_EAC:
353 		case GL_COMPRESSED_SIGNED_RG11_EAC:
354 		case GL_COMPRESSED_RGB8_ETC2:
355 		case GL_COMPRESSED_SRGB8_ETC2:
356 		case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
357 		case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
358 		case GL_COMPRESSED_RGBA8_ETC2_EAC:
359 		case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
360 		case GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
361 		case GL_COMPRESSED_RGBA_ASTC_5x4_KHR:
362 		case GL_COMPRESSED_RGBA_ASTC_5x5_KHR:
363 		case GL_COMPRESSED_RGBA_ASTC_6x5_KHR:
364 		case GL_COMPRESSED_RGBA_ASTC_6x6_KHR:
365 		case GL_COMPRESSED_RGBA_ASTC_8x5_KHR:
366 		case GL_COMPRESSED_RGBA_ASTC_8x6_KHR:
367 		case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
368 		case GL_COMPRESSED_RGBA_ASTC_10x5_KHR:
369 		case GL_COMPRESSED_RGBA_ASTC_10x6_KHR:
370 		case GL_COMPRESSED_RGBA_ASTC_10x8_KHR:
371 		case GL_COMPRESSED_RGBA_ASTC_10x10_KHR:
372 		case GL_COMPRESSED_RGBA_ASTC_12x10_KHR:
373 		case GL_COMPRESSED_RGBA_ASTC_12x12_KHR:
374 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
375 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
376 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
377 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
378 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
379 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
380 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
381 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
382 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
383 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
384 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
385 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
386 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
387 		case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
388 			return true;
389 
390 		default:
391 			return false;
392 	}
393 }
394 
mapGLChannelType(deUint32 dataType,bool normalized)395 static tcu::TextureFormat::ChannelType mapGLChannelType (deUint32 dataType, bool normalized)
396 {
397 	// \note Normalized bit is ignored where it doesn't apply.
398 	using tcu::TextureFormat;
399 
400 	switch (dataType)
401 	{
402 		case GL_UNSIGNED_BYTE:					return normalized ? TextureFormat::UNORM_INT8	: TextureFormat::UNSIGNED_INT8;
403 		case GL_BYTE:							return normalized ? TextureFormat::SNORM_INT8	: TextureFormat::SIGNED_INT8;
404 		case GL_UNSIGNED_SHORT:					return normalized ? TextureFormat::UNORM_INT16	: TextureFormat::UNSIGNED_INT16;
405 		case GL_SHORT:							return normalized ? TextureFormat::SNORM_INT16	: TextureFormat::SIGNED_INT16;
406 		case GL_UNSIGNED_INT:					return normalized ? TextureFormat::UNORM_INT32	: TextureFormat::UNSIGNED_INT32;
407 		case GL_INT:							return normalized ? TextureFormat::SNORM_INT32	: TextureFormat::SIGNED_INT32;
408 		case GL_FLOAT:							return TextureFormat::FLOAT;
409 		case GL_UNSIGNED_SHORT_4_4_4_4:			return TextureFormat::UNORM_SHORT_4444;
410 		case GL_UNSIGNED_SHORT_5_5_5_1:			return TextureFormat::UNORM_SHORT_5551;
411 		case GL_UNSIGNED_SHORT_5_6_5:			return TextureFormat::UNORM_SHORT_565;
412 		case GL_HALF_FLOAT:						return TextureFormat::HALF_FLOAT;
413 		case GL_UNSIGNED_INT_2_10_10_10_REV:	return normalized ? TextureFormat::UNORM_INT_1010102_REV : TextureFormat::UNSIGNED_INT_1010102_REV;
414 		case GL_UNSIGNED_INT_10F_11F_11F_REV:	return TextureFormat::UNSIGNED_INT_11F_11F_10F_REV;
415 		case GL_UNSIGNED_INT_24_8:				return TextureFormat::UNSIGNED_INT_24_8;
416 		case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:	return TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV;
417 		case GL_UNSIGNED_INT_5_9_9_9_REV:		return TextureFormat::UNSIGNED_INT_999_E5_REV;
418 
419 		default:
420 			DE_ASSERT(false);
421 			return TextureFormat::CHANNELTYPE_LAST;
422 	}
423 }
424 
425 /*--------------------------------------------------------------------*//*!
426  * \brief Map GL pixel transfer format to tcu::TextureFormat.
427  *
428  * If no mapping is found, throws tcu::InternalError.
429  *
430  * \param format	GL pixel format.
431  * \param dataType	GL data type.
432  * \return Generic texture format.
433  *//*--------------------------------------------------------------------*/
mapGLTransferFormat(deUint32 format,deUint32 dataType)434 tcu::TextureFormat mapGLTransferFormat (deUint32 format, deUint32 dataType)
435 {
436 	using tcu::TextureFormat;
437 	switch (format)
438 	{
439 		case GL_ALPHA:				return TextureFormat(TextureFormat::A,		mapGLChannelType(dataType, true));
440 		case GL_LUMINANCE:			return TextureFormat(TextureFormat::L,		mapGLChannelType(dataType, true));
441 		case GL_LUMINANCE_ALPHA:	return TextureFormat(TextureFormat::LA,		mapGLChannelType(dataType, true));
442 		case GL_RGB:				return TextureFormat(TextureFormat::RGB,	mapGLChannelType(dataType, true));
443 		case GL_RGBA:				return TextureFormat(TextureFormat::RGBA,	mapGLChannelType(dataType, true));
444 		case GL_BGRA:				return TextureFormat(TextureFormat::BGRA,	mapGLChannelType(dataType, true));
445 		case GL_RG:					return TextureFormat(TextureFormat::RG,		mapGLChannelType(dataType, true));
446 		case GL_RED:				return TextureFormat(TextureFormat::R,		mapGLChannelType(dataType, true));
447 		case GL_RGBA_INTEGER:		return TextureFormat(TextureFormat::RGBA,	mapGLChannelType(dataType, false));
448 		case GL_RGB_INTEGER:		return TextureFormat(TextureFormat::RGB,	mapGLChannelType(dataType, false));
449 		case GL_RG_INTEGER:			return TextureFormat(TextureFormat::RG,		mapGLChannelType(dataType, false));
450 		case GL_RED_INTEGER:		return TextureFormat(TextureFormat::R,		mapGLChannelType(dataType, false));
451 
452 		case GL_DEPTH_COMPONENT:	return TextureFormat(TextureFormat::D,		mapGLChannelType(dataType, true));
453 		case GL_DEPTH_STENCIL:		return TextureFormat(TextureFormat::DS,		mapGLChannelType(dataType, true));
454 
455 		default:
456 			throw tcu::InternalError(string("Can't map GL pixel format (") + tcu::toHex(format).toString() + ", " + tcu::toHex(dataType).toString() + ") to texture format");
457 	}
458 }
459 
460 /*--------------------------------------------------------------------*//*!
461  * \brief Map GL internal texture format to tcu::TextureFormat.
462  *
463  * If no mapping is found, throws tcu::InternalError.
464  *
465  * \param internalFormat Sized internal format.
466  * \return Generic texture format.
467  *//*--------------------------------------------------------------------*/
mapGLInternalFormat(deUint32 internalFormat)468 tcu::TextureFormat mapGLInternalFormat (deUint32 internalFormat)
469 {
470 	using tcu::TextureFormat;
471 	switch (internalFormat)
472 	{
473 		case GL_RGB5_A1:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_SHORT_5551);
474 		case GL_RGBA4:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_SHORT_4444);
475 		case GL_RGB565:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_SHORT_565);
476 		case GL_DEPTH_COMPONENT16:	return TextureFormat(TextureFormat::D,		TextureFormat::UNORM_INT16);
477 		case GL_STENCIL_INDEX8:		return TextureFormat(TextureFormat::S,		TextureFormat::UNSIGNED_INT8);
478 
479 		case GL_RGBA32F:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::FLOAT);
480 		case GL_RGBA32I:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::SIGNED_INT32);
481 		case GL_RGBA32UI:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNSIGNED_INT32);
482 		case GL_RGBA16:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_INT16);
483 		case GL_RGBA16_SNORM:		return TextureFormat(TextureFormat::RGBA,	TextureFormat::SNORM_INT16);
484 		case GL_RGBA16F:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::HALF_FLOAT);
485 		case GL_RGBA16I:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::SIGNED_INT16);
486 		case GL_RGBA16UI:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNSIGNED_INT16);
487 		case GL_RGBA8:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_INT8);
488 		case GL_RGBA8I:				return TextureFormat(TextureFormat::RGBA,	TextureFormat::SIGNED_INT8);
489 		case GL_RGBA8UI:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNSIGNED_INT8);
490 		case GL_SRGB8_ALPHA8:		return TextureFormat(TextureFormat::sRGBA,	TextureFormat::UNORM_INT8);
491 		case GL_RGB10_A2:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNORM_INT_1010102_REV);
492 		case GL_RGB10_A2UI:			return TextureFormat(TextureFormat::RGBA,	TextureFormat::UNSIGNED_INT_1010102_REV);
493 		case GL_RGBA8_SNORM:		return TextureFormat(TextureFormat::RGBA,	TextureFormat::SNORM_INT8);
494 
495 		case GL_RGB8:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_INT8);
496 		case GL_R11F_G11F_B10F:		return TextureFormat(TextureFormat::RGB,	TextureFormat::UNSIGNED_INT_11F_11F_10F_REV);
497 		case GL_RGB32F:				return TextureFormat(TextureFormat::RGB,	TextureFormat::FLOAT);
498 		case GL_RGB32I:				return TextureFormat(TextureFormat::RGB,	TextureFormat::SIGNED_INT32);
499 		case GL_RGB32UI:			return TextureFormat(TextureFormat::RGB,	TextureFormat::UNSIGNED_INT32);
500 		case GL_RGB16:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_INT16);
501 		case GL_RGB16_SNORM:		return TextureFormat(TextureFormat::RGB,	TextureFormat::SNORM_INT16);
502 		case GL_RGB16F:				return TextureFormat(TextureFormat::RGB,	TextureFormat::HALF_FLOAT);
503 		case GL_RGB16I:				return TextureFormat(TextureFormat::RGB,	TextureFormat::SIGNED_INT16);
504 		case GL_RGB16UI:			return TextureFormat(TextureFormat::RGB,	TextureFormat::UNSIGNED_INT16);
505 		case GL_RGB8_SNORM:			return TextureFormat(TextureFormat::RGB,	TextureFormat::SNORM_INT8);
506 		case GL_RGB8I:				return TextureFormat(TextureFormat::RGB,	TextureFormat::SIGNED_INT8);
507 		case GL_RGB8UI:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNSIGNED_INT8);
508 		case GL_SRGB8:				return TextureFormat(TextureFormat::sRGB,	TextureFormat::UNORM_INT8);
509 		case GL_RGB9_E5:			return TextureFormat(TextureFormat::RGB,	TextureFormat::UNSIGNED_INT_999_E5_REV);
510 		case GL_RGB10:				return TextureFormat(TextureFormat::RGB,	TextureFormat::UNORM_INT_1010102_REV);
511 
512 		case GL_RG32F:				return TextureFormat(TextureFormat::RG,		TextureFormat::FLOAT);
513 		case GL_RG32I:				return TextureFormat(TextureFormat::RG,		TextureFormat::SIGNED_INT32);
514 		case GL_RG32UI:				return TextureFormat(TextureFormat::RG,		TextureFormat::UNSIGNED_INT32);
515 		case GL_RG16:				return TextureFormat(TextureFormat::RG,		TextureFormat::UNORM_INT16);
516 		case GL_RG16_SNORM:			return TextureFormat(TextureFormat::RG,		TextureFormat::SNORM_INT16);
517 		case GL_RG16F:				return TextureFormat(TextureFormat::RG,		TextureFormat::HALF_FLOAT);
518 		case GL_RG16I:				return TextureFormat(TextureFormat::RG,		TextureFormat::SIGNED_INT16);
519 		case GL_RG16UI:				return TextureFormat(TextureFormat::RG,		TextureFormat::UNSIGNED_INT16);
520 		case GL_RG8:				return TextureFormat(TextureFormat::RG,		TextureFormat::UNORM_INT8);
521 		case GL_RG8I:				return TextureFormat(TextureFormat::RG,		TextureFormat::SIGNED_INT8);
522 		case GL_RG8UI:				return TextureFormat(TextureFormat::RG,		TextureFormat::UNSIGNED_INT8);
523 		case GL_RG8_SNORM:			return TextureFormat(TextureFormat::RG,		TextureFormat::SNORM_INT8);
524 		case GL_SRG8_EXT:			return TextureFormat(TextureFormat::sRG,	TextureFormat::UNORM_INT8);
525 
526 		case GL_R32F:				return TextureFormat(TextureFormat::R,		TextureFormat::FLOAT);
527 		case GL_R32I:				return TextureFormat(TextureFormat::R,		TextureFormat::SIGNED_INT32);
528 		case GL_R32UI:				return TextureFormat(TextureFormat::R,		TextureFormat::UNSIGNED_INT32);
529 		case GL_R16:				return TextureFormat(TextureFormat::R,		TextureFormat::UNORM_INT16);
530 		case GL_R16_SNORM:			return TextureFormat(TextureFormat::R,		TextureFormat::SNORM_INT16);
531 		case GL_R16F:				return TextureFormat(TextureFormat::R,		TextureFormat::HALF_FLOAT);
532 		case GL_R16I:				return TextureFormat(TextureFormat::R,		TextureFormat::SIGNED_INT16);
533 		case GL_R16UI:				return TextureFormat(TextureFormat::R,		TextureFormat::UNSIGNED_INT16);
534 		case GL_R8:					return TextureFormat(TextureFormat::R,		TextureFormat::UNORM_INT8);
535 		case GL_R8I:				return TextureFormat(TextureFormat::R,		TextureFormat::SIGNED_INT8);
536 		case GL_R8UI:				return TextureFormat(TextureFormat::R,		TextureFormat::UNSIGNED_INT8);
537 		case GL_R8_SNORM:			return TextureFormat(TextureFormat::R,		TextureFormat::SNORM_INT8);
538 		case GL_SR8_EXT:			return TextureFormat(TextureFormat::sR,		TextureFormat::UNORM_INT8);
539 
540 		case GL_DEPTH_COMPONENT32F:	return TextureFormat(TextureFormat::D,		TextureFormat::FLOAT);
541 		case GL_DEPTH_COMPONENT24:	return TextureFormat(TextureFormat::D,		TextureFormat::UNSIGNED_INT_24_8);
542 		case GL_DEPTH_COMPONENT32:	return TextureFormat(TextureFormat::D,		TextureFormat::UNSIGNED_INT32);
543 		case GL_DEPTH32F_STENCIL8:	return TextureFormat(TextureFormat::DS,		TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV);
544 		case GL_DEPTH24_STENCIL8:	return TextureFormat(TextureFormat::DS,		TextureFormat::UNSIGNED_INT_24_8);
545 
546 		default:
547 			throw tcu::InternalError(string("Can't map GL sized internal format (") + tcu::toHex(internalFormat).toString() + ") to texture format");
548 	}
549 }
550 
isGLInternalColorFormatFilterable(deUint32 format)551 bool isGLInternalColorFormatFilterable (deUint32 format)
552 {
553 	switch (format)
554 	{
555 		case GL_R8:
556 		case GL_R8_SNORM:
557 		case GL_RG8:
558 		case GL_RG8_SNORM:
559 		case GL_RGB8:
560 		case GL_RGB8_SNORM:
561 		case GL_RGB565:
562 		case GL_RGBA4:
563 		case GL_RGB5_A1:
564 		case GL_RGBA8:
565 		case GL_RGBA8_SNORM:
566 		case GL_RGB10_A2:
567 		case GL_SR8_EXT:
568 		case GL_SRG8_EXT:
569 		case GL_SRGB8:
570 		case GL_SRGB8_ALPHA8:
571 		case GL_R16F:
572 		case GL_RG16F:
573 		case GL_RGB16F:
574 		case GL_RGBA16F:
575 		case GL_R11F_G11F_B10F:
576 		case GL_RGB9_E5:
577 			return true;
578 
579 		case GL_RGB10_A2UI:
580 		case GL_R32F:
581 		case GL_RG32F:
582 		case GL_RGB32F:
583 		case GL_RGBA32F:
584 		case GL_R8I:
585 		case GL_R8UI:
586 		case GL_R16I:
587 		case GL_R16UI:
588 		case GL_R32I:
589 		case GL_R32UI:
590 		case GL_RG8I:
591 		case GL_RG8UI:
592 		case GL_RG16I:
593 		case GL_RG16UI:
594 		case GL_RG32I:
595 		case GL_RG32UI:
596 		case GL_RGB8I:
597 		case GL_RGB8UI:
598 		case GL_RGB16I:
599 		case GL_RGB16UI:
600 		case GL_RGB32I:
601 		case GL_RGB32UI:
602 		case GL_RGBA8I:
603 		case GL_RGBA8UI:
604 		case GL_RGBA16I:
605 		case GL_RGBA16UI:
606 		case GL_RGBA32I:
607 		case GL_RGBA32UI:
608 			return false;
609 
610 		default:
611 			DE_ASSERT(false);
612 			return false;
613 	}
614 }
615 
mapGLWrapMode(deUint32 wrapMode)616 static inline tcu::Sampler::WrapMode mapGLWrapMode (deUint32 wrapMode)
617 {
618 	switch (wrapMode)
619 	{
620 		case GL_CLAMP_TO_EDGE:		return tcu::Sampler::CLAMP_TO_EDGE;
621 		case GL_CLAMP_TO_BORDER:	return tcu::Sampler::CLAMP_TO_BORDER;
622 		case GL_REPEAT:				return tcu::Sampler::REPEAT_GL;
623 		case GL_MIRRORED_REPEAT:	return tcu::Sampler::MIRRORED_REPEAT_GL;
624 		default:
625 			throw tcu::InternalError("Can't map GL wrap mode " + tcu::toHex(wrapMode).toString());
626 	}
627 }
628 
mapGLMinFilterMode(deUint32 filterMode)629 static inline tcu::Sampler::FilterMode mapGLMinFilterMode (deUint32 filterMode)
630 {
631 	switch (filterMode)
632 	{
633 		case GL_NEAREST:				return tcu::Sampler::NEAREST;
634 		case GL_LINEAR:					return tcu::Sampler::LINEAR;
635 		case GL_NEAREST_MIPMAP_NEAREST:	return tcu::Sampler::NEAREST_MIPMAP_NEAREST;
636 		case GL_NEAREST_MIPMAP_LINEAR:	return tcu::Sampler::NEAREST_MIPMAP_LINEAR;
637 		case GL_LINEAR_MIPMAP_NEAREST:	return tcu::Sampler::LINEAR_MIPMAP_NEAREST;
638 		case GL_LINEAR_MIPMAP_LINEAR:	return tcu::Sampler::LINEAR_MIPMAP_LINEAR;
639 		default:
640 			throw tcu::InternalError("Can't map GL min filter mode" + tcu::toHex(filterMode).toString());
641 	}
642 }
643 
mapGLMagFilterMode(deUint32 filterMode)644 static inline tcu::Sampler::FilterMode mapGLMagFilterMode (deUint32 filterMode)
645 {
646 	switch (filterMode)
647 	{
648 		case GL_NEAREST:				return tcu::Sampler::NEAREST;
649 		case GL_LINEAR:					return tcu::Sampler::LINEAR;
650 		default:
651 			throw tcu::InternalError("Can't map GL mag filter mode" + tcu::toHex(filterMode).toString());
652 	}
653 }
654 
655 /*--------------------------------------------------------------------*//*!
656  * \brief Map GL sampler parameters to tcu::Sampler.
657  *
658  * If no mapping is found, throws tcu::InternalError.
659  *
660  * \param wrapS		S-component wrap mode
661  * \param minFilter	Minification filter mode
662  * \param magFilter	Magnification filter mode
663  * \return Sampler description.
664  *//*--------------------------------------------------------------------*/
mapGLSampler(deUint32 wrapS,deUint32 minFilter,deUint32 magFilter)665 tcu::Sampler mapGLSampler (deUint32 wrapS, deUint32 minFilter, deUint32 magFilter)
666 {
667 	return mapGLSampler(wrapS, wrapS, wrapS, minFilter, magFilter);
668 }
669 
670 
671 /*--------------------------------------------------------------------*//*!
672  * \brief Map GL sampler parameters to tcu::Sampler.
673  *
674  * If no mapping is found, throws tcu::InternalError.
675  *
676  * \param wrapS		S-component wrap mode
677  * \param wrapT		T-component wrap mode
678  * \param minFilter	Minification filter mode
679  * \param magFilter	Magnification filter mode
680  * \return Sampler description.
681  *//*--------------------------------------------------------------------*/
mapGLSampler(deUint32 wrapS,deUint32 wrapT,deUint32 minFilter,deUint32 magFilter)682 tcu::Sampler mapGLSampler (deUint32 wrapS, deUint32 wrapT, deUint32 minFilter, deUint32 magFilter)
683 {
684 	return mapGLSampler(wrapS, wrapT, wrapS, minFilter, magFilter);
685 }
686 
687 /*--------------------------------------------------------------------*//*!
688  * \brief Map GL sampler parameters to tcu::Sampler.
689  *
690  * If no mapping is found, throws tcu::InternalError.
691  *
692  * \param wrapS		S-component wrap mode
693  * \param wrapT		T-component wrap mode
694  * \param wrapR		R-component wrap mode
695  * \param minFilter	Minification filter mode
696  * \param magFilter	Magnification filter mode
697  * \return Sampler description.
698  *//*--------------------------------------------------------------------*/
mapGLSampler(deUint32 wrapS,deUint32 wrapT,deUint32 wrapR,deUint32 minFilter,deUint32 magFilter)699 tcu::Sampler mapGLSampler (deUint32 wrapS, deUint32 wrapT, deUint32 wrapR, deUint32 minFilter, deUint32 magFilter)
700 {
701 	return tcu::Sampler(mapGLWrapMode(wrapS), mapGLWrapMode(wrapT), mapGLWrapMode(wrapR),
702 						mapGLMinFilterMode(minFilter), mapGLMagFilterMode(magFilter),
703 						0.0f /* lod threshold */,
704 						true /* normalized coords */,
705 						tcu::Sampler::COMPAREMODE_NONE /* no compare */,
706 						0 /* compare channel */,
707 						tcu::Vec4(0.0f) /* border color, not used */);
708 }
709 
710 /*--------------------------------------------------------------------*//*!
711  * \brief Map GL compare function to tcu::Sampler::CompareMode.
712  *
713  * If no mapping is found, throws tcu::InternalError.
714  *
715  * \param mode GL compare mode
716  * \return Compare mode
717  *//*--------------------------------------------------------------------*/
mapGLCompareFunc(deUint32 mode)718 tcu::Sampler::CompareMode mapGLCompareFunc (deUint32 mode)
719 {
720 	switch (mode)
721 	{
722 		case GL_LESS:		return tcu::Sampler::COMPAREMODE_LESS;
723 		case GL_LEQUAL:		return tcu::Sampler::COMPAREMODE_LESS_OR_EQUAL;
724 		case GL_GREATER:	return tcu::Sampler::COMPAREMODE_GREATER;
725 		case GL_GEQUAL:		return tcu::Sampler::COMPAREMODE_GREATER_OR_EQUAL;
726 		case GL_EQUAL:		return tcu::Sampler::COMPAREMODE_EQUAL;
727 		case GL_NOTEQUAL:	return tcu::Sampler::COMPAREMODE_NOT_EQUAL;
728 		case GL_ALWAYS:		return tcu::Sampler::COMPAREMODE_ALWAYS;
729 		case GL_NEVER:		return tcu::Sampler::COMPAREMODE_NEVER;
730 		default:
731 			throw tcu::InternalError("Can't map GL compare mode " + tcu::toHex(mode).toString());
732 	}
733 }
734 
735 /*--------------------------------------------------------------------*//*!
736  * \brief Get GL wrap mode.
737  *
738  * If no mapping is found, throws tcu::InternalError.
739  *
740  * \param wrapMode Wrap mode
741  * \return GL wrap mode
742  *//*--------------------------------------------------------------------*/
getGLWrapMode(tcu::Sampler::WrapMode wrapMode)743 deUint32 getGLWrapMode (tcu::Sampler::WrapMode wrapMode)
744 {
745 	DE_ASSERT(wrapMode != tcu::Sampler::WRAPMODE_LAST);
746 	switch (wrapMode)
747 	{
748 		case tcu::Sampler::CLAMP_TO_EDGE:		return GL_CLAMP_TO_EDGE;
749 		case tcu::Sampler::CLAMP_TO_BORDER:		return GL_CLAMP_TO_BORDER;
750 		case tcu::Sampler::REPEAT_GL:			return GL_REPEAT;
751 		case tcu::Sampler::MIRRORED_REPEAT_GL:	return GL_MIRRORED_REPEAT;
752 		default:
753 			throw tcu::InternalError("Can't map wrap mode");
754 	}
755 }
756 
757 /*--------------------------------------------------------------------*//*!
758  * \brief Get GL filter mode.
759  *
760  * If no mapping is found, throws tcu::InternalError.
761  *
762  * \param filterMode Filter mode
763  * \return GL filter mode
764  *//*--------------------------------------------------------------------*/
getGLFilterMode(tcu::Sampler::FilterMode filterMode)765 deUint32 getGLFilterMode (tcu::Sampler::FilterMode filterMode)
766 {
767 	DE_ASSERT(filterMode != tcu::Sampler::FILTERMODE_LAST);
768 	switch (filterMode)
769 	{
770 		case tcu::Sampler::NEAREST:					return GL_NEAREST;
771 		case tcu::Sampler::LINEAR:					return GL_LINEAR;
772 		case tcu::Sampler::NEAREST_MIPMAP_NEAREST:	return GL_NEAREST_MIPMAP_NEAREST;
773 		case tcu::Sampler::NEAREST_MIPMAP_LINEAR:	return GL_NEAREST_MIPMAP_LINEAR;
774 		case tcu::Sampler::LINEAR_MIPMAP_NEAREST:	return GL_LINEAR_MIPMAP_NEAREST;
775 		case tcu::Sampler::LINEAR_MIPMAP_LINEAR:	return GL_LINEAR_MIPMAP_LINEAR;
776 		default:
777 			throw tcu::InternalError("Can't map filter mode");
778 	}
779 }
780 
781 /*--------------------------------------------------------------------*//*!
782  * \brief Get GL compare mode.
783  *
784  * If no mapping is found, throws tcu::InternalError.
785  *
786  * \param compareMode Compare mode
787  * \return GL compare mode
788  *//*--------------------------------------------------------------------*/
getGLCompareFunc(tcu::Sampler::CompareMode compareMode)789 deUint32 getGLCompareFunc (tcu::Sampler::CompareMode compareMode)
790 {
791 	DE_ASSERT(compareMode != tcu::Sampler::COMPAREMODE_NONE);
792 	switch (compareMode)
793 	{
794 		case tcu::Sampler::COMPAREMODE_NONE:				return GL_NONE;
795 		case tcu::Sampler::COMPAREMODE_LESS:				return GL_LESS;
796 		case tcu::Sampler::COMPAREMODE_LESS_OR_EQUAL:		return GL_LEQUAL;
797 		case tcu::Sampler::COMPAREMODE_GREATER:				return GL_GREATER;
798 		case tcu::Sampler::COMPAREMODE_GREATER_OR_EQUAL:	return GL_GEQUAL;
799 		case tcu::Sampler::COMPAREMODE_EQUAL:				return GL_EQUAL;
800 		case tcu::Sampler::COMPAREMODE_NOT_EQUAL:			return GL_NOTEQUAL;
801 		case tcu::Sampler::COMPAREMODE_ALWAYS:				return GL_ALWAYS;
802 		case tcu::Sampler::COMPAREMODE_NEVER:				return GL_NEVER;
803 		default:
804 			throw tcu::InternalError("Can't map compare mode");
805 	}
806 }
807 
808 /*--------------------------------------------------------------------*//*!
809  * \brief Get GL cube face.
810  *
811  * If no mapping is found, throws tcu::InternalError.
812  *
813  * \param face Cube face
814  * \return GL cube face
815  *//*--------------------------------------------------------------------*/
getGLCubeFace(tcu::CubeFace face)816 deUint32 getGLCubeFace (tcu::CubeFace face)
817 {
818 	DE_ASSERT(face != tcu::CUBEFACE_LAST);
819 	switch (face)
820 	{
821 		case tcu::CUBEFACE_NEGATIVE_X:	return GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
822 		case tcu::CUBEFACE_POSITIVE_X:	return GL_TEXTURE_CUBE_MAP_POSITIVE_X;
823 		case tcu::CUBEFACE_NEGATIVE_Y:	return GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
824 		case tcu::CUBEFACE_POSITIVE_Y:	return GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
825 		case tcu::CUBEFACE_NEGATIVE_Z:	return GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
826 		case tcu::CUBEFACE_POSITIVE_Z:	return GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
827 		default:
828 			throw tcu::InternalError("Can't map cube face");
829 	}
830 }
831 
getCubeFaceFromGL(deUint32 face)832 tcu::CubeFace getCubeFaceFromGL (deUint32 face)
833 {
834 	switch (face)
835 	{
836 		case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:	return tcu::CUBEFACE_NEGATIVE_X;
837 		case GL_TEXTURE_CUBE_MAP_POSITIVE_X:	return tcu::CUBEFACE_POSITIVE_X;
838 		case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:	return tcu::CUBEFACE_NEGATIVE_Y;
839 		case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:	return tcu::CUBEFACE_POSITIVE_Y;
840 		case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:	return tcu::CUBEFACE_NEGATIVE_Z;
841 		case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:	return tcu::CUBEFACE_POSITIVE_Z;
842 		default:
843 			throw tcu::InternalError("Can't map cube face");
844 	}
845 }
846 
847 /*--------------------------------------------------------------------*//*!
848  * \brief Get GLSL sampler type for texture format.
849  *
850  * If no mapping is found, glu::TYPE_LAST is returned.
851  *
852  * \param format Texture format
853  * \return GLSL 1D sampler type for format
854  *//*--------------------------------------------------------------------*/
getSampler1DType(tcu::TextureFormat format)855 DataType getSampler1DType (tcu::TextureFormat format)
856 {
857 	using tcu::TextureFormat;
858 
859 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
860 		return TYPE_SAMPLER_1D;
861 
862 	if (format.order == TextureFormat::S)
863 		return TYPE_LAST;
864 
865 	switch (tcu::getTextureChannelClass(format.type))
866 	{
867 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
868 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
869 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
870 			return glu::TYPE_SAMPLER_1D;
871 
872 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
873 			return glu::TYPE_INT_SAMPLER_1D;
874 
875 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
876 			return glu::TYPE_UINT_SAMPLER_1D;
877 
878 		default:
879 			return glu::TYPE_LAST;
880 	}
881 }
882 
883 /*--------------------------------------------------------------------*//*!
884  * \brief Get GLSL sampler type for texture format.
885  *
886  * If no mapping is found, glu::TYPE_LAST is returned.
887  *
888  * \param format Texture format
889  * \return GLSL 2D sampler type for format
890  *//*--------------------------------------------------------------------*/
getSampler2DType(tcu::TextureFormat format)891 DataType getSampler2DType (tcu::TextureFormat format)
892 {
893 	using tcu::TextureFormat;
894 
895 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
896 		return TYPE_SAMPLER_2D;
897 
898 	if (format.order == TextureFormat::S)
899 		return TYPE_LAST;
900 
901 	switch (tcu::getTextureChannelClass(format.type))
902 	{
903 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
904 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
905 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
906 			return glu::TYPE_SAMPLER_2D;
907 
908 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
909 			return glu::TYPE_INT_SAMPLER_2D;
910 
911 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
912 			return glu::TYPE_UINT_SAMPLER_2D;
913 
914 		default:
915 			return glu::TYPE_LAST;
916 	}
917 }
918 
919 /*--------------------------------------------------------------------*//*!
920  * \brief Get GLSL sampler type for texture format.
921  *
922  * If no mapping is found, glu::TYPE_LAST is returned.
923  *
924  * \param format Texture format
925  * \return GLSL cube map sampler type for format
926  *//*--------------------------------------------------------------------*/
getSamplerCubeType(tcu::TextureFormat format)927 DataType getSamplerCubeType (tcu::TextureFormat format)
928 {
929 	using tcu::TextureFormat;
930 
931 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
932 		return TYPE_SAMPLER_CUBE;
933 
934 	if (format.order == TextureFormat::S)
935 		return TYPE_LAST;
936 
937 	switch (tcu::getTextureChannelClass(format.type))
938 	{
939 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
940 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
941 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
942 			return glu::TYPE_SAMPLER_CUBE;
943 
944 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
945 			return glu::TYPE_INT_SAMPLER_CUBE;
946 
947 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
948 			return glu::TYPE_UINT_SAMPLER_CUBE;
949 
950 		default:
951 			return glu::TYPE_LAST;
952 	}
953 }
954 
955 /*--------------------------------------------------------------------*//*!
956  * \brief Get GLSL sampler type for texture format.
957  *
958  * If no mapping is found, glu::TYPE_LAST is returned.
959  *
960  * \param format Texture format
961  * \return GLSL 2D array sampler type for format
962  *//*--------------------------------------------------------------------*/
getSampler2DArrayType(tcu::TextureFormat format)963 DataType getSampler2DArrayType (tcu::TextureFormat format)
964 {
965 	using tcu::TextureFormat;
966 
967 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
968 		return TYPE_SAMPLER_2D_ARRAY;
969 
970 	if (format.order == TextureFormat::S)
971 		return TYPE_LAST;
972 
973 	switch (tcu::getTextureChannelClass(format.type))
974 	{
975 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
976 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
977 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
978 			return glu::TYPE_SAMPLER_2D_ARRAY;
979 
980 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
981 			return glu::TYPE_INT_SAMPLER_2D_ARRAY;
982 
983 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
984 			return glu::TYPE_UINT_SAMPLER_2D_ARRAY;
985 
986 		default:
987 			return glu::TYPE_LAST;
988 	}
989 }
990 
991 /*--------------------------------------------------------------------*//*!
992  * \brief Get GLSL sampler type for texture format.
993  *
994  * If no mapping is found, glu::TYPE_LAST is returned.
995  *
996  * \param format Texture format
997  * \return GLSL 3D sampler type for format
998  *//*--------------------------------------------------------------------*/
getSampler3DType(tcu::TextureFormat format)999 DataType getSampler3DType (tcu::TextureFormat format)
1000 {
1001 	using tcu::TextureFormat;
1002 
1003 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
1004 		return TYPE_SAMPLER_3D;
1005 
1006 	if (format.order == TextureFormat::S)
1007 		return TYPE_LAST;
1008 
1009 	switch (tcu::getTextureChannelClass(format.type))
1010 	{
1011 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1012 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1013 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1014 			return glu::TYPE_SAMPLER_3D;
1015 
1016 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1017 			return glu::TYPE_INT_SAMPLER_3D;
1018 
1019 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1020 			return glu::TYPE_UINT_SAMPLER_3D;
1021 
1022 		default:
1023 			return glu::TYPE_LAST;
1024 	}
1025 }
1026 
1027 /*--------------------------------------------------------------------*//*!
1028  * \brief Get GLSL sampler type for texture format.
1029  *
1030  * If no mapping is found, glu::TYPE_LAST is returned.
1031  *
1032  * \param format Texture format
1033  * \return GLSL cube map array sampler type for format
1034  *//*--------------------------------------------------------------------*/
getSamplerCubeArrayType(tcu::TextureFormat format)1035 DataType getSamplerCubeArrayType (tcu::TextureFormat format)
1036 {
1037 	using tcu::TextureFormat;
1038 
1039 	if (format.order == TextureFormat::D || format.order == TextureFormat::DS)
1040 		return TYPE_SAMPLER_CUBE_ARRAY;
1041 
1042 	if (format.order == TextureFormat::S)
1043 		return TYPE_LAST;
1044 
1045 	switch (tcu::getTextureChannelClass(format.type))
1046 	{
1047 		case tcu::TEXTURECHANNELCLASS_FLOATING_POINT:
1048 		case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT:
1049 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT:
1050 			return glu::TYPE_SAMPLER_CUBE_ARRAY;
1051 
1052 		case tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER:
1053 			return glu::TYPE_INT_SAMPLER_CUBE_ARRAY;
1054 
1055 		case tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER:
1056 			return glu::TYPE_UINT_SAMPLER_CUBE_ARRAY;
1057 
1058 		default:
1059 			return glu::TYPE_LAST;
1060 	}
1061 }
1062 
1063 enum RenderableType
1064 {
1065 	RENDERABLE_COLOR	= (1<<0),
1066 	RENDERABLE_DEPTH	= (1<<1),
1067 	RENDERABLE_STENCIL	= (1<<2)
1068 };
1069 
getRenderableBitsES3(const ContextInfo & contextInfo,deUint32 internalFormat)1070 static deUint32 getRenderableBitsES3 (const ContextInfo& contextInfo, deUint32 internalFormat)
1071 {
1072 	switch (internalFormat)
1073 	{
1074 		// Color-renderable formats
1075 		case GL_RGBA32I:
1076 		case GL_RGBA32UI:
1077 		case GL_RGBA16I:
1078 		case GL_RGBA16UI:
1079 		case GL_RGBA8:
1080 		case GL_RGBA8I:
1081 		case GL_RGBA8UI:
1082 		case GL_SRGB8_ALPHA8:
1083 		case GL_RGB10_A2:
1084 		case GL_RGB10_A2UI:
1085 		case GL_RGBA4:
1086 		case GL_RGB5_A1:
1087 		case GL_RGB8:
1088 		case GL_RGB565:
1089 		case GL_RG32I:
1090 		case GL_RG32UI:
1091 		case GL_RG16I:
1092 		case GL_RG16UI:
1093 		case GL_RG8:
1094 		case GL_RG8I:
1095 		case GL_RG8UI:
1096 		case GL_R32I:
1097 		case GL_R32UI:
1098 		case GL_R16I:
1099 		case GL_R16UI:
1100 		case GL_R8:
1101 		case GL_R8I:
1102 		case GL_R8UI:
1103 			return RENDERABLE_COLOR;
1104 
1105 		// GL_EXT_color_buffer_float
1106 		case GL_RGBA32F:
1107 		case GL_R11F_G11F_B10F:
1108 		case GL_RG32F:
1109 		case GL_R32F:
1110 			if (contextInfo.isExtensionSupported("GL_EXT_color_buffer_float"))
1111 				return RENDERABLE_COLOR;
1112 			else
1113 				return 0;
1114 
1115 		// GL_EXT_color_buffer_float / GL_EXT_color_buffer_half_float
1116 		case GL_RGBA16F:
1117 		case GL_RG16F:
1118 		case GL_R16F:
1119 			if (contextInfo.isExtensionSupported("GL_EXT_color_buffer_float") ||
1120 				contextInfo.isExtensionSupported("GL_EXT_color_buffer_half_float"))
1121 				return RENDERABLE_COLOR;
1122 			else
1123 				return 0;
1124 
1125 		// Depth formats
1126 		case GL_DEPTH_COMPONENT32F:
1127 		case GL_DEPTH_COMPONENT24:
1128 		case GL_DEPTH_COMPONENT16:
1129 			return RENDERABLE_DEPTH;
1130 
1131 		// Depth+stencil formats
1132 		case GL_DEPTH32F_STENCIL8:
1133 		case GL_DEPTH24_STENCIL8:
1134 			return RENDERABLE_DEPTH|RENDERABLE_STENCIL;
1135 
1136 		// Stencil formats
1137 		case GL_STENCIL_INDEX8:
1138 			return RENDERABLE_STENCIL;
1139 
1140 		default:
1141 			return 0;
1142 	}
1143 }
1144 
1145 /*--------------------------------------------------------------------*//*!
1146  * \brief Check if sized internal format is color-renderable.
1147  * \note Works currently only on ES3 context.
1148  *//*--------------------------------------------------------------------*/
isSizedFormatColorRenderable(const RenderContext & renderCtx,const ContextInfo & contextInfo,deUint32 sizedFormat)1149 bool isSizedFormatColorRenderable (const RenderContext& renderCtx, const ContextInfo& contextInfo, deUint32 sizedFormat)
1150 {
1151 	deUint32 renderable = 0;
1152 
1153 	if (renderCtx.getType().getAPI() == ApiType::es(3,0))
1154 		renderable = getRenderableBitsES3(contextInfo, sizedFormat);
1155 	else
1156 		throw tcu::InternalError("Context type not supported in query");
1157 
1158 	return (renderable & RENDERABLE_COLOR) != 0;
1159 }
1160 
1161 const tcu::IVec2 (&getDefaultGatherOffsets (void))[4]
__anon19a9f9830102null1162 {
1163 	static const tcu::IVec2 s_defaultOffsets[4] =
1164 	{
1165 		tcu::IVec2(0, 1),
1166 		tcu::IVec2(1, 1),
1167 		tcu::IVec2(1, 0),
1168 		tcu::IVec2(0, 0),
1169 	};
1170 	return s_defaultOffsets;
1171 }
1172 
1173 } // glu
1174