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