blob: bc22e6382de2a4974f1e9b19664f088f3408590b [file] [log] [blame]
Jose-Emilio Munoz-Lopez2a017e32018-10-30 09:19:30 +00001/* Copyright (c) 2015-2019 The Khronos Group Inc.
2 * Copyright (c) 2015-2019 Valve Corporation
3 * Copyright (c) 2015-2019 LunarG, Inc.
Dave Houlton3c9fca72017-03-27 17:25:54 -06004 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author: Mark Lobodzinski <mark@lunarg.com>
18 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
19 * Author: Dave Houlton <daveh@lunarg.com>
20 */
21
22#pragma once
23#include <stdbool.h>
24#include <vector>
25#include "vulkan/vulkan.h"
26
27#if !defined(VK_LAYER_EXPORT)
28#if defined(__GNUC__) && __GNUC__ >= 4
29#define VK_LAYER_EXPORT __attribute__((visibility("default")))
30#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
31#define VK_LAYER_EXPORT __attribute__((visibility("default")))
32#else
33#define VK_LAYER_EXPORT
34#endif
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
Dave Houltonc991cc92018-03-06 11:08:51 -070041#define VK_MULTIPLANE_FORMAT_MAX_PLANES 3
42
Dave Houlton3c9fca72017-03-27 17:25:54 -060043typedef enum VkFormatCompatibilityClass {
44 VK_FORMAT_COMPATIBILITY_CLASS_NONE_BIT = 0,
45 VK_FORMAT_COMPATIBILITY_CLASS_8_BIT = 1,
46 VK_FORMAT_COMPATIBILITY_CLASS_16_BIT = 2,
47 VK_FORMAT_COMPATIBILITY_CLASS_24_BIT = 3,
48 VK_FORMAT_COMPATIBILITY_CLASS_32_BIT = 4,
49 VK_FORMAT_COMPATIBILITY_CLASS_48_BIT = 5,
50 VK_FORMAT_COMPATIBILITY_CLASS_64_BIT = 6,
51 VK_FORMAT_COMPATIBILITY_CLASS_96_BIT = 7,
52 VK_FORMAT_COMPATIBILITY_CLASS_128_BIT = 8,
53 VK_FORMAT_COMPATIBILITY_CLASS_192_BIT = 9,
54 VK_FORMAT_COMPATIBILITY_CLASS_256_BIT = 10,
55 VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGB_BIT = 11,
56 VK_FORMAT_COMPATIBILITY_CLASS_BC1_RGBA_BIT = 12,
57 VK_FORMAT_COMPATIBILITY_CLASS_BC2_BIT = 13,
58 VK_FORMAT_COMPATIBILITY_CLASS_BC3_BIT = 14,
59 VK_FORMAT_COMPATIBILITY_CLASS_BC4_BIT = 15,
60 VK_FORMAT_COMPATIBILITY_CLASS_BC5_BIT = 16,
61 VK_FORMAT_COMPATIBILITY_CLASS_BC6H_BIT = 17,
62 VK_FORMAT_COMPATIBILITY_CLASS_BC7_BIT = 18,
63 VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGB_BIT = 19,
64 VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT = 20,
65 VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT = 21,
66 VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT = 22,
67 VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT = 23,
68 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_4X4_BIT = 24,
69 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X4_BIT = 25,
70 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_5X5_BIT = 26,
71 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X5_BIT = 27,
72 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_6X6_BIT = 28,
73 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X5_BIT = 29,
74 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X6_BIT = 20,
75 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_8X8_BIT = 31,
76 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X5_BIT = 32,
77 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X6_BIT = 33,
78 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X8_BIT = 34,
79 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_10X10_BIT = 35,
80 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X10_BIT = 36,
81 VK_FORMAT_COMPATIBILITY_CLASS_ASTC_12X12_BIT = 37,
82 VK_FORMAT_COMPATIBILITY_CLASS_D16_BIT = 38,
83 VK_FORMAT_COMPATIBILITY_CLASS_D24_BIT = 39,
84 VK_FORMAT_COMPATIBILITY_CLASS_D32_BIT = 30,
85 VK_FORMAT_COMPATIBILITY_CLASS_S8_BIT = 41,
86 VK_FORMAT_COMPATIBILITY_CLASS_D16S8_BIT = 42,
87 VK_FORMAT_COMPATIBILITY_CLASS_D24S8_BIT = 43,
88 VK_FORMAT_COMPATIBILITY_CLASS_D32S8_BIT = 44,
Dave Houlton23cdab92017-05-23 16:16:54 -060089 VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_2BPP_BIT = 45,
90 VK_FORMAT_COMPATIBILITY_CLASS_PVRTC1_4BPP_BIT = 46,
91 VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_2BPP_BIT = 47,
92 VK_FORMAT_COMPATIBILITY_CLASS_PVRTC2_4BPP_BIT = 48,
Dave Houltonc991cc92018-03-06 11:08:51 -070093 /* KHR_sampler_YCbCr_conversion */
94 VK_FORMAT_COMPATIBILITY_CLASS_32BIT_G8B8G8R8 = 49,
95 VK_FORMAT_COMPATIBILITY_CLASS_32BIT_B8G8R8G8 = 50,
96 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_R10G10B10A10 = 51,
97 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G10B10G10R10 = 52,
98 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B10G10R10G10 = 53,
99 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_R12G12B12A12 = 54,
100 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G12B12G12R12 = 55,
101 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B12G12R12G12 = 56,
102 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_G16B16G16R16 = 57,
103 VK_FORMAT_COMPATIBILITY_CLASS_64BIT_B16G16R16G16 = 58,
104 VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_420 = 59,
105 VK_FORMAT_COMPATIBILITY_CLASS_8BIT_2PLANE_420 = 60,
106 VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_422 = 61,
107 VK_FORMAT_COMPATIBILITY_CLASS_8BIT_2PLANE_422 = 62,
108 VK_FORMAT_COMPATIBILITY_CLASS_8BIT_3PLANE_444 = 63,
109 VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_420 = 64,
110 VK_FORMAT_COMPATIBILITY_CLASS_10BIT_2PLANE_420 = 65,
111 VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_422 = 66,
112 VK_FORMAT_COMPATIBILITY_CLASS_10BIT_2PLANE_422 = 67,
113 VK_FORMAT_COMPATIBILITY_CLASS_10BIT_3PLANE_444 = 68,
114 VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_420 = 69,
115 VK_FORMAT_COMPATIBILITY_CLASS_12BIT_2PLANE_420 = 70,
116 VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_422 = 71,
117 VK_FORMAT_COMPATIBILITY_CLASS_12BIT_2PLANE_422 = 72,
118 VK_FORMAT_COMPATIBILITY_CLASS_12BIT_3PLANE_444 = 73,
119 VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_420 = 74,
120 VK_FORMAT_COMPATIBILITY_CLASS_16BIT_2PLANE_420 = 75,
121 VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_422 = 76,
122 VK_FORMAT_COMPATIBILITY_CLASS_16BIT_2PLANE_422 = 77,
123 VK_FORMAT_COMPATIBILITY_CLASS_16BIT_3PLANE_444 = 78,
124 VK_FORMAT_COMPATIBILITY_CLASS_MAX_ENUM = 79
Dave Houlton3c9fca72017-03-27 17:25:54 -0600125} VkFormatCompatibilityClass;
126
Jose-Emilio Munoz-Lopez2a017e32018-10-30 09:19:30 +0000127typedef enum VkFormatNumericalType {
128 VK_FORMAT_NUMERICAL_TYPE_NONE,
129 VK_FORMAT_NUMERICAL_TYPE_UINT,
130 VK_FORMAT_NUMERICAL_TYPE_SINT,
131 VK_FORMAT_NUMERICAL_TYPE_UNORM,
132 VK_FORMAT_NUMERICAL_TYPE_SNORM,
133 VK_FORMAT_NUMERICAL_TYPE_USCALED,
134 VK_FORMAT_NUMERICAL_TYPE_SSCALED,
135 VK_FORMAT_NUMERICAL_TYPE_UFLOAT,
136 VK_FORMAT_NUMERICAL_TYPE_SFLOAT,
137 VK_FORMAT_NUMERICAL_TYPE_SRGB
138} VkFormatNumericalType;
139
Dave Houlton1d2022c2017-03-29 11:43:58 -0600140VK_LAYER_EXPORT bool FormatIsDepthOrStencil(VkFormat format);
141VK_LAYER_EXPORT bool FormatIsDepthAndStencil(VkFormat format);
142VK_LAYER_EXPORT bool FormatIsDepthOnly(VkFormat format);
143VK_LAYER_EXPORT bool FormatIsStencilOnly(VkFormat format);
144VK_LAYER_EXPORT bool FormatIsCompressed_ETC2_EAC(VkFormat format);
145VK_LAYER_EXPORT bool FormatIsCompressed_ASTC_LDR(VkFormat format);
146VK_LAYER_EXPORT bool FormatIsCompressed_BC(VkFormat format);
Dave Houlton23cdab92017-05-23 16:16:54 -0600147VK_LAYER_EXPORT bool FormatIsCompressed_PVRTC(VkFormat format);
Dave Houltonc991cc92018-03-06 11:08:51 -0700148VK_LAYER_EXPORT bool FormatIsSinglePlane_422(VkFormat format);
Dave Houlton1d2022c2017-03-29 11:43:58 -0600149VK_LAYER_EXPORT bool FormatIsNorm(VkFormat format);
150VK_LAYER_EXPORT bool FormatIsUNorm(VkFormat format);
151VK_LAYER_EXPORT bool FormatIsSNorm(VkFormat format);
152VK_LAYER_EXPORT bool FormatIsInt(VkFormat format);
153VK_LAYER_EXPORT bool FormatIsSInt(VkFormat format);
154VK_LAYER_EXPORT bool FormatIsUInt(VkFormat format);
155VK_LAYER_EXPORT bool FormatIsFloat(VkFormat format);
156VK_LAYER_EXPORT bool FormatIsSRGB(VkFormat format);
157VK_LAYER_EXPORT bool FormatIsUScaled(VkFormat format);
158VK_LAYER_EXPORT bool FormatIsSScaled(VkFormat format);
159VK_LAYER_EXPORT bool FormatIsCompressed(VkFormat format);
Peter Kohautaef965c2018-07-12 09:19:33 +0200160VK_LAYER_EXPORT bool FormatIsPacked(VkFormat format);
Tony-LunarG7482ca92018-10-01 14:20:22 -0600161VK_LAYER_EXPORT bool FormatSizesAreEqual(VkFormat srcFormat, VkFormat dstFormat, uint32_t region_count, const VkImageCopy *regions);
Dave Houlton3c9fca72017-03-27 17:25:54 -0600162
Jose-Emilio Munoz-Lopez2a017e32018-10-30 09:19:30 +0000163VK_LAYER_EXPORT uint32_t FormatDepthSize(VkFormat format);
164VK_LAYER_EXPORT VkFormatNumericalType FormatDepthNumericalType(VkFormat format);
165VK_LAYER_EXPORT uint32_t FormatStencilSize(VkFormat format);
166VK_LAYER_EXPORT VkFormatNumericalType FormatStencilNumericalType(VkFormat format);
Dave Houlton1d960ff2018-01-19 12:17:05 -0700167VK_LAYER_EXPORT uint32_t FormatPlaneCount(VkFormat format);
168VK_LAYER_EXPORT uint32_t FormatChannelCount(VkFormat format);
169VK_LAYER_EXPORT VkExtent3D FormatCompressedTexelBlockExtent(VkFormat format);
170VK_LAYER_EXPORT size_t FormatSize(VkFormat format);
171VK_LAYER_EXPORT VkFormatCompatibilityClass FormatCompatibilityClass(VkFormat format);
172VK_LAYER_EXPORT VkDeviceSize SafeModulo(VkDeviceSize dividend, VkDeviceSize divisor);
Dave Houltone48cd112019-01-03 17:01:18 -0700173VK_LAYER_EXPORT VkFormat FindMultiplaneCompatibleFormat(VkFormat fmt, VkImageAspectFlags plane_aspect);
174VK_LAYER_EXPORT VkExtent2D FindMultiplaneExtentDivisors(VkFormat mp_fmt, VkImageAspectFlags plane_aspect);
Peter Kohautaef965c2018-07-12 09:19:33 +0200175VK_LAYER_EXPORT size_t FormatAlignment(VkFormat format);
Dave Houlton1d960ff2018-01-19 12:17:05 -0700176
Dave Houlton1d2022c2017-03-29 11:43:58 -0600177static inline bool FormatIsUndef(VkFormat format) { return (format == VK_FORMAT_UNDEFINED); }
Dave Houlton1d2022c2017-03-29 11:43:58 -0600178static inline bool FormatHasDepth(VkFormat format) { return (FormatIsDepthOnly(format) || FormatIsDepthAndStencil(format)); }
179static inline bool FormatHasStencil(VkFormat format) { return (FormatIsStencilOnly(format) || FormatIsDepthAndStencil(format)); }
Dave Houlton1d960ff2018-01-19 12:17:05 -0700180static inline bool FormatIsMultiplane(VkFormat format) { return ((FormatPlaneCount(format)) > 1u); }
Dave Houlton501b15b2018-03-30 15:07:41 -0600181static inline bool FormatIsColor(VkFormat format) {
182 return !(FormatIsUndef(format) || FormatIsDepthOrStencil(format) || FormatIsMultiplane(format));
183}
Dave Houlton3c9fca72017-03-27 17:25:54 -0600184
185#ifdef __cplusplus
186}
187#endif