summaryrefslogtreecommitdiff
path: root/layers/vk_layer_utils.cpp
blob: 1c362706fcfc9fb7792433d542ee97cb8feab306 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
/* Copyright (c) 2015-2016 The Khronos Group Inc.
 * Copyright (c) 2015-2016 Valve Corporation
 * Copyright (c) 2015-2016 LunarG, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: Mark Lobodzinski <mark@lunarg.com>
 *
 */

#include <string.h>
#include <string>
#include <vector>
#include "vulkan/vulkan.h"
#include "vk_layer_config.h"
#include "vk_layer_utils.h"

struct VULKAN_FORMAT_INFO {
    size_t size;
    uint32_t channel_count;
    VkFormatCompatibilityClass format_class;
};

// Set up data structure with number of bytes and number of channels
// for each Vulkan format.
static const VULKAN_FORMAT_INFO vk_format_table[VK_FORMAT_RANGE_SIZE] = {
    {0, 0, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_UNDEFINED]
    {1, 2, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R4G4_UNORM_PACK8]
    {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R4G4B4A4_UNORM_PACK16]
    {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B4G4R4A4_UNORM_PACK16]
    {2, 3, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R5G6B5_UNORM_PACK16]
    {2, 3, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B5G6R5_UNORM_PACK16]
    {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R5G5B5A1_UNORM_PACK16]
    {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_B5G5R5A1_UNORM_PACK16]
    {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_A1R5G5B5_UNORM_PACK16]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_UNORM]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SNORM]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_USCALED]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SSCALED]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_UINT]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SINT]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT},             //    [VK_FORMAT_R8_SRGB]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_UNORM]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SNORM]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_USCALED]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SSCALED]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_UINT]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SINT]
    {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R8G8_SRGB]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_UNORM]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SNORM]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_USCALED]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SSCALED]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_UINT]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SINT]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_R8G8B8_SRGB]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_UNORM]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SNORM]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_USCALED]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SSCALED]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_UINT]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SINT]
    {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_BIT},            //    [VK_FORMAT_B8G8R8_SRGB]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_UNORM]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SNORM]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_USCALED]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SSCALED]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_UINT]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SINT]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R8G8B8A8_SRGB]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_UNORM]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SNORM]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_USCALED]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SSCALED]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_UINT]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SINT]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SRGB]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_UNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_USCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SSCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_UINT_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A8B8G8R8_SINT_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B8G8R8A8_SRGB_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_UNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_USCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SSCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_UINT_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2R10G10B10_SINT_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_UNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SNORM_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_USCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SSCALED_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_UINT_PACK32]
    {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_A2B10G10R10_SINT_PACK32]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_UNORM]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SNORM]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_USCALED]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SSCALED]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_UINT]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SINT]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT},            //    [VK_FORMAT_R16_SFLOAT]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_UNORM]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SNORM]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_USCALED]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SSCALED]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_UINT]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SINT]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R16G16_SFLOAT]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_UNORM]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SNORM]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_USCALED]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SSCALED]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_UINT]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SINT]
    {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_BIT},            //    [VK_FORMAT_R16G16B16_SFLOAT]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_UNORM]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SNORM]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_USCALED]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SSCALED]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_UINT]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SINT]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R16G16B16A16_SFLOAT]
    {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_UINT]
    {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_SINT]
    {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_R32_SFLOAT]
    {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_UINT]
    {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_SINT]
    {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R32G32_SFLOAT]
    {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_UINT]
    {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_SINT]
    {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_BIT},           //    [VK_FORMAT_R32G32B32_SFLOAT]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_UINT]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_SINT]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R32G32B32A32_SFLOAT]
    {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_UINT]
    {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_SINT]
    {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_BIT},            //    [VK_FORMAT_R64_SFLOAT]
    {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_UINT]
    {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_SINT]
    {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_BIT},          //    [VK_FORMAT_R64G64_SFLOAT]
    {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_UINT]
    {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_SINT]
    {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_BIT},          //    [VK_FORMAT_R64G64B64_SFLOAT]
    {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_UINT]
    {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_SINT]
    {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT},          //    [VK_FORMAT_R64G64B64A64_SFLOAT]
    {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_B10G11R11_UFLOAT_PACK32]
    {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT},            //    [VK_FORMAT_E5B9G9R9_UFLOAT_PACK32]
    {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D16_UNORM]
    {3, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_X8_D24_UNORM_PACK32]
    {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D32_SFLOAT]
    {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_S8_UINT]
    {3, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D16_UNORM_S8_UINT]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D24_UNORM_S8_UINT]
    {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT},          //    [VK_FORMAT_D32_SFLOAT_S8_UINT]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT},       //    [VK_FORMAT_BC1_RGB_UNORM_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT},       //    [VK_FORMAT_BC1_RGB_SRGB_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT},      //    [VK_FORMAT_BC1_RGBA_UNORM_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT},      //    [VK_FORMAT_BC1_RGBA_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT},          //    [VK_FORMAT_BC2_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT},          //    [VK_FORMAT_BC2_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT},          //    [VK_FORMAT_BC3_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT},          //    [VK_FORMAT_BC3_SRGB_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT},           //    [VK_FORMAT_BC4_UNORM_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT},           //    [VK_FORMAT_BC4_SNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT},          //    [VK_FORMAT_BC5_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT},          //    [VK_FORMAT_BC5_SNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT},         //    [VK_FORMAT_BC6H_UFLOAT_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT},         //    [VK_FORMAT_BC6H_SFLOAT_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT},          //    [VK_FORMAT_BC7_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT},          //    [VK_FORMAT_BC7_SRGB_BLOCK]
    {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT},      //    [VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK]
    {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT},      //    [VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT},     //    [VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT},     //    [VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}, //    [VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK]
    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}, // [VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK]
    {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT},         //    [VK_FORMAT_EAC_R11_UNORM_BLOCK]
    {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT},         //    [VK_FORMAT_EAC_R11_SNORM_BLOCK]
    {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT},       //    [VK_FORMAT_EAC_R11G11_UNORM_BLOCK]
    {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT},       //    [VK_FORMAT_EAC_R11G11_SNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT},     //    [VK_FORMAT_ASTC_4x4_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT},     //    [VK_FORMAT_ASTC_4x4_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT},     //    [VK_FORMAT_ASTC_5x4_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT},     //    [VK_FORMAT_ASTC_5x4_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT},     //    [VK_FORMAT_ASTC_5x5_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT},     //    [VK_FORMAT_ASTC_5x5_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT},     //    [VK_FORMAT_ASTC_6x5_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT},     //    [VK_FORMAT_ASTC_6x5_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT},     //    [VK_FORMAT_ASTC_6x6_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT},     //    [VK_FORMAT_ASTC_6x6_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT},     //    [VK_FORMAT_ASTC_8x5_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT},     //    [VK_FORMAT_ASTC_8x5_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT},     //    [VK_FORMAT_ASTC_8x6_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT},     //    [VK_FORMAT_ASTC_8x6_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT},     //    [VK_FORMAT_ASTC_8x8_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT},     //    [VK_FORMAT_ASTC_8x8_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT},    //    [VK_FORMAT_ASTC_10x5_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT},    //    [VK_FORMAT_ASTC_10x5_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT},    //    [VK_FORMAT_ASTC_10x6_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT},    //    [VK_FORMAT_ASTC_10x6_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT},    //    [VK_FORMAT_ASTC_10x8_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT},    //    [VK_FORMAT_ASTC_10x8_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT},   //    [VK_FORMAT_ASTC_10x10_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT},   //    [VK_FORMAT_ASTC_10x10_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT},   //    [VK_FORMAT_ASTC_12x10_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT},   //    [VK_FORMAT_ASTC_12x10_SRGB_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT},   //    [VK_FORMAT_ASTC_12x12_UNORM_BLOCK]
    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT},   //    [VK_FORMAT_ASTC_12x12_SRGB_BLOCK]
};

