.extensionName = VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
.specVersion = 1,
},
- {
- .extensionName = VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
- .specVersion = 1,
- },
};
static const VkExtensionProperties common_device_extensions[] = {
.extensionName = VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME,
.specVersion = 1,
},
- {
- .extensionName = VK_KHX_EXTERNAL_MEMORY_EXTENSION_NAME,
- .specVersion = 1,
- },
- {
- .extensionName = VK_KHX_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
- .specVersion = 1,
- },
};
static VkResult
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties2KHR *pProperties)
{
- RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
radv_GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
vk_foreach_struct(ext, pProperties->pNext) {
properties->maxPushDescriptors = MAX_PUSH_DESCRIPTORS;
break;
}
- case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHX: {
- VkPhysicalDeviceIDPropertiesKHX *properties = (VkPhysicalDeviceIDPropertiesKHX*)ext;
- radv_device_get_cache_uuid(0, properties->driverUUID);
- memcpy(properties->deviceUUID, pdevice->device_uuid, VK_UUID_SIZE);
- properties->deviceLUIDValid = false;
- break;
- }
default:
break;
}
*pMem = VK_NULL_HANDLE;
return VK_SUCCESS;
}
-
- const VkImportMemoryFdInfoKHX *import_info =
- vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHX);
const VkDedicatedAllocationMemoryAllocateInfoNV *dedicate_info =
vk_find_struct_const(pAllocateInfo->pNext, DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV);
mem->buffer = NULL;
}
- if (import_info) {
- assert(import_info->handleType ==
- VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX);
- mem->bo = device->ws->buffer_from_fd(device->ws, import_info->fd,
- NULL, NULL);
- if (!mem->bo) {
- result = VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX;
- goto fail;
- } else
- goto out_success;
- }
-
uint64_t alloc_size = align_u64(pAllocateInfo->allocationSize, 4096);
if (pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_WRITE_COMBINE ||
pAllocateInfo->memoryTypeIndex == RADV_MEM_TYPE_GTT_CACHED)
goto fail;
}
mem->type_index = pAllocateInfo->memoryTypeIndex;
-out_success:
+
*pMem = radv_device_memory_to_handle(mem);
return VK_SUCCESS;
*pSupportedVersion = MIN2(*pSupportedVersion, 3u);
return VK_SUCCESS;
}
-
-VkResult radv_GetMemoryFdKHX(VkDevice _device,
- VkDeviceMemory _memory,
- VkExternalMemoryHandleTypeFlagsKHX handleType,
- int *pFD)
-{
- RADV_FROM_HANDLE(radv_device, device, _device);
- RADV_FROM_HANDLE(radv_device_memory, memory, _memory);
-
- /* We support only one handle type. */
- assert(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX);
-
- bool ret = radv_get_memory_fd(device, memory, pFD);
- if (ret == false)
- return VK_ERROR_OUT_OF_DEVICE_MEMORY;
- return VK_SUCCESS;
-}
-
-VkResult radv_GetMemoryFdPropertiesKHX(VkDevice _device,
- VkExternalMemoryHandleTypeFlagBitsKHX handleType,
- int fd,
- VkMemoryFdPropertiesKHX *pMemoryFdProperties)
-{
- /* The valid usage section for this function says:
- *
- * "handleType must not be one of the handle types defined as opaque."
- *
- * Since we only handle opaque handles for now, there are no FD properties.
- */
- return VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX;
-}
pImageFormatProperties);
}
-static void
-get_external_image_format_properties(const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo,
- VkExternalMemoryPropertiesKHX *external_properties)
-{
- VkExternalMemoryFeatureFlagBitsKHX flags = 0;
- VkExternalMemoryHandleTypeFlagsKHX export_flags = 0;
- VkExternalMemoryHandleTypeFlagsKHX compat_flags = 0;
- switch (pImageFormatInfo->type) {
- case VK_IMAGE_TYPE_2D:
- flags = VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHX|VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHX|VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHX;
- compat_flags = export_flags = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX;
- break;
- default:
- break;
- }
-
- *external_properties = (VkExternalMemoryPropertiesKHX) {
- .externalMemoryFeatures = flags,
- .exportFromImportedHandleTypes = export_flags,
- .compatibleHandleTypes = compat_flags,
- };
-}
-
VkResult radv_GetPhysicalDeviceImageFormatProperties2KHR(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceImageFormatInfo2KHR *base_info,
VkImageFormatProperties2KHR *base_props)
{
RADV_FROM_HANDLE(radv_physical_device, physical_device, physicalDevice);
- const VkPhysicalDeviceExternalImageFormatInfoKHX *external_info = NULL;
- VkExternalImageFormatPropertiesKHX *external_props = NULL;
VkResult result;
result = radv_get_image_format_properties(physical_device, base_info,
if (result != VK_SUCCESS)
return result;
- /* Extract input structs */
- vk_foreach_struct_const(s, base_info->pNext) {
- switch (s->sType) {
- case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHX:
- external_info = (const void *) s;
- break;
- default:
- break;
- }
- }
-
- /* Extract output structs */
- vk_foreach_struct(s, base_props->pNext) {
- switch (s->sType) {
- case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHX:
- external_props = (void *) s;
- break;
- default:
- break;
- }
- }
-
- /* From the Vulkan 1.0.42 spec:
- *
- * If handleType is 0, vkGetPhysicalDeviceImageFormatProperties2KHR will
- * behave as if VkPhysicalDeviceExternalImageFormatInfoKHX was not
- * present and VkExternalImageFormatPropertiesKHX will be ignored.
- */
- if (external_info && external_info->handleType != 0) {
- switch (external_info->handleType) {
- case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX:
- get_external_image_format_properties(base_info, &external_props->externalMemoryProperties);
- 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;
-
-fail:
- if (result == VK_ERROR_FORMAT_NOT_SUPPORTED) {
- /* From the Vulkan 1.0.42 spec:
- *
- * If the combination of parameters to
- * vkGetPhysicalDeviceImageFormatProperties2KHR is not supported by
- * the implementation for use in vkCreateImage, then all members of
- * imageFormatProperties will be filled with zero.
- */
- base_props->imageFormatProperties = (VkImageFormatProperties) {0};
- }
-
- return result;
}
void radv_GetPhysicalDeviceSparseImageFormatProperties(
/* Sparse images are not yet supported. */
*pPropertyCount = 0;
}
-
-void radv_GetPhysicalDeviceExternalBufferPropertiesKHX(
- VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceExternalBufferInfoKHX *pExternalBufferInfo,
- VkExternalBufferPropertiesKHX *pExternalBufferProperties)
-{
- VkExternalMemoryFeatureFlagBitsKHX flags = 0;
- VkExternalMemoryHandleTypeFlagsKHX export_flags = 0;
- VkExternalMemoryHandleTypeFlagsKHX compat_flags = 0;
- switch(pExternalBufferInfo->handleType) {
- case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX:
- flags = VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHX |
- VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHX |
- VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHX;
- compat_flags = export_flags = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX;
- break;
- default:
- break;
- }
- pExternalBufferProperties->externalMemoryProperties = (VkExternalMemoryPropertiesKHX) {
- .externalMemoryFeatures = flags,
- .exportFromImportedHandleTypes = export_flags,
- .compatibleHandleTypes = compat_flags,
- };
-}