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 --- scripts/mock_icd_generator.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index 0a0e8adc..22b7d1ff 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -1016,10 +1016,19 @@ CUSTOM_C_INTERCEPTS = { GetPhysicalDeviceExternalFenceProperties(physicalDevice, pExternalFenceInfo, pExternalFenceProperties); ''', 'vkGetPhysicalDeviceExternalBufferProperties':''' - // 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; + } ''', 'vkGetPhysicalDeviceExternalBufferPropertiesKHR':''' GetPhysicalDeviceExternalBufferProperties(physicalDevice, pExternalBufferInfo, pExternalBufferProperties); @@ -1210,6 +1219,14 @@ CUSTOM_C_INTERCEPTS = { } return VK_SUCCESS; ''', +'vkGetFenceWin32HandleKHR': ''' + *pHandle = (HANDLE)0x12345678; + return VK_SUCCESS; +''', +'vkGetFenceFdKHR': ''' + *pFd = 0x42; + return VK_SUCCESS; +''', 'vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR': ''' if (!pCounters) { *pCounterCount = 3; -- cgit v1.2.3