// Return true if format is a depth or stencil format
bool vk_format_is_depth_or_stencil(VkFormat format) {
    return (vk_format_is_depth_and_stencil(format) || vk_format_is_depth_only(format) || vk_format_is_stencil_only(format));
}

// Return true if format contains depth and stencil information
bool vk_format_is_depth_and_stencil(VkFormat format) {
    bool is_ds = false;

    switch (format) {
    case VK_FORMAT_D16_UNORM_S8_UINT:
    case VK_FORMAT_D24_UNORM_S8_UINT:
    case VK_FORMAT_D32_SFLOAT_S8_UINT:
        is_ds = true;
        break;
    default:
        break;
    }
    return is_ds;
}

// Return true if format is a stencil-only format
bool vk_format_is_stencil_only(VkFormat format) { return (format == VK_FORMAT_S8_UINT); }

// Return true if format is a depth-only format
bool vk_format_is_depth_only(VkFormat format) {
    bool is_depth = false;

    switch (format) {
    case VK_FORMAT_D16_UNORM:
    case VK_FORMAT_X8_D24_UNORM_PACK32:
    case VK_FORMAT_D32_SFLOAT:
        is_depth = true;
        break;
    default:
        break;
    }

    return is_depth;
}

// Return true if format is of time UNORM
bool vk_format_is_norm(VkFormat format) {
    bool is_norm = false;

    switch (format) {
    case VK_FORMAT_R4G4_UNORM_PACK8:
    case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
    case VK_FORMAT_R5G6B5_UNORM_PACK16:
    case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
    case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
    case VK_FORMAT_R8_UNORM:
    case VK_FORMAT_R8_SNORM:
    case VK_FORMAT_R8G8_UNORM:
    case VK_FORMAT_R8G8_SNORM:
    case VK_FORMAT_R8G8B8_UNORM:
    case VK_FORMAT_R8G8B8_SNORM:
    case VK_FORMAT_R8G8B8A8_UNORM:
    case VK_FORMAT_R8G8B8A8_SNORM:
    case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
    case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
    case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
    case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
    case VK_FORMAT_R16_UNORM:
    case VK_FORMAT_R16_SNORM:
    case VK_FORMAT_R16G16_UNORM:
    case VK_FORMAT_R16G16_SNORM:
    case VK_FORMAT_R16G16B16_UNORM:
    case VK_FORMAT_R16G16B16_SNORM:
    case VK_FORMAT_R16G16B16A16_UNORM:
    case VK_FORMAT_R16G16B16A16_SNORM:
    case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
    case VK_FORMAT_BC2_UNORM_BLOCK:
    case VK_FORMAT_BC3_UNORM_BLOCK:
    case VK_FORMAT_BC4_UNORM_BLOCK:
    case VK_FORMAT_BC4_SNORM_BLOCK:
    case VK_FORMAT_BC5_UNORM_BLOCK:
    case VK_FORMAT_BC5_SNORM_BLOCK:
    case VK_FORMAT_BC7_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
    case VK_FORMAT_EAC_R11_UNORM_BLOCK:
    case VK_FORMAT_EAC_R11_SNORM_BLOCK:
    case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
    case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
    case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
    case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
    case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
    case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
    case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
    case VK_FORMAT_B5G6R5_UNORM_PACK16:
    case VK_FORMAT_B8G8R8_UNORM:
    case VK_FORMAT_B8G8R8_SNORM:
    case VK_FORMAT_B8G8R8A8_UNORM:
    case VK_FORMAT_B8G8R8A8_SNORM:
    case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
    case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
        is_norm = true;
        break;
    default:
        break;
    }

    return is_norm;
};

