1 /*
2 * GStreamer
3 * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "gstvkformat.h"
26
27 /**
28 * SECTION:vkformat
29 * @title: GstVulkanFormat
30 * @short_description: Vulkan formats
31 * @see_also: #GstVulkanDevice, #GstVulkanMemory, #GstVulkanImageMemory
32 */
33
34 #define FORMAT(name, scaling) \
35 G_PASTE(G_PASTE(VK_FORMAT_,name),G_PASTE(_,scaling)), G_STRINGIFY(G_PASTE(G_PASTE(name,_),scaling)), G_PASTE(GST_VULKAN_FORMAT_SCALING_, scaling)
36 #define FLAG(v) \
37 G_PASTE(GST_VULKAN_FORMAT_FLAG_,v)
38 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
39 #define NE FLAG(LE)
40 #define OE 0
41 #elif G_BYTE_ORDER == G_BIG_ENDIAN
42 #define NE 0
43 #define OE FLAG(LE)
44 #endif
45
46 /* depths: bits, n_components, shift, depth */
47 #define DPTH0 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
48 #define DPTH8 8, 1, { 0, 0, 0, 0 }, { 8, 0, 0, 0 }
49 #define DPTH88 8, 2, { 0, 0, 0, 0 }, { 8, 8, 0, 0 }
50 #define DPTH8_32 8, 2, { 0, 0, 0, 0 }, { 8, 32, 0, 0 }
51 #define DPTH888 8, 3, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
52 #define DPTH8888 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 8 }
53 #define DPTH8880 8, 4, { 0, 0, 0, 0 }, { 8, 8, 8, 0 }
54 #define DPTH10 10, 1, { 0, 0, 0, 0 }, { 10, 0, 0, 0 }
55 #define DPTH10_10_10 10, 3, { 0, 0, 0, 0 }, { 10, 10, 10, 0 }
56 #define DPTH10_10_10_10 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 10 }
57 #define DPTH10_10_10_HI 16, 3, { 6, 6, 6, 0 }, { 10, 10, 10, 0 }
58 #define DPTH10_10_10_2 10, 4, { 0, 0, 0, 0 }, { 10, 10, 10, 2}
59 #define DPTH12_12_12 12, 3, { 0, 0, 0, 0 }, { 12, 12, 12, 0 }
60 #define DPTH12_12_12_12 12, 4, { 0, 0, 0, 0 }, { 12, 12, 12, 12 }
61 #define DPTH16 16, 1, { 0, 0, 0, 0 }, { 16, 0, 0, 0 }
62 #define DPTH16_16_16 16, 3, { 0, 0, 0, 0 }, { 16, 16, 16, 0 }
63 #define DPTH16_16_16_16 16, 4, { 0, 0, 0, 0 }, { 16, 16, 16, 16 }
64 #define DPTH555 16, 3, { 10, 5, 0, 0 }, { 5, 5, 5, 0 }
65 #define DPTH565 16, 3, { 11, 5, 0, 0 }, { 5, 6, 5, 0 }
66
67 /* pixel strides */
68 #define PSTR0 { 0, 0, 0, 0 }
69 #define PSTR1 { 1, 0, 0, 0 }
70 #define PSTR14 { 1, 4, 0, 0 }
71 #define PSTR111 { 1, 1, 1, 0 }
72 #define PSTR1111 { 1, 1, 1, 1 }
73 #define PSTR122 { 1, 2, 2, 0 }
74 #define PSTR2 { 2, 0, 0, 0 }
75 #define PSTR222 { 2, 2, 2, 0 }
76 #define PSTR2222 { 2, 2, 2, 2 }
77 #define PSTR244 { 2, 4, 4, 0 }
78 #define PSTR4 { 4, 4, 0, 0 }
79 #define PSTR44 { 4, 4, 0, 0 }
80 #define PSTR444 { 4, 4, 4, 0 }
81 #define PSTR4444 { 4, 4, 4, 4 }
82 #define PSTR333 { 3, 3, 3, 0 }
83 #define PSTR488 { 4, 8, 8, 0 }
84 #define PSTR8888 { 8, 8, 8, 8 }
85
86 /* planes, in what plane do we find component N */
87 #define PLANE_NA 0, { 0, 0, 0, 0 }
88 #define PLANE0 1, { 0, 0, 0, 0 }
89 #define PLANE01 2, { 0, 1, 0, 0 }
90 #define PLANE011 2, { 0, 1, 1, 0 }
91 #define PLANE012 3, { 0, 1, 2, 0 }
92 #define PLANE0123 4, { 0, 1, 2, 3 }
93 #define PLANE021 3, { 0, 2, 1, 0 }
94 #define PLANE201 3, { 2, 0, 1, 0 }
95 #define PLANE2013 4, { 2, 0, 1, 3 }
96
97 /* offsets, what's the offset of the component N in the plane */
98 #define OFFS0 { 0, 0, 0, 0 }
99 #define OFFS013 { 0, 1, 3, 0 }
100 #define OFFS102 { 1, 0, 2, 0 }
101 #define OFFS1230 { 1, 2, 3, 0 }
102 #define OFFS012 { 0, 1, 2, 0 }
103 #define OFFS210 { 2, 1, 0, 0 }
104 #define OFFS123 { 1, 2, 3, 0 }
105 #define OFFS321 { 3, 2, 1, 0 }
106 #define OFFS0123 { 0, 1, 2, 3 }
107 #define OFFS2103 { 2, 1, 0, 3 }
108 #define OFFS3210 { 3, 2, 1, 0 }
109 #define OFFS031 { 0, 3, 1, 0 }
110 #define OFFS204 { 2, 0, 4, 0 }
111 #define OFFS001 { 0, 0, 1, 0 }
112 #define OFFS010 { 0, 1, 0, 0 }
113 #define OFFS01 { 0, 1, 0, 0 }
114 #define OFFS104 { 1, 0, 4, 0 }
115 #define OFFS2460 { 2, 4, 6, 0 }
116
117 /* subsampling, w_sub, h_sub */
118 #define SUB410 { 0, 2, 2, 0 }, { 0, 2, 2, 0 }
119 #define SUB411 { 0, 2, 2, 0 }, { 0, 0, 0, 0 }
120 #define SUB420 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
121 #define SUB422 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
122 #define SUB4 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
123 #define SUB44 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
124 #define SUB444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
125 #define SUB4444 { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
126 #define SUB4204 { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
127 #define SUB4224 { 0, 1, 1, 0 }, { 0, 0, 0, 0 }
128
129 static GstVulkanFormatInfo formats[] = {
130 {FORMAT (R8G8B8A8, UNORM), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
131 PLANE0, OFFS0123, SUB444},
132 {FORMAT (R8G8B8A8, SNORM), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
133 PLANE0, OFFS0123, SUB444},
134 {FORMAT (R8G8B8A8, USCALED), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888,
135 PSTR4444, PLANE0, OFFS0123, SUB444},
136 {FORMAT (R8G8B8A8, SSCALED), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888,
137 PSTR4444, PLANE0, OFFS0123, SUB444},
138 {FORMAT (R8G8B8A8, UINT), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
139 PLANE0, OFFS0123, SUB444},
140 {FORMAT (R8G8B8A8, SINT), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
141 PLANE0, OFFS0123, SUB444},
142 {FORMAT (R8G8B8A8, SRGB), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
143 PLANE0, OFFS0123, SUB444},
144 {FORMAT (B8G8R8A8, UNORM), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
145 PLANE0, OFFS2103, SUB444},
146 {FORMAT (B8G8R8A8, SNORM), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
147 PLANE0, OFFS2103, SUB444},
148 {FORMAT (B8G8R8A8, USCALED), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888,
149 PSTR4444, PLANE0, OFFS2103, SUB444},
150 {FORMAT (B8G8R8A8, SSCALED), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888,
151 PSTR4444, PLANE0, OFFS2103, SUB444},
152 {FORMAT (B8G8R8A8, UINT), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
153 PLANE0, OFFS2103, SUB444},
154 {FORMAT (B8G8R8A8, SINT), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
155 PLANE0, OFFS2103, SUB444},
156 {FORMAT (B8G8R8A8, SRGB), FLAG (RGB) | FLAG (ALPHA) | NE, DPTH8888, PSTR4444,
157 PLANE0, OFFS2103, SUB444},
158 {FORMAT (R8G8B8, UNORM), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
159 SUB444},
160 {FORMAT (R8G8B8, SNORM), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
161 SUB444},
162 {FORMAT (R8G8B8, USCALED), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
163 SUB444},
164 {FORMAT (R8G8B8, SSCALED), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
165 SUB444},
166 {FORMAT (R8G8B8, UINT), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
167 SUB444},
168 {FORMAT (R8G8B8, SINT), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
169 SUB444},
170 {FORMAT (R8G8B8, SRGB), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS012,
171 SUB444},
172 {FORMAT (B8G8R8, UNORM), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
173 SUB444},
174 {FORMAT (B8G8R8, SNORM), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
175 SUB444},
176 {FORMAT (B8G8R8, USCALED), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
177 SUB444},
178 {FORMAT (B8G8R8, SSCALED), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
179 SUB444},
180 {FORMAT (B8G8R8, UINT), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
181 SUB444},
182 {FORMAT (B8G8R8, SINT), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
183 SUB444},
184 {FORMAT (B8G8R8, SRGB), FLAG (RGB) | NE, DPTH888, PSTR444, PLANE0, OFFS210,
185 SUB444},
186 {FORMAT (R8G8, UNORM), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01,
187 SUB44},
188 {FORMAT (R8G8, SNORM), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01,
189 SUB44},
190 {FORMAT (R8G8, USCALED), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01,
191 SUB44},
192 {FORMAT (R8G8, SSCALED), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01,
193 SUB44},
194 {FORMAT (R8G8, UINT), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01, SUB44},
195 {FORMAT (R8G8, SINT), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01, SUB44},
196 {FORMAT (R8G8, SRGB), FLAG (RGB) | NE, DPTH88, PSTR44, PLANE0, OFFS01, SUB44},
197 {FORMAT (R8, UNORM), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
198 {FORMAT (R8, SNORM), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
199 {FORMAT (R8, USCALED), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
200 {FORMAT (R8, SSCALED), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
201 {FORMAT (R8, UINT), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
202 {FORMAT (R8, SINT), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
203 {FORMAT (R8, SRGB), FLAG (RGB) | NE, DPTH8, PSTR4, PLANE0, OFFS0, SUB4},
204
205 #if 0
206 FIXME: implement:
207 {VK_FORMAT_R4G4_UNORM_PACK8, {0, 1, -1, -1}},
208 {VK_FORMAT_R4G4B4A4_UNORM_PACK16, {0, 1, 2, 3}},
209 {VK_FORMAT_B4G4R4A4_UNORM_PACK16, {2, 1, 0, 3}},
210 {VK_FORMAT_R5G6B5_UNORM_PACK16, {0, 1, 2, -1}},
211 {VK_FORMAT_B5G6R5_UNORM_PACK16, {2, 1, 0, -1}},
212 {VK_FORMAT_R5G5B5A1_UNORM_PACK16, {0, 1, 2, 3}},
213 {VK_FORMAT_B5G5R5A1_UNORM_PACK16, {2, 1, 0, 3}},
214 {VK_FORMAT_A1R5G5B5_UNORM_PACK16, {3, 0, 1, 2}},
215 #if G_BYTE_ORDER == G_BIG_ENDIAN
216 {VK_FORMAT_A8B8G8R8_UNORM_PACK32, {3, 2, 1, 0}},
217 {VK_FORMAT_A8B8G8R8_SNORM_PACK32, {3, 2, 1, 0}},
218 {VK_FORMAT_A8B8G8R8_USCALED_PACK32, {3, 2, 1, 0}},
219 {VK_FORMAT_A8B8G8R8_SSCALED_PACK32, {3, 2, 1, 0}},
220 {VK_FORMAT_A8B8G8R8_UINT_PACK32, {3, 2, 1, 0}},
221 {VK_FORMAT_A8B8G8R8_SINT_PACK32, {3, 2, 1, 0}},
222 {VK_FORMAT_A8B8G8R8_SRGB_PACK32, {3, 2, 1, 0}},
223 {VK_FORMAT_A2R10G10B10_UNORM_PACK32, {3, 0, 1, 2}},
224 {VK_FORMAT_A2R10G10B10_SNORM_PACK32, {3, 2, 1, 0}},
225 {VK_FORMAT_A2R10G10B10_USCALED_PACK32, {3, 0, 1, 2}},
226 {VK_FORMAT_A2R10G10B10_SSCALED_PACK32, {3, 0, 1, 2}},
227 {VK_FORMAT_A2R10G10B10_UINT_PACK32, {3, 0, 1, 2}},
228 {VK_FORMAT_A2R10G10B10_SINT_PACK32, {3, 2, 1, 0}},
229 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, {3, 2, 1, 0}},
230 {VK_FORMAT_A2B10G10R10_SNORM_PACK32, {3, 2, 1, 0}},
231 {VK_FORMAT_A2B10G10R10_USCALED_PACK32, {3, 2, 1, 0}},
232 {VK_FORMAT_A2B10G10R10_SSCALED_PACK32, {3, 2, 1, 0}},
233 {VK_FORMAT_A2B10G10R10_UINT_PACK32, {3, 2, 1, 0}},
234 {VK_FORMAT_A2B10G10R10_SINT_PACK32, {3, 2, 1, 0}},
235 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, {3, 2, 1, 0}},
236 #elif G_BYTE_ORDER == G_LITTLE_ENDIAN
237 {VK_FORMAT_A8B8G8R8_UNORM_PACK32, {0, 1, 2, 3}},
238 {VK_FORMAT_A8B8G8R8_SNORM_PACK32, {0, 1, 2, 3}},
239 {VK_FORMAT_A8B8G8R8_USCALED_PACK32, {0, 1, 2, 3}},
240 {VK_FORMAT_A8B8G8R8_SSCALED_PACK32, {0, 1, 2, 3}},
241 {VK_FORMAT_A8B8G8R8_UINT_PACK32, {0, 1, 2, 3}},
242 {VK_FORMAT_A8B8G8R8_SINT_PACK32, {0, 1, 2, 3}},
243 {VK_FORMAT_A8B8G8R8_SRGB_PACK32, {0, 1, 2, 3}},
244 {VK_FORMAT_A2R10G10B10_UNORM_PACK32, {2, 1, 0, 3}},
245 {VK_FORMAT_A2R10G10B10_SNORM_PACK32, {2, 1, 0, 3}},
246 {VK_FORMAT_A2R10G10B10_USCALED_PACK32, {2, 1, 0, 3}},
247 {VK_FORMAT_A2R10G10B10_SSCALED_PACK32, {2, 1, 0, 3}},
248 {VK_FORMAT_A2R10G10B10_UINT_PACK32, {2, 1, 0, 3}},
249 {VK_FORMAT_A2R10G10B10_SINT_PACK32, {2, 1, 0, 3}},
250 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, {0, 1, 2, 3}},
251 {VK_FORMAT_A2B10G10R10_SNORM_PACK32, {0, 1, 2, 3}},
252 {VK_FORMAT_A2B10G10R10_USCALED_PACK32, {0, 1, 2, 3}},
253 {VK_FORMAT_A2B10G10R10_SSCALED_PACK32, {0, 1, 2, 3}},
254 {VK_FORMAT_A2B10G10R10_UINT_PACK32, {0, 1, 2, 3}},
255 {VK_FORMAT_A2B10G10R10_SINT_PACK32, {0, 1, 2, 3}},
256 {VK_FORMAT_A2B10G10R10_UNORM_PACK32, {0, 1, 2, 3}},
257 #endif
258 VK_FORMAT_R16_UNORM = 70,
259 VK_FORMAT_R16_SNORM = 71,
260 VK_FORMAT_R16_USCALED = 72,
261 VK_FORMAT_R16_SSCALED = 73,
262 VK_FORMAT_R16_UINT = 74,
263 VK_FORMAT_R16_SINT = 75,
264 VK_FORMAT_R16_SFLOAT = 76,
265 VK_FORMAT_R16G16_UNORM = 77,
266 VK_FORMAT_R16G16_SNORM = 78,
267 VK_FORMAT_R16G16_USCALED = 79,
268 VK_FORMAT_R16G16_SSCALED = 80,
269 VK_FORMAT_R16G16_UINT = 81,
270 VK_FORMAT_R16G16_SINT = 82,
271 VK_FORMAT_R16G16_SFLOAT = 83,
272 VK_FORMAT_R16G16B16_UNORM = 84,
273 VK_FORMAT_R16G16B16_SNORM = 85,
274 VK_FORMAT_R16G16B16_USCALED = 86,
275 VK_FORMAT_R16G16B16_SSCALED = 87,
276 VK_FORMAT_R16G16B16_UINT = 88,
277 VK_FORMAT_R16G16B16_SINT = 89,
278 VK_FORMAT_R16G16B16_SFLOAT = 90,
279 VK_FORMAT_R16G16B16A16_UNORM = 91,
280 VK_FORMAT_R16G16B16A16_SNORM = 92,
281 VK_FORMAT_R16G16B16A16_USCALED = 93,
282 VK_FORMAT_R16G16B16A16_SSCALED = 94,
283 VK_FORMAT_R16G16B16A16_UINT = 95,
284 VK_FORMAT_R16G16B16A16_SINT = 96,
285 VK_FORMAT_R16G16B16A16_SFLOAT = 97,
286 VK_FORMAT_R32_UINT = 98,
287 VK_FORMAT_R32_SINT = 99,
288 VK_FORMAT_R32_SFLOAT = 100,
289 VK_FORMAT_R32G32_UINT = 101,
290 VK_FORMAT_R32G32_SINT = 102,
291 VK_FORMAT_R32G32_SFLOAT = 103,
292 VK_FORMAT_R32G32B32_UINT = 104,
293 VK_FORMAT_R32G32B32_SINT = 105,
294 VK_FORMAT_R32G32B32_SFLOAT = 106,
295 VK_FORMAT_R32G32B32A32_UINT = 107,
296 VK_FORMAT_R32G32B32A32_SINT = 108,
297 VK_FORMAT_R32G32B32A32_SFLOAT = 109,
298 VK_FORMAT_R64_UINT = 110,
299 VK_FORMAT_R64_SINT = 111,
300 VK_FORMAT_R64_SFLOAT = 112,
301 VK_FORMAT_R64G64_UINT = 113,
302 VK_FORMAT_R64G64_SINT = 114,
303 VK_FORMAT_R64G64_SFLOAT = 115,
304 VK_FORMAT_R64G64B64_UINT = 116,
305 VK_FORMAT_R64G64B64_SINT = 117,
306 VK_FORMAT_R64G64B64_SFLOAT = 118,
307 VK_FORMAT_R64G64B64A64_UINT = 119,
308 VK_FORMAT_R64G64B64A64_SINT = 120,
309 VK_FORMAT_R64G64B64A64_SFLOAT = 121,
310 VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122,
311 VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123,
312 VK_FORMAT_D16_UNORM = 124,
313 VK_FORMAT_X8_D24_UNORM_PACK32 = 125,
314 VK_FORMAT_D32_SFLOAT = 126,
315 VK_FORMAT_S8_UINT = 127,
316 VK_FORMAT_D16_UNORM_S8_UINT = 128,
317 VK_FORMAT_D24_UNORM_S8_UINT = 129,
318 VK_FORMAT_D32_SFLOAT_S8_UINT = 130,
319 VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131,
320 VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132,
321 VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133,
322 VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134,
323 VK_FORMAT_BC2_UNORM_BLOCK = 135,
324 VK_FORMAT_BC2_SRGB_BLOCK = 136,
325 VK_FORMAT_BC3_UNORM_BLOCK = 137,
326 VK_FORMAT_BC3_SRGB_BLOCK = 138,
327 VK_FORMAT_BC4_UNORM_BLOCK = 139,
328 VK_FORMAT_BC4_SNORM_BLOCK = 140,
329 VK_FORMAT_BC5_UNORM_BLOCK = 141,
330 VK_FORMAT_BC5_SNORM_BLOCK = 142,
331 VK_FORMAT_BC6H_UFLOAT_BLOCK = 143,
332 VK_FORMAT_BC6H_SFLOAT_BLOCK = 144,
333 VK_FORMAT_BC7_UNORM_BLOCK = 145,
334 VK_FORMAT_BC7_SRGB_BLOCK = 146,
335 VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147,
336 VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148,
337 VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149,
338 VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150,
339 VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151,
340 VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152,
341 VK_FORMAT_EAC_R11_UNORM_BLOCK = 153,
342 VK_FORMAT_EAC_R11_SNORM_BLOCK = 154,
343 VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155,
344 VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156,
345 VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157,
346 VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158,
347 VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159,
348 VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160,
349 VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161,
350 VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162,
351 VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163,
352 VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164,
353 VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165,
354 VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166,
355 VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167,
356 VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168,
357 VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169,
358 VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170,
359 VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171,
360 VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172,
361 VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173,
362 VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174,
363 VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175,
364 VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176,
365 VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177,
366 VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178,
367 VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179,
368 VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180,
369 VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181,
370 VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182,
371 VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183,
372 VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184,
373 VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000,
374 VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001,
375 VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002,
376 VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003,
377 VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004,
378 VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005,
379 VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006,
380 VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007,
381 VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008,
382 VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009,
383 VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010,
384 VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011,
385 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012,
386 VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013,
387 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014,
388 VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015,
389 VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016,
390 VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017,
391 VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018,
392 VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019,
393 VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020,
394 VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021,
395 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022,
396 VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023,
397 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024,
398 VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025,
399 VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026,
400 VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027,
401 VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028,
402 VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029,
403 VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030,
404 VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031,
405 VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032,
406 VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033,
407 VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000,
408 VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001,
409 VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002,
410 VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003,
411 VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004,
412 VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005,
413 VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006,
414 VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007,
415 #endif
416 };
417
418 /**
419 * gst_vulkan_format_get_info:
420 * @format: a valid `VkFormat`
421 *
422 * Returns: the #GstVulkanFormatInfo for @format or %NULL
423 *
424 * Since: 1.18
425 */
426 const GstVulkanFormatInfo *
gst_vulkan_format_get_info(VkFormat format)427 gst_vulkan_format_get_info (VkFormat format)
428 {
429 int i;
430
431 for (i = 0; i < G_N_ELEMENTS (formats); i++) {
432 if (formats[i].format == format) {
433 return &formats[i];
434 }
435 }
436
437 return NULL;
438 }
439