• 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 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
527 			return true;
528 
529 		default:
530 			break;
531 	}
532 	return false;
533 }
534 
isVertexFormatComponentOrderABGR(VkFormat format)535 bool isVertexFormatComponentOrderABGR(VkFormat format)
536 {
537 	switch (format)
538 	{
539 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
540 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
541 		case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
542 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
543 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
544 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
545 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
546 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
547 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
548 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
549 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
550 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
551 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
552 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
553 			return true;
554 
555 		default:
556 			break;
557 	}
558 	return false;
559 }
560 
isVertexFormatComponentOrderARGB(VkFormat format)561 bool isVertexFormatComponentOrderARGB(VkFormat format)
562 {
563 	switch (format)
564 	{
565 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
566 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
567 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
568 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
569 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
570 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
571 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
572 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
573 		return true;
574 
575 	default:
576 		break;
577 	}
578 	return false;
579 }
580 
isVertexFormatSint(VkFormat format)581 bool isVertexFormatSint (VkFormat format)
582 {
583 	switch (format)
584 	{
585 		case VK_FORMAT_R8_SINT:
586 		case VK_FORMAT_R8G8_SINT:
587 		case VK_FORMAT_R16_SINT:
588 		case VK_FORMAT_R8G8B8_SINT:
589 		case VK_FORMAT_B8G8R8_SINT:
590 		case VK_FORMAT_R8G8B8A8_SINT:
591 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
592 		case VK_FORMAT_R16G16_SINT:
593 		case VK_FORMAT_R32_SINT:
594 		case VK_FORMAT_B8G8R8A8_SINT:
595 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
596 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
597 		case VK_FORMAT_R16G16B16_SINT:
598 		case VK_FORMAT_R16G16B16A16_SINT:
599 		case VK_FORMAT_R32G32_SINT:
600 		case VK_FORMAT_R32G32B32_SINT:
601 		case VK_FORMAT_R32G32B32A32_SINT:
602 			return true;
603 
604 		default:
605 			break;
606 	}
607 
608 	return false;
609 }
610 
isVertexFormatUint(VkFormat format)611 bool isVertexFormatUint (VkFormat format)
612 {
613 	switch (format)
614 	{
615 		case VK_FORMAT_R8_UINT:
616 		case VK_FORMAT_R8G8_UINT:
617 		case VK_FORMAT_R16_UINT:
618 		case VK_FORMAT_R8G8B8_UINT:
619 		case VK_FORMAT_B8G8R8_UINT:
620 		case VK_FORMAT_R8G8B8A8_UINT:
621 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
622 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
623 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
624 		case VK_FORMAT_R16G16_UINT:
625 		case VK_FORMAT_R32_UINT:
626 		case VK_FORMAT_B8G8R8A8_UINT:
627 		case VK_FORMAT_R16G16B16_UINT:
628 		case VK_FORMAT_R16G16B16A16_UINT:
629 		case VK_FORMAT_R32G32_UINT:
630 		case VK_FORMAT_R32G32B32_UINT:
631 		case VK_FORMAT_R32G32B32A32_UINT:
632 			return true;
633 
634 		default:
635 			break;
636 	}
637 
638 	return false;
639 
640 }
641 
isVertexFormatSfloat(VkFormat format)642 bool isVertexFormatSfloat (VkFormat format)
643 {
644 	switch (format)
645 	{
646 		case VK_FORMAT_R16_SFLOAT:
647 		case VK_FORMAT_R16G16_SFLOAT:
648 		case VK_FORMAT_R32_SFLOAT:
649 		case VK_FORMAT_R16G16B16_SFLOAT:
650 		case VK_FORMAT_R16G16B16A16_SFLOAT:
651 		case VK_FORMAT_R32G32_SFLOAT:
652 		case VK_FORMAT_R64_SFLOAT:
653 		case VK_FORMAT_R32G32B32_SFLOAT:
654 		case VK_FORMAT_R32G32B32A32_SFLOAT:
655 		case VK_FORMAT_R64G64_SFLOAT:
656 		case VK_FORMAT_R64G64B64_SFLOAT:
657 		case VK_FORMAT_R64G64B64A64_SFLOAT:
658 			return true;
659 
660 		default:
661 			break;
662 	}
663 
664 	return false;
665 
666 }
667 
isVertexFormatUfloat(VkFormat format)668 bool isVertexFormatUfloat (VkFormat format)
669 {
670 	switch (format)
671 	{
672 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
673 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
674 			return true;
675 
676 		default:
677 			break;
678 	}
679 
680 	return false;
681 
682 }
683 
isVertexFormatUnorm(VkFormat format)684 bool isVertexFormatUnorm (VkFormat format)
685 {
686 	switch (format)
687 	{
688 		case VK_FORMAT_R8_UNORM:
689 		case VK_FORMAT_R4G4_UNORM_PACK8:
690 		case VK_FORMAT_R8G8_UNORM:
691 		case VK_FORMAT_R16_UNORM:
692 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
693 		case VK_FORMAT_B5G6R5_UNORM_PACK16:
694 		case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
695 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
696 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
697 		case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
698 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
699 		case VK_FORMAT_R8G8B8_UNORM:
700 		case VK_FORMAT_B8G8R8_UNORM:
701 		case VK_FORMAT_R8G8B8A8_UNORM:
702 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
703 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
704 		case VK_FORMAT_R16G16_UNORM:
705 		case VK_FORMAT_B8G8R8A8_UNORM:
706 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
707 		case VK_FORMAT_X8_D24_UNORM_PACK32:
708 		case VK_FORMAT_R16G16B16_UNORM:
709 		case VK_FORMAT_R16G16B16A16_UNORM:
710 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
711 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
712 			return true;
713 
714 		default:
715 			break;
716 	}
717 
718 	return false;
719 
720 }
721 
isVertexFormatSnorm(VkFormat format)722 bool isVertexFormatSnorm (VkFormat format)
723 {
724 	switch (format)
725 	{
726 		case VK_FORMAT_R8_SNORM:
727 		case VK_FORMAT_R8G8_SNORM:
728 		case VK_FORMAT_R16_SNORM:
729 		case VK_FORMAT_R8G8B8_SNORM:
730 		case VK_FORMAT_B8G8R8_SNORM:
731 		case VK_FORMAT_R8G8B8A8_SNORM:
732 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
733 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
734 		case VK_FORMAT_R16G16_SNORM:
735 		case VK_FORMAT_B8G8R8A8_SNORM:
736 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
737 		case VK_FORMAT_R16G16B16_SNORM:
738 		case VK_FORMAT_R16G16B16A16_SNORM:
739 			return true;
740 
741 		default:
742 			break;
743 	}
744 
745 	return false;
746 
747 }
748 
isVertexFormatSRGB(VkFormat format)749 bool isVertexFormatSRGB (VkFormat format)
750 {
751 	switch (format)
752 	{
753 		case VK_FORMAT_R8_SRGB:
754 		case VK_FORMAT_R8G8_SRGB:
755 		case VK_FORMAT_R8G8B8_SRGB:
756 		case VK_FORMAT_B8G8R8_SRGB:
757 		case VK_FORMAT_R8G8B8A8_SRGB:
758 		case VK_FORMAT_B8G8R8A8_SRGB:
759 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
760 			return true;
761 
762 		default:
763 			break;
764 	}
765 
766 	return false;
767 
768 }
769 
isVertexFormatSscaled(VkFormat format)770 bool isVertexFormatSscaled (VkFormat format)
771 {
772 	switch (format)
773 	{
774 		case VK_FORMAT_R8_SSCALED:
775 		case VK_FORMAT_R8G8_SSCALED:
776 		case VK_FORMAT_R16_SSCALED:
777 		case VK_FORMAT_R8G8B8_SSCALED:
778 		case VK_FORMAT_B8G8R8_SSCALED:
779 		case VK_FORMAT_R8G8B8A8_SSCALED:
780 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
781 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
782 		case VK_FORMAT_R16G16_SSCALED:
783 		case VK_FORMAT_B8G8R8A8_SSCALED:
784 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
785 		case VK_FORMAT_R16G16B16_SSCALED:
786 		case VK_FORMAT_R16G16B16A16_SSCALED:
787 			return true;
788 
789 		default:
790 			break;
791 	}
792 
793 	return false;
794 
795 }
796 
isVertexFormatUscaled(VkFormat format)797 bool isVertexFormatUscaled (VkFormat format)
798 {
799 	switch (format)
800 	{
801 		case VK_FORMAT_R8_USCALED:
802 		case VK_FORMAT_R8G8_USCALED:
803 		case VK_FORMAT_R16_USCALED:
804 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
805 		case VK_FORMAT_R8G8B8_USCALED:
806 		case VK_FORMAT_B8G8R8_USCALED:
807 		case VK_FORMAT_R8G8B8A8_USCALED:
808 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
809 		case VK_FORMAT_R16G16_USCALED:
810 		case VK_FORMAT_B8G8R8A8_USCALED:
811 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
812 		case VK_FORMAT_R16G16B16_USCALED:
813 		case VK_FORMAT_R16G16B16A16_USCALED:
814 			return true;
815 
816 		default:
817 			break;
818 	}
819 
820 	return false;
821 
822 }
823 
isVertexFormatDouble(VkFormat format)824 bool isVertexFormatDouble (VkFormat format)
825 {
826 	switch (format)
827 	{
828 		case VK_FORMAT_R64_UINT:
829 		case VK_FORMAT_R64_SINT:
830 		case VK_FORMAT_R64_SFLOAT:
831 		case VK_FORMAT_R64G64_UINT:
832 		case VK_FORMAT_R64G64_SINT:
833 		case VK_FORMAT_R64G64_SFLOAT:
834 		case VK_FORMAT_R64G64B64_UINT:
835 		case VK_FORMAT_R64G64B64_SINT:
836 		case VK_FORMAT_R64G64B64_SFLOAT:
837 		case VK_FORMAT_R64G64B64A64_UINT:
838 		case VK_FORMAT_R64G64B64A64_SINT:
839 		case VK_FORMAT_R64G64B64A64_SFLOAT:
840 			return true;
841 
842 		default:
843 			break;
844 	}
845 	return false;
846 }
847 
isVertexFormatPacked(VkFormat format)848 bool isVertexFormatPacked(VkFormat format)
849 {
850 	switch (format)
851 	{
852 		case VK_FORMAT_R4G4_UNORM_PACK8:
853 		case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
854 		case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
855 		case VK_FORMAT_R5G6B5_UNORM_PACK16:
856 		case VK_FORMAT_B5G6R5_UNORM_PACK16:
857 		case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
858 		case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
859 		case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
860 		case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
861 		case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
862 		case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
863 		case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
864 		case VK_FORMAT_A8B8G8R8_UINT_PACK32:
865 		case VK_FORMAT_A8B8G8R8_SINT_PACK32:
866 		case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
867 		case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
868 		case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
869 		case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
870 		case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
871 		case VK_FORMAT_A2R10G10B10_UINT_PACK32:
872 		case VK_FORMAT_A2R10G10B10_SINT_PACK32:
873 		case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
874 		case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
875 		case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
876 		case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
877 		case VK_FORMAT_A2B10G10R10_UINT_PACK32:
878 		case VK_FORMAT_A2B10G10R10_SINT_PACK32:
879 		case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
880 		case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
881 		case VK_FORMAT_X8_D24_UNORM_PACK32:
882 		case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
883 		case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
884 			return true;
885 
886 		default:
887 			break;
888 	}
889 	return false;
890 }
891 
createOverlappingQuads(void)892 std::vector<Vertex4RGBA> createOverlappingQuads (void)
893 {
894 	using tcu::Vec2;
895 	using tcu::Vec4;
896 
897 	std::vector<Vertex4RGBA> vertices;
898 
899 	const Vec2 translations[4] =
900 	{
901 		Vec2(-0.25f, -0.25f),
902 		Vec2(-1.0f, -0.25f),
903 		Vec2(-1.0f, -1.0f),
904 		Vec2(-0.25f, -1.0f)
905 	};
906 
907 	const Vec4 quadColors[4] =
908 	{
909 		Vec4(1.0f, 0.0f, 0.0f, 1.0),
910 		Vec4(0.0f, 1.0f, 0.0f, 1.0),
911 		Vec4(0.0f, 0.0f, 1.0f, 1.0),
912 		Vec4(1.0f, 0.0f, 1.0f, 1.0)
913 	};
914 
915 	const float quadSize = 1.25f;
916 
917 	for (int quadNdx = 0; quadNdx < 4; quadNdx++)
918 	{
919 		const Vec2&	translation	= translations[quadNdx];
920 		const Vec4&	color		= quadColors[quadNdx];
921 
922 		const Vertex4RGBA lowerLeftVertex =
923 		{
924 			Vec4(translation.x(), translation.y(), 0.0f, 1.0f),
925 			color
926 		};
927 		const Vertex4RGBA upperLeftVertex =
928 		{
929 			Vec4(translation.x(), translation.y() + quadSize, 0.0f, 1.0f),
930 			color
931 		};
932 		const Vertex4RGBA lowerRightVertex =
933 		{
934 			Vec4(translation.x() + quadSize, translation.y(), 0.0f, 1.0f),
935 			color
936 		};
937 		const Vertex4RGBA upperRightVertex =
938 		{
939 			Vec4(translation.x() + quadSize, translation.y() + quadSize, 0.0f, 1.0f),
940 			color
941 		};
942 
943 		// Triangle 1, CCW
944 		vertices.push_back(lowerLeftVertex);
945 		vertices.push_back(lowerRightVertex);
946 		vertices.push_back(upperLeftVertex);
947 
948 		// Triangle 2, CW
949 		vertices.push_back(lowerRightVertex);
950 		vertices.push_back(upperLeftVertex);
951 		vertices.push_back(upperRightVertex);
952 	}
953 
954 	return vertices;
955 }
956 
createOverlappingQuadsDualSource(void)957 std::vector<Vertex4RGBARGBA> createOverlappingQuadsDualSource (void)
958 {
959 	using tcu::Vec2;
960 	using tcu::Vec4;
961 
962 	std::vector<Vertex4RGBARGBA> vertices;
963 
964 	const Vec2 translations[4] =
965 	{
966 		Vec2(-0.25f, -0.25f),
967 		Vec2(-1.0f, -0.25f),
968 		Vec2(-1.0f, -1.0f),
969 		Vec2(-0.25f, -1.0f)
970 	};
971 
972 	const Vec4 quadColors[4] =
973 	{
974 		Vec4(1.0f, 0.0f, 0.0f, 1.0),
975 		Vec4(0.0f, 1.0f, 0.0f, 1.0),
976 		Vec4(0.0f, 0.0f, 1.0f, 1.0),
977 		Vec4(1.0f, 0.0f, 1.0f, 1.0)
978 	};
979 
980 	const Vec4 color1 = Vec4(0.0f, 0.5f, 0.5f, 1.0f);
981 
982 	const float quadSize = 1.25f;
983 
984 	for (int quadNdx = 0; quadNdx < 4; quadNdx++)
985 	{
986 		const Vec2&	translation	= translations[quadNdx];
987 		const Vec4&	color0		= quadColors[quadNdx];
988 
989 		const Vertex4RGBARGBA lowerLeftVertex =
990 		{
991 			Vec4(translation.x(), translation.y(), 0.0f, 1.0f),
992 			color0,
993 			color1
994 		};
995 		const Vertex4RGBARGBA upperLeftVertex =
996 		{
997 			Vec4(translation.x(), translation.y() + quadSize, 0.0f, 1.0f),
998 			color0,
999 			color1
1000 		};
1001 		const Vertex4RGBARGBA lowerRightVertex =
1002 		{
1003 			Vec4(translation.x() + quadSize, translation.y(), 0.0f, 1.0f),
1004 			color0,
1005 			color1
1006 		};
1007 		const Vertex4RGBARGBA upperRightVertex =
1008 		{
1009 			Vec4(translation.x() + quadSize, translation.y() + quadSize, 0.0f, 1.0f),
1010 			color0,
1011 			color1
1012 		};
1013 
1014 		// Triangle 1, CCW
1015 		vertices.push_back(lowerLeftVertex);
1016 		vertices.push_back(lowerRightVertex);
1017 		vertices.push_back(upperLeftVertex);
1018 
1019 		// Triangle 2, CW
1020 		vertices.push_back(lowerRightVertex);
1021 		vertices.push_back(upperLeftVertex);
1022 		vertices.push_back(upperRightVertex);
1023 	}
1024 
1025 	return vertices;
1026 }
1027 
createFullscreenQuad(void)1028 std::vector<Vertex4Tex4> createFullscreenQuad (void)
1029 {
1030 	using tcu::Vec4;
1031 
1032 	const Vertex4Tex4 lowerLeftVertex =
1033 	{
1034 		Vec4(-1.0f, -1.0f, 0.0f, 1.0f),
1035 		Vec4(0.0f, 0.0f, 0.0f, 0.0f)
1036 	};
1037 	const Vertex4Tex4 upperLeftVertex =
1038 	{
1039 		Vec4(-1.0f, 1.0f, 0.0f, 1.0f),
1040 		Vec4(0.0f, 1.0f, 0.0f, 0.0f)
1041 	};
1042 	const Vertex4Tex4 lowerRightVertex =
1043 	{
1044 		Vec4(1.0f, -1.0f, 0.0f, 1.0f),
1045 		Vec4(1.0f, 0.0f, 0.0f, 0.0f)
1046 	};
1047 	const Vertex4Tex4 upperRightVertex =
1048 	{
1049 		Vec4(1.0f, 1.0f, 0.0f, 1.0f),
1050 		Vec4(1.0f, 1.0f, 0.0f, 0.0f)
1051 	};
1052 
1053 	const Vertex4Tex4 vertices[6] =
1054 	{
1055 		lowerLeftVertex,
1056 		lowerRightVertex,
1057 		upperLeftVertex,
1058 
1059 		upperLeftVertex,
1060 		lowerRightVertex,
1061 		upperRightVertex
1062 	};
1063 
1064 	return std::vector<Vertex4Tex4>(vertices, vertices + DE_LENGTH_OF_ARRAY(vertices));
1065 }
1066 
createQuadMosaic(int rows,int columns)1067 std::vector<Vertex4Tex4> createQuadMosaic (int rows, int columns)
1068 {
1069 	using tcu::Vec4;
1070 
1071 	DE_ASSERT(rows >= 1);
1072 	DE_ASSERT(columns >= 1);
1073 
1074 	std::vector<Vertex4Tex4>	vertices;
1075 	const float					rowSize		= 2.0f / (float)rows;
1076 	const float					columnSize	= 2.0f / (float)columns;
1077 	int							arrayIndex	= 0;
1078 
1079 	for (int rowNdx = 0; rowNdx < rows; rowNdx++)
1080 	{
1081 		for (int columnNdx = 0; columnNdx < columns; columnNdx++)
1082 		{
1083 			const Vertex4Tex4 lowerLeftVertex =
1084 			{
1085 				Vec4(-1.0f + (float)columnNdx * columnSize, -1.0f + (float)rowNdx * rowSize, 0.0f, 1.0f),
1086 				Vec4(0.0f, 0.0f, (float)arrayIndex, 0.0f)
1087 			};
1088 			const Vertex4Tex4 upperLeftVertex =
1089 			{
1090 				Vec4(lowerLeftVertex.position.x(), lowerLeftVertex.position.y() + rowSize, 0.0f, 1.0f),
1091 				Vec4(0.0f, 1.0f, (float)arrayIndex, 0.0f)
1092 			};
1093 			const Vertex4Tex4 lowerRightVertex =
1094 			{
1095 				Vec4(lowerLeftVertex.position.x() + columnSize, lowerLeftVertex.position.y(), 0.0f, 1.0f),
1096 				Vec4(1.0f, 0.0f, (float)arrayIndex, 0.0f)
1097 			};
1098 			const Vertex4Tex4 upperRightVertex =
1099 			{
1100 				Vec4(lowerLeftVertex.position.x() + columnSize, lowerLeftVertex.position.y() + rowSize, 0.0f, 1.0f),
1101 				Vec4(1.0f, 1.0f, (float)arrayIndex, 0.0f)
1102 			};
1103 
1104 			vertices.push_back(lowerLeftVertex);
1105 			vertices.push_back(lowerRightVertex);
1106 			vertices.push_back(upperLeftVertex);
1107 			vertices.push_back(upperLeftVertex);
1108 			vertices.push_back(lowerRightVertex);
1109 			vertices.push_back(upperRightVertex);
1110 
1111 			arrayIndex++;
1112 		}
1113 	}
1114 
1115 	return vertices;
1116 }
1117 
createQuadMosaicCube(void)1118 std::vector<Vertex4Tex4> createQuadMosaicCube (void)
1119 {
1120 	using tcu::Vec3;
1121 
1122 	static const Vec3 texCoordsCube[8] =
1123 	{
1124 		Vec3(-1.0f, -1.0f, -1.0f),	// 0: -X, -Y, -Z
1125 		Vec3(1.0f, -1.0f, -1.0f),	// 1:  X, -Y, -Z
1126 		Vec3(1.0f, -1.0f, 1.0f),	// 2:  X, -Y,  Z
1127 		Vec3(-1.0f, -1.0f, 1.0f),	// 3: -X, -Y,  Z
1128 
1129 		Vec3(-1.0f, 1.0f, -1.0f),	// 4: -X,  Y, -Z
1130 		Vec3(1.0f, 1.0f, -1.0f),	// 5:  X,  Y, -Z
1131 		Vec3(1.0f, 1.0f, 1.0f),		// 6:  X,  Y,  Z
1132 		Vec3(-1.0f, 1.0f, 1.0f),	// 7: -X,  Y,  Z
1133 	};
1134 
1135 	static const int texCoordCubeIndices[6][6] =
1136 	{
1137 		{ 6, 5, 2, 2, 5, 1 },		// +X face
1138 		{ 3, 0, 7, 7, 0, 4 },		// -X face
1139 		{ 4, 5, 7, 7, 5, 6 },		// +Y face
1140 		{ 3, 2, 0, 0, 2, 1 },		// -Y face
1141 		{ 2, 3, 6, 6, 3, 7 },		// +Z face
1142 		{ 0, 1, 4, 4, 1, 5 }		// -Z face
1143 	};
1144 
1145 	// Create 6 quads and set appropriate texture coordinates for cube mapping
1146 
1147 	std::vector<Vertex4Tex4>			vertices	= createQuadMosaic(2, 3);
1148 	std::vector<Vertex4Tex4>::iterator	vertexItr	= vertices.begin();
1149 
1150 	for (int quadNdx = 0; quadNdx < 6; quadNdx++)
1151 	{
1152 		for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1153 		{
1154 			vertexItr->texCoord.xyz() = texCoordsCube[texCoordCubeIndices[quadNdx][vertexNdx]];
1155 			vertexItr++;
1156 		}
1157 	}
1158 
1159 	return vertices;
1160 }
1161 
createQuadMosaicCubeArray(int faceArrayIndices[6])1162 std::vector<Vertex4Tex4> createQuadMosaicCubeArray (int faceArrayIndices[6])
1163 {
1164 	std::vector<Vertex4Tex4>			vertices	= createQuadMosaicCube();
1165 	std::vector<Vertex4Tex4>::iterator	vertexItr	= vertices.begin();
1166 
1167 	for (int quadNdx = 0; quadNdx < 6; quadNdx++)
1168 	{
1169 		for (int vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1170 		{
1171 			vertexItr->texCoord.w() = (float)faceArrayIndices[quadNdx];
1172 			vertexItr++;
1173 		}
1174 	}
1175 
1176 	return vertices;
1177 }
1178 
createTestQuadMosaic(vk::VkImageViewType viewType)1179 std::vector<Vertex4Tex4> createTestQuadMosaic (vk::VkImageViewType viewType)
1180 {
1181 	std::vector<Vertex4Tex4> vertices;
1182 
1183 	switch (viewType)
1184 	{
1185 		case vk::VK_IMAGE_VIEW_TYPE_1D:
1186 		case vk::VK_IMAGE_VIEW_TYPE_2D:
1187 			vertices = createFullscreenQuad();
1188 			break;
1189 
1190 		case vk::VK_IMAGE_VIEW_TYPE_1D_ARRAY:
1191 			vertices = createQuadMosaic(2, 3);
1192 
1193 			// Set up array indices
1194 			for (size_t quadNdx = 0; quadNdx < 6; quadNdx++)
1195 				for (size_t vertexNdx = 0; vertexNdx < 6; vertexNdx++)
1196 					vertices[quadNdx * 6 + vertexNdx].texCoord.y() = (float)quadNdx;
1197 
1198 			break;
1199 
1200 		case vk::VK_IMAGE_VIEW_TYPE_2D_ARRAY:
1201 			vertices = createQuadMosaic(2, 3);
1202 			break;
1203 
1204 		case vk::VK_IMAGE_VIEW_TYPE_3D:
1205 			vertices = createQuadMosaic(2, 3);
1206 
1207 			// Use z between 0.0 and 1.0.
1208 			for (size_t vertexNdx = 0; vertexNdx < vertices.size(); vertexNdx++)
1209 			{
1210 				vertices[vertexNdx].texCoord.z() /= 5.0f;
1211 				vertices[vertexNdx].texCoord.z() -= 0.001f; // Substract small value to correct floating-point errors at the boundaries between slices
1212 			}
1213 
1214 			break;
1215 
1216 		case vk::VK_IMAGE_VIEW_TYPE_CUBE:
1217 			vertices = createQuadMosaicCube();
1218 			break;
1219 
1220 		case vk::VK_IMAGE_VIEW_TYPE_CUBE_ARRAY:
1221 			{
1222 				int faceArrayIndices[6] = { 0, 1, 2, 3, 4, 5 };
1223 				vertices = createQuadMosaicCubeArray(faceArrayIndices);
1224 			}
1225 			break;
1226 
1227 		default:
1228 			DE_ASSERT(false);
1229 			break;
1230 	}
1231 
1232 	return vertices;
1233 }
1234 
1235 } // pipeline
1236 } // vkt
1237