// Return true if format is an integer format
bool vk_format_is_int(VkFormat format) { return (vk_format_is_sint(format) || vk_format_is_uint(format)); }

// Return true if format is an unsigned integer format
bool vk_format_is_uint(VkFormat format) {
    bool is_uint = false;

    switch (format) {
    case VK_FORMAT_R8_UINT:
    case VK_FORMAT_R8G8_UINT:
    case VK_FORMAT_R8G8B8_UINT:
    case VK_FORMAT_R8G8B8A8_UINT:
    case VK_FORMAT_A8B8G8R8_UINT_PACK32:
    case VK_FORMAT_A2B10G10R10_UINT_PACK32:
    case VK_FORMAT_R16_UINT:
    case VK_FORMAT_R16G16_UINT:
    case VK_FORMAT_R16G16B16_UINT:
    case VK_FORMAT_R16G16B16A16_UINT:
    case VK_FORMAT_R32_UINT:
    case VK_FORMAT_R32G32_UINT:
    case VK_FORMAT_R32G32B32_UINT:
    case VK_FORMAT_R32G32B32A32_UINT:
    case VK_FORMAT_R64_UINT:
    case VK_FORMAT_R64G64_UINT:
    case VK_FORMAT_R64G64B64_UINT:
    case VK_FORMAT_R64G64B64A64_UINT:
    case VK_FORMAT_B8G8R8_UINT:
    case VK_FORMAT_B8G8R8A8_UINT:
    case VK_FORMAT_A2R10G10B10_UINT_PACK32:
        is_uint = true;
        break;
    default:
        break;
    }

    return is_uint;
}

