From fec27a3f6e3bae96a8f3e784d6d643afb41989d6 Mon Sep 17 00:00:00 2001 From: Artem Kharytoniuk Date: Fri, 5 May 2023 23:12:12 +0200 Subject: mock: Extend external memory functionality GetPhysicalDeviceExternalBufferProperties changes: Previous implementation violated property that handle type is at least compatible with itself. It's needed to implement testing for VUID-VkMemoryAllocateInfo-pNext-00639 GetFenceWin32HandleKHR/GetFenceFdKHR changes: Return not null handles to pass VUID-VkImportFenceWin32HandleInfoKHR-handle-01462 --- icd/generated/mock_icd.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'icd/generated/mock_icd.cpp') diff --git a/icd/generated/mock_icd.cpp b/icd/generated/mock_icd.cpp index 845ced49..8c193180 100644 --- a/icd/generated/mock_icd.cpp +++ b/icd/generated/mock_icd.cpp @@ -2020,10 +2020,19 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalBufferProperties( const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties) { - // Hard-code support for all handle types and features - pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0x7; - pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = 0x1FF; - pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = 0x1FF; + constexpr VkExternalMemoryHandleTypeFlags supported_flags = 0x1FF; + if (pExternalBufferInfo->handleType & supported_flags) { + pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0x7; + pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = supported_flags; + pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = supported_flags; + } else { + pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0; + pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = 0; + // According to spec, handle type is always compatible with itself. Even if export/import + // not supported, it's important to properly implement self-compatibility property since + // application's control flow can rely on this. + pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = pExternalBufferInfo->handleType; + } } static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalFenceProperties( @@ -3504,7 +3513,7 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetFenceWin32HandleKHR( const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { -//Not a CREATE or DESTROY function + *pHandle = (HANDLE)0x12345678; return VK_SUCCESS; } #endif /* VK_USE_PLATFORM_WIN32_KHR */ @@ -3523,7 +3532,7 @@ static VKAPI_ATTR VkResult VKAPI_CALL GetFenceFdKHR( const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd) { -//Not a CREATE or DESTROY function + *pFd = 0x42; return VK_SUCCESS; } -- cgit v1.2.3