2 * Copyright © 2015 Intel Corporation
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:
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
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
24 #include "anv_private.h"
25 #include "vk_format_info.h"
29 * gcc-4 and earlier don't allow compound literals where a constant
30 * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
31 * here. -std=c89/gnu89 would allow it, but we depend on c99 features
32 * so using -std=c89/gnu89 is not an option. Starting from gcc-5
33 * compound literals can also be considered constant in -std=c99/gnu99
36 #define _ISL_SWIZZLE(r, g, b, a) { \
37 ISL_CHANNEL_SELECT_##r, \
38 ISL_CHANNEL_SELECT_##g, \
39 ISL_CHANNEL_SELECT_##b, \
40 ISL_CHANNEL_SELECT_##a, \
43 #define RGBA _ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
44 #define BGRA _ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
45 #define RGB1 _ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
47 #define _fmt(__hw_fmt, __swizzle) \
48 { .isl_format = __hw_fmt, \
49 .swizzle = __swizzle }
51 #define swiz_fmt1(__vk_fmt, __hw_fmt, __swizzle) \
52 [VK_ENUM_OFFSET(__vk_fmt)] = { \
54 { .isl_format = __hw_fmt, .swizzle = __swizzle }, \
59 #define fmt1(__vk_fmt, __hw_fmt) \
60 swiz_fmt1(__vk_fmt, __hw_fmt, RGBA)
62 #define fmt2(__vk_fmt, __fmt1, __fmt2) \
63 [VK_ENUM_OFFSET(__vk_fmt)] = { \
65 { .isl_format = __fmt1, \
68 { .isl_format = __fmt2, \
75 #define fmt_unsupported(__vk_fmt) \
76 [VK_ENUM_OFFSET(__vk_fmt)] = { \
78 { .isl_format = ISL_FORMAT_UNSUPPORTED, }, \
82 /* HINT: For array formats, the ISL name should match the VK name. For
83 * packed formats, they should have the channels in reverse order from each
84 * other. The reason for this is that, for packed formats, the ISL (and
85 * bspec) names are in LSB -> MSB order while VK formats are MSB -> LSB.
87 static const struct anv_format main_formats
[] = {
88 fmt_unsupported(VK_FORMAT_UNDEFINED
),
89 fmt_unsupported(VK_FORMAT_R4G4_UNORM_PACK8
),
90 fmt1(VK_FORMAT_R4G4B4A4_UNORM_PACK16
, ISL_FORMAT_A4B4G4R4_UNORM
),
91 swiz_fmt1(VK_FORMAT_B4G4R4A4_UNORM_PACK16
, ISL_FORMAT_A4B4G4R4_UNORM
, BGRA
),
92 fmt1(VK_FORMAT_R5G6B5_UNORM_PACK16
, ISL_FORMAT_B5G6R5_UNORM
),
93 swiz_fmt1(VK_FORMAT_B5G6R5_UNORM_PACK16
, ISL_FORMAT_B5G6R5_UNORM
, BGRA
),
94 fmt1(VK_FORMAT_R5G5B5A1_UNORM_PACK16
, ISL_FORMAT_A1B5G5R5_UNORM
),
95 fmt_unsupported(VK_FORMAT_B5G5R5A1_UNORM_PACK16
),
96 fmt1(VK_FORMAT_A1R5G5B5_UNORM_PACK16
, ISL_FORMAT_B5G5R5A1_UNORM
),
97 fmt1(VK_FORMAT_R8_UNORM
, ISL_FORMAT_R8_UNORM
),
98 fmt1(VK_FORMAT_R8_SNORM
, ISL_FORMAT_R8_SNORM
),
99 fmt1(VK_FORMAT_R8_USCALED
, ISL_FORMAT_R8_USCALED
),
100 fmt1(VK_FORMAT_R8_SSCALED
, ISL_FORMAT_R8_SSCALED
),
101 fmt1(VK_FORMAT_R8_UINT
, ISL_FORMAT_R8_UINT
),
102 fmt1(VK_FORMAT_R8_SINT
, ISL_FORMAT_R8_SINT
),
103 swiz_fmt1(VK_FORMAT_R8_SRGB
, ISL_FORMAT_L8_UNORM_SRGB
,
104 _ISL_SWIZZLE(RED
, ZERO
, ZERO
, ONE
)),
105 fmt1(VK_FORMAT_R8G8_UNORM
, ISL_FORMAT_R8G8_UNORM
),
106 fmt1(VK_FORMAT_R8G8_SNORM
, ISL_FORMAT_R8G8_SNORM
),
107 fmt1(VK_FORMAT_R8G8_USCALED
, ISL_FORMAT_R8G8_USCALED
),
108 fmt1(VK_FORMAT_R8G8_SSCALED
, ISL_FORMAT_R8G8_SSCALED
),
109 fmt1(VK_FORMAT_R8G8_UINT
, ISL_FORMAT_R8G8_UINT
),
110 fmt1(VK_FORMAT_R8G8_SINT
, ISL_FORMAT_R8G8_SINT
),
111 fmt_unsupported(VK_FORMAT_R8G8_SRGB
), /* L8A8_UNORM_SRGB */
112 fmt1(VK_FORMAT_R8G8B8_UNORM
, ISL_FORMAT_R8G8B8_UNORM
),
113 fmt1(VK_FORMAT_R8G8B8_SNORM
, ISL_FORMAT_R8G8B8_SNORM
),
114 fmt1(VK_FORMAT_R8G8B8_USCALED
, ISL_FORMAT_R8G8B8_USCALED
),
115 fmt1(VK_FORMAT_R8G8B8_SSCALED
, ISL_FORMAT_R8G8B8_SSCALED
),
116 fmt1(VK_FORMAT_R8G8B8_UINT
, ISL_FORMAT_R8G8B8_UINT
),
117 fmt1(VK_FORMAT_R8G8B8_SINT
, ISL_FORMAT_R8G8B8_SINT
),
118 fmt1(VK_FORMAT_R8G8B8_SRGB
, ISL_FORMAT_R8G8B8_UNORM_SRGB
),
119 fmt1(VK_FORMAT_R8G8B8A8_UNORM
, ISL_FORMAT_R8G8B8A8_UNORM
),
120 fmt1(VK_FORMAT_R8G8B8A8_SNORM
, ISL_FORMAT_R8G8B8A8_SNORM
),
121 fmt1(VK_FORMAT_R8G8B8A8_USCALED
, ISL_FORMAT_R8G8B8A8_USCALED
),
122 fmt1(VK_FORMAT_R8G8B8A8_SSCALED
, ISL_FORMAT_R8G8B8A8_SSCALED
),
123 fmt1(VK_FORMAT_R8G8B8A8_UINT
, ISL_FORMAT_R8G8B8A8_UINT
),
124 fmt1(VK_FORMAT_R8G8B8A8_SINT
, ISL_FORMAT_R8G8B8A8_SINT
),
125 fmt1(VK_FORMAT_R8G8B8A8_SRGB
, ISL_FORMAT_R8G8B8A8_UNORM_SRGB
),
126 fmt1(VK_FORMAT_A8B8G8R8_UNORM_PACK32
, ISL_FORMAT_R8G8B8A8_UNORM
),
127 fmt1(VK_FORMAT_A8B8G8R8_SNORM_PACK32
, ISL_FORMAT_R8G8B8A8_SNORM
),
128 fmt1(VK_FORMAT_A8B8G8R8_USCALED_PACK32
, ISL_FORMAT_R8G8B8A8_USCALED
),
129 fmt1(VK_FORMAT_A8B8G8R8_SSCALED_PACK32
, ISL_FORMAT_R8G8B8A8_SSCALED
),
130 fmt1(VK_FORMAT_A8B8G8R8_UINT_PACK32
, ISL_FORMAT_R8G8B8A8_UINT
),
131 fmt1(VK_FORMAT_A8B8G8R8_SINT_PACK32
, ISL_FORMAT_R8G8B8A8_SINT
),
132 fmt1(VK_FORMAT_A8B8G8R8_SRGB_PACK32
, ISL_FORMAT_R8G8B8A8_UNORM_SRGB
),
133 fmt1(VK_FORMAT_A2R10G10B10_UNORM_PACK32
, ISL_FORMAT_B10G10R10A2_UNORM
),
134 fmt1(VK_FORMAT_A2R10G10B10_SNORM_PACK32
, ISL_FORMAT_B10G10R10A2_SNORM
),
135 fmt1(VK_FORMAT_A2R10G10B10_USCALED_PACK32
, ISL_FORMAT_B10G10R10A2_USCALED
),
136 fmt1(VK_FORMAT_A2R10G10B10_SSCALED_PACK32
, ISL_FORMAT_B10G10R10A2_SSCALED
),
137 fmt1(VK_FORMAT_A2R10G10B10_UINT_PACK32
, ISL_FORMAT_B10G10R10A2_UINT
),
138 fmt1(VK_FORMAT_A2R10G10B10_SINT_PACK32
, ISL_FORMAT_B10G10R10A2_SINT
),
139 fmt1(VK_FORMAT_A2B10G10R10_UNORM_PACK32
, ISL_FORMAT_R10G10B10A2_UNORM
),
140 fmt1(VK_FORMAT_A2B10G10R10_SNORM_PACK32
, ISL_FORMAT_R10G10B10A2_SNORM
),
141 fmt1(VK_FORMAT_A2B10G10R10_USCALED_PACK32
, ISL_FORMAT_R10G10B10A2_USCALED
),
142 fmt1(VK_FORMAT_A2B10G10R10_SSCALED_PACK32
, ISL_FORMAT_R10G10B10A2_SSCALED
),
143 fmt1(VK_FORMAT_A2B10G10R10_UINT_PACK32
, ISL_FORMAT_R10G10B10A2_UINT
),
144 fmt1(VK_FORMAT_A2B10G10R10_SINT_PACK32
, ISL_FORMAT_R10G10B10A2_SINT
),
145 fmt1(VK_FORMAT_R16_UNORM
, ISL_FORMAT_R16_UNORM
),
146 fmt1(VK_FORMAT_R16_SNORM
, ISL_FORMAT_R16_SNORM
),
147 fmt1(VK_FORMAT_R16_USCALED
, ISL_FORMAT_R16_USCALED
),
148 fmt1(VK_FORMAT_R16_SSCALED
, ISL_FORMAT_R16_SSCALED
),
149 fmt1(VK_FORMAT_R16_UINT
, ISL_FORMAT_R16_UINT
),
150 fmt1(VK_FORMAT_R16_SINT
, ISL_FORMAT_R16_SINT
),
151 fmt1(VK_FORMAT_R16_SFLOAT
, ISL_FORMAT_R16_FLOAT
),
152 fmt1(VK_FORMAT_R16G16_UNORM
, ISL_FORMAT_R16G16_UNORM
),
153 fmt1(VK_FORMAT_R16G16_SNORM
, ISL_FORMAT_R16G16_SNORM
),
154 fmt1(VK_FORMAT_R16G16_USCALED
, ISL_FORMAT_R16G16_USCALED
),
155 fmt1(VK_FORMAT_R16G16_SSCALED
, ISL_FORMAT_R16G16_SSCALED
),
156 fmt1(VK_FORMAT_R16G16_UINT
, ISL_FORMAT_R16G16_UINT
),
157 fmt1(VK_FORMAT_R16G16_SINT
, ISL_FORMAT_R16G16_SINT
),
158 fmt1(VK_FORMAT_R16G16_SFLOAT
, ISL_FORMAT_R16G16_FLOAT
),
159 fmt1(VK_FORMAT_R16G16B16_UNORM
, ISL_FORMAT_R16G16B16_UNORM
),
160 fmt1(VK_FORMAT_R16G16B16_SNORM
, ISL_FORMAT_R16G16B16_SNORM
),
161 fmt1(VK_FORMAT_R16G16B16_USCALED
, ISL_FORMAT_R16G16B16_USCALED
),
162 fmt1(VK_FORMAT_R16G16B16_SSCALED
, ISL_FORMAT_R16G16B16_SSCALED
),
163 fmt1(VK_FORMAT_R16G16B16_UINT
, ISL_FORMAT_R16G16B16_UINT
),
164 fmt1(VK_FORMAT_R16G16B16_SINT
, ISL_FORMAT_R16G16B16_SINT
),
165 fmt1(VK_FORMAT_R16G16B16_SFLOAT
, ISL_FORMAT_R16G16B16_FLOAT
),
166 fmt1(VK_FORMAT_R16G16B16A16_UNORM
, ISL_FORMAT_R16G16B16A16_UNORM
),
167 fmt1(VK_FORMAT_R16G16B16A16_SNORM
, ISL_FORMAT_R16G16B16A16_SNORM
),
168 fmt1(VK_FORMAT_R16G16B16A16_USCALED
, ISL_FORMAT_R16G16B16A16_USCALED
),
169 fmt1(VK_FORMAT_R16G16B16A16_SSCALED
, ISL_FORMAT_R16G16B16A16_SSCALED
),
170 fmt1(VK_FORMAT_R16G16B16A16_UINT
, ISL_FORMAT_R16G16B16A16_UINT
),
171 fmt1(VK_FORMAT_R16G16B16A16_SINT
, ISL_FORMAT_R16G16B16A16_SINT
),
172 fmt1(VK_FORMAT_R16G16B16A16_SFLOAT
, ISL_FORMAT_R16G16B16A16_FLOAT
),
173 fmt1(VK_FORMAT_R32_UINT
, ISL_FORMAT_R32_UINT
),
174 fmt1(VK_FORMAT_R32_SINT
, ISL_FORMAT_R32_SINT
),
175 fmt1(VK_FORMAT_R32_SFLOAT
, ISL_FORMAT_R32_FLOAT
),
176 fmt1(VK_FORMAT_R32G32_UINT
, ISL_FORMAT_R32G32_UINT
),
177 fmt1(VK_FORMAT_R32G32_SINT
, ISL_FORMAT_R32G32_SINT
),
178 fmt1(VK_FORMAT_R32G32_SFLOAT
, ISL_FORMAT_R32G32_FLOAT
),
179 fmt1(VK_FORMAT_R32G32B32_UINT
, ISL_FORMAT_R32G32B32_UINT
),
180 fmt1(VK_FORMAT_R32G32B32_SINT
, ISL_FORMAT_R32G32B32_SINT
),
181 fmt1(VK_FORMAT_R32G32B32_SFLOAT
, ISL_FORMAT_R32G32B32_FLOAT
),
182 fmt1(VK_FORMAT_R32G32B32A32_UINT
, ISL_FORMAT_R32G32B32A32_UINT
),
183 fmt1(VK_FORMAT_R32G32B32A32_SINT
, ISL_FORMAT_R32G32B32A32_SINT
),
184 fmt1(VK_FORMAT_R32G32B32A32_SFLOAT
, ISL_FORMAT_R32G32B32A32_FLOAT
),
185 fmt1(VK_FORMAT_R64_UINT
, ISL_FORMAT_R64_PASSTHRU
),
186 fmt1(VK_FORMAT_R64_SINT
, ISL_FORMAT_R64_PASSTHRU
),
187 fmt1(VK_FORMAT_R64_SFLOAT
, ISL_FORMAT_R64_PASSTHRU
),
188 fmt1(VK_FORMAT_R64G64_UINT
, ISL_FORMAT_R64G64_PASSTHRU
),
189 fmt1(VK_FORMAT_R64G64_SINT
, ISL_FORMAT_R64G64_PASSTHRU
),
190 fmt1(VK_FORMAT_R64G64_SFLOAT
, ISL_FORMAT_R64G64_PASSTHRU
),
191 fmt1(VK_FORMAT_R64G64B64_UINT
, ISL_FORMAT_R64G64B64_PASSTHRU
),
192 fmt1(VK_FORMAT_R64G64B64_SINT
, ISL_FORMAT_R64G64B64_PASSTHRU
),
193 fmt1(VK_FORMAT_R64G64B64_SFLOAT
, ISL_FORMAT_R64G64B64_PASSTHRU
),
194 fmt1(VK_FORMAT_R64G64B64A64_UINT
, ISL_FORMAT_R64G64B64A64_PASSTHRU
),
195 fmt1(VK_FORMAT_R64G64B64A64_SINT
, ISL_FORMAT_R64G64B64A64_PASSTHRU
),
196 fmt1(VK_FORMAT_R64G64B64A64_SFLOAT
, ISL_FORMAT_R64G64B64A64_PASSTHRU
),
197 fmt1(VK_FORMAT_B10G11R11_UFLOAT_PACK32
, ISL_FORMAT_R11G11B10_FLOAT
),
198 fmt1(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32
, ISL_FORMAT_R9G9B9E5_SHAREDEXP
),
200 fmt1(VK_FORMAT_D16_UNORM
, ISL_FORMAT_R16_UNORM
),
201 fmt1(VK_FORMAT_X8_D24_UNORM_PACK32
, ISL_FORMAT_R24_UNORM_X8_TYPELESS
),
202 fmt1(VK_FORMAT_D32_SFLOAT
, ISL_FORMAT_R32_FLOAT
),
203 fmt1(VK_FORMAT_S8_UINT
, ISL_FORMAT_R8_UINT
),
204 fmt_unsupported(VK_FORMAT_D16_UNORM_S8_UINT
),
205 fmt2(VK_FORMAT_D24_UNORM_S8_UINT
, ISL_FORMAT_R24_UNORM_X8_TYPELESS
, ISL_FORMAT_R8_UINT
),
206 fmt2(VK_FORMAT_D32_SFLOAT_S8_UINT
, ISL_FORMAT_R32_FLOAT
, ISL_FORMAT_R8_UINT
),
208 swiz_fmt1(VK_FORMAT_BC1_RGB_UNORM_BLOCK
, ISL_FORMAT_BC1_UNORM
, RGB1
),
209 swiz_fmt1(VK_FORMAT_BC1_RGB_SRGB_BLOCK
, ISL_FORMAT_BC1_UNORM_SRGB
, RGB1
),
210 fmt1(VK_FORMAT_BC1_RGBA_UNORM_BLOCK
, ISL_FORMAT_BC1_UNORM
),
211 fmt1(VK_FORMAT_BC1_RGBA_SRGB_BLOCK
, ISL_FORMAT_BC1_UNORM_SRGB
),
212 fmt1(VK_FORMAT_BC2_UNORM_BLOCK
, ISL_FORMAT_BC2_UNORM
),
213 fmt1(VK_FORMAT_BC2_SRGB_BLOCK
, ISL_FORMAT_BC2_UNORM_SRGB
),
214 fmt1(VK_FORMAT_BC3_UNORM_BLOCK
, ISL_FORMAT_BC3_UNORM
),
215 fmt1(VK_FORMAT_BC3_SRGB_BLOCK
, ISL_FORMAT_BC3_UNORM_SRGB
),
216 fmt1(VK_FORMAT_BC4_UNORM_BLOCK
, ISL_FORMAT_BC4_UNORM
),
217 fmt1(VK_FORMAT_BC4_SNORM_BLOCK
, ISL_FORMAT_BC4_SNORM
),
218 fmt1(VK_FORMAT_BC5_UNORM_BLOCK
, ISL_FORMAT_BC5_UNORM
),
219 fmt1(VK_FORMAT_BC5_SNORM_BLOCK
, ISL_FORMAT_BC5_SNORM
),
220 fmt1(VK_FORMAT_BC6H_UFLOAT_BLOCK
, ISL_FORMAT_BC6H_UF16
),
221 fmt1(VK_FORMAT_BC6H_SFLOAT_BLOCK
, ISL_FORMAT_BC6H_SF16
),
222 fmt1(VK_FORMAT_BC7_UNORM_BLOCK
, ISL_FORMAT_BC7_UNORM
),
223 fmt1(VK_FORMAT_BC7_SRGB_BLOCK
, ISL_FORMAT_BC7_UNORM_SRGB
),
224 fmt1(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
, ISL_FORMAT_ETC2_RGB8
),
225 fmt1(VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK
, ISL_FORMAT_ETC2_SRGB8
),
226 fmt1(VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK
, ISL_FORMAT_ETC2_RGB8_PTA
),
227 fmt1(VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK
, ISL_FORMAT_ETC2_SRGB8_PTA
),
228 fmt1(VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK
, ISL_FORMAT_ETC2_EAC_RGBA8
),
229 fmt1(VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK
, ISL_FORMAT_ETC2_EAC_SRGB8_A8
),
230 fmt1(VK_FORMAT_EAC_R11_UNORM_BLOCK
, ISL_FORMAT_EAC_R11
),
231 fmt1(VK_FORMAT_EAC_R11_SNORM_BLOCK
, ISL_FORMAT_EAC_SIGNED_R11
),
232 fmt1(VK_FORMAT_EAC_R11G11_UNORM_BLOCK
, ISL_FORMAT_EAC_RG11
),
233 fmt1(VK_FORMAT_EAC_R11G11_SNORM_BLOCK
, ISL_FORMAT_EAC_SIGNED_RG11
),
234 fmt1(VK_FORMAT_ASTC_4x4_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_4X4_U8SRGB
),
235 fmt1(VK_FORMAT_ASTC_5x4_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_5X4_U8SRGB
),
236 fmt1(VK_FORMAT_ASTC_5x5_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_5X5_U8SRGB
),
237 fmt1(VK_FORMAT_ASTC_6x5_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_6X5_U8SRGB
),
238 fmt1(VK_FORMAT_ASTC_6x6_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_6X6_U8SRGB
),
239 fmt1(VK_FORMAT_ASTC_8x5_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X5_U8SRGB
),
240 fmt1(VK_FORMAT_ASTC_8x6_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X6_U8SRGB
),
241 fmt1(VK_FORMAT_ASTC_8x8_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X8_U8SRGB
),
242 fmt1(VK_FORMAT_ASTC_10x5_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X5_U8SRGB
),
243 fmt1(VK_FORMAT_ASTC_10x6_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X6_U8SRGB
),
244 fmt1(VK_FORMAT_ASTC_10x8_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X8_U8SRGB
),
245 fmt1(VK_FORMAT_ASTC_10x10_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X10_U8SRGB
),
246 fmt1(VK_FORMAT_ASTC_12x10_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_12X10_U8SRGB
),
247 fmt1(VK_FORMAT_ASTC_12x12_SRGB_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_12X12_U8SRGB
),
248 fmt1(VK_FORMAT_ASTC_4x4_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16
),
249 fmt1(VK_FORMAT_ASTC_5x4_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_5X4_FLT16
),
250 fmt1(VK_FORMAT_ASTC_5x5_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_5X5_FLT16
),
251 fmt1(VK_FORMAT_ASTC_6x5_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_6X5_FLT16
),
252 fmt1(VK_FORMAT_ASTC_6x6_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_6X6_FLT16
),
253 fmt1(VK_FORMAT_ASTC_8x5_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X5_FLT16
),
254 fmt1(VK_FORMAT_ASTC_8x6_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X6_FLT16
),
255 fmt1(VK_FORMAT_ASTC_8x8_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_8X8_FLT16
),
256 fmt1(VK_FORMAT_ASTC_10x5_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X5_FLT16
),
257 fmt1(VK_FORMAT_ASTC_10x6_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X6_FLT16
),
258 fmt1(VK_FORMAT_ASTC_10x8_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X8_FLT16
),
259 fmt1(VK_FORMAT_ASTC_10x10_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_10X10_FLT16
),
260 fmt1(VK_FORMAT_ASTC_12x10_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_12X10_FLT16
),
261 fmt1(VK_FORMAT_ASTC_12x12_UNORM_BLOCK
, ISL_FORMAT_ASTC_LDR_2D_12X12_FLT16
),
262 fmt_unsupported(VK_FORMAT_B8G8R8_UNORM
),
263 fmt_unsupported(VK_FORMAT_B8G8R8_SNORM
),
264 fmt_unsupported(VK_FORMAT_B8G8R8_USCALED
),
265 fmt_unsupported(VK_FORMAT_B8G8R8_SSCALED
),
266 fmt_unsupported(VK_FORMAT_B8G8R8_UINT
),
267 fmt_unsupported(VK_FORMAT_B8G8R8_SINT
),
268 fmt_unsupported(VK_FORMAT_B8G8R8_SRGB
),
269 fmt1(VK_FORMAT_B8G8R8A8_UNORM
, ISL_FORMAT_B8G8R8A8_UNORM
),
270 fmt_unsupported(VK_FORMAT_B8G8R8A8_SNORM
),
271 fmt_unsupported(VK_FORMAT_B8G8R8A8_USCALED
),
272 fmt_unsupported(VK_FORMAT_B8G8R8A8_SSCALED
),
273 fmt_unsupported(VK_FORMAT_B8G8R8A8_UINT
),
274 fmt_unsupported(VK_FORMAT_B8G8R8A8_SINT
),
275 fmt1(VK_FORMAT_B8G8R8A8_SRGB
, ISL_FORMAT_B8G8R8A8_UNORM_SRGB
),
283 static const struct {
284 const struct anv_format
*formats
;
287 [0] = { .formats
= main_formats
, .n_formats
= ARRAY_SIZE(main_formats
), },
290 const struct anv_format
*
291 anv_get_format(VkFormat vk_format
)
293 uint32_t enum_offset
= VK_ENUM_OFFSET(vk_format
);
294 uint32_t ext_number
= VK_ENUM_EXTENSION(vk_format
);
296 if (ext_number
>= ARRAY_SIZE(anv_formats
) ||
297 enum_offset
>= anv_formats
[ext_number
].n_formats
)
300 const struct anv_format
*format
=
301 &anv_formats
[ext_number
].formats
[enum_offset
];
302 if (format
->planes
[0].isl_format
== ISL_FORMAT_UNSUPPORTED
)
309 * Exactly one bit must be set in \a aspect.
311 struct anv_format_plane
312 anv_get_format_plane(const struct gen_device_info
*devinfo
, VkFormat vk_format
,
313 VkImageAspectFlags aspect
, VkImageTiling tiling
)
315 const struct anv_format
*format
= anv_get_format(vk_format
);
316 struct anv_format_plane plane_format
= {
317 .isl_format
= ISL_FORMAT_UNSUPPORTED
,
323 uint32_t plane
= anv_image_aspect_to_plane(vk_format_aspects(vk_format
), aspect
);
324 plane_format
= format
->planes
[plane
];
325 if (plane_format
.isl_format
== ISL_FORMAT_UNSUPPORTED
)
328 if (aspect
& (VK_IMAGE_ASPECT_DEPTH_BIT
| VK_IMAGE_ASPECT_STENCIL_BIT
)) {
329 assert(vk_format_aspects(vk_format
) &
330 (VK_IMAGE_ASPECT_DEPTH_BIT
| VK_IMAGE_ASPECT_STENCIL_BIT
));
334 assert(aspect
== VK_IMAGE_ASPECT_COLOR_BIT
);
335 assert(vk_format_aspects(vk_format
) == VK_IMAGE_ASPECT_COLOR_BIT
);
337 const struct isl_format_layout
*isl_layout
=
338 isl_format_get_layout(plane_format
.isl_format
);
340 if (tiling
== VK_IMAGE_TILING_OPTIMAL
&&
341 !util_is_power_of_two(isl_layout
->bpb
)) {
342 /* Tiled formats *must* be power-of-two because we need up upload
343 * them with the render pipeline. For 3-channel formats, we fix
344 * this by switching them over to RGBX or RGBA formats under the
347 enum isl_format rgbx
= isl_format_rgb_to_rgbx(plane_format
.isl_format
);
348 if (rgbx
!= ISL_FORMAT_UNSUPPORTED
&&
349 isl_format_supports_rendering(devinfo
, rgbx
)) {
350 plane_format
.isl_format
= rgbx
;
352 plane_format
.isl_format
=
353 isl_format_rgb_to_rgba(plane_format
.isl_format
);
354 plane_format
.swizzle
= ISL_SWIZZLE(RED
, GREEN
, BLUE
, ONE
);
358 /* The B4G4R4A4 format isn't available prior to Broadwell so we have to fall
359 * back to a format with a more complex swizzle.
361 if (vk_format
== VK_FORMAT_B4G4R4A4_UNORM_PACK16
&& devinfo
->gen
< 8) {
362 plane_format
.isl_format
= ISL_FORMAT_B4G4R4A4_UNORM
;
363 plane_format
.swizzle
= ISL_SWIZZLE(GREEN
, RED
, ALPHA
, BLUE
);
369 // Format capabilities
371 static VkFormatFeatureFlags
372 get_image_format_properties(const struct gen_device_info
*devinfo
,
373 enum isl_format base
, struct anv_format_plane format
)
375 if (format
.isl_format
== ISL_FORMAT_UNSUPPORTED
)
378 VkFormatFeatureFlags flags
= 0;
379 if (isl_format_supports_sampling(devinfo
, format
.isl_format
)) {
380 flags
|= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
381 VK_FORMAT_FEATURE_BLIT_SRC_BIT
;
383 if (isl_format_supports_filtering(devinfo
, format
.isl_format
))
384 flags
|= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
;
387 /* We can render to swizzled formats. However, if the alpha channel is
388 * moved, then blending won't work correctly. The PRM tells us
389 * straight-up not to render to such a surface.
391 if (isl_format_supports_rendering(devinfo
, format
.isl_format
) &&
392 format
.swizzle
.a
== ISL_CHANNEL_SELECT_ALPHA
) {
393 flags
|= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
|
394 VK_FORMAT_FEATURE_BLIT_DST_BIT
;
396 if (isl_format_supports_alpha_blending(devinfo
, format
.isl_format
))
397 flags
|= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT
;
400 /* Load/store is determined based on base format. This prevents RGB
401 * formats from showing up as load/store capable.
403 if (isl_is_storage_image_format(base
))
404 flags
|= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
;
406 if (base
== ISL_FORMAT_R32_SINT
|| base
== ISL_FORMAT_R32_UINT
)
407 flags
|= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT
;
410 flags
|= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR
|
411 VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR
;
417 static VkFormatFeatureFlags
418 get_buffer_format_properties(const struct gen_device_info
*devinfo
,
419 enum isl_format format
)
421 if (format
== ISL_FORMAT_UNSUPPORTED
)
424 VkFormatFeatureFlags flags
= 0;
425 if (isl_format_supports_sampling(devinfo
, format
) &&
426 !isl_format_is_compressed(format
))
427 flags
|= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT
;
429 if (isl_format_supports_vertex_fetch(devinfo
, format
))
430 flags
|= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT
;
432 if (isl_is_storage_image_format(format
))
433 flags
|= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT
;
435 if (format
== ISL_FORMAT_R32_SINT
|| format
== ISL_FORMAT_R32_UINT
)
436 flags
|= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT
;
442 anv_physical_device_get_format_properties(struct anv_physical_device
*physical_device
,
444 VkFormatProperties
*out_properties
)
446 int gen
= physical_device
->info
.gen
* 10;
447 if (physical_device
->info
.is_haswell
)
450 const struct anv_format
*format
= anv_get_format(vk_format
);
451 VkFormatFeatureFlags linear
= 0, tiled
= 0, buffer
= 0;
452 if (format
== NULL
) {
453 /* Nothing to do here */
454 } else if (vk_format_is_depth_or_stencil(vk_format
)) {
455 tiled
|= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
;
456 if (vk_format_aspects(vk_format
) == VK_IMAGE_ASPECT_DEPTH_BIT
||
457 physical_device
->info
.gen
>= 8)
458 tiled
|= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
;
460 tiled
|= VK_FORMAT_FEATURE_BLIT_SRC_BIT
|
461 VK_FORMAT_FEATURE_BLIT_DST_BIT
|
462 VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR
|
463 VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR
;
465 struct anv_format_plane linear_fmt
, tiled_fmt
;
466 linear_fmt
= anv_get_format_plane(&physical_device
->info
, vk_format
,
467 VK_IMAGE_ASPECT_COLOR_BIT
,
468 VK_IMAGE_TILING_LINEAR
);
469 tiled_fmt
= anv_get_format_plane(&physical_device
->info
, vk_format
,
470 VK_IMAGE_ASPECT_COLOR_BIT
,
471 VK_IMAGE_TILING_OPTIMAL
);
473 linear
= get_image_format_properties(&physical_device
->info
,
474 linear_fmt
.isl_format
, linear_fmt
);
475 tiled
= get_image_format_properties(&physical_device
->info
,
476 linear_fmt
.isl_format
, tiled_fmt
);
477 buffer
= get_buffer_format_properties(&physical_device
->info
,
478 linear_fmt
.isl_format
);
480 /* XXX: We handle 3-channel formats by switching them out for RGBX or
481 * RGBA formats behind-the-scenes. This works fine for textures
482 * because the upload process will fill in the extra channel.
483 * We could also support it for render targets, but it will take
484 * substantially more work and we have enough RGBX formats to handle
485 * what most clients will want.
487 if (linear_fmt
.isl_format
!= ISL_FORMAT_UNSUPPORTED
&&
488 !util_is_power_of_two(isl_format_layouts
[linear_fmt
.isl_format
].bpb
) &&
489 isl_format_rgb_to_rgbx(linear_fmt
.isl_format
) == ISL_FORMAT_UNSUPPORTED
) {
490 tiled
&= ~VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
&
491 ~VK_FORMAT_FEATURE_BLIT_DST_BIT
;
494 /* ASTC textures must be in Y-tiled memory */
495 if (isl_format_get_layout(linear_fmt
.isl_format
)->txc
== ISL_TXC_ASTC
)
499 out_properties
->linearTilingFeatures
= linear
;
500 out_properties
->optimalTilingFeatures
= tiled
;
501 out_properties
->bufferFeatures
= buffer
;
507 void anv_GetPhysicalDeviceFormatProperties(
508 VkPhysicalDevice physicalDevice
,
510 VkFormatProperties
* pFormatProperties
)
512 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
514 anv_physical_device_get_format_properties(
520 void anv_GetPhysicalDeviceFormatProperties2KHR(
521 VkPhysicalDevice physicalDevice
,
523 VkFormatProperties2KHR
* pFormatProperties
)
525 anv_GetPhysicalDeviceFormatProperties(physicalDevice
, format
,
526 &pFormatProperties
->formatProperties
);
528 vk_foreach_struct(ext
, pFormatProperties
->pNext
) {
529 switch (ext
->sType
) {
531 anv_debug_ignored_stype(ext
->sType
);
538 anv_get_image_format_properties(
539 struct anv_physical_device
*physical_device
,
540 const VkPhysicalDeviceImageFormatInfo2KHR
*info
,
541 VkImageFormatProperties
*pImageFormatProperties
)
543 VkFormatProperties format_props
;
544 VkFormatFeatureFlags format_feature_flags
;
545 VkExtent3D maxExtent
;
546 uint32_t maxMipLevels
;
547 uint32_t maxArraySize
;
548 VkSampleCountFlags sampleCounts
= VK_SAMPLE_COUNT_1_BIT
;
549 const struct anv_format
*format
= anv_get_format(info
->format
);
554 anv_physical_device_get_format_properties(physical_device
, info
->format
,
557 /* Extract the VkFormatFeatureFlags that are relevant for the queried
560 if (info
->tiling
== VK_IMAGE_TILING_LINEAR
) {
561 format_feature_flags
= format_props
.linearTilingFeatures
;
562 } else if (info
->tiling
== VK_IMAGE_TILING_OPTIMAL
) {
563 format_feature_flags
= format_props
.optimalTilingFeatures
;
565 unreachable("bad VkImageTiling");
568 switch (info
->type
) {
570 unreachable("bad VkImageType");
571 case VK_IMAGE_TYPE_1D
:
572 maxExtent
.width
= 16384;
573 maxExtent
.height
= 1;
575 maxMipLevels
= 15; /* log2(maxWidth) + 1 */
577 sampleCounts
= VK_SAMPLE_COUNT_1_BIT
;
579 case VK_IMAGE_TYPE_2D
:
580 /* FINISHME: Does this really differ for cube maps? The documentation
581 * for RENDER_SURFACE_STATE suggests so.
583 maxExtent
.width
= 16384;
584 maxExtent
.height
= 16384;
586 maxMipLevels
= 15; /* log2(maxWidth) + 1 */
589 case VK_IMAGE_TYPE_3D
:
590 maxExtent
.width
= 2048;
591 maxExtent
.height
= 2048;
592 maxExtent
.depth
= 2048;
593 maxMipLevels
= 12; /* log2(maxWidth) + 1 */
598 /* Our hardware doesn't support 1D compressed textures.
599 * From the SKL PRM, RENDER_SURFACE_STATE::SurfaceFormat:
600 * * This field cannot be a compressed (BC*, DXT*, FXT*, ETC*, EAC*) format
601 * if the Surface Type is SURFTYPE_1D.
602 * * This field cannot be ASTC format if the Surface Type is SURFTYPE_1D.
604 if (info
->type
== VK_IMAGE_TYPE_1D
&&
605 isl_format_is_compressed(format
->planes
[0].isl_format
)) {
609 if (info
->tiling
== VK_IMAGE_TILING_OPTIMAL
&&
610 info
->type
== VK_IMAGE_TYPE_2D
&&
611 (format_feature_flags
& (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
|
612 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
)) &&
613 !(info
->flags
& VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
) &&
614 !(info
->usage
& VK_IMAGE_USAGE_STORAGE_BIT
)) {
615 sampleCounts
= isl_device_get_sample_counts(&physical_device
->isl_dev
);
618 if (info
->usage
& (VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
619 VK_IMAGE_USAGE_TRANSFER_DST_BIT
)) {
620 /* Accept transfers on anything we can sample from or renderer to. */
621 if (!(format_feature_flags
& (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
|
622 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
|
623 VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
))) {
628 if (info
->usage
& VK_IMAGE_USAGE_SAMPLED_BIT
) {
629 if (!(format_feature_flags
& VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
)) {
634 if (info
->usage
& VK_IMAGE_USAGE_STORAGE_BIT
) {
635 if (!(format_feature_flags
& VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
)) {
640 if (info
->usage
& VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
) {
641 if (!(format_feature_flags
& VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT
)) {
646 if (info
->usage
& VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
) {
647 if (!(format_feature_flags
& VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
)) {
652 if (info
->usage
& VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT
) {
653 /* Nothing to check. */
656 if (info
->usage
& VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
) {
657 /* Ignore this flag because it was removed from the
658 * provisional_I_20150910 header.
662 *pImageFormatProperties
= (VkImageFormatProperties
) {
663 .maxExtent
= maxExtent
,
664 .maxMipLevels
= maxMipLevels
,
665 .maxArrayLayers
= maxArraySize
,
666 .sampleCounts
= sampleCounts
,
668 /* FINISHME: Accurately calculate
669 * VkImageFormatProperties::maxResourceSize.
671 .maxResourceSize
= UINT32_MAX
,
677 *pImageFormatProperties
= (VkImageFormatProperties
) {
678 .maxExtent
= { 0, 0, 0 },
682 .maxResourceSize
= 0,
685 return VK_ERROR_FORMAT_NOT_SUPPORTED
;
688 VkResult
anv_GetPhysicalDeviceImageFormatProperties(
689 VkPhysicalDevice physicalDevice
,
692 VkImageTiling tiling
,
693 VkImageUsageFlags usage
,
694 VkImageCreateFlags createFlags
,
695 VkImageFormatProperties
* pImageFormatProperties
)
697 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
699 const VkPhysicalDeviceImageFormatInfo2KHR info
= {
700 .sType
= VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR
,
706 .flags
= createFlags
,
709 return anv_get_image_format_properties(physical_device
, &info
,
710 pImageFormatProperties
);
713 static const VkExternalMemoryPropertiesKHR prime_fd_props
= {
714 /* If we can handle external, then we can both import and export it. */
715 .externalMemoryFeatures
= VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR
|
716 VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR
,
717 /* For the moment, let's not support mixing and matching */
718 .exportFromImportedHandleTypes
=
719 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR
,
720 .compatibleHandleTypes
=
721 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR
,
724 VkResult
anv_GetPhysicalDeviceImageFormatProperties2KHR(
725 VkPhysicalDevice physicalDevice
,
726 const VkPhysicalDeviceImageFormatInfo2KHR
* base_info
,
727 VkImageFormatProperties2KHR
* base_props
)
729 ANV_FROM_HANDLE(anv_physical_device
, physical_device
, physicalDevice
);
730 const VkPhysicalDeviceExternalImageFormatInfoKHR
*external_info
= NULL
;
731 VkExternalImageFormatPropertiesKHR
*external_props
= NULL
;
734 result
= anv_get_image_format_properties(physical_device
, base_info
,
735 &base_props
->imageFormatProperties
);
736 if (result
!= VK_SUCCESS
)
739 /* Extract input structs */
740 vk_foreach_struct_const(s
, base_info
->pNext
) {
742 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR
:
743 external_info
= (const void *) s
;
746 anv_debug_ignored_stype(s
->sType
);
751 /* Extract output structs */
752 vk_foreach_struct(s
, base_props
->pNext
) {
754 case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR
:
755 external_props
= (void *) s
;
758 anv_debug_ignored_stype(s
->sType
);
763 /* From the Vulkan 1.0.42 spec:
765 * If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2KHR will
766 * behave as if VkPhysicalDeviceExternalImageFormatInfoKHR was not
767 * present and VkExternalImageFormatPropertiesKHR will be ignored.
769 if (external_info
&& external_info
->handleType
!= 0) {
770 switch (external_info
->handleType
) {
771 case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR
:
773 external_props
->externalMemoryProperties
= prime_fd_props
;
776 /* From the Vulkan 1.0.42 spec:
778 * If handleType is not compatible with the [parameters] specified
779 * in VkPhysicalDeviceImageFormatInfo2KHR, then
780 * vkGetPhysicalDeviceImageFormatProperties2KHR returns
781 * VK_ERROR_FORMAT_NOT_SUPPORTED.
783 result
= vk_errorf(physical_device
->instance
, physical_device
,
784 VK_ERROR_FORMAT_NOT_SUPPORTED
,
785 "unsupported VkExternalMemoryTypeFlagBitsKHR 0x%x",
786 external_info
->handleType
);
794 if (result
== VK_ERROR_FORMAT_NOT_SUPPORTED
) {
795 /* From the Vulkan 1.0.42 spec:
797 * If the combination of parameters to
798 * vkGetPhysicalDeviceImageFormatProperties2KHR is not supported by
799 * the implementation for use in vkCreateImage, then all members of
800 * imageFormatProperties will be filled with zero.
802 base_props
->imageFormatProperties
= (VkImageFormatProperties
) {};
808 void anv_GetPhysicalDeviceSparseImageFormatProperties(
809 VkPhysicalDevice physicalDevice
,
813 VkImageUsageFlags usage
,
814 VkImageTiling tiling
,
815 uint32_t* pNumProperties
,
816 VkSparseImageFormatProperties
* pProperties
)
818 /* Sparse images are not yet supported. */
822 void anv_GetPhysicalDeviceSparseImageFormatProperties2KHR(
823 VkPhysicalDevice physicalDevice
,
824 const VkPhysicalDeviceSparseImageFormatInfo2KHR
* pFormatInfo
,
825 uint32_t* pPropertyCount
,
826 VkSparseImageFormatProperties2KHR
* pProperties
)
828 /* Sparse images are not yet supported. */
832 void anv_GetPhysicalDeviceExternalBufferPropertiesKHR(
833 VkPhysicalDevice physicalDevice
,
834 const VkPhysicalDeviceExternalBufferInfoKHR
* pExternalBufferInfo
,
835 VkExternalBufferPropertiesKHR
* pExternalBufferProperties
)
837 /* The Vulkan 1.0.42 spec says "handleType must be a valid
838 * VkExternalMemoryHandleTypeFlagBitsKHR value" in
839 * VkPhysicalDeviceExternalBufferInfoKHR. This differs from
840 * VkPhysicalDeviceExternalImageFormatInfoKHR, which surprisingly permits
843 assert(pExternalBufferInfo
->handleType
!= 0);
845 /* All of the current flags are for sparse which we don't support yet.
846 * Even when we do support it, doing sparse on external memory sounds
847 * sketchy. Also, just disallowing flags is the safe option.
849 if (pExternalBufferInfo
->flags
)
852 switch (pExternalBufferInfo
->handleType
) {
853 case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR
:
854 pExternalBufferProperties
->externalMemoryProperties
= prime_fd_props
;
861 pExternalBufferProperties
->externalMemoryProperties
=
862 (VkExternalMemoryPropertiesKHR
) {0};