// Return true if format is a signed integer format
bool vk_format_is_sint(VkFormat format) {
    bool is_sint = false;

    switch (format) {
    case VK_FORMAT_R8_SINT:
    case VK_FORMAT_R8G8_SINT:
    case VK_FORMAT_R8G8B8_SINT:
    case VK_FORMAT_R8G8B8A8_SINT:
    case VK_FORMAT_A8B8G8R8_SINT_PACK32:
    case VK_FORMAT_A2B10G10R10_SINT_PACK32:
    case VK_FORMAT_R16_SINT:
    case VK_FORMAT_R16G16_SINT:
    case VK_FORMAT_R16G16B16_SINT:
    case VK_FORMAT_R16G16B16A16_SINT:
    case VK_FORMAT_R32_SINT:
    case VK_FORMAT_R32G32_SINT:
    case VK_FORMAT_R32G32B32_SINT:
    case VK_FORMAT_R32G32B32A32_SINT:
    case VK_FORMAT_R64_SINT:
    case VK_FORMAT_R64G64_SINT:
    case VK_FORMAT_R64G64B64_SINT:
    case VK_FORMAT_R64G64B64A64_SINT:
    case VK_FORMAT_B8G8R8_SINT:
    case VK_FORMAT_B8G8R8A8_SINT:
    case VK_FORMAT_A2R10G10B10_SINT_PACK32:
        is_sint = true;
        break;
    default:
        break;
    }

    return is_sint;
}

// Return true if format is a floating-point format
bool vk_format_is_float(VkFormat format) {
    bool is_float = false;

    switch (format) {
    case VK_FORMAT_R16_SFLOAT:
    case VK_FORMAT_R16G16_SFLOAT:
    case VK_FORMAT_R16G16B16_SFLOAT:
    case VK_FORMAT_R16G16B16A16_SFLOAT:
    case VK_FORMAT_R32_SFLOAT:
    case VK_FORMAT_R32G32_SFLOAT:
    case VK_FORMAT_R32G32B32_SFLOAT:
    case VK_FORMAT_R32G32B32A32_SFLOAT:
    case VK_FORMAT_R64_SFLOAT:
    case VK_FORMAT_R64G64_SFLOAT:
    case VK_FORMAT_R64G64B64_SFLOAT:
    case VK_FORMAT_R64G64B64A64_SFLOAT:
    case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
    case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
    case VK_FORMAT_BC6H_UFLOAT_BLOCK:
    case VK_FORMAT_BC6H_SFLOAT_BLOCK:
        is_float = true;
        break;
    default:
        break;
    }

    return is_float;
}

// Return true if format is in the SRGB colorspace
bool vk_format_is_srgb(VkFormat format) {
    bool is_srgb = false;

    switch (format) {
    case VK_FORMAT_R8_SRGB:
    case VK_FORMAT_R8G8_SRGB:
    case VK_FORMAT_R8G8B8_SRGB:
    case VK_FORMAT_R8G8B8A8_SRGB:
    case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
    case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
    case VK_FORMAT_BC2_SRGB_BLOCK:
    case VK_FORMAT_BC3_SRGB_BLOCK:
    case VK_FORMAT_BC7_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
    case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
    case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
    case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
    case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
    case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
    case VK_FORMAT_B8G8R8_SRGB:
    case VK_FORMAT_B8G8R8A8_SRGB:
        is_srgb = true;
        break;
    default:
        break;
    }

    return is_srgb;
}

// Return true if format is compressed
bool vk_format_is_compressed(VkFormat format) {
    switch (format) {
    case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
    case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
    case VK_FORMAT_BC2_UNORM_BLOCK:
    case VK_FORMAT_BC2_SRGB_BLOCK:
    case VK_FORMAT_BC3_UNORM_BLOCK:
    case VK_FORMAT_BC3_SRGB_BLOCK:
    case VK_FORMAT_BC4_UNORM_BLOCK:
    case VK_FORMAT_BC4_SNORM_BLOCK:
    case VK_FORMAT_BC5_UNORM_BLOCK:
    case VK_FORMAT_BC5_SNORM_BLOCK:
    case VK_FORMAT_BC6H_UFLOAT_BLOCK:
    case VK_FORMAT_BC6H_SFLOAT_BLOCK:
    case VK_FORMAT_BC7_UNORM_BLOCK:
    case VK_FORMAT_BC7_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
    case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
    case VK_FORMAT_EAC_R11_UNORM_BLOCK:
    case VK_FORMAT_EAC_R11_SNORM_BLOCK:
    case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
    case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
    case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
    case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
    case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
    case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
    case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
    case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
    case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
    case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
    case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
    case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
    case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
    case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
        return true;
    default:
        return false;
    }
}

// Return format class of the specified format
VkFormatCompatibilityClass vk_format_get_compatibility_class(VkFormat format) { return vk_format_table[format].format_class; }

