summaryrefslogtreecommitdiffstats
path: root/thirdparty/libktx/lib/vkformat_check.c
blob: 5b86e3c8feadb4ac0c3493eba494376d78bd0d76 (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

/***************************** Do not edit.  *****************************
 Automatically generated from vulkan_core.h version 267 by mkvkformatfiles.
 *************************************************************************/

/*
** Copyright 2015-2023 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/

#include <stdint.h>
#include <stdbool.h>

#include "vkformat_enum.h"

bool
isProhibitedFormat(VkFormat format)
{
    switch (format) {
      case VK_FORMAT_R8_USCALED:
      case VK_FORMAT_R8_SSCALED:
      case VK_FORMAT_R8G8_USCALED:
      case VK_FORMAT_R8G8_SSCALED:
      case VK_FORMAT_R8G8B8_USCALED:
      case VK_FORMAT_R8G8B8_SSCALED:
      case VK_FORMAT_B8G8R8_USCALED:
      case VK_FORMAT_B8G8R8_SSCALED:
      case VK_FORMAT_R8G8B8A8_USCALED:
      case VK_FORMAT_R8G8B8A8_SSCALED:
      case VK_FORMAT_B8G8R8A8_USCALED:
      case VK_FORMAT_B8G8R8A8_SSCALED:
      case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
      case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
      case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
      case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
      case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
      case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
      case VK_FORMAT_R16_USCALED:
      case VK_FORMAT_R16_SSCALED:
      case VK_FORMAT_R16G16_USCALED:
      case VK_FORMAT_R16G16_SSCALED:
      case VK_FORMAT_R16G16B16_USCALED:
      case VK_FORMAT_R16G16B16_SSCALED:
      case VK_FORMAT_R16G16B16A16_USCALED:
      case VK_FORMAT_R16G16B16A16_SSCALED:
      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_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:
      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_G8_B8R8_2PLANE_444_UNORM:
      case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16:
      case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16:
      case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM:
        return true;
      default:
        return false;
    }
}

bool
isValidFormat(VkFormat format)
{
    // On MSVC VkFormat can be a signed integer
    if ((uint32_t) format <= VK_FORMAT_MAX_STANDARD_ENUM)
        return true;
    else switch(format) {
        case VK_FORMAT_G8B8G8R8_422_UNORM:
        case VK_FORMAT_B8G8R8G8_422_UNORM:
        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_G16B16G16R16_422_UNORM:
        case VK_FORMAT_B16G16R16G16_422_UNORM:
        case VK_FORMAT_A4R4G4B4_UNORM_PACK16:
        case VK_FORMAT_A4B4G4R4_UNORM_PACK16:
        case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK:
        case VK_FORMAT_ASTC_12x12_SFLOAT_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_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:
        case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT:
        case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT:
        case VK_FORMAT_R16G16_S10_5_NV:
        case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR:
        case VK_FORMAT_A8_UNORM_KHR:
        return true;
      default:
        return false;
    }
}