Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/intel/vulkan/anv_formats.c
4547 views
1
/*
2
* Copyright © 2015 Intel Corporation
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a
5
* copy of this software and associated documentation files (the "Software"),
6
* to deal in the Software without restriction, including without limitation
7
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice (including the next
12
* paragraph) shall be included in all copies or substantial portions of the
13
* Software.
14
*
15
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
* IN THE SOFTWARE.
22
*/
23
24
#include "anv_private.h"
25
#include "drm-uapi/drm_fourcc.h"
26
#include "vk_enum_to_str.h"
27
#include "vk_format.h"
28
#include "vk_util.h"
29
30
/*
31
* gcc-4 and earlier don't allow compound literals where a constant
32
* is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
33
* here. -std=c89/gnu89 would allow it, but we depend on c99 features
34
* so using -std=c89/gnu89 is not an option. Starting from gcc-5
35
* compound literals can also be considered constant in -std=c99/gnu99
36
* mode.
37
*/
38
#define _ISL_SWIZZLE(r, g, b, a) { \
39
ISL_CHANNEL_SELECT_##r, \
40
ISL_CHANNEL_SELECT_##g, \
41
ISL_CHANNEL_SELECT_##b, \
42
ISL_CHANNEL_SELECT_##a, \
43
}
44
45
#define RGBA _ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
46
#define BGRA _ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
47
#define RGB1 _ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
48
49
#define swiz_fmt1(__vk_fmt, __hw_fmt, __swizzle) \
50
[VK_ENUM_OFFSET(__vk_fmt)] = { \
51
.planes = { \
52
{ .isl_format = __hw_fmt, .swizzle = __swizzle, \
53
.denominator_scales = { 1, 1, }, \
54
.aspect = VK_IMAGE_ASPECT_COLOR_BIT, \
55
}, \
56
}, \
57
.vk_format = __vk_fmt, \
58
.n_planes = 1, \
59
}
60
61
#define fmt1(__vk_fmt, __hw_fmt) \
62
swiz_fmt1(__vk_fmt, __hw_fmt, RGBA)
63
64
#define d_fmt(__vk_fmt, __hw_fmt) \
65
[VK_ENUM_OFFSET(__vk_fmt)] = { \
66
.planes = { \
67
{ .isl_format = __hw_fmt, .swizzle = RGBA, \
68
.denominator_scales = { 1, 1, }, \
69
.aspect = VK_IMAGE_ASPECT_DEPTH_BIT, \
70
}, \
71
}, \
72
.vk_format = __vk_fmt, \
73
.n_planes = 1, \
74
}
75
76
#define s_fmt(__vk_fmt, __hw_fmt) \
77
[VK_ENUM_OFFSET(__vk_fmt)] = { \
78
.planes = { \
79
{ .isl_format = __hw_fmt, .swizzle = RGBA, \
80
.denominator_scales = { 1, 1, }, \
81
.aspect = VK_IMAGE_ASPECT_STENCIL_BIT, \
82
}, \
83
}, \
84
.vk_format = __vk_fmt, \
85
.n_planes = 1, \
86
}
87
88
#define ds_fmt2(__vk_fmt, __fmt1, __fmt2) \
89
[VK_ENUM_OFFSET(__vk_fmt)] = { \
90
.planes = { \
91
{ .isl_format = __fmt1, .swizzle = RGBA, \
92
.denominator_scales = { 1, 1, }, \
93
.aspect = VK_IMAGE_ASPECT_DEPTH_BIT, \
94
}, \
95
{ .isl_format = __fmt2, .swizzle = RGBA, \
96
.denominator_scales = { 1, 1, }, \
97
.aspect = VK_IMAGE_ASPECT_STENCIL_BIT, \
98
}, \
99
}, \
100
.vk_format = __vk_fmt, \
101
.n_planes = 2, \
102
}
103
104
#define fmt_unsupported(__vk_fmt) \
105
[VK_ENUM_OFFSET(__vk_fmt)] = { \
106
.planes = { \
107
{ .isl_format = ISL_FORMAT_UNSUPPORTED, }, \
108
}, \
109
.vk_format = VK_FORMAT_UNDEFINED, \
110
}
111
112
#define y_plane(__plane, __hw_fmt, __swizzle, __ycbcr_swizzle, dhs, dvs) \
113
{ .isl_format = __hw_fmt, \
114
.swizzle = __swizzle, \
115
.ycbcr_swizzle = __ycbcr_swizzle, \
116
.denominator_scales = { dhs, dvs, }, \
117
.has_chroma = false, \
118
.aspect = VK_IMAGE_ASPECT_PLANE_0_BIT, /* Y plane is always plane 0 */ \
119
}
120
121
#define chroma_plane(__plane, __hw_fmt, __swizzle, __ycbcr_swizzle, dhs, dvs) \
122
{ .isl_format = __hw_fmt, \
123
.swizzle = __swizzle, \
124
.ycbcr_swizzle = __ycbcr_swizzle, \
125
.denominator_scales = { dhs, dvs, }, \
126
.has_chroma = true, \
127
.aspect = VK_IMAGE_ASPECT_PLANE_ ## __plane ## _BIT, \
128
}
129
130
#define ycbcr_fmt(__vk_fmt, __n_planes, ...) \
131
[VK_ENUM_OFFSET(__vk_fmt)] = { \
132
.planes = { \
133
__VA_ARGS__, \
134
}, \
135
.vk_format = __vk_fmt, \
136
.n_planes = __n_planes, \
137
.can_ycbcr = true, \
138
}
139
140
/* HINT: For array formats, the ISL name should match the VK name. For
141
* packed formats, they should have the channels in reverse order from each
142
* other. The reason for this is that, for packed formats, the ISL (and
143
* bspec) names are in LSB -> MSB order while VK formats are MSB -> LSB.
144
*/
145
static const struct anv_format main_formats[] = {
146
fmt_unsupported(VK_FORMAT_UNDEFINED),
147
fmt_unsupported(VK_FORMAT_R4G4_UNORM_PACK8),
148
fmt1(VK_FORMAT_R4G4B4A4_UNORM_PACK16, ISL_FORMAT_A4B4G4R4_UNORM),
149
swiz_fmt1(VK_FORMAT_B4G4R4A4_UNORM_PACK16, ISL_FORMAT_A4B4G4R4_UNORM, BGRA),
150
fmt1(VK_FORMAT_R5G6B5_UNORM_PACK16, ISL_FORMAT_B5G6R5_UNORM),
151
fmt_unsupported(VK_FORMAT_B5G6R5_UNORM_PACK16),
152
fmt1(VK_FORMAT_R5G5B5A1_UNORM_PACK16, ISL_FORMAT_A1B5G5R5_UNORM),
153
fmt_unsupported(VK_FORMAT_B5G5R5A1_UNORM_PACK16),
154
fmt1(VK_FORMAT_A1R5G5B5_UNORM_PACK16, ISL_FORMAT_B5G5R5A1_UNORM),
155
fmt1(VK_FORMAT_R8_UNORM, ISL_FORMAT_R8_UNORM),
156
fmt1(VK_FORMAT_R8_SNORM, ISL_FORMAT_R8_SNORM),
157
fmt1(VK_FORMAT_R8_USCALED, ISL_FORMAT_R8_USCALED),
158
fmt1(VK_FORMAT_R8_SSCALED, ISL_FORMAT_R8_SSCALED),
159
fmt1(VK_FORMAT_R8_UINT, ISL_FORMAT_R8_UINT),
160
fmt1(VK_FORMAT_R8_SINT, ISL_FORMAT_R8_SINT),
161
swiz_fmt1(VK_FORMAT_R8_SRGB, ISL_FORMAT_L8_UNORM_SRGB,
162
_ISL_SWIZZLE(RED, ZERO, ZERO, ONE)),
163
fmt1(VK_FORMAT_R8G8_UNORM, ISL_FORMAT_R8G8_UNORM),
164
fmt1(VK_FORMAT_R8G8_SNORM, ISL_FORMAT_R8G8_SNORM),
165
fmt1(VK_FORMAT_R8G8_USCALED, ISL_FORMAT_R8G8_USCALED),
166
fmt1(VK_FORMAT_R8G8_SSCALED, ISL_FORMAT_R8G8_SSCALED),
167
fmt1(VK_FORMAT_R8G8_UINT, ISL_FORMAT_R8G8_UINT),
168
fmt1(VK_FORMAT_R8G8_SINT, ISL_FORMAT_R8G8_SINT),
169
fmt_unsupported(VK_FORMAT_R8G8_SRGB), /* L8A8_UNORM_SRGB */
170
fmt1(VK_FORMAT_R8G8B8_UNORM, ISL_FORMAT_R8G8B8_UNORM),
171
fmt1(VK_FORMAT_R8G8B8_SNORM, ISL_FORMAT_R8G8B8_SNORM),
172
fmt1(VK_FORMAT_R8G8B8_USCALED, ISL_FORMAT_R8G8B8_USCALED),
173
fmt1(VK_FORMAT_R8G8B8_SSCALED, ISL_FORMAT_R8G8B8_SSCALED),
174
fmt1(VK_FORMAT_R8G8B8_UINT, ISL_FORMAT_R8G8B8_UINT),
175
fmt1(VK_FORMAT_R8G8B8_SINT, ISL_FORMAT_R8G8B8_SINT),
176
fmt1(VK_FORMAT_R8G8B8_SRGB, ISL_FORMAT_R8G8B8_UNORM_SRGB),
177
fmt1(VK_FORMAT_R8G8B8A8_UNORM, ISL_FORMAT_R8G8B8A8_UNORM),
178
fmt1(VK_FORMAT_R8G8B8A8_SNORM, ISL_FORMAT_R8G8B8A8_SNORM),
179
fmt1(VK_FORMAT_R8G8B8A8_USCALED, ISL_FORMAT_R8G8B8A8_USCALED),
180
fmt1(VK_FORMAT_R8G8B8A8_SSCALED, ISL_FORMAT_R8G8B8A8_SSCALED),
181
fmt1(VK_FORMAT_R8G8B8A8_UINT, ISL_FORMAT_R8G8B8A8_UINT),
182
fmt1(VK_FORMAT_R8G8B8A8_SINT, ISL_FORMAT_R8G8B8A8_SINT),
183
fmt1(VK_FORMAT_R8G8B8A8_SRGB, ISL_FORMAT_R8G8B8A8_UNORM_SRGB),
184
fmt1(VK_FORMAT_A8B8G8R8_UNORM_PACK32, ISL_FORMAT_R8G8B8A8_UNORM),
185
fmt1(VK_FORMAT_A8B8G8R8_SNORM_PACK32, ISL_FORMAT_R8G8B8A8_SNORM),
186
fmt1(VK_FORMAT_A8B8G8R8_USCALED_PACK32, ISL_FORMAT_R8G8B8A8_USCALED),
187
fmt1(VK_FORMAT_A8B8G8R8_SSCALED_PACK32, ISL_FORMAT_R8G8B8A8_SSCALED),
188
fmt1(VK_FORMAT_A8B8G8R8_UINT_PACK32, ISL_FORMAT_R8G8B8A8_UINT),
189
fmt1(VK_FORMAT_A8B8G8R8_SINT_PACK32, ISL_FORMAT_R8G8B8A8_SINT),
190
fmt1(VK_FORMAT_A8B8G8R8_SRGB_PACK32, ISL_FORMAT_R8G8B8A8_UNORM_SRGB),
191
fmt1(VK_FORMAT_A2R10G10B10_UNORM_PACK32, ISL_FORMAT_B10G10R10A2_UNORM),
192
fmt1(VK_FORMAT_A2R10G10B10_SNORM_PACK32, ISL_FORMAT_B10G10R10A2_SNORM),
193
fmt1(VK_FORMAT_A2R10G10B10_USCALED_PACK32, ISL_FORMAT_B10G10R10A2_USCALED),
194
fmt1(VK_FORMAT_A2R10G10B10_SSCALED_PACK32, ISL_FORMAT_B10G10R10A2_SSCALED),
195
fmt1(VK_FORMAT_A2R10G10B10_UINT_PACK32, ISL_FORMAT_B10G10R10A2_UINT),
196
fmt1(VK_FORMAT_A2R10G10B10_SINT_PACK32, ISL_FORMAT_B10G10R10A2_SINT),
197
fmt1(VK_FORMAT_A2B10G10R10_UNORM_PACK32, ISL_FORMAT_R10G10B10A2_UNORM),
198
fmt1(VK_FORMAT_A2B10G10R10_SNORM_PACK32, ISL_FORMAT_R10G10B10A2_SNORM),
199
fmt1(VK_FORMAT_A2B10G10R10_USCALED_PACK32, ISL_FORMAT_R10G10B10A2_USCALED),
200
fmt1(VK_FORMAT_A2B10G10R10_SSCALED_PACK32, ISL_FORMAT_R10G10B10A2_SSCALED),
201
fmt1(VK_FORMAT_A2B10G10R10_UINT_PACK32, ISL_FORMAT_R10G10B10A2_UINT),
202
fmt1(VK_FORMAT_A2B10G10R10_SINT_PACK32, ISL_FORMAT_R10G10B10A2_SINT),
203
fmt1(VK_FORMAT_R16_UNORM, ISL_FORMAT_R16_UNORM),
204
fmt1(VK_FORMAT_R16_SNORM, ISL_FORMAT_R16_SNORM),
205
fmt1(VK_FORMAT_R16_USCALED, ISL_FORMAT_R16_USCALED),
206
fmt1(VK_FORMAT_R16_SSCALED, ISL_FORMAT_R16_SSCALED),
207
fmt1(VK_FORMAT_R16_UINT, ISL_FORMAT_R16_UINT),
208
fmt1(VK_FORMAT_R16_SINT, ISL_FORMAT_R16_SINT),
209
fmt1(VK_FORMAT_R16_SFLOAT, ISL_FORMAT_R16_FLOAT),
210
fmt1(VK_FORMAT_R16G16_UNORM, ISL_FORMAT_R16G16_UNORM),
211
fmt1(VK_FORMAT_R16G16_SNORM, ISL_FORMAT_R16G16_SNORM),
212
fmt1(VK_FORMAT_R16G16_USCALED, ISL_FORMAT_R16G16_USCALED),
213
fmt1(VK_FORMAT_R16G16_SSCALED, ISL_FORMAT_R16G16_SSCALED),
214
fmt1(VK_FORMAT_R16G16_UINT, ISL_FORMAT_R16G16_UINT),
215
fmt1(VK_FORMAT_R16G16_SINT, ISL_FORMAT_R16G16_SINT),
216
fmt1(VK_FORMAT_R16G16_SFLOAT, ISL_FORMAT_R16G16_FLOAT),
217
fmt1(VK_FORMAT_R16G16B16_UNORM, ISL_FORMAT_R16G16B16_UNORM),
218
fmt1(VK_FORMAT_R16G16B16_SNORM, ISL_FORMAT_R16G16B16_SNORM),
219
fmt1(VK_FORMAT_R16G16B16_USCALED, ISL_FORMAT_R16G16B16_USCALED),
220
fmt1(VK_FORMAT_R16G16B16_SSCALED, ISL_FORMAT_R16G16B16_SSCALED),
221
fmt1(VK_FORMAT_R16G16B16_UINT, ISL_FORMAT_R16G16B16_UINT),
222
fmt1(VK_FORMAT_R16G16B16_SINT, ISL_FORMAT_R16G16B16_SINT),
223
fmt1(VK_FORMAT_R16G16B16_SFLOAT, ISL_FORMAT_R16G16B16_FLOAT),
224
fmt1(VK_FORMAT_R16G16B16A16_UNORM, ISL_FORMAT_R16G16B16A16_UNORM),
225
fmt1(VK_FORMAT_R16G16B16A16_SNORM, ISL_FORMAT_R16G16B16A16_SNORM),
226
fmt1(VK_FORMAT_R16G16B16A16_USCALED, ISL_FORMAT_R16G16B16A16_USCALED),
227
fmt1(VK_FORMAT_R16G16B16A16_SSCALED, ISL_FORMAT_R16G16B16A16_SSCALED),
228
fmt1(VK_FORMAT_R16G16B16A16_UINT, ISL_FORMAT_R16G16B16A16_UINT),
229
fmt1(VK_FORMAT_R16G16B16A16_SINT, ISL_FORMAT_R16G16B16A16_SINT),
230
fmt1(VK_FORMAT_R16G16B16A16_SFLOAT, ISL_FORMAT_R16G16B16A16_FLOAT),
231
fmt1(VK_FORMAT_R32_UINT, ISL_FORMAT_R32_UINT),
232
fmt1(VK_FORMAT_R32_SINT, ISL_FORMAT_R32_SINT),
233
fmt1(VK_FORMAT_R32_SFLOAT, ISL_FORMAT_R32_FLOAT),
234
fmt1(VK_FORMAT_R32G32_UINT, ISL_FORMAT_R32G32_UINT),
235
fmt1(VK_FORMAT_R32G32_SINT, ISL_FORMAT_R32G32_SINT),
236
fmt1(VK_FORMAT_R32G32_SFLOAT, ISL_FORMAT_R32G32_FLOAT),
237
fmt1(VK_FORMAT_R32G32B32_UINT, ISL_FORMAT_R32G32B32_UINT),
238
fmt1(VK_FORMAT_R32G32B32_SINT, ISL_FORMAT_R32G32B32_SINT),
239
fmt1(VK_FORMAT_R32G32B32_SFLOAT, ISL_FORMAT_R32G32B32_FLOAT),
240
fmt1(VK_FORMAT_R32G32B32A32_UINT, ISL_FORMAT_R32G32B32A32_UINT),
241
fmt1(VK_FORMAT_R32G32B32A32_SINT, ISL_FORMAT_R32G32B32A32_SINT),
242
fmt1(VK_FORMAT_R32G32B32A32_SFLOAT, ISL_FORMAT_R32G32B32A32_FLOAT),
243
fmt1(VK_FORMAT_R64_UINT, ISL_FORMAT_R64_PASSTHRU),
244
fmt1(VK_FORMAT_R64_SINT, ISL_FORMAT_R64_PASSTHRU),
245
fmt1(VK_FORMAT_R64_SFLOAT, ISL_FORMAT_R64_PASSTHRU),
246
fmt1(VK_FORMAT_R64G64_UINT, ISL_FORMAT_R64G64_PASSTHRU),
247
fmt1(VK_FORMAT_R64G64_SINT, ISL_FORMAT_R64G64_PASSTHRU),
248
fmt1(VK_FORMAT_R64G64_SFLOAT, ISL_FORMAT_R64G64_PASSTHRU),
249
fmt1(VK_FORMAT_R64G64B64_UINT, ISL_FORMAT_R64G64B64_PASSTHRU),
250
fmt1(VK_FORMAT_R64G64B64_SINT, ISL_FORMAT_R64G64B64_PASSTHRU),
251
fmt1(VK_FORMAT_R64G64B64_SFLOAT, ISL_FORMAT_R64G64B64_PASSTHRU),
252
fmt1(VK_FORMAT_R64G64B64A64_UINT, ISL_FORMAT_R64G64B64A64_PASSTHRU),
253
fmt1(VK_FORMAT_R64G64B64A64_SINT, ISL_FORMAT_R64G64B64A64_PASSTHRU),
254
fmt1(VK_FORMAT_R64G64B64A64_SFLOAT, ISL_FORMAT_R64G64B64A64_PASSTHRU),
255
fmt1(VK_FORMAT_B10G11R11_UFLOAT_PACK32, ISL_FORMAT_R11G11B10_FLOAT),
256
fmt1(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, ISL_FORMAT_R9G9B9E5_SHAREDEXP),
257
258
d_fmt(VK_FORMAT_D16_UNORM, ISL_FORMAT_R16_UNORM),
259
d_fmt(VK_FORMAT_X8_D24_UNORM_PACK32, ISL_FORMAT_R24_UNORM_X8_TYPELESS),
260
d_fmt(VK_FORMAT_D32_SFLOAT, ISL_FORMAT_R32_FLOAT),
261
s_fmt(VK_FORMAT_S8_UINT, ISL_FORMAT_R8_UINT),
262
fmt_unsupported(VK_FORMAT_D16_UNORM_S8_UINT),
263
ds_fmt2(VK_FORMAT_D24_UNORM_S8_UINT, ISL_FORMAT_R24_UNORM_X8_TYPELESS, ISL_FORMAT_R8_UINT),
264
ds_fmt2(VK_FORMAT_D32_SFLOAT_S8_UINT, ISL_FORMAT_R32_FLOAT, ISL_FORMAT_R8_UINT),
265
266
swiz_fmt1(VK_FORMAT_BC1_RGB_UNORM_BLOCK, ISL_FORMAT_BC1_UNORM, RGB1),
267
swiz_fmt1(VK_FORMAT_BC1_RGB_SRGB_BLOCK, ISL_FORMAT_BC1_UNORM_SRGB, RGB1),
268
fmt1(VK_FORMAT_BC1_RGBA_UNORM_BLOCK, ISL_FORMAT_BC1_UNORM),
269
fmt1(VK_FORMAT_BC1_RGBA_SRGB_BLOCK, ISL_FORMAT_BC1_UNORM_SRGB),
270
fmt1(VK_FORMAT_BC2_UNORM_BLOCK, ISL_FORMAT_BC2_UNORM),
271
fmt1(VK_FORMAT_BC2_SRGB_BLOCK, ISL_FORMAT_BC2_UNORM_SRGB),
272
fmt1(VK_FORMAT_BC3_UNORM_BLOCK, ISL_FORMAT_BC3_UNORM),
273
fmt1(VK_FORMAT_BC3_SRGB_BLOCK, ISL_FORMAT_BC3_UNORM_SRGB),
274
fmt1(VK_FORMAT_BC4_UNORM_BLOCK, ISL_FORMAT_BC4_UNORM),
275
fmt1(VK_FORMAT_BC4_SNORM_BLOCK, ISL_FORMAT_BC4_SNORM),
276
fmt1(VK_FORMAT_BC5_UNORM_BLOCK, ISL_FORMAT_BC5_UNORM),
277
fmt1(VK_FORMAT_BC5_SNORM_BLOCK, ISL_FORMAT_BC5_SNORM),
278
fmt1(VK_FORMAT_BC6H_UFLOAT_BLOCK, ISL_FORMAT_BC6H_UF16),
279
fmt1(VK_FORMAT_BC6H_SFLOAT_BLOCK, ISL_FORMAT_BC6H_SF16),
280
fmt1(VK_FORMAT_BC7_UNORM_BLOCK, ISL_FORMAT_BC7_UNORM),
281
fmt1(VK_FORMAT_BC7_SRGB_BLOCK, ISL_FORMAT_BC7_UNORM_SRGB),
282
fmt1(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, ISL_FORMAT_ETC2_RGB8),
283
fmt1(VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, ISL_FORMAT_ETC2_SRGB8),
284
fmt1(VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, ISL_FORMAT_ETC2_RGB8_PTA),
285
fmt1(VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, ISL_FORMAT_ETC2_SRGB8_PTA),
286
fmt1(VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, ISL_FORMAT_ETC2_EAC_RGBA8),
287
fmt1(VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, ISL_FORMAT_ETC2_EAC_SRGB8_A8),
288
fmt1(VK_FORMAT_EAC_R11_UNORM_BLOCK, ISL_FORMAT_EAC_R11),
289
fmt1(VK_FORMAT_EAC_R11_SNORM_BLOCK, ISL_FORMAT_EAC_SIGNED_R11),
290
fmt1(VK_FORMAT_EAC_R11G11_UNORM_BLOCK, ISL_FORMAT_EAC_RG11),
291
fmt1(VK_FORMAT_EAC_R11G11_SNORM_BLOCK, ISL_FORMAT_EAC_SIGNED_RG11),
292
fmt1(VK_FORMAT_ASTC_4x4_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_4X4_U8SRGB),
293
fmt1(VK_FORMAT_ASTC_5x4_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_5X4_U8SRGB),
294
fmt1(VK_FORMAT_ASTC_5x5_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_5X5_U8SRGB),
295
fmt1(VK_FORMAT_ASTC_6x5_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_6X5_U8SRGB),
296
fmt1(VK_FORMAT_ASTC_6x6_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_6X6_U8SRGB),
297
fmt1(VK_FORMAT_ASTC_8x5_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X5_U8SRGB),
298
fmt1(VK_FORMAT_ASTC_8x6_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X6_U8SRGB),
299
fmt1(VK_FORMAT_ASTC_8x8_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X8_U8SRGB),
300
fmt1(VK_FORMAT_ASTC_10x5_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X5_U8SRGB),
301
fmt1(VK_FORMAT_ASTC_10x6_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X6_U8SRGB),
302
fmt1(VK_FORMAT_ASTC_10x8_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X8_U8SRGB),
303
fmt1(VK_FORMAT_ASTC_10x10_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X10_U8SRGB),
304
fmt1(VK_FORMAT_ASTC_12x10_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_12X10_U8SRGB),
305
fmt1(VK_FORMAT_ASTC_12x12_SRGB_BLOCK, ISL_FORMAT_ASTC_LDR_2D_12X12_U8SRGB),
306
fmt1(VK_FORMAT_ASTC_4x4_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16),
307
fmt1(VK_FORMAT_ASTC_5x4_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_5X4_FLT16),
308
fmt1(VK_FORMAT_ASTC_5x5_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_5X5_FLT16),
309
fmt1(VK_FORMAT_ASTC_6x5_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_6X5_FLT16),
310
fmt1(VK_FORMAT_ASTC_6x6_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_6X6_FLT16),
311
fmt1(VK_FORMAT_ASTC_8x5_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X5_FLT16),
312
fmt1(VK_FORMAT_ASTC_8x6_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X6_FLT16),
313
fmt1(VK_FORMAT_ASTC_8x8_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_8X8_FLT16),
314
fmt1(VK_FORMAT_ASTC_10x5_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X5_FLT16),
315
fmt1(VK_FORMAT_ASTC_10x6_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X6_FLT16),
316
fmt1(VK_FORMAT_ASTC_10x8_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X8_FLT16),
317
fmt1(VK_FORMAT_ASTC_10x10_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_10X10_FLT16),
318
fmt1(VK_FORMAT_ASTC_12x10_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_12X10_FLT16),
319
fmt1(VK_FORMAT_ASTC_12x12_UNORM_BLOCK, ISL_FORMAT_ASTC_LDR_2D_12X12_FLT16),
320
fmt_unsupported(VK_FORMAT_B8G8R8_UNORM),
321
fmt_unsupported(VK_FORMAT_B8G8R8_SNORM),
322
fmt_unsupported(VK_FORMAT_B8G8R8_USCALED),
323
fmt_unsupported(VK_FORMAT_B8G8R8_SSCALED),
324
fmt_unsupported(VK_FORMAT_B8G8R8_UINT),
325
fmt_unsupported(VK_FORMAT_B8G8R8_SINT),
326
fmt_unsupported(VK_FORMAT_B8G8R8_SRGB),
327
fmt1(VK_FORMAT_B8G8R8A8_UNORM, ISL_FORMAT_B8G8R8A8_UNORM),
328
fmt_unsupported(VK_FORMAT_B8G8R8A8_SNORM),
329
fmt_unsupported(VK_FORMAT_B8G8R8A8_USCALED),
330
fmt_unsupported(VK_FORMAT_B8G8R8A8_SSCALED),
331
fmt_unsupported(VK_FORMAT_B8G8R8A8_UINT),
332
fmt_unsupported(VK_FORMAT_B8G8R8A8_SINT),
333
fmt1(VK_FORMAT_B8G8R8A8_SRGB, ISL_FORMAT_B8G8R8A8_UNORM_SRGB),
334
};
335
336
static const struct anv_format _4444_formats[] = {
337
fmt1(VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, ISL_FORMAT_B4G4R4A4_UNORM),
338
fmt_unsupported(VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT),
339
};
340
341
static const struct anv_format ycbcr_formats[] = {
342
ycbcr_fmt(VK_FORMAT_G8B8G8R8_422_UNORM, 1,
343
y_plane(0, ISL_FORMAT_YCRCB_SWAPUV, RGBA, _ISL_SWIZZLE(BLUE, GREEN, RED, ZERO), 1, 1)),
344
ycbcr_fmt(VK_FORMAT_B8G8R8G8_422_UNORM, 1,
345
y_plane(0, ISL_FORMAT_YCRCB_SWAPUVY, RGBA, _ISL_SWIZZLE(BLUE, GREEN, RED, ZERO), 1, 1)),
346
ycbcr_fmt(VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, 3,
347
y_plane(0, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
348
chroma_plane(1, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 2, 2),
349
chroma_plane(2, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 2, 2)),
350
ycbcr_fmt(VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, 2,
351
y_plane(0, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
352
chroma_plane(1, ISL_FORMAT_R8G8_UNORM, RGBA, _ISL_SWIZZLE(BLUE, RED, ZERO, ZERO), 2, 2)),
353
ycbcr_fmt(VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, 3,
354
y_plane(0, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
355
chroma_plane(1, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 2, 1),
356
chroma_plane(2, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 2, 1)),
357
ycbcr_fmt(VK_FORMAT_G8_B8R8_2PLANE_422_UNORM, 2,
358
y_plane(0, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
359
chroma_plane(1, ISL_FORMAT_R8G8_UNORM, RGBA, _ISL_SWIZZLE(BLUE, RED, ZERO, ZERO), 2, 1)),
360
ycbcr_fmt(VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM, 3,
361
y_plane(0, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
362
chroma_plane(1, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 1, 1),
363
chroma_plane(2, ISL_FORMAT_R8_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 1, 1)),
364
365
fmt_unsupported(VK_FORMAT_R10X6_UNORM_PACK16),
366
fmt_unsupported(VK_FORMAT_R10X6G10X6_UNORM_2PACK16),
367
fmt_unsupported(VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16),
368
fmt_unsupported(VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16),
369
fmt_unsupported(VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16),
370
fmt_unsupported(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16),
371
fmt_unsupported(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16),
372
fmt_unsupported(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16),
373
fmt_unsupported(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16),
374
fmt_unsupported(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16),
375
fmt_unsupported(VK_FORMAT_R12X4_UNORM_PACK16),
376
fmt_unsupported(VK_FORMAT_R12X4G12X4_UNORM_2PACK16),
377
fmt_unsupported(VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16),
378
fmt_unsupported(VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16),
379
fmt_unsupported(VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16),
380
fmt_unsupported(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16),
381
fmt_unsupported(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16),
382
fmt_unsupported(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16),
383
fmt_unsupported(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16),
384
fmt_unsupported(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16),
385
/* TODO: it is possible to enable the following 2 formats, but that
386
* requires further refactoring of how we handle multiplanar formats.
387
*/
388
fmt_unsupported(VK_FORMAT_G16B16G16R16_422_UNORM),
389
fmt_unsupported(VK_FORMAT_B16G16R16G16_422_UNORM),
390
391
ycbcr_fmt(VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM, 3,
392
y_plane(0, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
393
chroma_plane(1, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 2, 2),
394
chroma_plane(2, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 2, 2)),
395
ycbcr_fmt(VK_FORMAT_G16_B16R16_2PLANE_420_UNORM, 2,
396
y_plane(0, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
397
chroma_plane(1, ISL_FORMAT_R16G16_UNORM, RGBA, _ISL_SWIZZLE(BLUE, RED, ZERO, ZERO), 2, 2)),
398
ycbcr_fmt(VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, 3,
399
y_plane(0, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
400
chroma_plane(1, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 2, 1),
401
chroma_plane(2, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 2, 1)),
402
ycbcr_fmt(VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, 2,
403
y_plane(0, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
404
chroma_plane(1, ISL_FORMAT_R16G16_UNORM, RGBA, _ISL_SWIZZLE(BLUE, RED, ZERO, ZERO), 2, 1)),
405
ycbcr_fmt(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, 3,
406
y_plane(0, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(GREEN, ZERO, ZERO, ZERO), 1, 1),
407
chroma_plane(1, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(BLUE, ZERO, ZERO, ZERO), 1, 1),
408
chroma_plane(2, ISL_FORMAT_R16_UNORM, RGBA, _ISL_SWIZZLE(RED, ZERO, ZERO, ZERO), 1, 1)),
409
};
410
411
#undef _fmt
412
#undef swiz_fmt1
413
#undef fmt1
414
#undef fmt
415
416
static const struct {
417
const struct anv_format *formats;
418
uint32_t n_formats;
419
} anv_formats[] = {
420
[0] = { .formats = main_formats,
421
.n_formats = ARRAY_SIZE(main_formats), },
422
[_VK_EXT_4444_formats_number] = { .formats = _4444_formats,
423
.n_formats = ARRAY_SIZE(_4444_formats), },
424
[_VK_KHR_sampler_ycbcr_conversion_number] = { .formats = ycbcr_formats,
425
.n_formats = ARRAY_SIZE(ycbcr_formats), },
426
};
427
428
const struct anv_format *
429
anv_get_format(VkFormat vk_format)
430
{
431
uint32_t enum_offset = VK_ENUM_OFFSET(vk_format);
432
uint32_t ext_number = VK_ENUM_EXTENSION(vk_format);
433
434
if (ext_number >= ARRAY_SIZE(anv_formats) ||
435
enum_offset >= anv_formats[ext_number].n_formats)
436
return NULL;
437
438
const struct anv_format *format =
439
&anv_formats[ext_number].formats[enum_offset];
440
if (format->planes[0].isl_format == ISL_FORMAT_UNSUPPORTED)
441
return NULL;
442
443
return format;
444
}
445
446
/** Return true if any format plane has non-power-of-two bits-per-block. */
447
static bool
448
anv_format_has_npot_plane(const struct anv_format *anv_format) {
449
for (uint32_t i = 0; i < anv_format->n_planes; ++i) {
450
const struct isl_format_layout *isl_layout =
451
isl_format_get_layout(anv_format->planes[i].isl_format);
452
453
if (!util_is_power_of_two_or_zero(isl_layout->bpb))
454
return true;
455
}
456
457
return false;
458
}
459
460
/**
461
* Exactly one bit must be set in \a aspect.
462
*
463
* If tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, then return the
464
* requested anv_format_plane without checking for compatibility with modifiers.
465
* It is the caller's responsibility to verify that the the returned
466
* anv_format_plane is compatible with a particular modifier. (Observe that
467
* this function has no parameter for the DRM format modifier, and therefore
468
* _cannot_ check for compatibility).
469
*/
470
struct anv_format_plane
471
anv_get_format_plane(const struct intel_device_info *devinfo,
472
VkFormat vk_format,
473
VkImageAspectFlagBits aspect, VkImageTiling tiling)
474
{
475
const struct anv_format *format = anv_get_format(vk_format);
476
const struct anv_format_plane unsupported = {
477
.isl_format = ISL_FORMAT_UNSUPPORTED,
478
};
479
480
if (format == NULL)
481
return unsupported;
482
483
uint32_t plane = anv_image_aspect_to_plane(vk_format_aspects(vk_format), aspect);
484
struct anv_format_plane plane_format = format->planes[plane];
485
if (plane_format.isl_format == ISL_FORMAT_UNSUPPORTED)
486
return unsupported;
487
488
if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
489
return plane_format;
490
491
if (aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
492
assert(vk_format_aspects(vk_format) &
493
(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
494
495
/* There's no reason why we strictly can't support depth or stencil with
496
* modifiers but there's also no reason why we should.
497
*/
498
return plane_format;
499
}
500
501
assert((aspect & ~VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV) == 0);
502
503
const struct isl_format_layout *isl_layout =
504
isl_format_get_layout(plane_format.isl_format);
505
506
/* On Ivy Bridge we don't even have enough 24 and 48-bit formats that we
507
* can reliably do texture upload with BLORP so just don't claim support
508
* for any of them.
509
*/
510
if (devinfo->verx10 == 70 &&
511
(isl_layout->bpb == 24 || isl_layout->bpb == 48))
512
return unsupported;
513
514
if (tiling == VK_IMAGE_TILING_OPTIMAL &&
515
!util_is_power_of_two_or_zero(isl_layout->bpb)) {
516
/* Tiled formats *must* be power-of-two because we need up upload
517
* them with the render pipeline. For 3-channel formats, we fix
518
* this by switching them over to RGBX or RGBA formats under the
519
* hood.
520
*/
521
enum isl_format rgbx = isl_format_rgb_to_rgbx(plane_format.isl_format);
522
if (rgbx != ISL_FORMAT_UNSUPPORTED &&
523
isl_format_supports_rendering(devinfo, rgbx)) {
524
plane_format.isl_format = rgbx;
525
} else {
526
plane_format.isl_format =
527
isl_format_rgb_to_rgba(plane_format.isl_format);
528
plane_format.swizzle = ISL_SWIZZLE(RED, GREEN, BLUE, ONE);
529
}
530
}
531
532
/* The B4G4R4A4 format isn't available prior to Broadwell so we have to fall
533
* back to a format with a more complex swizzle.
534
*/
535
if (vk_format == VK_FORMAT_B4G4R4A4_UNORM_PACK16 && devinfo->ver < 8) {
536
plane_format.isl_format = ISL_FORMAT_B4G4R4A4_UNORM;
537
plane_format.swizzle = ISL_SWIZZLE(GREEN, RED, ALPHA, BLUE);
538
}
539
540
return plane_format;
541
}
542
543
// Format capabilities
544
545
VkFormatFeatureFlags
546
anv_get_image_format_features(const struct intel_device_info *devinfo,
547
VkFormat vk_format,
548
const struct anv_format *anv_format,
549
VkImageTiling vk_tiling,
550
const struct isl_drm_modifier_info *isl_mod_info)
551
{
552
VkFormatFeatureFlags flags = 0;
553
554
if (anv_format == NULL)
555
return 0;
556
557
assert((isl_mod_info != NULL) ==
558
(vk_tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT));
559
560
const VkImageAspectFlags aspects = vk_format_aspects(vk_format);
561
562
if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
563
if (vk_tiling == VK_IMAGE_TILING_LINEAR ||
564
vk_tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
565
return 0;
566
567
flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
568
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
569
VK_FORMAT_FEATURE_BLIT_SRC_BIT |
570
VK_FORMAT_FEATURE_BLIT_DST_BIT |
571
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
572
VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
573
574
if (aspects & VK_IMAGE_ASPECT_DEPTH_BIT)
575
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
576
577
if ((aspects & VK_IMAGE_ASPECT_DEPTH_BIT) && devinfo->ver >= 9)
578
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
579
580
return flags;
581
}
582
583
const struct anv_format_plane plane_format =
584
anv_get_format_plane(devinfo, vk_format, VK_IMAGE_ASPECT_COLOR_BIT,
585
vk_tiling);
586
587
if (plane_format.isl_format == ISL_FORMAT_UNSUPPORTED)
588
return 0;
589
590
struct anv_format_plane base_plane_format = plane_format;
591
if (vk_tiling != VK_IMAGE_TILING_LINEAR) {
592
base_plane_format = anv_get_format_plane(devinfo, vk_format,
593
VK_IMAGE_ASPECT_COLOR_BIT,
594
VK_IMAGE_TILING_LINEAR);
595
}
596
597
enum isl_format base_isl_format = base_plane_format.isl_format;
598
599
/* ASTC textures must be in Y-tiled memory, and we reject compressed formats
600
* with modifiers.
601
*/
602
if (vk_tiling != VK_IMAGE_TILING_OPTIMAL &&
603
isl_format_get_layout(plane_format.isl_format)->txc == ISL_TXC_ASTC)
604
return 0;
605
606
/* ASTC requires nasty workarounds on BSW so we just disable it for now.
607
*
608
* TODO: Figure out the ASTC workarounds and re-enable on BSW.
609
*/
610
if (devinfo->ver < 9 &&
611
isl_format_get_layout(plane_format.isl_format)->txc == ISL_TXC_ASTC)
612
return 0;
613
614
if (isl_format_supports_sampling(devinfo, plane_format.isl_format)) {
615
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
616
617
if (devinfo->ver >= 9)
618
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT;
619
620
if (isl_format_supports_filtering(devinfo, plane_format.isl_format))
621
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
622
}
623
624
/* We can render to swizzled formats. However, if the alpha channel is
625
* moved, then blending won't work correctly. The PRM tells us
626
* straight-up not to render to such a surface.
627
*/
628
if (isl_format_supports_rendering(devinfo, plane_format.isl_format) &&
629
plane_format.swizzle.a == ISL_CHANNEL_SELECT_ALPHA) {
630
flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
631
632
if (isl_format_supports_alpha_blending(devinfo, plane_format.isl_format))
633
flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
634
}
635
636
/* Load/store is determined based on base format. This prevents RGB
637
* formats from showing up as load/store capable.
638
*/
639
if (isl_format_supports_typed_writes(devinfo, base_isl_format))
640
flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
641
642
if (base_isl_format == ISL_FORMAT_R32_SINT ||
643
base_isl_format == ISL_FORMAT_R32_UINT ||
644
base_isl_format == ISL_FORMAT_R32_FLOAT)
645
flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
646
647
if (flags) {
648
flags |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
649
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
650
VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
651
652
/* Blit destination requires rendering support. */
653
if (isl_format_supports_rendering(devinfo, plane_format.isl_format))
654
flags |= VK_FORMAT_FEATURE_BLIT_DST_BIT;
655
}
656
657
/* XXX: We handle 3-channel formats by switching them out for RGBX or
658
* RGBA formats behind-the-scenes. This works fine for textures
659
* because the upload process will fill in the extra channel.
660
* We could also support it for render targets, but it will take
661
* substantially more work and we have enough RGBX formats to handle
662
* what most clients will want.
663
*/
664
if (vk_tiling == VK_IMAGE_TILING_OPTIMAL &&
665
base_isl_format != ISL_FORMAT_UNSUPPORTED &&
666
!util_is_power_of_two_or_zero(isl_format_layouts[base_isl_format].bpb) &&
667
isl_format_rgb_to_rgbx(base_isl_format) == ISL_FORMAT_UNSUPPORTED) {
668
flags &= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
669
flags &= ~VK_FORMAT_FEATURE_BLIT_DST_BIT;
670
}
671
672
if (anv_format->can_ycbcr) {
673
/* The sampler doesn't have support for mid point when it handles YUV on
674
* its own.
675
*/
676
if (isl_format_is_yuv(anv_format->planes[0].isl_format)) {
677
/* TODO: We've disabled linear implicit reconstruction with the
678
* sampler. The failures show a slightly out of range values on the
679
* bottom left of the sampled image.
680
*/
681
flags |= VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT;
682
} else {
683
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT |
684
VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT |
685
VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT;
686
}
687
688
/* We can support cosited chroma locations when handle planes with our
689
* own shader snippets.
690
*/
691
for (unsigned p = 0; p < anv_format->n_planes; p++) {
692
if (anv_format->planes[p].denominator_scales[0] > 1 ||
693
anv_format->planes[p].denominator_scales[1] > 1) {
694
flags |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT;
695
break;
696
}
697
}
698
699
if (anv_format->n_planes > 1)
700
flags |= VK_FORMAT_FEATURE_DISJOINT_BIT;
701
702
const VkFormatFeatureFlags disallowed_ycbcr_image_features =
703
VK_FORMAT_FEATURE_BLIT_SRC_BIT |
704
VK_FORMAT_FEATURE_BLIT_DST_BIT |
705
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
706
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT |
707
VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
708
709
flags &= ~disallowed_ycbcr_image_features;
710
}
711
712
if (vk_tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
713
if (!isl_drm_modifier_get_score(devinfo, isl_mod_info->modifier))
714
return 0;
715
716
/* Try to restrict the supported formats to those in drm_fourcc.h. The
717
* VK_EXT_image_drm_format_modifier does not require this (after all, two
718
* Vulkan apps could share an image by exchanging its VkFormat instead of
719
* a DRM_FORMAT), but there exist no users of such non-drm_fourcc formats
720
* yet. And the restriction shrinks our test surface.
721
*/
722
const struct isl_format_layout *isl_layout =
723
isl_format_get_layout(plane_format.isl_format);
724
725
switch (isl_layout->colorspace) {
726
case ISL_COLORSPACE_LINEAR:
727
case ISL_COLORSPACE_SRGB:
728
/* Each DRM_FORMAT that we support uses unorm (if the DRM format name
729
* has no type suffix) or sfloat (if it has suffix F). No format
730
* contains mixed types. (as of 2021-06-14)
731
*/
732
if (isl_layout->uniform_channel_type != ISL_UNORM &&
733
isl_layout->uniform_channel_type != ISL_SFLOAT)
734
return 0;
735
break;
736
case ISL_COLORSPACE_YUV:
737
anv_finishme("support YUV colorspace with DRM format modifiers");
738
return 0;
739
case ISL_COLORSPACE_NONE:
740
return 0;
741
}
742
743
/* We could support compressed formats if we wanted to. */
744
if (isl_format_is_compressed(plane_format.isl_format))
745
return 0;
746
747
/* No non-power-of-two fourcc formats exist.
748
*
749
* Even if non-power-of-two fourcc formats existed, we could support them
750
* only with DRM_FORMAT_MOD_LINEAR. Tiled formats must be power-of-two
751
* because we implement transfers with the render pipeline.
752
*/
753
if (anv_format_has_npot_plane(anv_format))
754
return 0;
755
756
if (anv_format->n_planes > 1) {
757
/* For simplicity, keep DISJOINT disabled for multi-planar format. */
758
flags &= ~VK_FORMAT_FEATURE_DISJOINT_BIT;
759
760
/* VK_ANDROID_external_memory_android_hardware_buffer in Virtio-GPU
761
* Venus driver layers on top of VK_EXT_image_drm_format_modifier of
762
* the host Vulkan driver, and VK_FORMAT_G8_B8R8_2PLANE_420_UNORM is
763
* required to support camera/media interop in Android.
764
*/
765
if (vk_format != VK_FORMAT_G8_B8R8_2PLANE_420_UNORM) {
766
anv_finishme("support more multi-planar formats with DRM modifiers");
767
return 0;
768
}
769
770
/* Currently there is no way to properly map memory planes to format
771
* planes and aux planes due to the lack of defined ABI for external
772
* multi-planar images.
773
*/
774
if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE) {
775
return 0;
776
}
777
}
778
779
if (isl_mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
780
!isl_format_supports_ccs_e(devinfo, plane_format.isl_format)) {
781
return 0;
782
}
783
784
if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE) {
785
/* Rejection DISJOINT for consistency with the GL driver. In
786
* eglCreateImage, we require that the dma_buf for the primary surface
787
* and the dma_buf for its aux surface refer to the same bo.
788
*/
789
flags &= ~VK_FORMAT_FEATURE_DISJOINT_BIT;
790
791
/* When the hardware accesses a storage image, it bypasses the aux
792
* surface. We could support storage access on images with aux
793
* modifiers by resolving the aux surface prior to the storage access.
794
*/
795
flags &= ~VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
796
flags &= ~VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
797
}
798
}
799
800
return flags;
801
}
802
803
static VkFormatFeatureFlags
804
get_buffer_format_features(const struct intel_device_info *devinfo,
805
VkFormat vk_format,
806
const struct anv_format *anv_format)
807
{
808
VkFormatFeatureFlags flags = 0;
809
810
if (anv_format == NULL)
811
return 0;
812
813
const enum isl_format isl_format = anv_format->planes[0].isl_format;
814
815
if (isl_format == ISL_FORMAT_UNSUPPORTED)
816
return 0;
817
818
if (anv_format->n_planes > 1)
819
return 0;
820
821
if (anv_format->can_ycbcr)
822
return 0;
823
824
if (vk_format_is_depth_or_stencil(vk_format))
825
return 0;
826
827
if (isl_format_supports_sampling(devinfo, isl_format) &&
828
!isl_format_is_compressed(isl_format))
829
flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
830
831
if (isl_format_supports_vertex_fetch(devinfo, isl_format))
832
flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
833
834
if (isl_is_storage_image_format(isl_format))
835
flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
836
837
if (isl_format == ISL_FORMAT_R32_SINT || isl_format == ISL_FORMAT_R32_UINT)
838
flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
839
840
return flags;
841
}
842
843
static void
844
get_drm_format_modifier_properties_list(const struct anv_physical_device *physical_device,
845
VkFormat vk_format,
846
VkDrmFormatModifierPropertiesListEXT *list)
847
{
848
const struct intel_device_info *devinfo = &physical_device->info;
849
const struct anv_format *anv_format = anv_get_format(vk_format);
850
851
VK_OUTARRAY_MAKE(out, list->pDrmFormatModifierProperties,
852
&list->drmFormatModifierCount);
853
854
isl_drm_modifier_info_for_each(isl_mod_info) {
855
VkFormatFeatureFlags features =
856
anv_get_image_format_features(devinfo, vk_format, anv_format,
857
VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT,
858
isl_mod_info);
859
if (!features)
860
continue;
861
862
uint32_t planes = anv_format->n_planes;
863
if (isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE)
864
++planes;
865
866
vk_outarray_append(&out, out_props) {
867
*out_props = (VkDrmFormatModifierPropertiesEXT) {
868
.drmFormatModifier = isl_mod_info->modifier,
869
.drmFormatModifierPlaneCount = planes,
870
.drmFormatModifierTilingFeatures = features,
871
};
872
};
873
}
874
}
875
876
void anv_GetPhysicalDeviceFormatProperties(
877
VkPhysicalDevice physicalDevice,
878
VkFormat vk_format,
879
VkFormatProperties* pFormatProperties)
880
{
881
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
882
const struct intel_device_info *devinfo = &physical_device->info;
883
const struct anv_format *anv_format = anv_get_format(vk_format);
884
885
*pFormatProperties = (VkFormatProperties) {
886
.linearTilingFeatures =
887
anv_get_image_format_features(devinfo, vk_format, anv_format,
888
VK_IMAGE_TILING_LINEAR, NULL),
889
.optimalTilingFeatures =
890
anv_get_image_format_features(devinfo, vk_format, anv_format,
891
VK_IMAGE_TILING_OPTIMAL, NULL),
892
.bufferFeatures =
893
get_buffer_format_features(devinfo, vk_format, anv_format),
894
};
895
}
896
897
void anv_GetPhysicalDeviceFormatProperties2(
898
VkPhysicalDevice physicalDevice,
899
VkFormat format,
900
VkFormatProperties2* pFormatProperties)
901
{
902
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
903
anv_GetPhysicalDeviceFormatProperties(physicalDevice, format,
904
&pFormatProperties->formatProperties);
905
906
vk_foreach_struct(ext, pFormatProperties->pNext) {
907
/* Use unsigned since some cases are not in the VkStructureType enum. */
908
switch ((unsigned)ext->sType) {
909
case VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT:
910
get_drm_format_modifier_properties_list(physical_device, format,
911
(void *)ext);
912
break;
913
default:
914
anv_debug_ignored_stype(ext->sType);
915
break;
916
}
917
}
918
}
919
920
static VkResult
921
anv_get_image_format_properties(
922
struct anv_physical_device *physical_device,
923
const VkPhysicalDeviceImageFormatInfo2 *info,
924
VkImageFormatProperties *pImageFormatProperties,
925
VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties)
926
{
927
VkFormatFeatureFlags format_feature_flags;
928
VkExtent3D maxExtent;
929
uint32_t maxMipLevels;
930
uint32_t maxArraySize;
931
VkSampleCountFlags sampleCounts;
932
struct anv_instance *instance = physical_device->instance;
933
const struct intel_device_info *devinfo = &physical_device->info;
934
const struct anv_format *format = anv_get_format(info->format);
935
const struct isl_drm_modifier_info *isl_mod_info = NULL;
936
const VkImageFormatListCreateInfo *format_list_info =
937
vk_find_struct_const(info->pNext, IMAGE_FORMAT_LIST_CREATE_INFO);
938
939
if (format == NULL)
940
goto unsupported;
941
942
if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
943
const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *vk_mod_info =
944
vk_find_struct_const(info->pNext, PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
945
946
isl_mod_info = isl_drm_modifier_get_info(vk_mod_info->drmFormatModifier);
947
if (isl_mod_info == NULL)
948
goto unsupported;
949
}
950
951
assert(format->vk_format == info->format);
952
format_feature_flags = anv_get_image_format_features(devinfo, info->format,
953
format, info->tiling,
954
isl_mod_info);
955
956
/* Remove the VkFormatFeatureFlags that are incompatible with any declared
957
* image view format. (Removals are more likely to occur when a DRM format
958
* modifier is present).
959
*/
960
if ((info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) && format_list_info) {
961
for (uint32_t i = 0; i < format_list_info->viewFormatCount; ++i) {
962
VkFormat vk_view_format = format_list_info->pViewFormats[i];
963
const struct anv_format *anv_view_format = anv_get_format(vk_view_format);
964
VkFormatFeatureFlags view_format_features =
965
anv_get_image_format_features(devinfo, vk_view_format,
966
anv_view_format,
967
info->tiling,
968
isl_mod_info);
969
format_feature_flags &= view_format_features;
970
}
971
}
972
973
if (!format_feature_flags)
974
goto unsupported;
975
976
switch (info->type) {
977
default:
978
unreachable("bad VkImageType");
979
case VK_IMAGE_TYPE_1D:
980
maxExtent.width = 16384;
981
maxExtent.height = 1;
982
maxExtent.depth = 1;
983
maxMipLevels = 15; /* log2(maxWidth) + 1 */
984
maxArraySize = 2048;
985
sampleCounts = VK_SAMPLE_COUNT_1_BIT;
986
break;
987
case VK_IMAGE_TYPE_2D:
988
/* FINISHME: Does this really differ for cube maps? The documentation
989
* for RENDER_SURFACE_STATE suggests so.
990
*/
991
maxExtent.width = 16384;
992
maxExtent.height = 16384;
993
maxExtent.depth = 1;
994
maxMipLevels = 15; /* log2(maxWidth) + 1 */
995
maxArraySize = 2048;
996
sampleCounts = VK_SAMPLE_COUNT_1_BIT;
997
break;
998
case VK_IMAGE_TYPE_3D:
999
maxExtent.width = 2048;
1000
maxExtent.height = 2048;
1001
maxExtent.depth = 2048;
1002
/* Prior to SKL, the mipmaps for 3D surfaces are laid out in a way
1003
* that make it impossible to represent in the way that
1004
* VkSubresourceLayout expects. Since we can't tell users how to make
1005
* sense of them, don't report them as available.
1006
*/
1007
if (devinfo->ver < 9 && info->tiling == VK_IMAGE_TILING_LINEAR)
1008
maxMipLevels = 1;
1009
else
1010
maxMipLevels = 12; /* log2(maxWidth) + 1 */
1011
maxArraySize = 1;
1012
sampleCounts = VK_SAMPLE_COUNT_1_BIT;
1013
break;
1014
}
1015
1016
if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
1017
/* We support modifiers only for "simple" (that is, non-array
1018
* non-mipmapped single-sample) 2D images.
1019
*/
1020
if (info->type != VK_IMAGE_TYPE_2D) {
1021
vk_errorfi(instance, &physical_device->vk.base,
1022
VK_ERROR_FORMAT_NOT_SUPPORTED,
1023
"VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT "
1024
"requires VK_IMAGE_TYPE_2D");
1025
goto unsupported;
1026
}
1027
1028
maxArraySize = 1;
1029
maxMipLevels = 1;
1030
sampleCounts = VK_SAMPLE_COUNT_1_BIT;
1031
1032
if (isl_mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
1033
!anv_formats_ccs_e_compatible(devinfo, info->flags, info->format,
1034
info->tiling, format_list_info)) {
1035
goto unsupported;
1036
}
1037
}
1038
1039
/* Our hardware doesn't support 1D compressed textures.
1040
* From the SKL PRM, RENDER_SURFACE_STATE::SurfaceFormat:
1041
* * This field cannot be a compressed (BC*, DXT*, FXT*, ETC*, EAC*) format
1042
* if the Surface Type is SURFTYPE_1D.
1043
* * This field cannot be ASTC format if the Surface Type is SURFTYPE_1D.
1044
*/
1045
if (info->type == VK_IMAGE_TYPE_1D &&
1046
isl_format_is_compressed(format->planes[0].isl_format)) {
1047
goto unsupported;
1048
}
1049
1050
if (info->tiling == VK_IMAGE_TILING_OPTIMAL &&
1051
info->type == VK_IMAGE_TYPE_2D &&
1052
(format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
1053
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) &&
1054
!(info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
1055
!(info->usage & VK_IMAGE_USAGE_STORAGE_BIT)) {
1056
sampleCounts = isl_device_get_sample_counts(&physical_device->isl_dev);
1057
}
1058
1059
if (info->usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
1060
VK_IMAGE_USAGE_TRANSFER_DST_BIT)) {
1061
/* Accept transfers on anything we can sample from or renderer to. */
1062
if (!(format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
1063
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
1064
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))) {
1065
goto unsupported;
1066
}
1067
}
1068
1069
if (info->usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
1070
if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
1071
goto unsupported;
1072
}
1073
}
1074
1075
if (info->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
1076
if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) {
1077
goto unsupported;
1078
}
1079
}
1080
1081
if (info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
1082
if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
1083
goto unsupported;
1084
}
1085
}
1086
1087
if (info->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
1088
if (!(format_feature_flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
1089
goto unsupported;
1090
}
1091
}
1092
1093
if (info->flags & VK_IMAGE_CREATE_DISJOINT_BIT) {
1094
/* From the Vulkan 1.2.149 spec, VkImageCreateInfo:
1095
*
1096
* If format is a multi-planar format, and if imageCreateFormatFeatures
1097
* (as defined in Image Creation Limits) does not contain
1098
* VK_FORMAT_FEATURE_DISJOINT_BIT, then flags must not contain
1099
* VK_IMAGE_CREATE_DISJOINT_BIT.
1100
*/
1101
if (format->n_planes > 1 &&
1102
!(format_feature_flags & VK_FORMAT_FEATURE_DISJOINT_BIT)) {
1103
goto unsupported;
1104
}
1105
1106
/* From the Vulkan 1.2.149 spec, VkImageCreateInfo:
1107
*
1108
* If format is not a multi-planar format, and flags does not include
1109
* VK_IMAGE_CREATE_ALIAS_BIT, flags must not contain
1110
* VK_IMAGE_CREATE_DISJOINT_BIT.
1111
*/
1112
if (format->n_planes == 1 &&
1113
!(info->flags & VK_IMAGE_CREATE_ALIAS_BIT)) {
1114
goto unsupported;
1115
}
1116
1117
if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
1118
isl_mod_info->aux_usage != ISL_AUX_USAGE_NONE) {
1119
/* Rejection DISJOINT for consistency with the GL driver. In
1120
* eglCreateImage, we require that the dma_buf for the primary surface
1121
* and the dma_buf for its aux surface refer to the same bo.
1122
*/
1123
goto unsupported;
1124
}
1125
}
1126
1127
if (info->flags & VK_IMAGE_CREATE_ALIAS_BIT) {
1128
/* Reject aliasing of images with non-linear DRM format modifiers because:
1129
*
1130
* 1. For modifiers with compression, we store aux tracking state in
1131
* ANV_IMAGE_MEMORY_BINDING_PRIVATE, which is not aliasable because it's
1132
* not client-bound.
1133
*
1134
* 2. For tiled modifiers without compression, we may attempt to compress
1135
* them behind the scenes, in which case both the aux tracking state
1136
* and the CCS data are bound to ANV_IMAGE_MEMORY_BINDING_PRIVATE.
1137
*/
1138
if (info->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT &&
1139
isl_mod_info->modifier != DRM_FORMAT_MOD_LINEAR) {
1140
goto unsupported;
1141
}
1142
}
1143
1144
if (info->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) {
1145
/* Nothing to check. */
1146
}
1147
1148
if (info->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) {
1149
/* Ignore this flag because it was removed from the
1150
* provisional_I_20150910 header.
1151
*/
1152
}
1153
1154
/* From the bspec section entitled "Surface Layout and Tiling",
1155
* pre-gfx9 has a 2 GB limitation of the size in bytes,
1156
* gfx9 and gfx10 have a 256 GB limitation and gfx11+
1157
* has a 16 TB limitation.
1158
*/
1159
uint64_t maxResourceSize = 0;
1160
if (devinfo->ver < 9)
1161
maxResourceSize = (uint64_t) 1 << 31;
1162
else if (devinfo->ver < 11)
1163
maxResourceSize = (uint64_t) 1 << 38;
1164
else
1165
maxResourceSize = (uint64_t) 1 << 44;
1166
1167
*pImageFormatProperties = (VkImageFormatProperties) {
1168
.maxExtent = maxExtent,
1169
.maxMipLevels = maxMipLevels,
1170
.maxArrayLayers = maxArraySize,
1171
.sampleCounts = sampleCounts,
1172
1173
/* FINISHME: Accurately calculate
1174
* VkImageFormatProperties::maxResourceSize.
1175
*/
1176
.maxResourceSize = maxResourceSize,
1177
};
1178
1179
if (pYcbcrImageFormatProperties) {
1180
pYcbcrImageFormatProperties->combinedImageSamplerDescriptorCount =
1181
format->n_planes;
1182
}
1183
1184
return VK_SUCCESS;
1185
1186
unsupported:
1187
*pImageFormatProperties = (VkImageFormatProperties) {
1188
.maxExtent = { 0, 0, 0 },
1189
.maxMipLevels = 0,
1190
.maxArrayLayers = 0,
1191
.sampleCounts = 0,
1192
.maxResourceSize = 0,
1193
};
1194
1195
return VK_ERROR_FORMAT_NOT_SUPPORTED;
1196
}
1197
1198
VkResult anv_GetPhysicalDeviceImageFormatProperties(
1199
VkPhysicalDevice physicalDevice,
1200
VkFormat format,
1201
VkImageType type,
1202
VkImageTiling tiling,
1203
VkImageUsageFlags usage,
1204
VkImageCreateFlags createFlags,
1205
VkImageFormatProperties* pImageFormatProperties)
1206
{
1207
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
1208
1209
const VkPhysicalDeviceImageFormatInfo2 info = {
1210
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
1211
.pNext = NULL,
1212
.format = format,
1213
.type = type,
1214
.tiling = tiling,
1215
.usage = usage,
1216
.flags = createFlags,
1217
};
1218
1219
return anv_get_image_format_properties(physical_device, &info,
1220
pImageFormatProperties, NULL);
1221
}
1222
1223
1224
/* Supports opaque fd but not dma_buf. */
1225
static const VkExternalMemoryProperties opaque_fd_only_props = {
1226
.externalMemoryFeatures =
1227
VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
1228
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
1229
.exportFromImportedHandleTypes =
1230
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
1231
.compatibleHandleTypes =
1232
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
1233
};
1234
1235
/* Supports opaque fd and dma_buf. */
1236
static const VkExternalMemoryProperties opaque_fd_dma_buf_props = {
1237
.externalMemoryFeatures =
1238
VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
1239
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
1240
.exportFromImportedHandleTypes =
1241
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
1242
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
1243
.compatibleHandleTypes =
1244
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
1245
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
1246
};
1247
1248
static const VkExternalMemoryProperties userptr_props = {
1249
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
1250
.exportFromImportedHandleTypes = 0,
1251
.compatibleHandleTypes =
1252
VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT,
1253
};
1254
1255
static const VkExternalMemoryProperties android_buffer_props = {
1256
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
1257
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
1258
.exportFromImportedHandleTypes =
1259
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
1260
.compatibleHandleTypes =
1261
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
1262
};
1263
1264
1265
static const VkExternalMemoryProperties android_image_props = {
1266
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
1267
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT |
1268
VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT,
1269
.exportFromImportedHandleTypes =
1270
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
1271
.compatibleHandleTypes =
1272
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
1273
};
1274
1275
VkResult anv_GetPhysicalDeviceImageFormatProperties2(
1276
VkPhysicalDevice physicalDevice,
1277
const VkPhysicalDeviceImageFormatInfo2* base_info,
1278
VkImageFormatProperties2* base_props)
1279
{
1280
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
1281
struct anv_instance *instance = physical_device->instance;
1282
const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
1283
VkExternalImageFormatProperties *external_props = NULL;
1284
VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = NULL;
1285
VkAndroidHardwareBufferUsageANDROID *android_usage = NULL;
1286
VkResult result;
1287
1288
/* Extract input structs */
1289
vk_foreach_struct_const(s, base_info->pNext) {
1290
switch (s->sType) {
1291
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
1292
external_info = (const void *) s;
1293
break;
1294
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
1295
/* anv_get_image_format_properties will handle this */
1296
break;
1297
case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT:
1298
/* Ignore but don't warn */
1299
break;
1300
default:
1301
anv_debug_ignored_stype(s->sType);
1302
break;
1303
}
1304
}
1305
1306
/* Extract output structs */
1307
vk_foreach_struct(s, base_props->pNext) {
1308
switch (s->sType) {
1309
case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
1310
external_props = (void *) s;
1311
break;
1312
case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
1313
ycbcr_props = (void *) s;
1314
break;
1315
case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
1316
android_usage = (void *) s;
1317
break;
1318
default:
1319
anv_debug_ignored_stype(s->sType);
1320
break;
1321
}
1322
}
1323
1324
result = anv_get_image_format_properties(physical_device, base_info,
1325
&base_props->imageFormatProperties, ycbcr_props);
1326
if (result != VK_SUCCESS)
1327
goto fail;
1328
1329
bool ahw_supported =
1330
physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer;
1331
1332
if (ahw_supported && android_usage) {
1333
android_usage->androidHardwareBufferUsage =
1334
anv_ahw_usage_from_vk_usage(base_info->flags,
1335
base_info->usage);
1336
1337
/* Limit maxArrayLayers to 1 for AHardwareBuffer based images for now. */
1338
base_props->imageFormatProperties.maxArrayLayers = 1;
1339
}
1340
1341
/* From the Vulkan 1.0.42 spec:
1342
*
1343
* If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2 will
1344
* behave as if VkPhysicalDeviceExternalImageFormatInfo was not
1345
* present and VkExternalImageFormatProperties will be ignored.
1346
*/
1347
if (external_info && external_info->handleType != 0) {
1348
/* Does there exist a method for app and driver to explicitly communicate
1349
* to each other the image's memory layout?
1350
*/
1351
bool tiling_has_explicit_layout;
1352
1353
switch (base_info->tiling) {
1354
default:
1355
unreachable("bad VkImageTiling");
1356
case VK_IMAGE_TILING_LINEAR:
1357
/* The app can query the image's memory layout with
1358
* vkGetImageSubresourceLayout.
1359
*/
1360
tiling_has_explicit_layout = true;
1361
break;
1362
case VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT:
1363
/* The app can provide the image's memory layout with
1364
* VkImageDrmFormatModifierExplicitCreateInfoEXT;
1365
* or the app can query it with vkGetImageSubresourceLayout.
1366
*/
1367
tiling_has_explicit_layout = true;
1368
break;
1369
case VK_IMAGE_TILING_OPTIMAL:
1370
/* The app can neither query nor provide the image's memory layout. */
1371
tiling_has_explicit_layout = false;
1372
break;
1373
}
1374
1375
/* Compatibility between tiling and external memory handles
1376
* --------------------------------------------------------
1377
* When importing or exporting an image, there must exist a method that
1378
* enables the app and driver to agree on the image's memory layout. If no
1379
* method exists, then we reject image creation here.
1380
*
1381
* If the memory handle requires matching
1382
* VkPhysicalDeviceIDPropertiesKHR::driverUUID and ::deviceUUID, then the
1383
* match-requirement guarantees that all users of the image agree on the
1384
* image's memory layout.
1385
*
1386
* If the memory handle does not require matching
1387
* VkPhysicalDeviceIDPropertiesKHR::driverUUID nor ::deviceUUID, then we
1388
* require that the app and driver be able to explicitly communicate to
1389
* each other the image's memory layout.
1390
*
1391
* (For restrictions on driverUUID and deviceUUID, see the Vulkan 1.2.149
1392
* spec, Table 73 "External memory handle types").
1393
*/
1394
switch (external_info->handleType) {
1395
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT:
1396
1397
/* Disable stencil export, there are issues. */
1398
if (vk_format_aspects(base_info->format) & VK_IMAGE_ASPECT_STENCIL_BIT) {
1399
result = vk_errorfi(instance, &physical_device->vk.base,
1400
VK_ERROR_FORMAT_NOT_SUPPORTED,
1401
"External stencil buffers are not supported yet");
1402
goto fail;
1403
}
1404
1405
if (external_props) {
1406
if (tiling_has_explicit_layout) {
1407
/* With an explicit memory layout, we don't care which type of fd
1408
* the image belongs too. Both OPAQUE_FD and DMA_BUF are
1409
* interchangeable here.
1410
*/
1411
external_props->externalMemoryProperties = opaque_fd_dma_buf_props;
1412
} else {
1413
/* With an implicit memory layout, we must rely on deviceUUID
1414
* and driverUUID to determine the layout. Therefore DMA_BUF is
1415
* incompatible here.
1416
*/
1417
external_props->externalMemoryProperties = opaque_fd_only_props;
1418
}
1419
}
1420
break;
1421
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
1422
/* This memory handle has no restrictions on driverUUID nor deviceUUID,
1423
* and therefore requires explicit memory layout.
1424
*/
1425
if (!tiling_has_explicit_layout) {
1426
result = vk_errorfi(instance, &physical_device->vk.base,
1427
VK_ERROR_FORMAT_NOT_SUPPORTED,
1428
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT "
1429
"requires VK_IMAGE_TILING_LINEAR or "
1430
"VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT");
1431
goto fail;
1432
}
1433
1434
/* With an explicit memory layout, we don't care which type of fd
1435
* the image belongs too. Both OPAQUE_FD and DMA_BUF are
1436
* interchangeable here.
1437
*/
1438
if (external_props)
1439
external_props->externalMemoryProperties = opaque_fd_dma_buf_props;
1440
break;
1441
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT:
1442
/* This memory handle has no restrictions on driverUUID nor deviceUUID,
1443
* and therefore requires explicit memory layout.
1444
*/
1445
if (!tiling_has_explicit_layout) {
1446
result = vk_errorfi(instance, &physical_device->vk.base,
1447
VK_ERROR_FORMAT_NOT_SUPPORTED,
1448
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT "
1449
"requires VK_IMAGE_TILING_LINEAR or "
1450
"VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT");
1451
goto fail;
1452
}
1453
1454
if (external_props)
1455
external_props->externalMemoryProperties = userptr_props;
1456
break;
1457
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
1458
/* This memory handle is magic. The Vulkan spec says it has no
1459
* requirements regarding deviceUUID nor driverUUID, but Android still
1460
* requires support for VK_IMAGE_TILING_OPTIMAL. Android systems
1461
* communicate the image's memory layout through backdoor channels.
1462
*/
1463
if (ahw_supported && external_props) {
1464
external_props->externalMemoryProperties = android_image_props;
1465
break;
1466
}
1467
FALLTHROUGH; /* If ahw not supported */
1468
default:
1469
/* From the Vulkan 1.0.42 spec:
1470
*
1471
* If handleType is not compatible with the [parameters] specified
1472
* in VkPhysicalDeviceImageFormatInfo2, then
1473
* vkGetPhysicalDeviceImageFormatProperties2 returns
1474
* VK_ERROR_FORMAT_NOT_SUPPORTED.
1475
*/
1476
result = vk_errorfi(instance, &physical_device->vk.base,
1477
VK_ERROR_FORMAT_NOT_SUPPORTED,
1478
"unsupported VkExternalMemoryTypeFlagBits 0x%x",
1479
external_info->handleType);
1480
goto fail;
1481
}
1482
}
1483
1484
return VK_SUCCESS;
1485
1486
fail:
1487
if (result == VK_ERROR_FORMAT_NOT_SUPPORTED) {
1488
/* From the Vulkan 1.0.42 spec:
1489
*
1490
* If the combination of parameters to
1491
* vkGetPhysicalDeviceImageFormatProperties2 is not supported by
1492
* the implementation for use in vkCreateImage, then all members of
1493
* imageFormatProperties will be filled with zero.
1494
*/
1495
base_props->imageFormatProperties = (VkImageFormatProperties) {};
1496
}
1497
1498
return result;
1499
}
1500
1501
void anv_GetPhysicalDeviceSparseImageFormatProperties(
1502
VkPhysicalDevice physicalDevice,
1503
VkFormat format,
1504
VkImageType type,
1505
uint32_t samples,
1506
VkImageUsageFlags usage,
1507
VkImageTiling tiling,
1508
uint32_t* pNumProperties,
1509
VkSparseImageFormatProperties* pProperties)
1510
{
1511
/* Sparse images are not yet supported. */
1512
*pNumProperties = 0;
1513
}
1514
1515
void anv_GetPhysicalDeviceSparseImageFormatProperties2(
1516
VkPhysicalDevice physicalDevice,
1517
const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo,
1518
uint32_t* pPropertyCount,
1519
VkSparseImageFormatProperties2* pProperties)
1520
{
1521
/* Sparse images are not yet supported. */
1522
*pPropertyCount = 0;
1523
}
1524
1525
void anv_GetPhysicalDeviceExternalBufferProperties(
1526
VkPhysicalDevice physicalDevice,
1527
const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo,
1528
VkExternalBufferProperties* pExternalBufferProperties)
1529
{
1530
/* The Vulkan 1.0.42 spec says "handleType must be a valid
1531
* VkExternalMemoryHandleTypeFlagBits value" in
1532
* VkPhysicalDeviceExternalBufferInfo. This differs from
1533
* VkPhysicalDeviceExternalImageFormatInfo, which surprisingly permits
1534
* handleType == 0.
1535
*/
1536
assert(pExternalBufferInfo->handleType != 0);
1537
1538
/* All of the current flags are for sparse which we don't support yet.
1539
* Even when we do support it, doing sparse on external memory sounds
1540
* sketchy. Also, just disallowing flags is the safe option.
1541
*/
1542
if (pExternalBufferInfo->flags)
1543
goto unsupported;
1544
1545
ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
1546
1547
switch (pExternalBufferInfo->handleType) {
1548
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT:
1549
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
1550
pExternalBufferProperties->externalMemoryProperties = opaque_fd_dma_buf_props;
1551
return;
1552
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT:
1553
pExternalBufferProperties->externalMemoryProperties = userptr_props;
1554
return;
1555
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
1556
if (physical_device->vk.supported_extensions.ANDROID_external_memory_android_hardware_buffer) {
1557
pExternalBufferProperties->externalMemoryProperties = android_buffer_props;
1558
return;
1559
}
1560
FALLTHROUGH; /* If ahw not supported */
1561
default:
1562
goto unsupported;
1563
}
1564
1565
unsupported:
1566
/* From the Vulkan 1.1.113 spec:
1567
*
1568
* compatibleHandleTypes must include at least handleType.
1569
*/
1570
pExternalBufferProperties->externalMemoryProperties =
1571
(VkExternalMemoryProperties) {
1572
.compatibleHandleTypes = pExternalBufferInfo->handleType,
1573
};
1574
}
1575
1576
VkResult anv_CreateSamplerYcbcrConversion(
1577
VkDevice _device,
1578
const VkSamplerYcbcrConversionCreateInfo* pCreateInfo,
1579
const VkAllocationCallbacks* pAllocator,
1580
VkSamplerYcbcrConversion* pYcbcrConversion)
1581
{
1582
ANV_FROM_HANDLE(anv_device, device, _device);
1583
struct anv_ycbcr_conversion *conversion;
1584
1585
/* Search for VkExternalFormatANDROID and resolve the format. */
1586
struct anv_format *ext_format = NULL;
1587
const VkExternalFormatANDROID *ext_info =
1588
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_FORMAT_ANDROID);
1589
1590
uint64_t format = ext_info ? ext_info->externalFormat : 0;
1591
if (format) {
1592
assert(pCreateInfo->format == VK_FORMAT_UNDEFINED);
1593
ext_format = (struct anv_format *) (uintptr_t) format;
1594
}
1595
1596
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
1597
1598
conversion = vk_object_zalloc(&device->vk, pAllocator, sizeof(*conversion),
1599
VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
1600
if (!conversion)
1601
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
1602
1603
conversion->format = anv_get_format(pCreateInfo->format);
1604
conversion->ycbcr_model = pCreateInfo->ycbcrModel;
1605
conversion->ycbcr_range = pCreateInfo->ycbcrRange;
1606
1607
/* The Vulkan 1.1.95 spec says "When creating an external format conversion,
1608
* the value of components if ignored."
1609
*/
1610
if (!ext_format) {
1611
conversion->mapping[0] = pCreateInfo->components.r;
1612
conversion->mapping[1] = pCreateInfo->components.g;
1613
conversion->mapping[2] = pCreateInfo->components.b;
1614
conversion->mapping[3] = pCreateInfo->components.a;
1615
}
1616
1617
conversion->chroma_offsets[0] = pCreateInfo->xChromaOffset;
1618
conversion->chroma_offsets[1] = pCreateInfo->yChromaOffset;
1619
conversion->chroma_filter = pCreateInfo->chromaFilter;
1620
1621
/* Setup external format. */
1622
if (ext_format)
1623
conversion->format = ext_format;
1624
1625
bool has_chroma_subsampled = false;
1626
for (uint32_t p = 0; p < conversion->format->n_planes; p++) {
1627
if (conversion->format->planes[p].has_chroma &&
1628
(conversion->format->planes[p].denominator_scales[0] > 1 ||
1629
conversion->format->planes[p].denominator_scales[1] > 1))
1630
has_chroma_subsampled = true;
1631
}
1632
conversion->chroma_reconstruction = has_chroma_subsampled &&
1633
(conversion->chroma_offsets[0] == VK_CHROMA_LOCATION_COSITED_EVEN ||
1634
conversion->chroma_offsets[1] == VK_CHROMA_LOCATION_COSITED_EVEN);
1635
1636
*pYcbcrConversion = anv_ycbcr_conversion_to_handle(conversion);
1637
1638
return VK_SUCCESS;
1639
}
1640
1641
void anv_DestroySamplerYcbcrConversion(
1642
VkDevice _device,
1643
VkSamplerYcbcrConversion YcbcrConversion,
1644
const VkAllocationCallbacks* pAllocator)
1645
{
1646
ANV_FROM_HANDLE(anv_device, device, _device);
1647
ANV_FROM_HANDLE(anv_ycbcr_conversion, conversion, YcbcrConversion);
1648
1649
if (!conversion)
1650
return;
1651
1652
vk_object_free(&device->vk, pAllocator, conversion);
1653
}
1654
1655