// Return size, in bytes, of a pixel of the specified format
size_t vk_format_get_size(VkFormat format) { return vk_format_table[format].size; }

// Return the number of channels for a given format
unsigned int vk_format_get_channel_count(VkFormat format) { return vk_format_table[format].channel_count; }

// Perform a zero-tolerant modulo operation
VkDeviceSize vk_safe_modulo(VkDeviceSize dividend, VkDeviceSize divisor) {
    VkDeviceSize result = 0;
    if (divisor != 0) {
        result = dividend % divisor;
    }
    return result;
}

static const uint8_t UTF8_ONE_BYTE_CODE = 0xC0;
static const uint8_t UTF8_ONE_BYTE_MASK = 0xE0;
static const uint8_t UTF8_TWO_BYTE_CODE = 0xE0;
static const uint8_t UTF8_TWO_BYTE_MASK = 0xF0;
static const uint8_t UTF8_THREE_BYTE_CODE = 0xF0;
static const uint8_t UTF8_THREE_BYTE_MASK = 0xF8;
static const uint8_t UTF8_DATA_BYTE_CODE = 0x80;
static const uint8_t UTF8_DATA_BYTE_MASK = 0xC0;

VkStringErrorFlags vk_string_validate(const int max_length, const char *utf8) {
    VkStringErrorFlags result = VK_STRING_ERROR_NONE;
    int num_char_bytes = 0;
    int i, j;

    for (i = 0; i < max_length; i++) {
        if (utf8[i] == 0) {
            break;
        } else if ((utf8[i] >= 0xa) && (utf8[i] < 0x7f)) {
            num_char_bytes = 0;
        } else if ((utf8[i] & UTF8_ONE_BYTE_MASK) == UTF8_ONE_BYTE_CODE) {
            num_char_bytes = 1;
        } else if ((utf8[i] & UTF8_TWO_BYTE_MASK) == UTF8_TWO_BYTE_CODE) {
            num_char_bytes = 2;
        } else if ((utf8[i] & UTF8_THREE_BYTE_MASK) == UTF8_THREE_BYTE_CODE) {
            num_char_bytes = 3;
        } else {
            result = VK_STRING_ERROR_BAD_DATA;
        }

        // Validate the following num_char_bytes of data
        for (j = 0; (j < num_char_bytes) && (i < max_length); j++) {
            if (++i == max_length) {
                result |= VK_STRING_ERROR_LENGTH;
                break;
            }
            if ((utf8[i] & UTF8_DATA_BYTE_MASK) != UTF8_DATA_BYTE_CODE) {
                result |= VK_STRING_ERROR_BAD_DATA;
            }
        }
    }
    return result;
}

void layer_debug_actions(debug_report_data *report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback,
                      const VkAllocationCallbacks *pAllocator, const char *layer_identifier) {

    uint32_t report_flags = 0;
    uint32_t debug_action = 0;
    VkDebugReportCallbackEXT callback = VK_NULL_HANDLE;

    std::string report_flags_key = layer_identifier;
    std::string debug_action_key = layer_identifier;
    std::string log_filename_key = layer_identifier;
    report_flags_key.append(".report_flags");
    debug_action_key.append(".debug_action");
    log_filename_key.append(".log_filename");

    // initialize layer options
    report_flags = getLayerOptionFlags(report_flags_key.c_str(), 0);
    getLayerOptionEnum(debug_action_key.c_str(), (uint32_t *)&debug_action);

    if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) {
        const char *log_filename = getLayerOption(log_filename_key.c_str());
        FILE *log_output = getLayerLogOutput(log_filename, layer_identifier);
        VkDebugReportCallbackCreateInfoEXT dbgCreateInfo;
        memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
        dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
        dbgCreateInfo.flags = report_flags;
        dbgCreateInfo.pfnCallback = log_callback;
        dbgCreateInfo.pUserData = (void *)log_output;
        layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback);
        logging_callback.push_back(callback);
    }

    if (debug_action & VK_DBG_LAYER_ACTION_DEBUG_OUTPUT) {
        VkDebugReportCallbackCreateInfoEXT dbgCreateInfo;
        memset(&dbgCreateInfo, 0, sizeof(dbgCreateInfo));
        dbgCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
        dbgCreateInfo.flags = report_flags;
        dbgCreateInfo.pfnCallback = win32_debug_output_msg;
        dbgCreateInfo.pUserData = NULL;
        layer_create_msg_callback(report_data, &dbgCreateInfo, pAllocator, &callback);
        logging_callback.push_back(callback);
    }
}