• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*------------------------------------------------------------------------
2  * Vulkan Conformance Tests
3  * ------------------------
4  *
5  * Copyright (c) 2015 The Khronos Group Inc.
6  * Copyright (c) 2015 Imagination Technologies Ltd.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *//*!
21  * \file
22  * \brief Utilities for vertex buffers.
23  *//*--------------------------------------------------------------------*/
24 
25 #include "vktPipelineVertexUtil.hpp"
26 #include "vkStrUtil.hpp"
27 #include "tcuVectorUtil.hpp"
28 #include "deStringUtil.hpp"
29 
30 namespace vkt
31 {
32 namespace pipeline
33 {
34 
35 using namespace vk;
36 
getVertexFormatSize(VkFormat format)37 deUint32 getVertexFormatSize (VkFormat format)
38 {
39 	switch (format)
40 	{
41 		case VK_FORMAT_R8_UNORM:
42 		case VK_FORMAT_R8_SNORM:
43 		case VK_FORMAT_R8_USCALED:
44 		case VK_FORMAT_R8_SSCALED:
45 		case VK_FORMAT_R8_UINT:
46 		case VK_FORMAT_R8_SINT:
47 		case VK_FORMAT_R8_SRGB:
48 		case VK_FORMAT_R4G4_UNORM_PACK8:
49 			return 1;
50 
51 		case VK_FORMAT_R8G8_UNORM:
52 		case VK_FORMAT_R8G8_SNORM:
53 		case VK_FORMAT_R8G8_USCALED:
54 		case VK_FORMAT_R8G8_SSCALED:
55 		case VK_FORMAT_R8G8_UINT:
56 		case VK_FORMAT_R8G8_SINT:
57 		case VK_FORMAT_R8G8_SRGB:
58 		case VK_FORMAT_R16_UNORM:
59 		case VK_FORMAT_R16_SNORM:
60 		case VK_FORMAT_R16_USCALED:
61 		case VK_FORMAT_R16_SSCALED:
62 		case VK_FORMAT_R16_UINT:
63 		case VK_FORMAT_R16_SINT:
64 		case VK_FORMAT_R16_SFLOAT:
65 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
66 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
67 			return 2;
68 
69 		case VK_FORMAT_R8G8B8_UNORM:
70 		case VK_FORMAT_R8G8B8_SNORM:
71 		case VK_FORMAT_R8G8B8_USCALED:
72 		case VK_FORMAT_R8G8B8_SSCALED:
73 		case VK_FORMAT_R8G8B8_UINT:
74 		case VK_FORMAT_R8G8B8_SINT:
75 		case VK_FORMAT_R8G8B8_SRGB:
76 		case VK_FORMAT_B8G8R8_UNORM:
77 		case VK_FORMAT_B8G8R8_SNORM:
78 		case VK_FORMAT_B8G8R8_USCALED:
79 		case VK_FORMAT_B8G8R8_SSCALED:
80 		case VK_FORMAT_B8G8R8_UINT:
81 		case VK_FORMAT_B8G8R8_SINT:
82 		case VK_FORMAT_B8G8R8_SRGB:
83 			return 3;
84 
85 		case VK_FORMAT_R8G8B8A8_UNORM:
86 		case VK_FORMAT_R8G8B8A8_SNORM:
87 		case VK_FORMAT_R8G8B8A8_USCALED:
88 		case VK_FORMAT_R8G8B8A8_SSCALED:
89 		case VK_FORMAT_R8G8B8A8_UINT:
90 		case VK_FORMAT_R8G8B8A8_SINT:
91 		case VK_FORMAT_R8G8B8A8_SRGB:
92 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
93 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
94 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
95 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
96 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
97 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
98 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
99 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
100 		case VK_FORMAT_R16G16_UNORM:
101 		case VK_FORMAT_R16G16_SNORM:
102 		case VK_FORMAT_R16G16_USCALED:
103 		case VK_FORMAT_R16G16_SSCALED:
104 		case VK_FORMAT_R16G16_UINT:
105 		case VK_FORMAT_R16G16_SINT:
106 		case VK_FORMAT_R16G16_SFLOAT:
107 		case VK_FORMAT_R32_UINT:
108 		case VK_FORMAT_R32_SINT:
109 		case VK_FORMAT_R32_SFLOAT:
110 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
111 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
112 		case VK_FORMAT_B8G8R8A8_UNORM:
113 		case VK_FORMAT_B8G8R8A8_SNORM:
114 		case VK_FORMAT_B8G8R8A8_USCALED:
115 		case VK_FORMAT_B8G8R8A8_SSCALED:
116 		case VK_FORMAT_B8G8R8A8_UINT:
117 		case VK_FORMAT_B8G8R8A8_SINT:
118 		case VK_FORMAT_B8G8R8A8_SRGB:
119 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
120 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
121 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
122 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
123 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
124 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
125 			return 4;
126 
127 		case VK_FORMAT_R16G16B16_UNORM:
128 		case VK_FORMAT_R16G16B16_SNORM:
129 		case VK_FORMAT_R16G16B16_USCALED:
130 		case VK_FORMAT_R16G16B16_SSCALED:
131 		case VK_FORMAT_R16G16B16_UINT:
132 		case VK_FORMAT_R16G16B16_SINT:
133 		case VK_FORMAT_R16G16B16_SFLOAT:
134 			return 6;
135 
136 		case VK_FORMAT_R16G16B16A16_UNORM:
137 		case VK_FORMAT_R16G16B16A16_SNORM:
138 		case VK_FORMAT_R16G16B16A16_USCALED:
139 		case VK_FORMAT_R16G16B16A16_SSCALED:
140 		case VK_FORMAT_R16G16B16A16_UINT:
141 		case VK_FORMAT_R16G16B16A16_SINT:
142 		case VK_FORMAT_R16G16B16A16_SFLOAT:
143 		case VK_FORMAT_R32G32_UINT:
144 		case VK_FORMAT_R32G32_SINT:
145 		case VK_FORMAT_R32G32_SFLOAT:
146 		case VK_FORMAT_R64_SFLOAT:
147 			return 8;
148 
149 		case VK_FORMAT_R32G32B32_UINT:
150 		case VK_FORMAT_R32G32B32_SINT:
151 		case VK_FORMAT_R32G32B32_SFLOAT:
152 			return 12;
153 
154 		case VK_FORMAT_R32G32B32A32_UINT:
155 		case VK_FORMAT_R32G32B32A32_SINT:
156 		case VK_FORMAT_R32G32B32A32_SFLOAT:
157 		case VK_FORMAT_R64G64_SFLOAT:
158 			return 16;
159 
160 		case VK_FORMAT_R64G64B64_SFLOAT:
161 			return 24;
162 
163 		case VK_FORMAT_R64G64B64A64_SFLOAT:
164 			return 32;
165 
166 		default:
167 			break;
168 	}
169 
170 	DE_ASSERT(false);
171 	return 0;
172 }
173 
getVertexFormatComponentCount(VkFormat format)174 deUint32 getVertexFormatComponentCount (VkFormat format)
175 {
176 	switch (format)
177 	{
178 		case VK_FORMAT_R8_USCALED:
179 		case VK_FORMAT_R8_UNORM:
180 		case VK_FORMAT_R8_UINT:
181 		case VK_FORMAT_R8_SSCALED:
182 		case VK_FORMAT_R8_SRGB:
183 		case VK_FORMAT_R8_SNORM:
184 		case VK_FORMAT_R8_SINT:
185 		case VK_FORMAT_R16_USCALED:
186 		case VK_FORMAT_R16_UNORM:
187 		case VK_FORMAT_R16_UINT:
188 		case VK_FORMAT_R16_SSCALED:
189 		case VK_FORMAT_R16_SNORM:
190 		case VK_FORMAT_R16_SINT:
191 		case VK_FORMAT_R16_SFLOAT:
192 		case VK_FORMAT_R32_UINT:
193 		case VK_FORMAT_R32_SINT:
194 		case VK_FORMAT_R32_SFLOAT:
195 		case VK_FORMAT_R64_SFLOAT:
196 			return 1;
197 
198 		case VK_FORMAT_R4G4_UNORM_PACK8:
199 		case VK_FORMAT_R8G8_UNORM:
200 		case VK_FORMAT_R8G8_SNORM:
201 		case VK_FORMAT_R8G8_USCALED:
202 		case VK_FORMAT_R8G8_SSCALED:
203 		case VK_FORMAT_R8G8_UINT:
204 		case VK_FORMAT_R8G8_SINT:
205 		case VK_FORMAT_R8G8_SRGB:
206 		case VK_FORMAT_R16G16_UNORM:
207 		case VK_FORMAT_R16G16_SNORM:
208 		case VK_FORMAT_R16G16_USCALED:
209 		case VK_FORMAT_R16G16_SSCALED:
210 		case VK_FORMAT_R16G16_UINT:
211 		case VK_FORMAT_R16G16_SINT:
212 		case VK_FORMAT_R16G16_SFLOAT:
213 		case VK_FORMAT_R32G32_UINT:
214 		case VK_FORMAT_R32G32_SINT:
215 		case VK_FORMAT_R32G32_SFLOAT:
216 		case VK_FORMAT_R64G64_SFLOAT:
217 			return 2;
218 
219 		case VK_FORMAT_R8G8B8_UNORM:
220 		case VK_FORMAT_R8G8B8_SNORM:
221 		case VK_FORMAT_R8G8B8_USCALED:
222 		case VK_FORMAT_R8G8B8_SSCALED:
223 		case VK_FORMAT_R8G8B8_UINT:
224 		case VK_FORMAT_R8G8B8_SINT:
225 		case VK_FORMAT_R8G8B8_SRGB:
226 		case VK_FORMAT_B8G8R8_UNORM:
227 		case VK_FORMAT_B8G8R8_SNORM:
228 		case VK_FORMAT_B8G8R8_USCALED:
229 		case VK_FORMAT_B8G8R8_SSCALED:
230 		case VK_FORMAT_B8G8R8_UINT:
231 		case VK_FORMAT_B8G8R8_SINT:
232 		case VK_FORMAT_B8G8R8_SRGB:
233 		case VK_FORMAT_R16G16B16_UNORM:
234 		case VK_FORMAT_R16G16B16_SNORM:
235 		case VK_FORMAT_R16G16B16_USCALED:
236 		case VK_FORMAT_R16G16B16_SSCALED:
237 		case VK_FORMAT_R16G16B16_UINT:
238 		case VK_FORMAT_R16G16B16_SINT:
239 		case VK_FORMAT_R16G16B16_SFLOAT:
240 		case VK_FORMAT_R32G32B32_UINT:
241 		case VK_FORMAT_R32G32B32_SINT:
242 		case VK_FORMAT_R32G32B32_SFLOAT:
243 		case VK_FORMAT_R64G64B64_SFLOAT:
244 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
245 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
246 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
247 			return 3;
248 
249 		case VK_FORMAT_R8G8B8A8_UNORM:
250 		case VK_FORMAT_R8G8B8A8_SNORM:
251 		case VK_FORMAT_R8G8B8A8_USCALED:
252 		case VK_FORMAT_R8G8B8A8_SSCALED:
253 		case VK_FORMAT_R8G8B8A8_UINT:
254 		case VK_FORMAT_R8G8B8A8_SINT:
255 		case VK_FORMAT_R8G8B8A8_SRGB:
256 		case VK_FORMAT_B8G8R8A8_UNORM:
257 		case VK_FORMAT_B8G8R8A8_SNORM:
258 		case VK_FORMAT_B8G8R8A8_USCALED:
259 		case VK_FORMAT_B8G8R8A8_SSCALED:
260 		case VK_FORMAT_B8G8R8A8_UINT:
261 		case VK_FORMAT_B8G8R8A8_SINT:
262 		case VK_FORMAT_B8G8R8A8_SRGB:
263 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
264 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
265 		case VK_FORMAT_R16G16B16A16_UNORM:
266 		case VK_FORMAT_R16G16B16A16_SNORM:
267 		case VK_FORMAT_R16G16B16A16_USCALED:
268 		case VK_FORMAT_R16G16B16A16_SSCALED:
269 		case VK_FORMAT_R16G16B16A16_UINT:
270 		case VK_FORMAT_R16G16B16A16_SINT:
271 		case VK_FORMAT_R16G16B16A16_SFLOAT:
272 		case VK_FORMAT_R32G32B32A32_UINT:
273 		case VK_FORMAT_R32G32B32A32_SINT:
274 		case VK_FORMAT_R32G32B32A32_SFLOAT:
275 		case VK_FORMAT_R64G64B64A64_SFLOAT:
276 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
277 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
278 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
279 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
280 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
281 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
282 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
283 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
284 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
285 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
286 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
287 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
288 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
289 			return 4;
290 
291 		default:
292 			break;
293 	}
294 
295 	DE_ASSERT(false);
296 	return 0;
297 }
298 
getVertexFormatComponentSize(VkFormat format)299 deUint32 getVertexFormatComponentSize (VkFormat format)
300 {
301 	switch (format)
302 	{
303 		case VK_FORMAT_R8_UNORM:
304 		case VK_FORMAT_R8_SNORM:
305 		case VK_FORMAT_R8_USCALED:
306 		case VK_FORMAT_R8_SSCALED:
307 		case VK_FORMAT_R8_UINT:
308 		case VK_FORMAT_R8_SINT:
309 		case VK_FORMAT_R8_SRGB:
310 		case VK_FORMAT_R8G8_UNORM:
311 		case VK_FORMAT_R8G8_SNORM:
312 		case VK_FORMAT_R8G8_USCALED:
313 		case VK_FORMAT_R8G8_SSCALED:
314 		case VK_FORMAT_R8G8_UINT:
315 		case VK_FORMAT_R8G8_SINT:
316 		case VK_FORMAT_R8G8_SRGB:
317 		case VK_FORMAT_R8G8B8_UNORM:
318 		case VK_FORMAT_R8G8B8_SNORM:
319 		case VK_FORMAT_R8G8B8_USCALED:
320 		case VK_FORMAT_R8G8B8_SSCALED:
321 		case VK_FORMAT_R8G8B8_UINT:
322 		case VK_FORMAT_R8G8B8_SINT:
323 		case VK_FORMAT_R8G8B8_SRGB:
324 		case VK_FORMAT_B8G8R8_UNORM:
325 		case VK_FORMAT_B8G8R8_SNORM:
326 		case VK_FORMAT_B8G8R8_USCALED:
327 		case VK_FORMAT_B8G8R8_SSCALED:
328 		case VK_FORMAT_B8G8R8_UINT:
329 		case VK_FORMAT_B8G8R8_SINT:
330 		case VK_FORMAT_B8G8R8_SRGB:
331 		case VK_FORMAT_R8G8B8A8_UNORM:
332 		case VK_FORMAT_R8G8B8A8_SNORM:
333 		case VK_FORMAT_R8G8B8A8_USCALED:
334 		case VK_FORMAT_R8G8B8A8_SSCALED:
335 		case VK_FORMAT_R8G8B8A8_UINT:
336 		case VK_FORMAT_R8G8B8A8_SINT:
337 		case VK_FORMAT_R8G8B8A8_SRGB:
338 		case VK_FORMAT_B8G8R8A8_UNORM:
339 		case VK_FORMAT_B8G8R8A8_SNORM:
340 		case VK_FORMAT_B8G8R8A8_USCALED:
341 		case VK_FORMAT_B8G8R8A8_SSCALED:
342 		case VK_FORMAT_B8G8R8A8_UINT:
343 		case VK_FORMAT_B8G8R8A8_SINT:
344 		case VK_FORMAT_B8G8R8A8_SRGB:
345 			return 1;
346 
347 		case VK_FORMAT_R16_UNORM:
348 		case VK_FORMAT_R16_SNORM:
349 		case VK_FORMAT_R16_USCALED:
350 		case VK_FORMAT_R16_SSCALED:
351 		case VK_FORMAT_R16_UINT:
352 		case VK_FORMAT_R16_SINT:
353 		case VK_FORMAT_R16_SFLOAT:
354 		case VK_FORMAT_R16G16_UNORM:
355 		case VK_FORMAT_R16G16_SNORM:
356 		case VK_FORMAT_R16G16_USCALED:
357 		case VK_FORMAT_R16G16_SSCALED:
358 		case VK_FORMAT_R16G16_UINT:
359 		case VK_FORMAT_R16G16_SINT:
360 		case VK_FORMAT_R16G16_SFLOAT:
361 		case VK_FORMAT_R16G16B16_UNORM:
362 		case VK_FORMAT_R16G16B16_SNORM:
363 		case VK_FORMAT_R16G16B16_USCALED:
364 		case VK_FORMAT_R16G16B16_SSCALED:
365 		case VK_FORMAT_R16G16B16_UINT:
366 		case VK_FORMAT_R16G16B16_SINT:
367 		case VK_FORMAT_R16G16B16_SFLOAT:
368 		case VK_FORMAT_R16G16B16A16_UNORM:
369 		case VK_FORMAT_R16G16B16A16_SNORM:
370 		case VK_FORMAT_R16G16B16A16_USCALED:
371 		case VK_FORMAT_R16G16B16A16_SSCALED:
372 		case VK_FORMAT_R16G16B16A16_UINT:
373 		case VK_FORMAT_R16G16B16A16_SINT:
374 		case VK_FORMAT_R16G16B16A16_SFLOAT:
375 			return 2;
376 
377 		case VK_FORMAT_R32_UINT:
378 		case VK_FORMAT_R32_SINT:
379 		case VK_FORMAT_R32_SFLOAT:
380 		case VK_FORMAT_R32G32_UINT:
381 		case VK_FORMAT_R32G32_SINT:
382 		case VK_FORMAT_R32G32_SFLOAT:
383 		case VK_FORMAT_R32G32B32_UINT:
384 		case VK_FORMAT_R32G32B32_SINT:
385 		case VK_FORMAT_R32G32B32_SFLOAT:
386 		case VK_FORMAT_R32G32B32A32_UINT:
387 		case VK_FORMAT_R32G32B32A32_SINT:
388 		case VK_FORMAT_R32G32B32A32_SFLOAT:
389 			return 4;
390 
391 		case VK_FORMAT_R64_SFLOAT:
392 		case VK_FORMAT_R64G64_SFLOAT:
393 		case VK_FORMAT_R64G64B64_SFLOAT:
394 		case VK_FORMAT_R64G64B64A64_SFLOAT:
395 			return 8;
396 
397 		default:
398 			break;
399 	}
400 
401 	DE_ASSERT(false);
402 	return 0;
403 }
404 
getPackedVertexFormatComponentWidth(VkFormat format,deUint32 componentNdx)405 deUint32 getPackedVertexFormatComponentWidth(VkFormat format, deUint32 componentNdx)
406 {
407 	switch (format)
408 	{
409 		case VK_FORMAT_R4G4_UNORM_PACK8:
410 		{
411 			DE_ASSERT(componentNdx < 2);
412 			return 4;
413 		}
414 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
415 		case VK_FORMAT_B5G6R5_UNORM_PACK16:
416 		{
417 			deUint32 componentSizes[3] = { 5, 6, 5 };
418 
419 			DE_ASSERT(componentNdx < 3);
420 			return componentSizes[componentNdx];
421 		}
422 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
423 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
424 		case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
425 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
426 		{
427 			DE_ASSERT(componentNdx < 4);
428 			return 4;
429 		}
430 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
431 		case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
432 		{
433 			deUint32 componentSizes[4] = { 5, 5, 5, 1 };
434 
435 			DE_ASSERT(componentNdx < 4);
436 			return componentSizes[componentNdx];
437 		}
438 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
439 		{
440 			deUint32 componentSizes[4] = { 1, 5, 5, 5 };
441 
442 			DE_ASSERT(componentNdx < 4);
443 			return componentSizes[componentNdx];
444 		}
445 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
446 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
447 		case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
448 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
449 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
450 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
451 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
452 		{
453 			DE_ASSERT(componentNdx < 4);
454 			return 8;
455 		}
456 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
457 		{
458 			deUint32 componentSizes[3] = { 10, 11, 11 };
459 
460 			DE_ASSERT(componentNdx < 3);
461 			return componentSizes[componentNdx];
462 		}
463 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
464 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
465 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
466 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
467 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
468 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
469 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
470 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
471 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
472 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
473 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
474 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
475 		{
476 			deUint32 componentSizes[4] = {2, 10, 10, 10};
477 
478 			DE_ASSERT(componentNdx < 4);
479 			return componentSizes[componentNdx];
480 		}
481 		case VK_FORMAT_X8_D24_UNORM_PACK32:
482 		{
483 			deUint32 componentSizes[2] = { 8, 24 };
484 
485 			DE_ASSERT(componentNdx < 2);
486 			return componentSizes[componentNdx];
487 		}
488 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
489 		{
490 			deUint32 componentSizes[4] = { 5, 9, 9, 9 };
491 
492 			DE_ASSERT(componentNdx < 4);
493 			return componentSizes[componentNdx];
494 		}
495 		default:
496 			break;
497 	}
498 	DE_ASSERT(false);
499 	return 0;
500 }
501 
isVertexFormatComponentOrderBGR(VkFormat format)502 bool isVertexFormatComponentOrderBGR (VkFormat format)
503 {
504 	switch (format)
505 	{
506 		case VK_FORMAT_B8G8R8_UNORM:
507 		case VK_FORMAT_B8G8R8_SNORM:
508 		case VK_FORMAT_B8G8R8_USCALED:
509 		case VK_FORMAT_B8G8R8_SSCALED:
510 		case VK_FORMAT_B8G8R8_UINT:
511 		case VK_FORMAT_B8G8R8_SINT:
512 		case VK_FORMAT_B8G8R8_SRGB:
513 		case VK_FORMAT_B8G8R8A8_UNORM:
514 		case VK_FORMAT_B8G8R8A8_SNORM:
515 		case VK_FORMAT_B8G8R8A8_USCALED:
516 		case VK_FORMAT_B8G8R8A8_SSCALED:
517 		case VK_FORMAT_B8G8R8A8_UINT:
518 		case VK_FORMAT_B8G8R8A8_SINT:
519 		case VK_FORMAT_B8G8R8A8_SRGB:
520 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
521 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
522 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
523 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
524 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
525 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
526 			return true;
527 
528 		default:
529 			break;
530 	}
531 	return false;
532 }
533 
isVertexFormatComponentOrderABGR(VkFormat format)534 bool isVertexFormatComponentOrderABGR(VkFormat format)
535 {
536 	switch (format)
537 	{
538 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
539 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
540 		case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
541 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
542 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
543 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
544 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
545 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
546 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
547 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
548 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
549 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
550 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
551 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
552 			return true;
553 
554 		default:
555 			break;
556 	}
557 	return false;
558 }
559 
isVertexFormatComponentOrderARGB(VkFormat format)560 bool isVertexFormatComponentOrderARGB(VkFormat format)
561 {
562 	switch (format)
563 	{
564 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
565 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
566 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
567 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
568 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
569 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
570 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
571 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
572 		return true;
573 
574 	default:
575 		break;
576 	}
577 	return false;
578 }
579 
isVertexFormatSint(VkFormat format)580 bool isVertexFormatSint (VkFormat format)
581 {
582 	switch (format)
583 	{
584 		case VK_FORMAT_R8_SINT:
585 		case VK_FORMAT_R8G8_SINT:
586 		case VK_FORMAT_R16_SINT:
587 		case VK_FORMAT_R8G8B8_SINT:
588 		case VK_FORMAT_B8G8R8_SINT:
589 		case VK_FORMAT_R8G8B8A8_SINT:
590 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
591 		case VK_FORMAT_R16G16_SINT:
592 		case VK_FORMAT_R32_SINT:
593 		case VK_FORMAT_B8G8R8A8_SINT:
594 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
595 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
596 		case VK_FORMAT_R16G16B16_SINT:
597 		case VK_FORMAT_R16G16B16A16_SINT:
598 		case VK_FORMAT_R32G32_SINT:
599 		case VK_FORMAT_R32G32B32_SINT:
600 		case VK_FORMAT_R32G32B32A32_SINT:
601 			return true;
602 
603 		default:
604 			break;
605 	}
606 
607 	return false;
608 }
609 
isVertexFormatUint(VkFormat format)610 bool isVertexFormatUint (VkFormat format)
611 {
612 	switch (format)
613 	{
614 		case VK_FORMAT_R8_UINT:
615 		case VK_FORMAT_R8G8_UINT:
616 		case VK_FORMAT_R16_UINT:
617 		case VK_FORMAT_R8G8B8_UINT:
618 		case VK_FORMAT_B8G8R8_UINT:
619 		case VK_FORMAT_R8G8B8A8_UINT:
620 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
621 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
622 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
623 		case VK_FORMAT_R16G16_UINT:
624 		case VK_FORMAT_R32_UINT:
625 		case VK_FORMAT_B8G8R8A8_UINT:
626 		case VK_FORMAT_R16G16B16_UINT:
627 		case VK_FORMAT_R16G16B16A16_UINT:
628 		case VK_FORMAT_R32G32_UINT:
629 		case VK_FORMAT_R32G32B32_UINT:
630 		case VK_FORMAT_R32G32B32A32_UINT:
631 			return true;
632 
633 		default:
634 			break;
635 	}
636 
637 	return false;
638 
639 }
640 
isVertexFormatSfloat(VkFormat format)641 bool isVertexFormatSfloat (VkFormat format)
642 {
643 	switch (format)
644 	{
645 		case VK_FORMAT_R16_SFLOAT:
646 		case VK_FORMAT_R16G16_SFLOAT:
647 		case VK_FORMAT_R32_SFLOAT:
648 		case VK_FORMAT_R16G16B16_SFLOAT:
649 		case VK_FORMAT_R16G16B16A16_SFLOAT:
650 		case VK_FORMAT_R32G32_SFLOAT:
651 		case VK_FORMAT_R64_SFLOAT:
652 		case VK_FORMAT_R32G32B32_SFLOAT:
653 		case VK_FORMAT_R32G32B32A32_SFLOAT:
654 		case VK_FORMAT_R64G64_SFLOAT:
655 		case VK_FORMAT_R64G64B64_SFLOAT:
656 		case VK_FORMAT_R64G64B64A64_SFLOAT:
657 			return true;
658 
659 		default:
660 			break;
661 	}
662 
663 	return false;
664 
665 }
666 
isVertexFormatUfloat(VkFormat format)667 bool isVertexFormatUfloat (VkFormat format)
668 {
669 	switch (format)
670 	{
671 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
672 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
673 			return true;
674 
675 		default:
676 			break;
677 	}
678 
679 	return false;
680 
681 }
682 
isVertexFormatUnorm(VkFormat format)683 bool isVertexFormatUnorm (VkFormat format)
684 {
685 	switch (format)
686 	{
687 		case VK_FORMAT_R8_UNORM:
688 		case VK_FORMAT_R4G4_UNORM_PACK8:
689 		case VK_FORMAT_R8G8_UNORM:
690 		case VK_FORMAT_R16_UNORM:
691 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
692 		case VK_FORMAT_B5G6R5_UNORM_PACK16:
693 		case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
694 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
695 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
696 		case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
697 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
698 		case VK_FORMAT_R8G8B8_UNORM:
699 		case VK_FORMAT_B8G8R8_UNORM:
700 		case VK_FORMAT_R8G8B8A8_UNORM:
701 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
702 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
703 		case VK_FORMAT_R16G16_UNORM:
704 		case VK_FORMAT_B8G8R8A8_UNORM:
705 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
706 		case VK_FORMAT_X8_D24_UNORM_PACK32:
707 		case VK_FORMAT_R16G16B16_UNORM:
708 		case VK_FORMAT_R16G16B16A16_UNORM:
709 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
710 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
711 			return true;
712 
713 		default:
714 			break;
715 	}
716 
717 	return false;
718 
719 }
720 
isVertexFormatSnorm(VkFormat format)721 bool isVertexFormatSnorm (VkFormat format)
722 {
723 	switch (format)
724 	{
725 		case VK_FORMAT_R8_SNORM:
726 		case VK_FORMAT_R8G8_SNORM:
727 		case VK_FORMAT_R16_SNORM:
728 		case VK_FORMAT_R8G8B8_SNORM:
729 		case VK_FORMAT_B8G8R8_SNORM:
730 		case VK_FORMAT_R8G8B8A8_SNORM:
731 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
732 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
733 		case VK_FORMAT_R16G16_SNORM:
734 		case VK_FORMAT_B8G8R8A8_SNORM:
735 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
736 		case VK_FORMAT_R16G16B16_SNORM:
737 		case VK_FORMAT_R16G16B16A16_SNORM:
738 			return true;
739 
740 		default:
741 			break;
742 	}
743 
744 	return false;
745 
746 }
747 
isVertexFormatSRGB(VkFormat format)748 bool isVertexFormatSRGB (VkFormat format)
749 {
750 	switch (format)
751 	{
752 		case VK_FORMAT_R8_SRGB:
753 		case VK_FORMAT_R8G8_SRGB:
754 		case VK_FORMAT_R8G8B8_SRGB:
755 		case VK_FORMAT_B8G8R8_SRGB:
756 		case VK_FORMAT_R8G8B8A8_SRGB:
757 		case VK_FORMAT_B8G8R8A8_SRGB:
758 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
759 			return true;
760 
761 		default:
762 			break;
763 	}
764 
765 	return false;
766 
767 }
768 
isVertexFormatSscaled(VkFormat format)769 bool isVertexFormatSscaled (VkFormat format)
770 {
771 	switch (format)
772 	{
773 		case VK_FORMAT_R8_SSCALED:
774 		case VK_FORMAT_R8G8_SSCALED:
775 		case VK_FORMAT_R16_SSCALED:
776 		case VK_FORMAT_R8G8B8_SSCALED:
777 		case VK_FORMAT_B8G8R8_SSCALED:
778 		case VK_FORMAT_R8G8B8A8_SSCALED:
779 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
780 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
781 		case VK_FORMAT_R16G16_SSCALED:
782 		case VK_FORMAT_B8G8R8A8_SSCALED:
783 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
784 		case VK_FORMAT_R16G16B16_SSCALED:
785 		case VK_FORMAT_R16G16B16A16_SSCALED:
786 			return true;
787 
788 		default:
789 			break;
790 	}
791 
792 	return false;
793 
794 }
795 
isVertexFormatUscaled(VkFormat format)796 bool isVertexFormatUscaled (VkFormat format)
797 {
798 	switch (format)
799 	{
800 		case VK_FORMAT_R8_USCALED:
801 		case VK_FORMAT_R8G8_USCALED:
802 		case VK_FORMAT_R16_USCALED:
803 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
804 		case VK_FORMAT_R8G8B8_USCALED:
805 		case VK_FORMAT_B8G8R8_USCALED:
806 		case VK_FORMAT_R8G8B8A8_USCALED:
807 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
808 		case VK_FORMAT_R16G16_USCALED:
809 		case VK_FORMAT_B8G8R8A8_USCALED:
810 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
811 		case VK_FORMAT_R16G16B16_USCALED:
812 		case VK_FORMAT_R16G16B16A16_USCALED:
813 			return true;
814 
815 		default:
816 			break;
817 	}
818 
819 	return false;
820 
821 }
822 
isVertexFormatDouble(VkFormat format)823 bool isVertexFormatDouble (VkFormat format)
824 {
825 	switch (format)
826 	{
827 		case VK_FORMAT_R64_UINT:
828 		case VK_FORMAT_R64_SINT:
829 		case VK_FORMAT_R64_SFLOAT:
830 		case VK_FORMAT_R64G64_UINT:
831 		case VK_FORMAT_R64G64_SINT:
832 		case VK_FORMAT_R64G64_SFLOAT:
833 		case VK_FORMAT_R64G64B64_UINT:
834 		case VK_FORMAT_R64G64B64_SINT:
835 		case VK_FORMAT_R64G64B64_SFLOAT:
836 		case VK_FORMAT_R64G64B64A64_UINT:
837 		case VK_FORMAT_R64G64B64A64_SINT:
838 		case VK_FORMAT_R64G64B64A64_SFLOAT:
839 			return true;
840 
841 		default:
842 			break;
843 	}
844 	return false;
845 }
846 
isVertexFormatPacked(VkFormat format)847 bool isVertexFormatPacked(VkFormat format)
848 {
849 	switch (format)
850 	{
851 		case VK_FORMAT_R4G4_UNORM_PACK8:
852 		case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
853 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
854 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
855 		case VK_FORMAT_B5G6R5_UNORM_PACK16:
856 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
857 		case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
858 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
859 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
860 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
861 		case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
862 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
863 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
864 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
865 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
866 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
867 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
868 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
869 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
870 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
871 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
872 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
873 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
874 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
875 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
876 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
877 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
878 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
879 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
880 		case VK_FORMAT_X8_D24_UNORM_PACK32:
881 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
882 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
883 			return true;
884 
885 		default:
886 			break;
887 	}
888 	return false;
889 }
890 
createOverlappingQuads(void)891 std::vector<Vertex4RGBA> createOverlappingQuads (void)
892 {
893 	using tcu::Vec2;
894 	using tcu::Vec4;
895 
896 	std::vector<Vertex4RGBA> vertices;
897 
898 	const Vec2 translations[4] =
899 	{
900 		Vec2(-0.25f, -0.25f),
901 		Vec2(-1.0f, -0.25f),
902 		Vec2(-1.0f, -1.0f),
903 		Vec2(-0.25f, -1.0f)
904 	};
905 
906 	const Vec4 quadColors[4] =
907 	{
908 		Vec4(1.0f, 0.0f, 0.0f, 1.0),
909 		Vec4(0.0f, 1.0f, 0.0f, 1.0),
910 		Vec4(0.0f, 0.0f, 1.0f, 1.0),
911 		Vec4(1.0f, 0.0f, 1.0f, 1.0)
912 	};
913 
914 	const float quadSize = 1.25f;
915 
916 	for (int quadNdx = 0; quadNdx < 4; quadNdx++)
917 	{
918 		const Vec2&	translation	= translations[quadNdx];
919 		const Vec4&	color		= quadColors[quadNdx];
920 
921 		const Vertex4RGBA lowerLeftVertex =
922 		{
923 			Vec4(translation.x(), translation.y(), 0.0f, 1.0f),
924 			color
925 		};
926 		const Vertex4RGBA upperLeftVertex =
927 		{
928 			Vec4(translation.x(), translation.y() + quadSize, 0.0f, 1.0f),
929 			color
930 		};
931 		const Vertex4RGBA lowerRightVertex =
932 		{
933 			Vec4(translation.x() + quadSize, translation.y(), 0.0f, 1.0f),
934 			color
935 		};
936 		const Vertex4RGBA upperRightVertex =
937 		{
938 			Vec4(translation.x() + quadSize, translation.y() + quadSize, 0.0f, 1.0f),
939 			color
940 		};
941 
942 		// Triangle 1, CCW
943 		vertices.push_back(lowerLeftVertex);
944 		vertices.push_back(lowerRightVertex);
945 		vertices.push_back(upperLeftVertex);
946 
947 		// Triangle 2, CW
948 		vertices.push_back(lowerRightVertex);
949 		vertices.push_back(upperLeftVertex);
950 		vertices.push_back(upperRightVertex);
951 	}
952 
953 	return vertices;
954 }
955 
createOverlappingQuadsDualSource(void)956 std::vector<Vertex4RGBARGBA> createOverlappingQuadsDualSource (void)
957 {
958 	using tcu::Vec2;
959 	using tcu::Vec4;
960 
961 	std::vector<Vertex4RGBARGBA> vertices;
962 
963 	const Vec2 translations[4] =
964 	{
965 		Vec2(-0.25f, -0.25f),
966 		Vec2(-1.0f, -0.25f),
967 		Vec2(-1.0f, -1.0f),
968 		Vec2(-0.25f, -1.0f)
969 	};
970 
971 	const Vec4 quadColors[4] =
972 	{
973 		Vec4(1.0f, 0.0f, 0.0f, 1.0),
974 		Vec4(0.0f, 1.0f, 0.0f, 1.0),
975 		Vec4(0.0f, 0.0f, 1.0f, 1.0),
976 		Vec4(1.0f, 0.0f, 1.0f, 1.0)
977 	};
978 
979 	const Vec4 color1 = Vec4(0.0f, 0.5f, 0.5f, 1.0f);
980 
981 	const float quadSize = 1.25f;
982 
983 	for (int quadNdx = 0; quadNdx < 4; quadNdx++)
984 	{
985 		const Vec2&	translation	= translations[quadNdx];
986 		const Vec4&	color0		= quadColors[quadNdx];
987 
988 		const Vertex4RGBARGBA lowerLeftVertex =
989 		{
990 			Vec4(translation.x(), translation.y(), 0.0f, 1.0f),
991 			color0,
992 			color1
993 		};
994 		const Vertex4RGBARGBA upperLeftVertex =
995 		{
996 			Vec4(translation.x(), translation.y() + quadSize, 0.0f, 1.0f),
997 			color0,
998 			color1
999 		};
1000 		const Vertex4RGBARGBA lowerRightVertex =
1001 		{
1002 			Vec4(translation.x() + quadSize, translation.y(), 0.0f, 1.0f),
1003 			color0,
1004 			color1
1005 		};
1006 		const Vertex4RGBARGBA upperRightVertex =
1007 		{
1008 			Vec4(translation.x() + quadSize, translation.y() + quadSize, 0.0f, 1.0f),
1009 			color0,
1010 			color1
1011 		};
1012 
1013 		// Triangle 1, CCW
1014 		vertices.push_back(lowerLeftVertex);
1015 		vertices.push_back(lowerRightVertex);
1016 		vertices.push_back(upperLeftVertex);
1017 
1018 		// Triangle 2, CW
1019 		vertices.push_back(lowerRightVertex);
1020 		vertices.push_back(upperLeftVertex);
1021 		vertices.push_back(upperRightVertex);
1022 	}
1023 
1024 	return vertices;
1025 }
1026 
createFullscreenQuad(void)1027 std::vector<Vertex4Tex4> createFullscreenQuad (void)
1028 {
1029 	using tcu::Vec4;
1030 
1031 	const Vertex4Tex4 lowerLeftVertex =
1032 	{
1033 		Vec4(-1.0f, -1.0f, 0.0f, 1.0f),
1034 		Vec4(0.0f, 0.0f, 0.0f, 0.0f)
1035 	};
1036 	const Vertex4Tex4 upperLeftVertex =
1037 	{
1038 		Vec4(-1.0f, 1.0f, 0.0f, 1.0f),
1039 		Vec4(0.0f, 1.0f, 0.0f, 0.0f)
1040 	};
1041 	const Vertex4Tex4 lowerRightVertex =
1042 	{
1043 		Vec4(1.0f, -1.0f, 0.0f, 1.0f),
1044 		Vec4(1.0f, 0.0f, 0.0f, 0.0f)
1045 	};
1046 	const Vertex4Tex4 upperRightVertex =
1047 	{
1048 		Vec4(1.0f, 1.0f, 0.0f, 1.0f),
1049 		Vec4(1.0f, 1.0f, 0.0f, 0.0f)
1050 	};
1051 
1052 	const Vertex4Tex4 vertices[6] =
1053 	{
1054 		lowerLeftVertex,
1055 		lowerRightVertex,
1056 		upperLeftVertex,
1057 
1058 		upperLeftVertex,
1059 		lowerRightVertex,
1060 		upperRightVertex
1061 	};
1062 
1063 	return std::vector<Vertex4Tex4>(vertices, vertices + DE_LENGTH_OF_ARRAY(vertices));
1064 }
1065 
createQuadMosaic(int rows,int columns)1066 std::vector<Vertex4Tex4> createQuadMosaic (int rows, int columns)
1067 {
1068 	using tcu::Vec4;
1069 
1070 	DE_ASSERT(rows >= 1);
1071 	DE_ASSERT(columns >= 1);
1072 
1073 	std::vector<Vertex4Tex4>	vertices;
1074 	const float					rowSize		= 2.0f / (float)rows;
1075 	const float					columnSize	= 2.0f / (float)columns;
1076 	int							arrayIndex	= 0;
1077 
1078 	for (int rowNdx = 0; rowNdx < rows; rowNdx++)
1079 	{
1080 		for (int columnNdx = 0; columnNdx < columns; columnNdx++)
1081 		{
1082 			const Vertex4Tex4 lowerLeftVertex =
1083 			{
1084 				Vec4(-1.0f + (float)columnNdx * columnSize, -1.0f + (float)rowNdx * rowSize, 0.0f, 1.0f),
1085 				Vec4(0.0f, 0.0f, (float)arrayIndex, 0.0f)
1086 			};
1087 			const Vertex4Tex4 upperLeftVertex =
1088 			{
1089 				Vec4(lowerLeftVertex.position.x(), lowerLeftVertex.position.y() + rowSize, 0.0f, 1.0f),
1090 				Vec4(0.0f, 1.0f, (float)arrayIndex, 0.0f)
1091 			};
1092 			const Vertex4Tex4 lowerRightVertex =
1093 			{
1094 				Vec4(lowerLeftVertex.position.x() + columnSize, lowerLeftVertex.position.y(), 0.0f, 1.0f),
1095 				Vec4(1.0f, 0.0f, (float)arrayIndex, 0.0f)
1096 			};
1097 			const Vertex4Tex4 upperRightVertex =
1098 			{
1099 				Vec4(lowerLeftVertex.position.x() + columnSize, lowerLeftVertex.position.y() + rowSize, 0.0f, 1.0f),
1100 				Vec4(1.0f, 1.0f, (float)arrayIndex, 0.0f)
1101 			};
1102 
1103 			vertices.push_back(lowerLeftVertex);
1104 			vertices.push_back(lowerRightVertex);
1105 			vertices.push_back(upperLeftVertex);
1106 			vertices.push_back(upperLeftVertex);
1107 			vertices.push_back(lowerRightVertex);
1108 			vertices.push_back(upperRightVertex);
1109 
1110 			arrayIndex++;
1111 		}
1112 	}
1113 
1114 	return vertices;
1115 }
1116 
createQuadMosaicCube(void)1117 std::vector<Vertex4Tex4> createQuadMosaicCube (void)
1118 {
1119 	using tcu::Vec3;
1120 
1121 	static const Vec3 texCoordsCube[8] =
1122 	{
1123 		Vec3(-1.0f, -1.0f, -1.0f),	// 0: -X, -Y, -Z
1124 		Vec3(1.0f, -1.0f, -1.0f),	// 1:  X, -Y, -Z
1125 		Vec3(1.0f, -1.0f, 1.0f),	// 2:  X, -Y,  Z
1126 		Vec3(-1.0f, -1.0f, 1.0f),	// 3: -X, -Y,  Z
1127 
1128 		Vec3(-1.0f, 1.0f, -1.0f),	// 4: -X,  Y, -Z
1129 		Vec3(1.0f, 1.0f, -1.0f),	// 5:  X,  Y, -Z
1130 		Vec3(1.0f, 1.0f, 1.0f),		// 6:  X,  Y,  Z
1131 		Vec3(-1.0f, 1.0f, 1.0f),	// 7: -X,  Y,  Z
1132 	};
1133 
1134 	static const int texCoordCubeIndices[6][6] =
1135 	{
1136 		{ 6, 5, 2, 2, 5, 1 },		// +X face
1137 		{ 3, 0, 7, 7, 0, 4 },		// -X face
1138 		{ 4, 5, 7, 7, 5, 6 },		// +Y face
1139 		{ 3, 2, 0, 0, 2, 1 },		// -Y face
1140 		{ 2, 3, 6, 6, 3, 7 },		// +Z face
1141 		{ 0, 1, 4, 4, 1, 5 }		// -Z face
1142 	};
1143 
1144 	// Create 6 quads and set appropriate texture coordinates for cube mapping
1145 
1146 	std::vector<Vertex4Tex4>			vertices	= createQuadMosaic(2, 3);
1147 	std::vector<Vertex4Tex4>::iterator	vertexItr	= vertices.begin();
1148 
1149 	for (int quadNdx = 0; quadNdx < 6; quadNdx++)
1150 	{
1151 		for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1152 		{
1153 			vertexItr->texCoord.xyz() = texCoordsCube[texCoordCubeIndices[quadNdx][vertexNdx]];
1154 			vertexItr++;
1155 		}
1156 	}
1157 
1158 	return vertices;
1159 }
1160 
createQuadMosaicCubeArray(int faceArrayIndices[6])1161 std::vector<Vertex4Tex4> createQuadMosaicCubeArray (int faceArrayIndices[6])
1162 {
1163 	std::vector<Vertex4Tex4>			vertices	= createQuadMosaicCube();
1164 	std::vector<Vertex4Tex4>::iterator	vertexItr	= vertices.begin();
1165 
1166 	for (int quadNdx = 0; quadNdx < 6; quadNdx++)
1167 	{
1168 		for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1169 		{
1170 			vertexItr->texCoord.w() = (float)faceArrayIndices[quadNdx];
1171 			vertexItr++;
1172 		}
1173 	}
1174 
1175 	return vertices;
1176 }
1177 
createTestQuadMosaic(vk::VkImageViewType viewType)1178 std::vector<Vertex4Tex4> createTestQuadMosaic (vk::VkImageViewType viewType)
1179 {
1180 	std::vector<Vertex4Tex4> vertices;
1181 
1182 	switch (viewType)
1183 	{
1184 		case vk::VK_IMAGE_VIEW_TYPE_1D:
1185 		case vk::VK_IMAGE_VIEW_TYPE_2D:
1186 			vertices = createFullscreenQuad();
1187 			break;
1188 
1189 		case vk::VK_IMAGE_VIEW_TYPE_1D_ARRAY:
1190 			vertices = createQuadMosaic(2, 3);
1191 
1192 			// Set up array indices
1193 			for (size_t quadNdx = 0; quadNdx < 6; quadNdx++)
1194 				for (size_t vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1195 					vertices[quadNdx * 6 + vertexNdx].texCoord.y() = (float)quadNdx;
1196 
1197 			break;
1198 
1199 		case vk::VK_IMAGE_VIEW_TYPE_2D_ARRAY:
1200 			vertices = createQuadMosaic(2, 3);
1201 			break;
1202 
1203 		case vk::VK_IMAGE_VIEW_TYPE_3D:
1204 			vertices = createQuadMosaic(2, 3);
1205 
1206 			// Use z between 0.0 and 1.0.
1207 			for (size_t vertexNdx = 0; vertexNdx < vertices.size(); vertexNdx++)
1208 			{
1209 				vertices[vertexNdx].texCoord.z() /= 5.0f;
1210 				vertices[vertexNdx].texCoord.z() -= 0.001f; // Substract small value to correct floating-point errors at the boundaries between slices
1211 			}
1212 
1213 			break;
1214 
1215 		case vk::VK_IMAGE_VIEW_TYPE_CUBE:
1216 			vertices = createQuadMosaicCube();
1217 			break;
1218 
1219 		case vk::VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
1220 			{
1221 				int faceArrayIndices[6] = { 0, 1, 2, 3, 4, 5 };
1222 				vertices = createQuadMosaicCubeArray(faceArrayIndices);
1223 			}
1224 			break;
1225 
1226 		default:
1227 			DE_ASSERT(false);
1228 			break;
1229 	}
1230 
1231 	return vertices;
1232 }
1233 
1234 } // pipeline
1235 } // vkt
1236