1 /*-------------------------------------------------------------------------
5 * Copyright (c) 2015 The Khronos Group Inc.
6 * Copyright (c) 2015 Imagination Technologies Ltd.
7 * Copyright (c) 2015 Google Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and/or associated documentation files (the
11 * "Materials"), to deal in the Materials without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Materials, and to
14 * permit persons to whom the Materials are furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice(s) and this permission notice shall be
18 * included in all copies or substantial portions of the Materials.
20 * The Materials are Confidential Information as defined by the
21 * Khronos Membership Agreement until designated non-confidential by
22 * Khronos, at which point this condition clause shall be removed.
24 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
34 * \brief Utilities for images.
35 *//*--------------------------------------------------------------------*/
37 #include "vkImageUtil.hpp"
38 #include "tcuTextureUtil.hpp"
43 bool isFloatFormat (VkFormat format)
45 return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_FLOATING_POINT;
48 bool isUnormFormat (VkFormat format)
50 return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_FIXED_POINT;
53 bool isSnormFormat (VkFormat format)
55 return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT;
58 bool isIntFormat (VkFormat format)
60 return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER;
63 bool isUintFormat (VkFormat format)
65 return tcu::getTextureChannelClass(mapVkFormat(format).type) == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
68 bool isDepthStencilFormat (VkFormat format)
70 if (isCompressedFormat(format))
73 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
74 return tcuFormat.order == tcu::TextureFormat::D || tcuFormat.order == tcu::TextureFormat::S || tcuFormat.order == tcu::TextureFormat::DS;
77 bool isCompressedFormat (VkFormat format)
79 // update this mapping if VkFormat changes
80 DE_STATIC_ASSERT(VK_FORMAT_LAST == 174);
84 case VK_FORMAT_BC1_RGB_UNORM:
85 case VK_FORMAT_BC1_RGB_SRGB:
86 case VK_FORMAT_BC1_RGBA_UNORM:
87 case VK_FORMAT_BC1_RGBA_SRGB:
88 case VK_FORMAT_BC2_UNORM:
89 case VK_FORMAT_BC2_SRGB:
90 case VK_FORMAT_BC3_UNORM:
91 case VK_FORMAT_BC3_SRGB:
92 case VK_FORMAT_BC4_UNORM:
93 case VK_FORMAT_BC4_SNORM:
94 case VK_FORMAT_BC5_UNORM:
95 case VK_FORMAT_BC5_SNORM:
96 case VK_FORMAT_BC6H_UFLOAT:
97 case VK_FORMAT_BC6H_SFLOAT:
98 case VK_FORMAT_BC7_UNORM:
99 case VK_FORMAT_BC7_SRGB:
100 case VK_FORMAT_ETC2_R8G8B8_UNORM:
101 case VK_FORMAT_ETC2_R8G8B8_SRGB:
102 case VK_FORMAT_ETC2_R8G8B8A1_UNORM:
103 case VK_FORMAT_ETC2_R8G8B8A1_SRGB:
104 case VK_FORMAT_ETC2_R8G8B8A8_UNORM:
105 case VK_FORMAT_ETC2_R8G8B8A8_SRGB:
106 case VK_FORMAT_EAC_R11_UNORM:
107 case VK_FORMAT_EAC_R11_SNORM:
108 case VK_FORMAT_EAC_R11G11_UNORM:
109 case VK_FORMAT_EAC_R11G11_SNORM:
110 case VK_FORMAT_ASTC_4x4_UNORM:
111 case VK_FORMAT_ASTC_4x4_SRGB:
112 case VK_FORMAT_ASTC_5x4_UNORM:
113 case VK_FORMAT_ASTC_5x4_SRGB:
114 case VK_FORMAT_ASTC_5x5_UNORM:
115 case VK_FORMAT_ASTC_5x5_SRGB:
116 case VK_FORMAT_ASTC_6x5_UNORM:
117 case VK_FORMAT_ASTC_6x5_SRGB:
118 case VK_FORMAT_ASTC_6x6_UNORM:
119 case VK_FORMAT_ASTC_6x6_SRGB:
120 case VK_FORMAT_ASTC_8x5_UNORM:
121 case VK_FORMAT_ASTC_8x5_SRGB:
122 case VK_FORMAT_ASTC_8x6_UNORM:
123 case VK_FORMAT_ASTC_8x6_SRGB:
124 case VK_FORMAT_ASTC_8x8_UNORM:
125 case VK_FORMAT_ASTC_8x8_SRGB:
126 case VK_FORMAT_ASTC_10x5_UNORM:
127 case VK_FORMAT_ASTC_10x5_SRGB:
128 case VK_FORMAT_ASTC_10x6_UNORM:
129 case VK_FORMAT_ASTC_10x6_SRGB:
130 case VK_FORMAT_ASTC_10x8_UNORM:
131 case VK_FORMAT_ASTC_10x8_SRGB:
132 case VK_FORMAT_ASTC_10x10_UNORM:
133 case VK_FORMAT_ASTC_10x10_SRGB:
134 case VK_FORMAT_ASTC_12x10_UNORM:
135 case VK_FORMAT_ASTC_12x10_SRGB:
136 case VK_FORMAT_ASTC_12x12_UNORM:
137 case VK_FORMAT_ASTC_12x12_SRGB:
145 VkFormat mapTextureFormat (const tcu::TextureFormat& format)
147 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELORDER_LAST < (1<<16));
148 DE_STATIC_ASSERT(tcu::TextureFormat::CHANNELTYPE_LAST < (1<<16));
150 #define PACK_FMT(ORDER, TYPE) ((int(ORDER) << 16) | int(TYPE))
151 #define FMT_CASE(ORDER, TYPE) PACK_FMT(tcu::TextureFormat::ORDER, tcu::TextureFormat::TYPE)
153 // update this mapping if VkFormat changes
154 DE_STATIC_ASSERT(VK_FORMAT_LAST == 174);
156 switch (PACK_FMT(format.order, format.type))
158 case FMT_CASE(RG, UNORM_BYTE_44): return VK_FORMAT_R4G4_UNORM;
159 case FMT_CASE(RGB, UNORM_SHORT_565): return VK_FORMAT_R5G6B5_UNORM;
160 case FMT_CASE(RGBA, UNORM_SHORT_4444): return VK_FORMAT_R4G4B4A4_UNORM;
161 case FMT_CASE(RGBA, UNORM_SHORT_5551): return VK_FORMAT_R5G5B5A1_UNORM;
163 case FMT_CASE(RG, UNSIGNED_BYTE_44): return VK_FORMAT_R4G4_USCALED;
164 case FMT_CASE(RGBA, UNSIGNED_SHORT_4444): return VK_FORMAT_R4G4B4A4_USCALED;
165 case FMT_CASE(RGB, UNSIGNED_SHORT_565): return VK_FORMAT_R5G6B5_USCALED;
166 case FMT_CASE(RGBA, UNSIGNED_SHORT_5551): return VK_FORMAT_R5G5B5A1_USCALED;
168 case FMT_CASE(BGR, UNORM_SHORT_565): return VK_FORMAT_B5G6R5_UNORM;
169 case FMT_CASE(BGRA, UNORM_SHORT_4444): return VK_FORMAT_B4G4R4A4_UNORM;
170 case FMT_CASE(BGRA, UNORM_SHORT_5551): return VK_FORMAT_B5G5R5A1_UNORM;
172 case FMT_CASE(BGR, UNSIGNED_SHORT_565): return VK_FORMAT_B5G6R5_USCALED;
174 case FMT_CASE(R, UNORM_INT8): return VK_FORMAT_R8_UNORM;
175 case FMT_CASE(R, SNORM_INT8): return VK_FORMAT_R8_SNORM;
176 case FMT_CASE(R, UNSIGNED_INT8): return VK_FORMAT_R8_UINT;
177 case FMT_CASE(R, SIGNED_INT8): return VK_FORMAT_R8_SINT;
178 case FMT_CASE(sR, UNORM_INT8): return VK_FORMAT_R8_SRGB;
180 case FMT_CASE(RG, UNORM_INT8): return VK_FORMAT_R8G8_UNORM;
181 case FMT_CASE(RG, SNORM_INT8): return VK_FORMAT_R8G8_SNORM;
182 case FMT_CASE(RG, UNSIGNED_INT8): return VK_FORMAT_R8G8_UINT;
183 case FMT_CASE(RG, SIGNED_INT8): return VK_FORMAT_R8G8_SINT;
184 case FMT_CASE(sRG, UNORM_INT8): return VK_FORMAT_R8G8_SRGB;
186 case FMT_CASE(RGB, UNORM_INT8): return VK_FORMAT_R8G8B8_UNORM;
187 case FMT_CASE(RGB, SNORM_INT8): return VK_FORMAT_R8G8B8_SNORM;
188 case FMT_CASE(RGB, UNSIGNED_INT8): return VK_FORMAT_R8G8B8_UINT;
189 case FMT_CASE(RGB, SIGNED_INT8): return VK_FORMAT_R8G8B8_SINT;
190 case FMT_CASE(sRGB, UNORM_INT8): return VK_FORMAT_R8G8B8_SRGB;
192 case FMT_CASE(RGBA, UNORM_INT8): return VK_FORMAT_R8G8B8A8_UNORM;
193 case FMT_CASE(RGBA, SNORM_INT8): return VK_FORMAT_R8G8B8A8_SNORM;
194 case FMT_CASE(RGBA, UNSIGNED_INT8): return VK_FORMAT_R8G8B8A8_UINT;
195 case FMT_CASE(RGBA, SIGNED_INT8): return VK_FORMAT_R8G8B8A8_SINT;
196 case FMT_CASE(sRGBA, UNORM_INT8): return VK_FORMAT_R8G8B8A8_SRGB;
198 case FMT_CASE(RGBA, SNORM_INT_1010102_REV): return VK_FORMAT_R10G10B10A2_SNORM;
199 case FMT_CASE(RGBA, UNORM_INT_1010102_REV): return VK_FORMAT_R10G10B10A2_UNORM;
200 case FMT_CASE(RGBA, UNSIGNED_INT_1010102_REV): return VK_FORMAT_R10G10B10A2_UINT;
201 case FMT_CASE(RGBA, SIGNED_INT_1010102_REV): return VK_FORMAT_R10G10B10A2_SINT;
203 case FMT_CASE(R, UNORM_INT16): return VK_FORMAT_R16_UNORM;
204 case FMT_CASE(R, SNORM_INT16): return VK_FORMAT_R16_SNORM;
205 case FMT_CASE(R, UNSIGNED_INT16): return VK_FORMAT_R16_UINT;
206 case FMT_CASE(R, SIGNED_INT16): return VK_FORMAT_R16_SINT;
207 case FMT_CASE(R, HALF_FLOAT): return VK_FORMAT_R16_SFLOAT;
209 case FMT_CASE(RG, UNORM_INT16): return VK_FORMAT_R16G16_UNORM;
210 case FMT_CASE(RG, SNORM_INT16): return VK_FORMAT_R16G16_SNORM;
211 case FMT_CASE(RG, UNSIGNED_INT16): return VK_FORMAT_R16G16_UINT;
212 case FMT_CASE(RG, SIGNED_INT16): return VK_FORMAT_R16G16_SINT;
213 case FMT_CASE(RG, HALF_FLOAT): return VK_FORMAT_R16G16_SFLOAT;
215 case FMT_CASE(RGB, UNORM_INT16): return VK_FORMAT_R16G16B16_UNORM;
216 case FMT_CASE(RGB, SNORM_INT16): return VK_FORMAT_R16G16B16_SNORM;
217 case FMT_CASE(RGB, UNSIGNED_INT16): return VK_FORMAT_R16G16B16_UINT;
218 case FMT_CASE(RGB, SIGNED_INT16): return VK_FORMAT_R16G16B16_SINT;
219 case FMT_CASE(RGB, HALF_FLOAT): return VK_FORMAT_R16G16B16_SFLOAT;
221 case FMT_CASE(RGBA, UNORM_INT16): return VK_FORMAT_R16G16B16A16_UNORM;
222 case FMT_CASE(RGBA, SNORM_INT16): return VK_FORMAT_R16G16B16A16_SNORM;
223 case FMT_CASE(RGBA, UNSIGNED_INT16): return VK_FORMAT_R16G16B16A16_UINT;
224 case FMT_CASE(RGBA, SIGNED_INT16): return VK_FORMAT_R16G16B16A16_SINT;
225 case FMT_CASE(RGBA, HALF_FLOAT): return VK_FORMAT_R16G16B16A16_SFLOAT;
227 case FMT_CASE(R, UNSIGNED_INT32): return VK_FORMAT_R32_UINT;
228 case FMT_CASE(R, SIGNED_INT32): return VK_FORMAT_R32_SINT;
229 case FMT_CASE(R, FLOAT): return VK_FORMAT_R32_SFLOAT;
231 case FMT_CASE(RG, UNSIGNED_INT32): return VK_FORMAT_R32G32_UINT;
232 case FMT_CASE(RG, SIGNED_INT32): return VK_FORMAT_R32G32_SINT;
233 case FMT_CASE(RG, FLOAT): return VK_FORMAT_R32G32_SFLOAT;
235 case FMT_CASE(RGB, UNSIGNED_INT32): return VK_FORMAT_R32G32B32_UINT;
236 case FMT_CASE(RGB, SIGNED_INT32): return VK_FORMAT_R32G32B32_SINT;
237 case FMT_CASE(RGB, FLOAT): return VK_FORMAT_R32G32B32_SFLOAT;
239 case FMT_CASE(RGBA, UNSIGNED_INT32): return VK_FORMAT_R32G32B32A32_UINT;
240 case FMT_CASE(RGBA, SIGNED_INT32): return VK_FORMAT_R32G32B32A32_SINT;
241 case FMT_CASE(RGBA, FLOAT): return VK_FORMAT_R32G32B32A32_SFLOAT;
243 case FMT_CASE(R, FLOAT64): return VK_FORMAT_R64_SFLOAT;
244 case FMT_CASE(RG, FLOAT64): return VK_FORMAT_R64G64_SFLOAT;
245 case FMT_CASE(RGB, FLOAT64): return VK_FORMAT_R64G64B64_SFLOAT;
246 case FMT_CASE(RGBA, FLOAT64): return VK_FORMAT_R64G64B64A64_SFLOAT;
248 case FMT_CASE(RGB, UNSIGNED_INT_11F_11F_10F_REV): return VK_FORMAT_R11G11B10_UFLOAT;
249 case FMT_CASE(RGB, UNSIGNED_INT_999_E5_REV): return VK_FORMAT_R9G9B9E5_UFLOAT;
251 case FMT_CASE(BGR, UNORM_INT8): return VK_FORMAT_B8G8R8_UNORM;
252 case FMT_CASE(BGR, SNORM_INT8): return VK_FORMAT_B8G8R8_SNORM;
253 case FMT_CASE(BGR, UNSIGNED_INT8): return VK_FORMAT_B8G8R8_UINT;
254 case FMT_CASE(BGR, SIGNED_INT8): return VK_FORMAT_B8G8R8_SINT;
255 case FMT_CASE(sBGR, UNORM_INT8): return VK_FORMAT_B8G8R8_SRGB;
257 case FMT_CASE(BGRA, UNORM_INT8): return VK_FORMAT_B8G8R8A8_UNORM;
258 case FMT_CASE(BGRA, SNORM_INT8): return VK_FORMAT_B8G8R8A8_SNORM;
259 case FMT_CASE(BGRA, UNSIGNED_INT8): return VK_FORMAT_B8G8R8A8_UINT;
260 case FMT_CASE(BGRA, SIGNED_INT8): return VK_FORMAT_B8G8R8A8_SINT;
261 case FMT_CASE(sBGRA, UNORM_INT8): return VK_FORMAT_B8G8R8A8_SRGB;
263 case FMT_CASE(BGRA, UNORM_INT_1010102_REV): return VK_FORMAT_B10G10R10A2_UNORM;
264 case FMT_CASE(BGRA, SNORM_INT_1010102_REV): return VK_FORMAT_B10G10R10A2_SNORM;
265 case FMT_CASE(BGRA, UNSIGNED_INT_1010102_REV): return VK_FORMAT_B10G10R10A2_UINT;
266 case FMT_CASE(BGRA, SIGNED_INT_1010102_REV): return VK_FORMAT_B10G10R10A2_SINT;
268 case FMT_CASE(D, UNORM_INT16): return VK_FORMAT_D16_UNORM;
269 case FMT_CASE(D, UNSIGNED_INT_24_8_REV): return VK_FORMAT_D24_UNORM_X8;
270 case FMT_CASE(D, FLOAT): return VK_FORMAT_D32_SFLOAT;
272 case FMT_CASE(S, UNSIGNED_INT8): return VK_FORMAT_S8_UINT;
274 case FMT_CASE(DS, UNSIGNED_INT_16_8_8): return VK_FORMAT_D16_UNORM_S8_UINT;
275 case FMT_CASE(DS, UNSIGNED_INT_24_8_REV): return VK_FORMAT_D24_UNORM_S8_UINT;
276 case FMT_CASE(DS, FLOAT_UNSIGNED_INT_24_8_REV): return VK_FORMAT_D32_SFLOAT_S8_UINT;
279 TCU_THROW(InternalError, "Unknown texture format");
286 tcu::TextureFormat mapVkFormat (VkFormat format)
288 using tcu::TextureFormat;
290 // update this mapping if VkFormat changes
291 DE_STATIC_ASSERT(VK_FORMAT_LAST == 174);
295 case VK_FORMAT_R4G4_UNORM: return TextureFormat(TextureFormat::RG, TextureFormat::UNORM_BYTE_44);
296 case VK_FORMAT_R5G6B5_UNORM: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_SHORT_565);
297 case VK_FORMAT_R4G4B4A4_UNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_SHORT_4444);
298 case VK_FORMAT_R5G5B5A1_UNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_SHORT_5551);
300 case VK_FORMAT_R4G4_USCALED: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_BYTE_44);
301 case VK_FORMAT_R4G4B4A4_USCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_SHORT_4444);
302 case VK_FORMAT_R5G6B5_USCALED: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_SHORT_565);
303 case VK_FORMAT_R5G5B5A1_USCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_SHORT_5551);
305 case VK_FORMAT_B5G6R5_UNORM: return TextureFormat(TextureFormat::BGR, TextureFormat::UNORM_SHORT_565);
306 case VK_FORMAT_B4G4R4A4_UNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_SHORT_4444);
307 case VK_FORMAT_B5G5R5A1_UNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_SHORT_5551);
309 case VK_FORMAT_B5G6R5_USCALED: return TextureFormat(TextureFormat::BGR, TextureFormat::UNSIGNED_SHORT_565);
311 case VK_FORMAT_R8_UNORM: return TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT8);
312 case VK_FORMAT_R8_SNORM: return TextureFormat(TextureFormat::R, TextureFormat::SNORM_INT8);
313 case VK_FORMAT_R8_USCALED: return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8);
314 case VK_FORMAT_R8_SSCALED: return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT8);
315 case VK_FORMAT_R8_UINT: return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8);
316 case VK_FORMAT_R8_SINT: return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT8);
317 case VK_FORMAT_R8_SRGB: return TextureFormat(TextureFormat::sR, TextureFormat::UNORM_INT8);
319 case VK_FORMAT_R8G8_UNORM: return TextureFormat(TextureFormat::RG, TextureFormat::UNORM_INT8);
320 case VK_FORMAT_R8G8_SNORM: return TextureFormat(TextureFormat::RG, TextureFormat::SNORM_INT8);
321 case VK_FORMAT_R8G8_USCALED: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT8);
322 case VK_FORMAT_R8G8_SSCALED: return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT8);
323 case VK_FORMAT_R8G8_UINT: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT8);
324 case VK_FORMAT_R8G8_SINT: return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT8);
325 case VK_FORMAT_R8G8_SRGB: return TextureFormat(TextureFormat::sRG, TextureFormat::UNORM_INT8);
327 case VK_FORMAT_R8G8B8_UNORM: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT8);
328 case VK_FORMAT_R8G8B8_SNORM: return TextureFormat(TextureFormat::RGB, TextureFormat::SNORM_INT8);
329 case VK_FORMAT_R8G8B8_USCALED: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT8);
330 case VK_FORMAT_R8G8B8_SSCALED: return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT8);
331 case VK_FORMAT_R8G8B8_UINT: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT8);
332 case VK_FORMAT_R8G8B8_SINT: return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT8);
333 case VK_FORMAT_R8G8B8_SRGB: return TextureFormat(TextureFormat::sRGB, TextureFormat::UNORM_INT8);
335 case VK_FORMAT_R8G8B8A8_UNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT8);
336 case VK_FORMAT_R8G8B8A8_SNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::SNORM_INT8);
337 case VK_FORMAT_R8G8B8A8_USCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT8);
338 case VK_FORMAT_R8G8B8A8_SSCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT8);
339 case VK_FORMAT_R8G8B8A8_UINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT8);
340 case VK_FORMAT_R8G8B8A8_SINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT8);
341 case VK_FORMAT_R8G8B8A8_SRGB: return TextureFormat(TextureFormat::sRGBA, TextureFormat::UNORM_INT8);
343 case VK_FORMAT_R10G10B10A2_UNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT_1010102_REV);
344 case VK_FORMAT_R10G10B10A2_SNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::SNORM_INT_1010102_REV);
345 case VK_FORMAT_R10G10B10A2_UINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT_1010102_REV);
346 case VK_FORMAT_R10G10B10A2_SINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT_1010102_REV);
347 case VK_FORMAT_R10G10B10A2_USCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT_1010102_REV);
348 case VK_FORMAT_R10G10B10A2_SSCALED: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT_1010102_REV);
350 case VK_FORMAT_R16_UNORM: return TextureFormat(TextureFormat::R, TextureFormat::UNORM_INT16);
351 case VK_FORMAT_R16_SNORM: return TextureFormat(TextureFormat::R, TextureFormat::SNORM_INT16);
352 case VK_FORMAT_R16_USCALED: return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT16);
353 case VK_FORMAT_R16_SSCALED: return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT16);
354 case VK_FORMAT_R16_UINT: return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT16);
355 case VK_FORMAT_R16_SINT: return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT16);
356 case VK_FORMAT_R16_SFLOAT: return TextureFormat(TextureFormat::R, TextureFormat::HALF_FLOAT);
358 case VK_FORMAT_R16G16_UNORM: return TextureFormat(TextureFormat::RG, TextureFormat::UNORM_INT16);
359 case VK_FORMAT_R16G16_SNORM: return TextureFormat(TextureFormat::RG, TextureFormat::SNORM_INT16);
360 case VK_FORMAT_R16G16_USCALED: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT16);
361 case VK_FORMAT_R16G16_SSCALED: return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT16);
362 case VK_FORMAT_R16G16_UINT: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT16);
363 case VK_FORMAT_R16G16_SINT: return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT16);
364 case VK_FORMAT_R16G16_SFLOAT: return TextureFormat(TextureFormat::RG, TextureFormat::HALF_FLOAT);
366 case VK_FORMAT_R16G16B16_UNORM: return TextureFormat(TextureFormat::RGB, TextureFormat::UNORM_INT16);
367 case VK_FORMAT_R16G16B16_SNORM: return TextureFormat(TextureFormat::RGB, TextureFormat::SNORM_INT16);
368 case VK_FORMAT_R16G16B16_USCALED: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT16);
369 case VK_FORMAT_R16G16B16_SSCALED: return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT16);
370 case VK_FORMAT_R16G16B16_UINT: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT16);
371 case VK_FORMAT_R16G16B16_SINT: return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT16);
372 case VK_FORMAT_R16G16B16_SFLOAT: return TextureFormat(TextureFormat::RGB, TextureFormat::HALF_FLOAT);
374 case VK_FORMAT_R16G16B16A16_UNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNORM_INT16);
375 case VK_FORMAT_R16G16B16A16_SNORM: return TextureFormat(TextureFormat::RGBA, TextureFormat::SNORM_INT16);
376 case VK_FORMAT_R16G16B16A16_USCALED:return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT16);
377 case VK_FORMAT_R16G16B16A16_SSCALED:return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT16);
378 case VK_FORMAT_R16G16B16A16_UINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT16);
379 case VK_FORMAT_R16G16B16A16_SINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT16);
380 case VK_FORMAT_R16G16B16A16_SFLOAT: return TextureFormat(TextureFormat::RGBA, TextureFormat::HALF_FLOAT);
382 case VK_FORMAT_R32_UINT: return TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT32);
383 case VK_FORMAT_R32_SINT: return TextureFormat(TextureFormat::R, TextureFormat::SIGNED_INT32);
384 case VK_FORMAT_R32_SFLOAT: return TextureFormat(TextureFormat::R, TextureFormat::FLOAT);
386 case VK_FORMAT_R32G32_UINT: return TextureFormat(TextureFormat::RG, TextureFormat::UNSIGNED_INT32);
387 case VK_FORMAT_R32G32_SINT: return TextureFormat(TextureFormat::RG, TextureFormat::SIGNED_INT32);
388 case VK_FORMAT_R32G32_SFLOAT: return TextureFormat(TextureFormat::RG, TextureFormat::FLOAT);
390 case VK_FORMAT_R32G32B32_UINT: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT32);
391 case VK_FORMAT_R32G32B32_SINT: return TextureFormat(TextureFormat::RGB, TextureFormat::SIGNED_INT32);
392 case VK_FORMAT_R32G32B32_SFLOAT: return TextureFormat(TextureFormat::RGB, TextureFormat::FLOAT);
394 case VK_FORMAT_R32G32B32A32_UINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::UNSIGNED_INT32);
395 case VK_FORMAT_R32G32B32A32_SINT: return TextureFormat(TextureFormat::RGBA, TextureFormat::SIGNED_INT32);
396 case VK_FORMAT_R32G32B32A32_SFLOAT: return TextureFormat(TextureFormat::RGBA, TextureFormat::FLOAT);
398 case VK_FORMAT_R64_SFLOAT: return TextureFormat(TextureFormat::R, TextureFormat::FLOAT64);
399 case VK_FORMAT_R64G64_SFLOAT: return TextureFormat(TextureFormat::RG, TextureFormat::FLOAT64);
400 case VK_FORMAT_R64G64B64_SFLOAT: return TextureFormat(TextureFormat::RGB, TextureFormat::FLOAT64);
401 case VK_FORMAT_R64G64B64A64_SFLOAT: return TextureFormat(TextureFormat::RGBA, TextureFormat::FLOAT64);
403 case VK_FORMAT_R11G11B10_UFLOAT: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT_11F_11F_10F_REV);
404 case VK_FORMAT_R9G9B9E5_UFLOAT: return TextureFormat(TextureFormat::RGB, TextureFormat::UNSIGNED_INT_999_E5_REV);
406 case VK_FORMAT_B8G8R8_UNORM: return TextureFormat(TextureFormat::BGR, TextureFormat::UNORM_INT8);
407 case VK_FORMAT_B8G8R8_SNORM: return TextureFormat(TextureFormat::BGR, TextureFormat::SNORM_INT8);
408 case VK_FORMAT_B8G8R8_USCALED: return TextureFormat(TextureFormat::BGR, TextureFormat::UNSIGNED_INT8);
409 case VK_FORMAT_B8G8R8_SSCALED: return TextureFormat(TextureFormat::BGR, TextureFormat::SIGNED_INT8);
410 case VK_FORMAT_B8G8R8_UINT: return TextureFormat(TextureFormat::BGR, TextureFormat::UNSIGNED_INT8);
411 case VK_FORMAT_B8G8R8_SINT: return TextureFormat(TextureFormat::BGR, TextureFormat::SIGNED_INT8);
412 case VK_FORMAT_B8G8R8_SRGB: return TextureFormat(TextureFormat::sBGR, TextureFormat::UNORM_INT8);
414 case VK_FORMAT_B8G8R8A8_UNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT8);
415 case VK_FORMAT_B8G8R8A8_SNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::SNORM_INT8);
416 case VK_FORMAT_B8G8R8A8_USCALED: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNSIGNED_INT8);
417 case VK_FORMAT_B8G8R8A8_SSCALED: return TextureFormat(TextureFormat::BGRA, TextureFormat::SIGNED_INT8);
418 case VK_FORMAT_B8G8R8A8_UINT: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNSIGNED_INT8);
419 case VK_FORMAT_B8G8R8A8_SINT: return TextureFormat(TextureFormat::BGRA, TextureFormat::SIGNED_INT8);
420 case VK_FORMAT_B8G8R8A8_SRGB: return TextureFormat(TextureFormat::sBGRA, TextureFormat::UNORM_INT8);
422 case VK_FORMAT_D16_UNORM: return TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT16);
423 case VK_FORMAT_D24_UNORM_X8: return TextureFormat(TextureFormat::D, TextureFormat::UNSIGNED_INT_24_8_REV);
424 case VK_FORMAT_D32_SFLOAT: return TextureFormat(TextureFormat::D, TextureFormat::FLOAT);
426 case VK_FORMAT_S8_UINT: return TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8);
428 // \note There is no standard interleaved memory layout for DS formats; buffer-image copies
429 // will always operate on either D or S aspect only. See Khronos bug 12998
430 case VK_FORMAT_D16_UNORM_S8_UINT: return TextureFormat(TextureFormat::DS, TextureFormat::UNSIGNED_INT_16_8_8);
431 case VK_FORMAT_D24_UNORM_S8_UINT: return TextureFormat(TextureFormat::DS, TextureFormat::UNSIGNED_INT_24_8_REV);
432 case VK_FORMAT_D32_SFLOAT_S8_UINT: return TextureFormat(TextureFormat::DS, TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV);
434 case VK_FORMAT_B10G10R10A2_UNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNORM_INT_1010102_REV);
435 case VK_FORMAT_B10G10R10A2_SNORM: return TextureFormat(TextureFormat::BGRA, TextureFormat::SNORM_INT_1010102_REV);
436 case VK_FORMAT_B10G10R10A2_USCALED: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNSIGNED_INT_1010102_REV);
437 case VK_FORMAT_B10G10R10A2_SSCALED: return TextureFormat(TextureFormat::BGRA, TextureFormat::SIGNED_INT_1010102_REV);
438 case VK_FORMAT_B10G10R10A2_UINT: return TextureFormat(TextureFormat::BGRA, TextureFormat::UNSIGNED_INT_1010102_REV);
439 case VK_FORMAT_B10G10R10A2_SINT: return TextureFormat(TextureFormat::BGRA, TextureFormat::SIGNED_INT_1010102_REV);
442 TCU_THROW(InternalError, "Unknown image format");
446 tcu::CompressedTexFormat mapVkCompressedFormat (VkFormat format)
450 case VK_FORMAT_ETC2_R8G8B8_UNORM: return tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8;
451 case VK_FORMAT_ETC2_R8G8B8_SRGB: return tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8;
452 case VK_FORMAT_ETC2_R8G8B8A1_UNORM: return tcu::COMPRESSEDTEXFORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
453 case VK_FORMAT_ETC2_R8G8B8A1_SRGB: return tcu::COMPRESSEDTEXFORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
454 case VK_FORMAT_ETC2_R8G8B8A8_UNORM: return tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_RGBA8;
455 case VK_FORMAT_ETC2_R8G8B8A8_SRGB: return tcu::COMPRESSEDTEXFORMAT_ETC2_EAC_SRGB8_ALPHA8;
456 case VK_FORMAT_EAC_R11_UNORM: return tcu::COMPRESSEDTEXFORMAT_EAC_R11;
457 case VK_FORMAT_EAC_R11_SNORM: return tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_R11;
458 case VK_FORMAT_EAC_R11G11_UNORM: return tcu::COMPRESSEDTEXFORMAT_EAC_RG11;
459 case VK_FORMAT_EAC_R11G11_SNORM: return tcu::COMPRESSEDTEXFORMAT_EAC_SIGNED_RG11;
460 case VK_FORMAT_ASTC_4x4_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_RGBA;
461 case VK_FORMAT_ASTC_4x4_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_4x4_SRGB8_ALPHA8;
462 case VK_FORMAT_ASTC_5x4_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_5x4_RGBA;
463 case VK_FORMAT_ASTC_5x4_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8;
464 case VK_FORMAT_ASTC_5x5_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_RGBA;
465 case VK_FORMAT_ASTC_5x5_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_5x5_SRGB8_ALPHA8;
466 case VK_FORMAT_ASTC_6x5_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_RGBA;
467 case VK_FORMAT_ASTC_6x5_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_6x5_SRGB8_ALPHA8;
468 case VK_FORMAT_ASTC_6x6_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_RGBA;
469 case VK_FORMAT_ASTC_6x6_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_6x6_SRGB8_ALPHA8;
470 case VK_FORMAT_ASTC_8x5_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x5_RGBA;
471 case VK_FORMAT_ASTC_8x5_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8;
472 case VK_FORMAT_ASTC_8x6_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_RGBA;
473 case VK_FORMAT_ASTC_8x6_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x6_SRGB8_ALPHA8;
474 case VK_FORMAT_ASTC_8x8_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_RGBA;
475 case VK_FORMAT_ASTC_8x8_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_8x8_SRGB8_ALPHA8;
476 case VK_FORMAT_ASTC_10x5_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_RGBA;
477 case VK_FORMAT_ASTC_10x5_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x5_SRGB8_ALPHA8;
478 case VK_FORMAT_ASTC_10x6_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_RGBA;
479 case VK_FORMAT_ASTC_10x6_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x6_SRGB8_ALPHA8;
480 case VK_FORMAT_ASTC_10x8_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_RGBA;
481 case VK_FORMAT_ASTC_10x8_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x8_SRGB8_ALPHA8;
482 case VK_FORMAT_ASTC_10x10_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_RGBA;
483 case VK_FORMAT_ASTC_10x10_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_10x10_SRGB8_ALPHA8;
484 case VK_FORMAT_ASTC_12x10_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_RGBA;
485 case VK_FORMAT_ASTC_12x10_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_12x10_SRGB8_ALPHA8;
486 case VK_FORMAT_ASTC_12x12_UNORM: return tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_RGBA;
487 case VK_FORMAT_ASTC_12x12_SRGB: return tcu::COMPRESSEDTEXFORMAT_ASTC_12x12_SRGB8_ALPHA8;
492 return tcu::COMPRESSEDTEXFORMAT_LAST;
495 VkChannelMapping getFormatChannelMapping (VkFormat format)
497 using tcu::TextureFormat;
499 static const VkChannelMapping R = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ONE };
500 static const VkChannelMapping RG = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ONE };
501 static const VkChannelMapping RGB = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_ONE };
502 static const VkChannelMapping RGBA = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_A };
503 static const VkChannelMapping S = { VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_A };
504 static const VkChannelMapping DS = { VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_ZERO, VK_CHANNEL_SWIZZLE_A };
505 static const VkChannelMapping BGRA = { VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_A };
507 if (format == VK_FORMAT_UNDEFINED)
510 const tcu::TextureFormat tcuFormat = (isCompressedFormat(format)) ? tcu::getUncompressedFormat(mapVkCompressedFormat(format))
511 : mapVkFormat(format);
513 switch (tcuFormat.order)
515 case TextureFormat::R: return R;
516 case TextureFormat::RG: return RG;
517 case TextureFormat::RGB: return RGB;
518 case TextureFormat::RGBA: return RGBA;
519 case TextureFormat::BGRA: return BGRA;
520 case TextureFormat::sR: return R;
521 case TextureFormat::sRG: return RG;
522 case TextureFormat::sRGB: return RGB;
523 case TextureFormat::sRGBA: return RGBA;
524 case TextureFormat::D: return R;
525 case TextureFormat::S: return S;
526 case TextureFormat::DS: return DS;
535 static bool isScaledFormat (VkFormat format)
537 // update this mapping if VkFormat changes
538 DE_STATIC_ASSERT(VK_FORMAT_LAST == 174);
542 case VK_FORMAT_R4G4_USCALED:
543 case VK_FORMAT_R4G4B4A4_USCALED:
544 case VK_FORMAT_R5G6B5_USCALED:
545 case VK_FORMAT_R5G5B5A1_USCALED:
546 case VK_FORMAT_R8_USCALED:
547 case VK_FORMAT_R8_SSCALED:
548 case VK_FORMAT_R8G8_USCALED:
549 case VK_FORMAT_R8G8_SSCALED:
550 case VK_FORMAT_R8G8B8_USCALED:
551 case VK_FORMAT_R8G8B8_SSCALED:
552 case VK_FORMAT_R8G8B8A8_USCALED:
553 case VK_FORMAT_R8G8B8A8_SSCALED:
554 case VK_FORMAT_R10G10B10A2_USCALED:
555 case VK_FORMAT_R10G10B10A2_SSCALED:
556 case VK_FORMAT_R16_USCALED:
557 case VK_FORMAT_R16_SSCALED:
558 case VK_FORMAT_R16G16_USCALED:
559 case VK_FORMAT_R16G16_SSCALED:
560 case VK_FORMAT_R16G16B16_USCALED:
561 case VK_FORMAT_R16G16B16_SSCALED:
562 case VK_FORMAT_R16G16B16A16_USCALED:
563 case VK_FORMAT_R16G16B16A16_SSCALED:
564 case VK_FORMAT_B5G6R5_USCALED:
565 case VK_FORMAT_B8G8R8_USCALED:
566 case VK_FORMAT_B8G8R8_SSCALED:
567 case VK_FORMAT_B8G8R8A8_USCALED:
568 case VK_FORMAT_B8G8R8A8_SSCALED:
569 case VK_FORMAT_B10G10R10A2_USCALED:
570 case VK_FORMAT_B10G10R10A2_SSCALED:
578 static bool fullTextureFormatRoundTripSupported (VkFormat format)
580 if (isScaledFormat(format))
582 // *SCALED formats get mapped to correspoding (u)int formats since
583 // accessing them through (float) getPixel/setPixel has same behavior
584 // as in shader access in Vulkan.
585 // Unfortunately full round-trip between tcu::TextureFormat and VkFormat
586 // for most SCALED formats is not supported though.
588 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
590 switch (tcuFormat.type)
592 case tcu::TextureFormat::UNSIGNED_INT8:
593 case tcu::TextureFormat::UNSIGNED_INT16:
594 case tcu::TextureFormat::UNSIGNED_INT32:
595 case tcu::TextureFormat::SIGNED_INT8:
596 case tcu::TextureFormat::SIGNED_INT16:
597 case tcu::TextureFormat::SIGNED_INT32:
598 case tcu::TextureFormat::UNSIGNED_INT_1010102_REV:
599 case tcu::TextureFormat::SIGNED_INT_1010102_REV:
607 return (format != VK_FORMAT_UNDEFINED);
610 void imageUtilSelfTest (void)
612 for (int formatNdx = 0; formatNdx < VK_FORMAT_LAST; formatNdx++)
614 const VkFormat format = (VkFormat)formatNdx;
616 if (format != VK_FORMAT_UNDEFINED && !isCompressedFormat(format))
618 const tcu::TextureFormat tcuFormat = mapVkFormat(format);
619 const VkFormat remappedFormat = mapTextureFormat(tcuFormat);
621 DE_TEST_ASSERT(isValid(tcuFormat));
623 if (fullTextureFormatRoundTripSupported(format))
624 DE_TEST_ASSERT(format == remappedFormat);
629 VkTexFilter mapFilterMode (tcu::Sampler::FilterMode filterMode)
631 DE_STATIC_ASSERT(tcu::Sampler::FILTERMODE_LAST == 6);
635 case tcu::Sampler::NEAREST: return VK_TEX_FILTER_NEAREST;
636 case tcu::Sampler::LINEAR: return VK_TEX_FILTER_LINEAR;
637 case tcu::Sampler::NEAREST_MIPMAP_NEAREST: return VK_TEX_FILTER_NEAREST;
638 case tcu::Sampler::NEAREST_MIPMAP_LINEAR: return VK_TEX_FILTER_NEAREST;
639 case tcu::Sampler::LINEAR_MIPMAP_NEAREST: return VK_TEX_FILTER_LINEAR;
640 case tcu::Sampler::LINEAR_MIPMAP_LINEAR: return VK_TEX_FILTER_LINEAR;
642 DE_FATAL("Illegal filter mode");
643 return (VkTexFilter)0;
648 VkTexMipmapMode mapMipmapMode (tcu::Sampler::FilterMode filterMode)
650 DE_STATIC_ASSERT(tcu::Sampler::FILTERMODE_LAST == 6);
654 case tcu::Sampler::NEAREST: return VK_TEX_MIPMAP_MODE_BASE;
655 case tcu::Sampler::LINEAR: return VK_TEX_MIPMAP_MODE_BASE;
656 case tcu::Sampler::NEAREST_MIPMAP_NEAREST: return VK_TEX_MIPMAP_MODE_NEAREST;
657 case tcu::Sampler::NEAREST_MIPMAP_LINEAR: return VK_TEX_MIPMAP_MODE_LINEAR;
658 case tcu::Sampler::LINEAR_MIPMAP_NEAREST: return VK_TEX_MIPMAP_MODE_NEAREST;
659 case tcu::Sampler::LINEAR_MIPMAP_LINEAR: return VK_TEX_MIPMAP_MODE_LINEAR;
661 DE_FATAL("Illegal filter mode");
662 return (VkTexMipmapMode)0;
666 VkTexAddressMode mapWrapMode (tcu::Sampler::WrapMode wrapMode)
670 case tcu::Sampler::CLAMP_TO_EDGE: return VK_TEX_ADDRESS_MODE_CLAMP;
671 case tcu::Sampler::CLAMP_TO_BORDER: return VK_TEX_ADDRESS_MODE_CLAMP_BORDER;
672 case tcu::Sampler::REPEAT_GL: return VK_TEX_ADDRESS_MODE_WRAP;
673 case tcu::Sampler::MIRRORED_REPEAT_GL: return VK_TEX_ADDRESS_MODE_MIRROR;
675 DE_FATAL("Wrap mode can't be mapped to Vulkan");
676 return (vk::VkTexAddressMode)0;
680 vk::VkCompareOp mapCompareMode (tcu::Sampler::CompareMode mode)
684 case tcu::Sampler::COMPAREMODE_NONE: return vk::VK_COMPARE_OP_NEVER;
685 case tcu::Sampler::COMPAREMODE_LESS: return vk::VK_COMPARE_OP_LESS;
686 case tcu::Sampler::COMPAREMODE_LESS_OR_EQUAL: return vk::VK_COMPARE_OP_LESS_EQUAL;
687 case tcu::Sampler::COMPAREMODE_GREATER: return vk::VK_COMPARE_OP_GREATER;
688 case tcu::Sampler::COMPAREMODE_GREATER_OR_EQUAL: return vk::VK_COMPARE_OP_GREATER_EQUAL;
689 case tcu::Sampler::COMPAREMODE_EQUAL: return vk::VK_COMPARE_OP_EQUAL;
690 case tcu::Sampler::COMPAREMODE_NOT_EQUAL: return vk::VK_COMPARE_OP_NOT_EQUAL;
691 case tcu::Sampler::COMPAREMODE_ALWAYS: return vk::VK_COMPARE_OP_ALWAYS;
692 case tcu::Sampler::COMPAREMODE_NEVER: return vk::VK_COMPARE_OP_NEVER;
694 DE_FATAL("Illegal compare mode");
695 return (vk::VkCompareOp)0;