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