Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/broadcom/vulkan/v3dv_formats.c
4560 views
1
/*
2
* Copyright © 2019 Raspberry Pi
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 "v3dv_private.h"
25
#include "vk_util.h"
26
#include "vk_format_info.h"
27
28
#include "drm-uapi/drm_fourcc.h"
29
#include "util/format/u_format.h"
30
#include "vulkan/wsi/wsi_common.h"
31
32
const uint8_t *
33
v3dv_get_format_swizzle(struct v3dv_device *device, VkFormat f)
34
{
35
const struct v3dv_format *vf = v3dv_X(device, get_format)(f);
36
static const uint8_t fallback[] = {0, 1, 2, 3};
37
38
if (!vf)
39
return fallback;
40
41
return vf->swizzle;
42
}
43
44
uint8_t
45
v3dv_get_tex_return_size(const struct v3dv_format *vf,
46
bool compare_enable)
47
{
48
if (compare_enable)
49
return 16;
50
51
return vf->return_size;
52
}
53
54
/* Some cases of transfer operations are raw data copies that don't depend
55
* on the semantics of the pixel format (no pixel format conversions are
56
* involved). In these cases, it is safe to choose any format supported by
57
* the TFU so long as it has the same texel size, which allows us to use the
58
* TFU paths with formats that are not TFU supported otherwise.
59
*/
60
const struct v3dv_format *
61
v3dv_get_compatible_tfu_format(struct v3dv_device *device,
62
uint32_t bpp,
63
VkFormat *out_vk_format)
64
{
65
VkFormat vk_format;
66
switch (bpp) {
67
case 16: vk_format = VK_FORMAT_R32G32B32A32_SFLOAT; break;
68
case 8: vk_format = VK_FORMAT_R16G16B16A16_SFLOAT; break;
69
case 4: vk_format = VK_FORMAT_R32_SFLOAT; break;
70
case 2: vk_format = VK_FORMAT_R16_SFLOAT; break;
71
case 1: vk_format = VK_FORMAT_R8_UNORM; break;
72
default: unreachable("unsupported format bit-size"); break;
73
};
74
75
if (out_vk_format)
76
*out_vk_format = vk_format;
77
78
const struct v3dv_format *format = v3dv_X(device, get_format)(vk_format);
79
assert(v3dv_X(device, tfu_supports_tex_format)(format->tex_type));
80
81
return format;
82
}
83
84
static VkFormatFeatureFlags
85
image_format_features(struct v3dv_physical_device *pdevice,
86
VkFormat vk_format,
87
const struct v3dv_format *v3dv_format,
88
VkImageTiling tiling)
89
{
90
if (!v3dv_format || !v3dv_format->supported)
91
return 0;
92
93
const VkImageAspectFlags aspects = vk_format_aspects(vk_format);
94
95
const VkImageAspectFlags zs_aspects = VK_IMAGE_ASPECT_DEPTH_BIT |
96
VK_IMAGE_ASPECT_STENCIL_BIT;
97
const VkImageAspectFlags supported_aspects = VK_IMAGE_ASPECT_COLOR_BIT |
98
zs_aspects;
99
if ((aspects & supported_aspects) != aspects)
100
return 0;
101
102
/* FIXME: We don't support separate stencil yet */
103
if ((aspects & zs_aspects) == VK_IMAGE_ASPECT_STENCIL_BIT)
104
return 0;
105
106
if (v3dv_format->tex_type == TEXTURE_DATA_FORMAT_NO &&
107
v3dv_format->rt_type == V3D_OUTPUT_IMAGE_FORMAT_NO) {
108
return 0;
109
}
110
111
VkFormatFeatureFlags flags = 0;
112
113
/* Raster format is only supported for 1D textures, so let's just
114
* always require optimal tiling for anything that requires sampling.
115
* Note: even if the user requests optimal for a 1D image, we will still
116
* use raster format since that is what the HW requires.
117
*/
118
if (v3dv_format->tex_type != TEXTURE_DATA_FORMAT_NO &&
119
tiling == VK_IMAGE_TILING_OPTIMAL) {
120
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
121
VK_FORMAT_FEATURE_BLIT_SRC_BIT;
122
123
if (v3dv_format->supports_filtering)
124
flags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
125
}
126
127
if (v3dv_format->rt_type != V3D_OUTPUT_IMAGE_FORMAT_NO) {
128
if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
129
flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
130
VK_FORMAT_FEATURE_BLIT_DST_BIT;
131
if (v3dv_X(pdevice, format_supports_blending)(v3dv_format))
132
flags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
133
} else if (aspects & zs_aspects) {
134
flags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
135
VK_FORMAT_FEATURE_BLIT_DST_BIT;
136
}
137
}
138
139
const struct util_format_description *desc =
140
vk_format_description(vk_format);
141
assert(desc);
142
143
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN && desc->is_array) {
144
flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
145
if (desc->nr_channels == 1 && vk_format_is_int(vk_format))
146
flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT;
147
} else if (vk_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32 ||
148
vk_format == VK_FORMAT_A2B10G10R10_UINT_PACK32 ||
149
vk_format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) {
150
/* To comply with shaderStorageImageExtendedFormats */
151
flags |= VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT;
152
}
153
154
if (flags) {
155
flags |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
156
VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
157
}
158
159
return flags;
160
}
161
162
static VkFormatFeatureFlags
163
buffer_format_features(VkFormat vk_format, const struct v3dv_format *v3dv_format)
164
{
165
if (!v3dv_format || !v3dv_format->supported)
166
return 0;
167
168
if (!v3dv_format->supported)
169
return 0;
170
171
/* We probably only want to support buffer formats that have a
172
* color format specification.
173
*/
174
if (!vk_format_is_color(vk_format))
175
return 0;
176
177
const struct util_format_description *desc =
178
vk_format_description(vk_format);
179
assert(desc);
180
181
VkFormatFeatureFlags flags = 0;
182
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
183
desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB &&
184
desc->is_array) {
185
flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
186
if (v3dv_format->tex_type != TEXTURE_DATA_FORMAT_NO) {
187
flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT |
188
VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
189
}
190
} else if (vk_format == VK_FORMAT_A2B10G10R10_UNORM_PACK32) {
191
flags |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT |
192
VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT |
193
VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
194
} else if (vk_format == VK_FORMAT_A2B10G10R10_UINT_PACK32 ||
195
vk_format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) {
196
flags |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT |
197
VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT;
198
}
199
200
if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN &&
201
desc->is_array &&
202
desc->nr_channels == 1 &&
203
vk_format_is_int(vk_format)) {
204
flags |= VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT;
205
}
206
207
return flags;
208
}
209
210
bool
211
v3dv_buffer_format_supports_features(struct v3dv_device *device,
212
VkFormat vk_format,
213
VkFormatFeatureFlags features)
214
{
215
const struct v3dv_format *v3dv_format = v3dv_X(device, get_format)(vk_format);
216
const VkFormatFeatureFlags supported =
217
buffer_format_features(vk_format, v3dv_format);
218
return (supported & features) == features;
219
}
220
221
VKAPI_ATTR void VKAPI_CALL
222
v3dv_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
223
VkFormat format,
224
VkFormatProperties* pFormatProperties)
225
{
226
V3DV_FROM_HANDLE(v3dv_physical_device, pdevice, physicalDevice);
227
const struct v3dv_format *v3dv_format = v3dv_X(pdevice, get_format)(format);
228
229
*pFormatProperties = (VkFormatProperties) {
230
.linearTilingFeatures =
231
image_format_features(pdevice, format, v3dv_format, VK_IMAGE_TILING_LINEAR),
232
.optimalTilingFeatures =
233
image_format_features(pdevice, format, v3dv_format, VK_IMAGE_TILING_OPTIMAL),
234
.bufferFeatures =
235
buffer_format_features(format, v3dv_format),
236
};
237
}
238
239
VKAPI_ATTR void VKAPI_CALL
240
v3dv_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,
241
VkFormat format,
242
VkFormatProperties2 *pFormatProperties)
243
{
244
v3dv_GetPhysicalDeviceFormatProperties(physicalDevice, format,
245
&pFormatProperties->formatProperties);
246
247
vk_foreach_struct(ext, pFormatProperties->pNext) {
248
switch ((unsigned)ext->sType) {
249
case VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT: {
250
struct VkDrmFormatModifierPropertiesListEXT *list = (void *)ext;
251
VK_OUTARRAY_MAKE(out, list->pDrmFormatModifierProperties,
252
&list->drmFormatModifierCount);
253
if (pFormatProperties->formatProperties.linearTilingFeatures) {
254
vk_outarray_append(&out, mod_props) {
255
mod_props->drmFormatModifier = DRM_FORMAT_MOD_LINEAR;
256
mod_props->drmFormatModifierPlaneCount = 1;
257
}
258
}
259
if (pFormatProperties->formatProperties.optimalTilingFeatures) {
260
vk_outarray_append(&out, mod_props) {
261
mod_props->drmFormatModifier = DRM_FORMAT_MOD_BROADCOM_UIF;
262
mod_props->drmFormatModifierPlaneCount = 1;
263
}
264
}
265
break;
266
}
267
default:
268
v3dv_debug_ignored_stype(ext->sType);
269
break;
270
}
271
}
272
}
273
274
static VkResult
275
get_image_format_properties(
276
struct v3dv_physical_device *physical_device,
277
const VkPhysicalDeviceImageFormatInfo2 *info,
278
VkImageTiling tiling,
279
VkImageFormatProperties *pImageFormatProperties,
280
VkSamplerYcbcrConversionImageFormatProperties *pYcbcrImageFormatProperties)
281
{
282
const struct v3dv_format *v3dv_format = v3dv_X(physical_device, get_format)(info->format);
283
VkFormatFeatureFlags format_feature_flags =
284
image_format_features(physical_device, info->format, v3dv_format, tiling);
285
if (!format_feature_flags)
286
goto unsupported;
287
288
/* This allows users to create uncompressed views of compressed images,
289
* however this is not something the hardware supports naturally and requires
290
* the driver to lie when programming the texture state to make the hardware
291
* sample with the uncompressed view correctly, and even then, there are
292
* issues when running on real hardware.
293
*
294
* See https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11336
295
* for details.
296
*/
297
if (info->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT)
298
goto unsupported;
299
300
if (info->usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
301
if (!(format_feature_flags & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT)) {
302
goto unsupported;
303
}
304
305
/* Sampling of raster depth/stencil images is not supported. Since 1D
306
* images are always raster, even if the user requested optimal tiling,
307
* we can't have them be used as transfer sources, since that includes
308
* using them for blit sources, which might require sampling.
309
*/
310
if (info->type == VK_IMAGE_TYPE_1D &&
311
vk_format_is_depth_or_stencil(info->format)) {
312
goto unsupported;
313
}
314
}
315
316
if (info->usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) {
317
if (!(format_feature_flags & VK_FORMAT_FEATURE_TRANSFER_DST_BIT)) {
318
goto unsupported;
319
}
320
}
321
322
if (info->usage & VK_IMAGE_USAGE_SAMPLED_BIT) {
323
if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) {
324
goto unsupported;
325
}
326
327
/* Sampling of raster depth/stencil images is not supported. Since 1D
328
* images are always raster, even if the user requested optimal tiling,
329
* we can't allow sampling if the format is depth/stencil.
330
*/
331
if (info->type == VK_IMAGE_TYPE_1D &&
332
vk_format_is_depth_or_stencil(info->format)) {
333
goto unsupported;
334
}
335
}
336
337
if (info->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
338
if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) {
339
goto unsupported;
340
}
341
}
342
343
if (info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
344
if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) {
345
goto unsupported;
346
}
347
}
348
349
if (info->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
350
if (!(format_feature_flags &
351
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
352
goto unsupported;
353
}
354
}
355
356
/* FIXME: these are taken from VkPhysicalDeviceLimits, we should just put
357
* these limits available in the physical device and read them from there
358
* wherever we need them.
359
*/
360
switch (info->type) {
361
case VK_IMAGE_TYPE_1D:
362
pImageFormatProperties->maxExtent.width = 4096;
363
pImageFormatProperties->maxExtent.height = 1;
364
pImageFormatProperties->maxExtent.depth = 1;
365
pImageFormatProperties->maxArrayLayers = 2048;
366
pImageFormatProperties->maxMipLevels = 13; /* log2(maxWidth) + 1 */
367
break;
368
case VK_IMAGE_TYPE_2D:
369
pImageFormatProperties->maxExtent.width = 4096;
370
pImageFormatProperties->maxExtent.height = 4096;
371
pImageFormatProperties->maxExtent.depth = 1;
372
pImageFormatProperties->maxArrayLayers = 2048;
373
pImageFormatProperties->maxMipLevels = 13; /* log2(maxWidth) + 1 */
374
break;
375
case VK_IMAGE_TYPE_3D:
376
pImageFormatProperties->maxExtent.width = 4096;
377
pImageFormatProperties->maxExtent.height = 4096;
378
pImageFormatProperties->maxExtent.depth = 4096;
379
pImageFormatProperties->maxArrayLayers = 1;
380
pImageFormatProperties->maxMipLevels = 13; /* log2(maxWidth) + 1 */
381
break;
382
default:
383
unreachable("bad VkImageType");
384
}
385
386
/* Our hw doesn't support 1D compressed textures. */
387
if (info->type == VK_IMAGE_TYPE_1D &&
388
vk_format_is_compressed(info->format)) {
389
goto unsupported;
390
}
391
392
/* From the Vulkan 1.0 spec, section 34.1.1. Supported Sample Counts:
393
*
394
* sampleCounts will be set to VK_SAMPLE_COUNT_1_BIT if at least one of the
395
* following conditions is true:
396
*
397
* - tiling is VK_IMAGE_TILING_LINEAR
398
* - type is not VK_IMAGE_TYPE_2D
399
* - flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
400
* - neither the VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT flag nor the
401
* VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT flag in
402
* VkFormatProperties::optimalTilingFeatures returned by
403
* vkGetPhysicalDeviceFormatProperties is set.
404
*/
405
pImageFormatProperties->sampleCounts = VK_SAMPLE_COUNT_1_BIT;
406
if (tiling != VK_IMAGE_TILING_LINEAR &&
407
info->type == VK_IMAGE_TYPE_2D &&
408
!(info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) &&
409
(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT ||
410
format_feature_flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) {
411
pImageFormatProperties->sampleCounts |= VK_SAMPLE_COUNT_4_BIT;
412
}
413
414
if (tiling == VK_IMAGE_TILING_LINEAR)
415
pImageFormatProperties->maxMipLevels = 1;
416
417
pImageFormatProperties->maxResourceSize = 0xffffffff; /* 32-bit allocation */
418
419
return VK_SUCCESS;
420
421
unsupported:
422
*pImageFormatProperties = (VkImageFormatProperties) {
423
.maxExtent = { 0, 0, 0 },
424
.maxMipLevels = 0,
425
.maxArrayLayers = 0,
426
.sampleCounts = 0,
427
.maxResourceSize = 0,
428
};
429
430
return VK_ERROR_FORMAT_NOT_SUPPORTED;
431
}
432
433
static const VkExternalMemoryProperties prime_fd_props = {
434
.externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT |
435
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT,
436
.exportFromImportedHandleTypes =
437
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
438
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
439
.compatibleHandleTypes =
440
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
441
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
442
};
443
444
VKAPI_ATTR VkResult VKAPI_CALL
445
v3dv_GetPhysicalDeviceImageFormatProperties(
446
VkPhysicalDevice physicalDevice,
447
VkFormat format,
448
VkImageType type,
449
VkImageTiling tiling,
450
VkImageUsageFlags usage,
451
VkImageCreateFlags createFlags,
452
VkImageFormatProperties *pImageFormatProperties)
453
{
454
V3DV_FROM_HANDLE(v3dv_physical_device, physical_device, physicalDevice);
455
456
const VkPhysicalDeviceImageFormatInfo2 info = {
457
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
458
.pNext = NULL,
459
.format = format,
460
.type = type,
461
.tiling = tiling,
462
.usage = usage,
463
.flags = createFlags,
464
};
465
466
return get_image_format_properties(physical_device, &info, tiling,
467
pImageFormatProperties, NULL);
468
}
469
470
VKAPI_ATTR VkResult VKAPI_CALL
471
v3dv_GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
472
const VkPhysicalDeviceImageFormatInfo2 *base_info,
473
VkImageFormatProperties2 *base_props)
474
{
475
V3DV_FROM_HANDLE(v3dv_physical_device, physical_device, physicalDevice);
476
const VkPhysicalDeviceExternalImageFormatInfo *external_info = NULL;
477
const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *drm_format_mod_info = NULL;
478
VkExternalImageFormatProperties *external_props = NULL;
479
VkImageTiling tiling = base_info->tiling;
480
481
/* Extract input structs */
482
vk_foreach_struct_const(s, base_info->pNext) {
483
switch (s->sType) {
484
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
485
external_info = (const void *) s;
486
break;
487
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
488
drm_format_mod_info = (const void *) s;
489
switch (drm_format_mod_info->drmFormatModifier) {
490
case DRM_FORMAT_MOD_LINEAR:
491
tiling = VK_IMAGE_TILING_LINEAR;
492
break;
493
case DRM_FORMAT_MOD_BROADCOM_UIF:
494
tiling = VK_IMAGE_TILING_OPTIMAL;
495
break;
496
default:
497
assert("Unknown DRM format modifier");
498
}
499
break;
500
default:
501
v3dv_debug_ignored_stype(s->sType);
502
break;
503
}
504
}
505
506
assert(tiling == VK_IMAGE_TILING_OPTIMAL ||
507
tiling == VK_IMAGE_TILING_LINEAR);
508
509
/* Extract output structs */
510
vk_foreach_struct(s, base_props->pNext) {
511
switch (s->sType) {
512
case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
513
external_props = (void *) s;
514
break;
515
default:
516
v3dv_debug_ignored_stype(s->sType);
517
break;
518
}
519
}
520
521
VkResult result =
522
get_image_format_properties(physical_device, base_info, tiling,
523
&base_props->imageFormatProperties, NULL);
524
if (result != VK_SUCCESS)
525
goto done;
526
527
if (external_info && external_info->handleType != 0) {
528
switch (external_info->handleType) {
529
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT:
530
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
531
if (external_props)
532
external_props->externalMemoryProperties = prime_fd_props;
533
break;
534
default:
535
result = VK_ERROR_FORMAT_NOT_SUPPORTED;
536
break;
537
}
538
}
539
540
done:
541
return result;
542
}
543
544
VKAPI_ATTR void VKAPI_CALL
545
v3dv_GetPhysicalDeviceSparseImageFormatProperties(
546
VkPhysicalDevice physicalDevice,
547
VkFormat format,
548
VkImageType type,
549
VkSampleCountFlagBits samples,
550
VkImageUsageFlags usage,
551
VkImageTiling tiling,
552
uint32_t *pPropertyCount,
553
VkSparseImageFormatProperties *pProperties)
554
{
555
*pPropertyCount = 0;
556
}
557
558
VKAPI_ATTR void VKAPI_CALL
559
v3dv_GetPhysicalDeviceSparseImageFormatProperties2(
560
VkPhysicalDevice physicalDevice,
561
const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo,
562
uint32_t *pPropertyCount,
563
VkSparseImageFormatProperties2 *pProperties)
564
{
565
*pPropertyCount = 0;
566
}
567
568
VKAPI_ATTR void VKAPI_CALL
569
v3dv_GetPhysicalDeviceExternalBufferProperties(
570
VkPhysicalDevice physicalDevice,
571
const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo,
572
VkExternalBufferProperties *pExternalBufferProperties)
573
{
574
switch (pExternalBufferInfo->handleType) {
575
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT:
576
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT:
577
pExternalBufferProperties->externalMemoryProperties = prime_fd_props;
578
return;
579
default: /* Unsupported */
580
pExternalBufferProperties->externalMemoryProperties =
581
(VkExternalMemoryProperties) {
582
.compatibleHandleTypes = pExternalBufferInfo->handleType,
583
};
584
break;
585
}
586
}
587
588