forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vk_format_utils.cpp
1525 lines (1433 loc) · 75.6 KB
/
vk_format_utils.cpp
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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 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 <[email protected]>
* Author: Dave Houlton <[email protected]>
*
*/
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include "vulkan/vulkan.h"
#include "vk_format_utils.h"
struct VULKAN_FORMAT_INFO {
uint32_t size;
uint32_t channel_count;
VkFormatCompatibilityClass format_class;
};
// Disable auto-formatting for this large table
// clang-format off
// Set up data structure with size(bytes) and number of channels for each Vulkan format
// For compressed and multi-plane formats, size is bytes per compressed or shared block
const std::map<VkFormat, VULKAN_FORMAT_INFO> kVkFormatTable = {
{VK_FORMAT_UNDEFINED, {0, 0, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT }},
{VK_FORMAT_R4G4_UNORM_PACK8, {1, 2, VK_FORMAT_COMPATIBILITY_CLASS_8_BIT}},
{VK_FORMAT_R4G4B4A4_UNORM_PACK16, {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_B4G4R4A4_UNORM_PACK16, {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT, {2, 4, 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, 3, 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, {2, 4, VK_FORMAT_COMPATIBILITY_CLASS_16_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, {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_8_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, {2, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_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, {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_24_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_A8B8G8R8_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, {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32_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, {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_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, {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_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, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_48_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, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64_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, {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_32_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, {8, 2, VK_FORMAT_COMPATIBILITY_CLASS_64_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, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_96_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, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_128_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, {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_64_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, {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_128_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, {24, 3, VK_FORMAT_COMPATIBILITY_CLASS_192_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, {32, 4, VK_FORMAT_COMPATIBILITY_CLASS_256_BIT}},
{VK_FORMAT_B10G11R11_UFLOAT_PACK32, {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT}},
{VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT}},
{VK_FORMAT_D16_UNORM, {2, 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, {4, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT}},
{VK_FORMAT_S8_UINT, {1, 1, VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT}},
{VK_FORMAT_D16_UNORM_S8_UINT, {3, 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, 2, VK_FORMAT_COMPATIBILITY_CLASS_NONE_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_RGB_BIT}},
{VK_FORMAT_BC1_RGBA_UNORM_BLOCK, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT}},
{VK_FORMAT_BC1_RGBA_SRGB_BLOCK, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_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_BC2_BIT}},
{VK_FORMAT_BC3_UNORM_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT}},
{VK_FORMAT_BC3_SRGB_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT}},
{VK_FORMAT_BC4_UNORM_BLOCK, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT}},
{VK_FORMAT_BC4_SNORM_BLOCK, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC4_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_BC5_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_BC6H_BIT}},
{VK_FORMAT_BC7_UNORM_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT}},
{VK_FORMAT_BC7_SRGB_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT}},
{VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT}},
{VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_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_RGBA_BIT}},
{VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}},
{VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}},
{VK_FORMAT_EAC_R11_UNORM_BLOCK, {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT}},
{VK_FORMAT_EAC_R11_SNORM_BLOCK, {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT}},
{VK_FORMAT_EAC_R11G11_UNORM_BLOCK, {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT}},
{VK_FORMAT_EAC_R11G11_SNORM_BLOCK, {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_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_4X4_BIT}},
{VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_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_5X4_BIT}},
{VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_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_5X5_BIT}},
{VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_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_6X5_BIT}},
{VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_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_6X6_BIT}},
{VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_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_8X5_BIT}},
{VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_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_8X6_BIT}},
{VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_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_8X8_BIT}},
{VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_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_10X5_BIT}},
{VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_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_10X6_BIT}},
{VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_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_10X8_BIT}},
{VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_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_10X10_BIT}},
{VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_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_12X10_BIT}},
{VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT}},
{VK_FORMAT_ASTC_12x12_UNORM_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT}},
{VK_FORMAT_ASTC_12x12_SRGB_BLOCK, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT}},
{VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT, {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT}},
{VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_2BPP_BIT}},
{VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_4BPP_BIT}},
{VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_2BPP_BIT}},
{VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_4BPP_BIT}},
{VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_2BPP_BIT}},
{VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_4BPP_BIT}},
{VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_2BPP_BIT}},
{VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_4BPP_BIT}},
// KHR_sampler_YCbCr_conversion extension - single-plane variants
// 'PACK' formats are normal, uncompressed
{VK_FORMAT_R10X6_UNORM_PACK16, {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_R10X6G10X6_UNORM_2PACK16, {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_32_BIT}},
{VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_R10G10B10A10}},
{VK_FORMAT_R12X4_UNORM_PACK16, {2, 1, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_R12X4G12X4_UNORM_2PACK16, {4, 2, VK_FORMAT_COMPATIBILITY_CLASS_16_BIT}},
{VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_R12G12B12A12}},
// _422 formats encode 2 texels per entry with B, R components shared - treated as compressed w/ 2x1 block size
{VK_FORMAT_G8B8G8R8_422_UNORM, {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32BIT_G8B8G8R8}},
{VK_FORMAT_B8G8R8G8_422_UNORM, {4, 4, VK_FORMAT_COMPATIBILITY_CLASS_32BIT_B8G8R8G8}},
{VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G10B10G10R10}},
{VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B10G10R10G10}},
{VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G12B12G12R12}},
{VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B12G12R12G12}},
{VK_FORMAT_G16B16G16R16_422_UNORM, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G16B16G16R16}},
{VK_FORMAT_B16G16R16G16_422_UNORM, {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B16G16R16G16}},
// KHR_sampler_YCbCr_conversion extension - multi-plane variants
// Formats that 'share' components among texels (_420 and _422), size represents total bytes for the smallest possible texel block
// _420 share B, R components within a 2x2 texel block
{VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_420}},
{VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_8BIT_2PLANE_420}},
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_420}},
{VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_10BIT_2PLANE_420}},
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_420}},
{VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_12BIT_2PLANE_420}},
{VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_420}},
{VK_FORMAT_G16_B16R16_2PLANE_420_UNORM, {12, 3, VK_FORMAT_COMPATIBILITY_CLASS_16BIT_2PLANE_420}},
// _422 share B, R components within a 2x1 texel block
{VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_422}},
{VK_FORMAT_G8_B8R8_2PLANE_422_UNORM, {4, 3, VK_FORMAT_COMPATIBILITY_CLASS_8BIT_2PLANE_422}},
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_422}},
{VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_10BIT_2PLANE_422}},
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_422}},
{VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_12BIT_2PLANE_422}},
{VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_422}},
{VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, {8, 3, VK_FORMAT_COMPATIBILITY_CLASS_16BIT_2PLANE_422}},
// _444 do not share
{VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM, {3, 3, VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_444}},
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_444}},
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_444}},
{VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, {6, 3, VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_444}}
};
// Renable formatting
// clang-format on
// Return true if format is an ETC2 or EAC compressed texture format
VK_LAYER_EXPORT bool FormatIsCompressed_ETC2_EAC(VkFormat format) {
bool found = false;
switch (format) {
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:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is either a LDR or HDR ASTC compressed textyre format
VK_LAYER_EXPORT bool FormatIsCompressed_ASTC(VkFormat format) {
return (FormatIsCompressed_ASTC_LDR(format) || FormatIsCompressed_ASTC_HDR(format));
}
// Return true if format is an LDR ASTC compressed texture format
VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_LDR(VkFormat format) {
bool found = false;
switch (format) {
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:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is an HDR ASTC compressed texture format
VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_HDR(VkFormat format) {
bool found = false;
switch (format) {
case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT:
case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is a BC compressed texture format
VK_LAYER_EXPORT bool FormatIsCompressed_BC(VkFormat format) {
bool found = false;
switch (format) {
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
case VK_FORMAT_BC1_RGBA_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:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is a PVRTC compressed texture format
VK_LAYER_EXPORT bool FormatIsCompressed_PVRTC(VkFormat format) {
bool found = false;
switch (format) {
case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG:
case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG:
case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG:
case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG:
found = true;
break;
default:
break;
}
return found;
}
// Single-plane "_422" formats are treated as 2x1 compressed (for copies)
VK_LAYER_EXPORT bool FormatIsSinglePlane_422(VkFormat format) {
bool found = false;
switch (format) {
case VK_FORMAT_G8B8G8R8_422_UNORM:
case VK_FORMAT_B8G8R8G8_422_UNORM:
case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16:
case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16:
case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16:
case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16:
case VK_FORMAT_G16B16G16R16_422_UNORM:
case VK_FORMAT_B16G16R16G16_422_UNORM:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is compressed
VK_LAYER_EXPORT bool FormatIsCompressed(VkFormat format) {
return (FormatIsCompressed_ASTC(format) || FormatIsCompressed_BC(format) || FormatIsCompressed_ETC2_EAC(format) ||
FormatIsCompressed_PVRTC(format));
}
// Return true if format is packed
VK_LAYER_EXPORT bool FormatIsPacked(VkFormat format) {
bool found = false;
switch (format) {
case VK_FORMAT_R4G4_UNORM_PACK8:
case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_B5G6R5_UNORM_PACK16:
case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
case VK_FORMAT_A8B8G8R8_UINT_PACK32:
case VK_FORMAT_A8B8G8R8_SINT_PACK32:
case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
case VK_FORMAT_A2R10G10B10_UINT_PACK32:
case VK_FORMAT_A2R10G10B10_SINT_PACK32:
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
case VK_FORMAT_A2B10G10R10_UINT_PACK32:
case VK_FORMAT_A2B10G10R10_SINT_PACK32:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
case VK_FORMAT_X8_D24_UNORM_PACK32:
case VK_FORMAT_R10X6_UNORM_PACK16:
case VK_FORMAT_R10X6G10X6_UNORM_2PACK16:
case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16:
case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16:
case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16:
case VK_FORMAT_R12X4_UNORM_PACK16:
case VK_FORMAT_R12X4G12X4_UNORM_2PACK16:
case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16:
case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16:
case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16:
found = true;
break;
default:
break;
}
return found;
}
// Return true if format is 'normal', with one texel per format element
VK_LAYER_EXPORT bool FormatElementIsTexel(VkFormat format) {
if (FormatIsPacked(format) || FormatIsCompressed(format) || FormatIsSinglePlane_422(format) || FormatIsMultiplane(format)) {
return false;
} else {
return true;
}
}
// Return true if format is a depth or stencil format
VK_LAYER_EXPORT bool FormatIsDepthOrStencil(VkFormat format) {
return (FormatIsDepthAndStencil(format) || FormatIsDepthOnly(format) || FormatIsStencilOnly(format));
}
// Return true if format contains depth and stencil information
VK_LAYER_EXPORT bool FormatIsDepthAndStencil(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
VK_LAYER_EXPORT bool FormatIsStencilOnly(VkFormat format) { return (format == VK_FORMAT_S8_UINT); }
// Return true if format is a depth-only format
VK_LAYER_EXPORT bool FormatIsDepthOnly(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 type NORM
VK_LAYER_EXPORT bool FormatIsNorm(VkFormat format) { return (FormatIsUNorm(format) || FormatIsSNorm(format)); }
// Return true if format is of type UNORM
VK_LAYER_EXPORT bool FormatIsUNorm(VkFormat format) {
bool is_unorm = false;
switch (format) {
case VK_FORMAT_R4G4_UNORM_PACK8:
case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT:
case VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT:
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_R8G8_UNORM:
case VK_FORMAT_R8G8B8_UNORM:
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
case VK_FORMAT_R16_UNORM:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM:
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_BC5_UNORM_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_R11G11_UNORM_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_B8G8R8A8_UNORM:
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_G8B8G8R8_422_UNORM:
case VK_FORMAT_B8G8R8G8_422_UNORM:
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16:
case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16:
case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16:
case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16:
case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16:
case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16:
case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16:
case VK_FORMAT_G16B16G16R16_422_UNORM:
case VK_FORMAT_B16G16R16G16_422_UNORM:
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG:
case VK_FORMAT_R10X6_UNORM_PACK16:
case VK_FORMAT_R10X6G10X6_UNORM_2PACK16:
case VK_FORMAT_R12X4_UNORM_PACK16:
case VK_FORMAT_R12X4G12X4_UNORM_2PACK16:
is_unorm = true;
break;
default:
break;
}
return is_unorm;
}
// Return true if format is of type SNORM
VK_LAYER_EXPORT bool FormatIsSNorm(VkFormat format) {
bool is_snorm = false;
switch (format) {
case VK_FORMAT_R8_SNORM:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
case VK_FORMAT_R16_SNORM:
case VK_FORMAT_R16G16_SNORM:
case VK_FORMAT_R16G16B16_SNORM:
case VK_FORMAT_R16G16B16A16_SNORM:
case VK_FORMAT_BC4_SNORM_BLOCK:
case VK_FORMAT_BC5_SNORM_BLOCK:
case VK_FORMAT_EAC_R11_SNORM_BLOCK:
case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
case VK_FORMAT_B8G8R8_SNORM:
case VK_FORMAT_B8G8R8A8_SNORM:
case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
is_snorm = true;
break;
default:
break;
}
return is_snorm;
}
// Return true if format is an integer format
VK_LAYER_EXPORT bool FormatIsInt(VkFormat format) { return (FormatIsSInt(format) || FormatIsUInt(format)); }
// Return true if format is an unsigned integer format
VK_LAYER_EXPORT bool FormatIsUInt(VkFormat format) {
bool is_uint = false;
switch (format) {
case VK_FORMAT_R8_UINT:
case VK_FORMAT_S8_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
VK_LAYER_EXPORT bool FormatIsSInt(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
VK_LAYER_EXPORT bool FormatIsFloat(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
VK_LAYER_EXPORT bool FormatIsSRGB(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 a USCALED format
VK_LAYER_EXPORT bool FormatIsUScaled(VkFormat format) {
bool is_uscaled = false;
switch (format) {
case VK_FORMAT_R8_USCALED:
case VK_FORMAT_R8G8_USCALED:
case VK_FORMAT_R8G8B8_USCALED:
case VK_FORMAT_B8G8R8_USCALED:
case VK_FORMAT_R8G8B8A8_USCALED:
case VK_FORMAT_B8G8R8A8_USCALED:
case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
case VK_FORMAT_R16_USCALED:
case VK_FORMAT_R16G16_USCALED:
case VK_FORMAT_R16G16B16_USCALED:
case VK_FORMAT_R16G16B16A16_USCALED:
is_uscaled = true;
break;
default:
break;
}
return is_uscaled;
}
// Return true if format is a SSCALED format
VK_LAYER_EXPORT bool FormatIsSScaled(VkFormat format) {
bool is_sscaled = false;
switch (format) {
case VK_FORMAT_R8_SSCALED:
case VK_FORMAT_R8G8_SSCALED:
case VK_FORMAT_R8G8B8_SSCALED:
case VK_FORMAT_B8G8R8_SSCALED:
case VK_FORMAT_R8G8B8A8_SSCALED:
case VK_FORMAT_B8G8R8A8_SSCALED:
case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
case VK_FORMAT_R16_SSCALED:
case VK_FORMAT_R16G16_SSCALED:
case VK_FORMAT_R16G16B16_SSCALED:
case VK_FORMAT_R16G16B16A16_SSCALED:
is_sscaled = true;
break;
default:
break;
}
return is_sscaled;
}
// Types from "Interpretation of Numeric Format" table
VK_LAYER_EXPORT bool FormatIsSampledInt(VkFormat format) { return FormatIsInt(format); }
VK_LAYER_EXPORT bool FormatIsSampledFloat(VkFormat format) {
return (FormatIsUNorm(format) || FormatIsSNorm(format) || FormatIsUScaled(format) || FormatIsSScaled(format) ||
FormatIsFloat(format) || FormatIsSRGB(format));
}
// Return texel block sizes for all formats
// Uncompressed formats return {1, 1, 1}
// Compressed formats return the compression block extents
// Multiplane formats return the 'shared' extent of their low-res channel(s)
VK_LAYER_EXPORT VkExtent3D FormatTexelBlockExtent(VkFormat format) {
VkExtent3D block_size = {1, 1, 1};
switch (format) {
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
case VK_FORMAT_BC1_RGBA_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_4x4_SFLOAT_BLOCK_EXT:
block_size = {4, 4, 1};
break;
case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT:
block_size = {5, 4, 1};
break;
case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT:
block_size = {5, 5, 1};
break;
case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT:
block_size = {6, 5, 1};
break;
case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT:
block_size = {6, 6, 1};
break;
case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT:
block_size = {8, 5, 1};
break;
case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT:
block_size = {8, 6, 1};
break;
case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT:
block_size = {8, 8, 1};
break;
case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: