diff options
author | Jason Ekstrand <[email protected]> | 2017-02-28 10:58:40 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-04-27 20:08:46 -0700 |
commit | 9bd1f0348734e5dbbdc84e96ac1f11836427ed7c (patch) | |
tree | ec7203946ba99bc2d5823042b7eaf846998c15ac /src/intel/vulkan/anv_formats.c | |
parent | 818b8579145196c7a8d4095bd5e65367e02a8fef (diff) |
anv: Implement VK_KHX_external_memory_fd
This commit just exposes the memory handle type. There's interesting we
need to do here for images. So long as the user doesn't set any crazy
environment variables such as INTEL_DEBUG=nohiz, all of the compression
formats etc. should "just work" at least for opaque handle types.
v2 (chadv):
- Rebase.
- Fix vkGetPhysicalDeviceImageFormatProperties2KHR when
handleType == 0.
- Move handleType-independency comments out of handleType-switch, in
vkGetPhysicalDeviceExternalBufferPropertiesKHX. Reduces diff in
future dma_buf patches.
Co-authored-with: Chad Versace <[email protected]>
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_formats.c')
-rw-r--r-- | src/intel/vulkan/anv_formats.c | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index b250931d4bf..4c930eda1dd 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -656,6 +656,17 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( pImageFormatProperties); } +static const VkExternalMemoryPropertiesKHX prime_fd_props = { + /* If we can handle external, then we can both import and export it. */ + .externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHX | + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHX, + /* For the moment, let's not support mixing and matching */ + .exportFromImportedHandleTypes = + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX, + .compatibleHandleTypes = + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX, +}; + VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* base_info, @@ -702,13 +713,23 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR( * present and VkExternalImageFormatPropertiesKHX will be ignored. */ if (external_info && external_info->handleType != 0) { - /* FINISHME: Support at least one external memory type for images. */ - (void) external_props; - - result = vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED, - "unsupported VkExternalMemoryTypeFlagBitsKHX 0x%x", - external_info->handleType); - goto fail; + switch (external_info->handleType) { + case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX: + external_props->externalMemoryProperties = prime_fd_props; + break; + default: + /* From the Vulkan 1.0.42 spec: + * + * If handleType is not compatible with the [parameters] specified + * in VkPhysicalDeviceImageFormatInfo2KHR, then + * vkGetPhysicalDeviceImageFormatProperties2KHR returns + * VK_ERROR_FORMAT_NOT_SUPPORTED. + */ + result = vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED, + "unsupported VkExternalMemoryTypeFlagBitsKHX 0x%x", + external_info->handleType); + goto fail; + } } return VK_SUCCESS; @@ -757,8 +778,30 @@ void anv_GetPhysicalDeviceExternalBufferPropertiesKHX( const VkPhysicalDeviceExternalBufferInfoKHX* pExternalBufferInfo, VkExternalBufferPropertiesKHX* pExternalBufferProperties) { - anv_finishme("Handle external buffers"); + /* The Vulkan 1.0.42 spec says "handleType must be a valid + * VkExternalMemoryHandleTypeFlagBitsKHX value" in + * VkPhysicalDeviceExternalBufferInfoKHX. This differs from + * VkPhysicalDeviceExternalImageFormatInfoKHX, which surprisingly permits + * handleType == 0. + */ + assert(pExternalBufferInfo->handleType != 0); + + /* All of the current flags are for sparse which we don't support yet. + * Even when we do support it, doing sparse on external memory sounds + * sketchy. Also, just disallowing flags is the safe option. + */ + if (pExternalBufferInfo->flags) + goto unsupported; + + switch (pExternalBufferInfo->handleType) { + case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX: + pExternalBufferProperties->externalMemoryProperties = prime_fd_props; + return; + default: + goto unsupported; + } + unsupported: pExternalBufferProperties->externalMemoryProperties = (VkExternalMemoryPropertiesKHX) {0}; } |