1 // *** THIS FILE IS GENERATED - DO NOT EDIT ***
2 // See format_utils_generator.py for modifications
3 
4 
5 /***************************************************************************
6  *
7  * Copyright (c) 2015-2021 The Khronos Group Inc.
8  * Copyright (c) 2015-2021 Valve Corporation
9  * Copyright (c) 2015-2021 LunarG, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *     http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * Author: Mark Lobodzinski <mark@lunarg.com>
24  * Author: Dave Houlton <daveh@lunarg.com>
25  * Author: Spencer Fricke <s.fricke@samsung.com>
26  *
27  ****************************************************************************/
28 
29 #pragma once
30 #include <vulkan/vk_layer.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 static constexpr uint32_t FORMAT_MAX_PLANES = 3;
37 static constexpr uint32_t FORMAT_MAX_COMPONENTS = 4;
38 
39 enum class FORMAT_NUMERICAL_TYPE {
40     NONE = 0,
41     SFLOAT,
42     SINT,
43     SNORM,
44     SRGB,
45     SSCALED,
46     UFLOAT,
47     UINT,
48     UNORM,
49     USCALED
50 };
51 
52 enum class FORMAT_COMPATIBILITY_CLASS {
53     NONE = 0,
54     _10BIT_2PLANE_420,
55     _10BIT_2PLANE_422,
56     _10BIT_2PLANE_444,
57     _10BIT_3PLANE_420,
58     _10BIT_3PLANE_422,
59     _10BIT_3PLANE_444,
60     _12BIT_2PLANE_420,
61     _12BIT_2PLANE_422,
62     _12BIT_2PLANE_444,
63     _12BIT_3PLANE_420,
64     _12BIT_3PLANE_422,
65     _12BIT_3PLANE_444,
66     _128BIT,
67     _16BIT,
68     _16BIT_2PLANE_420,
69     _16BIT_2PLANE_422,
70     _16BIT_2PLANE_444,
71     _16BIT_3PLANE_420,
72     _16BIT_3PLANE_422,
73     _16BIT_3PLANE_444,
74     _192BIT,
75     _24BIT,
76     _256BIT,
77     _32BIT,
78     _32BIT_B8G8R8G8,
79     _32BIT_G8B8G8R8,
80     _48BIT,
81     _64BIT,
82     _64BIT_B10G10R10G10,
83     _64BIT_B12G12R12G12,
84     _64BIT_B16G16R16G16,
85     _64BIT_G10B10G10R10,
86     _64BIT_G12B12G12R12,
87     _64BIT_G16B16G16R16,
88     _64BIT_R10G10B10A10,
89     _64BIT_R12G12B12A12,
90     _8BIT,
91     _8BIT_2PLANE_420,
92     _8BIT_2PLANE_422,
93     _8BIT_2PLANE_444,
94     _8BIT_3PLANE_420,
95     _8BIT_3PLANE_422,
96     _8BIT_3PLANE_444,
97     _96BIT,
98     ASTC_10X10,
99     ASTC_10X5,
100     ASTC_10X6,
101     ASTC_10X8,
102     ASTC_12X10,
103     ASTC_12X12,
104     ASTC_4X4,
105     ASTC_5X4,
106     ASTC_5X5,
107     ASTC_6X5,
108     ASTC_6X6,
109     ASTC_8X5,
110     ASTC_8X6,
111     ASTC_8X8,
112     BC1_RGB,
113     BC1_RGBA,
114     BC2,
115     BC3,
116     BC4,
117     BC5,
118     BC6H,
119     BC7,
120     D16,
121     D16S8,
122     D24,
123     D24S8,
124     D32,
125     D32S8,
126     EAC_R,
127     EAC_RG,
128     ETC2_EAC_RGBA,
129     ETC2_RGB,
130     ETC2_RGBA,
131     PVRTC1_2BPP,
132     PVRTC1_4BPP,
133     PVRTC2_2BPP,
134     PVRTC2_4BPP,
135     S8
136 };
137 
138 // Numeric
139 // Formats with more then one numeric type (VK_FORMAT_D16_UNORM_S8_UINT) will return false
140 VK_LAYER_EXPORT bool FormatIsUNORM(VkFormat format);
141 VK_LAYER_EXPORT bool FormatIsSNORM(VkFormat format);
142 VK_LAYER_EXPORT bool FormatIsUSCALED(VkFormat format);
143 VK_LAYER_EXPORT bool FormatIsSSCALED(VkFormat format);
144 VK_LAYER_EXPORT bool FormatIsUINT(VkFormat format);
145 VK_LAYER_EXPORT bool FormatIsSINT(VkFormat format);
146 VK_LAYER_EXPORT bool FormatIsSRGB(VkFormat format);
147 VK_LAYER_EXPORT bool FormatIsSFLOAT(VkFormat format);
148 VK_LAYER_EXPORT bool FormatIsUFLOAT(VkFormat format);
149 
150 // Types from "Interpretation of Numeric Format" table (OpTypeFloat vs OpTypeInt)
FormatIsSampledInt(VkFormat format)151 static inline bool FormatIsSampledInt(VkFormat format) { return (FormatIsSINT(format) || FormatIsUINT(format)); }
FormatIsSampledFloat(VkFormat format)152 static inline bool FormatIsSampledFloat(VkFormat format) {
153     return (FormatIsUNORM(format)   || FormatIsSNORM(format)   ||
154             FormatIsUSCALED(format) || FormatIsSSCALED(format) ||
155             FormatIsUFLOAT(format)  || FormatIsSFLOAT(format)  ||
156             FormatIsSRGB(format));
157 }
158 
159 // Compressed
160 VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_HDR(VkFormat format);
161 VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_LDR(VkFormat format);
162 VK_LAYER_EXPORT bool FormatIsCompressed_BC(VkFormat format);
163 VK_LAYER_EXPORT bool FormatIsCompressed_EAC(VkFormat format);
164 VK_LAYER_EXPORT bool FormatIsCompressed_ETC2(VkFormat format);
165 VK_LAYER_EXPORT bool FormatIsCompressed_PVRTC(VkFormat format);
166 VK_LAYER_EXPORT bool FormatIsCompressed(VkFormat format);
167 
168 // Depth/Stencil
169 VK_LAYER_EXPORT bool FormatIsDepthOrStencil(VkFormat format);
170 VK_LAYER_EXPORT bool FormatIsDepthAndStencil(VkFormat format);
171 VK_LAYER_EXPORT bool FormatIsDepthOnly(VkFormat format);
172 VK_LAYER_EXPORT bool FormatIsStencilOnly(VkFormat format);
FormatHasDepth(VkFormat format)173 static inline bool FormatHasDepth(VkFormat format) { return (FormatIsDepthOnly(format) || FormatIsDepthAndStencil(format)); }
FormatHasStencil(VkFormat format)174 static inline bool FormatHasStencil(VkFormat format) { return (FormatIsStencilOnly(format) || FormatIsDepthAndStencil(format)); }
175 VK_LAYER_EXPORT uint32_t FormatDepthSize(VkFormat format);
176 VK_LAYER_EXPORT uint32_t FormatStencilSize(VkFormat format);
177 VK_LAYER_EXPORT FORMAT_NUMERICAL_TYPE FormatDepthNumericalType(VkFormat format);
178 VK_LAYER_EXPORT FORMAT_NUMERICAL_TYPE FormatStencilNumericalType(VkFormat format);
179 
180 // Packed
181 VK_LAYER_EXPORT bool FormatIsPacked(VkFormat format);
182 
183 // YCbCr
184 VK_LAYER_EXPORT bool FormatRequiresYcbcrConversion(VkFormat format);
185 VK_LAYER_EXPORT bool FormatIsXChromaSubsampled(VkFormat format);
186 VK_LAYER_EXPORT bool FormatIsYChromaSubsampled(VkFormat format);
187 
188 // Multiplane
189 VK_LAYER_EXPORT bool FormatIsSinglePlane_422(VkFormat format);
190 VK_LAYER_EXPORT uint32_t FormatPlaneCount(VkFormat format);
FormatIsMultiplane(VkFormat format)191 static inline bool FormatIsMultiplane(VkFormat format) { return ((FormatPlaneCount(format)) > 1u); }
192 VK_LAYER_EXPORT VkFormat FindMultiplaneCompatibleFormat(VkFormat mp_fmt, VkImageAspectFlags plane_aspect);
193 VK_LAYER_EXPORT VkExtent2D FindMultiplaneExtentDivisors(VkFormat mp_fmt, VkImageAspectFlags plane_aspect);
194 
195 // Size
196 VK_LAYER_EXPORT uint32_t FormatComponentCount(VkFormat format);
197 VK_LAYER_EXPORT VkExtent3D FormatTexelBlockExtent(VkFormat format);
198 VK_LAYER_EXPORT FORMAT_COMPATIBILITY_CLASS FormatCompatibilityClass(VkFormat format);
199 VK_LAYER_EXPORT bool FormatElementIsTexel(VkFormat format);
200 VK_LAYER_EXPORT uint32_t FormatElementSize(VkFormat format, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT);
201 VK_LAYER_EXPORT double FormatTexelSize(VkFormat format, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT);
202 
203 
204 // Utils/misc
FormatIsUndef(VkFormat format)205 static inline bool FormatIsUndef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); }
206 // "blocked image" are defined in the spec (vkspec.html#blocked-image)
FormatIsBlockedImage(VkFormat format)207 static inline bool FormatIsBlockedImage(VkFormat format) {
208     return (FormatIsCompressed(format) || FormatIsSinglePlane_422(format));
209 }
210 // No official spec definition of "color format"
211 // So anything that could NOT be a "color format" is a color format
FormatIsColor(VkFormat format)212 static inline bool FormatIsColor(VkFormat format) {
213     return !(FormatIsUndef(format) || FormatIsDepthOrStencil(format) || FormatIsMultiplane(format));
214 }
215 
216 #ifdef __cplusplus
217 }
218 #endif
219