diff options
author | 2020-07-05 22:52:04 -0700 | |
---|---|---|
committer | 2020-07-07 16:55:52 -0700 | |
commit | e1f35011c42fe3f93cfe68c5916a746a92c20557 (patch) | |
tree | 73de251d6e6d51a66fddf0441771ee8e3b285910 | |
parent | a55624ba5ae108daf326b03e1fe68165206b883a (diff) |
libvulkan: fix support for promoted VK_KHR_external_* extensions
This change intercepts below entry points:
vkGetPhysicalDeviceExternalBufferProperties
vkGetPhysicalDeviceExternalSemaphoreProperties
vkGetPhysicalDeviceExternalFenceProperties
Bug: 160276146
Test: adb shell cmd gpu vkjson
Test: dEQP-VK.api.external.*
Change-Id: I08e5647fd7ea48c2a0b2e28ef688dee44f85684c
-rw-r--r-- | vulkan/libvulkan/driver.cpp | 82 | ||||
-rw-r--r-- | vulkan/libvulkan/driver.h | 4 | ||||
-rw-r--r-- | vulkan/libvulkan/driver_gen.cpp | 30 | ||||
-rw-r--r-- | vulkan/libvulkan/driver_gen.h | 9 | ||||
-rw-r--r-- | vulkan/scripts/driver_generator.py | 24 |
5 files changed, 149 insertions, 0 deletions
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp index d2fdf42bd6..535e19063f 100644 --- a/vulkan/libvulkan/driver.cpp +++ b/vulkan/libvulkan/driver.cpp @@ -634,6 +634,9 @@ void CreateInfoWrapper::FilterExtension(const char* name) { break; case ProcHook::KHR_get_physical_device_properties2: case ProcHook::KHR_device_group_creation: + case ProcHook::KHR_external_memory_capabilities: + case ProcHook::KHR_external_semaphore_capabilities: + case ProcHook::KHR_external_fence_capabilities: case ProcHook::EXTENSION_UNKNOWN: // Extensions we don't need to do anything about at this level break; @@ -691,6 +694,9 @@ void CreateInfoWrapper::FilterExtension(const char* name) { case ProcHook::KHR_android_surface: case ProcHook::KHR_get_physical_device_properties2: case ProcHook::KHR_device_group_creation: + case ProcHook::KHR_external_memory_capabilities: + case ProcHook::KHR_external_semaphore_capabilities: + case ProcHook::KHR_external_fence_capabilities: case ProcHook::KHR_get_surface_capabilities2: case ProcHook::KHR_surface: case ProcHook::EXT_debug_report: @@ -1484,5 +1490,81 @@ void GetPhysicalDeviceSparseImageFormatProperties2( physicalDevice, pFormatInfo, pPropertyCount, pProperties); } +void GetPhysicalDeviceExternalBufferProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties) { + ATRACE_CALL(); + + const auto& driver = GetData(physicalDevice).driver; + + if (driver.GetPhysicalDeviceExternalBufferProperties) { + driver.GetPhysicalDeviceExternalBufferProperties( + physicalDevice, pExternalBufferInfo, pExternalBufferProperties); + return; + } + + if (driver.GetPhysicalDeviceExternalBufferPropertiesKHR) { + driver.GetPhysicalDeviceExternalBufferPropertiesKHR( + physicalDevice, pExternalBufferInfo, pExternalBufferProperties); + return; + } + + memset(&pExternalBufferProperties->externalMemoryProperties, 0, + sizeof(VkExternalMemoryProperties)); +} + +void GetPhysicalDeviceExternalSemaphoreProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties) { + ATRACE_CALL(); + + const auto& driver = GetData(physicalDevice).driver; + + if (driver.GetPhysicalDeviceExternalSemaphoreProperties) { + driver.GetPhysicalDeviceExternalSemaphoreProperties( + physicalDevice, pExternalSemaphoreInfo, + pExternalSemaphoreProperties); + return; + } + + if (driver.GetPhysicalDeviceExternalSemaphorePropertiesKHR) { + driver.GetPhysicalDeviceExternalSemaphorePropertiesKHR( + physicalDevice, pExternalSemaphoreInfo, + pExternalSemaphoreProperties); + return; + } + + pExternalSemaphoreProperties->exportFromImportedHandleTypes = 0; + pExternalSemaphoreProperties->compatibleHandleTypes = 0; + pExternalSemaphoreProperties->externalSemaphoreFeatures = 0; +} + +void GetPhysicalDeviceExternalFenceProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties) { + ATRACE_CALL(); + + const auto& driver = GetData(physicalDevice).driver; + + if (driver.GetPhysicalDeviceExternalFenceProperties) { + driver.GetPhysicalDeviceExternalFenceProperties( + physicalDevice, pExternalFenceInfo, pExternalFenceProperties); + return; + } + + if (driver.GetPhysicalDeviceExternalFencePropertiesKHR) { + driver.GetPhysicalDeviceExternalFencePropertiesKHR( + physicalDevice, pExternalFenceInfo, pExternalFenceProperties); + return; + } + + pExternalFenceProperties->exportFromImportedHandleTypes = 0; + pExternalFenceProperties->compatibleHandleTypes = 0; + pExternalFenceProperties->externalFenceFeatures = 0; +} + } // namespace driver } // namespace vulkan diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h index 360e724589..e7b4bb25bf 100644 --- a/vulkan/libvulkan/driver.h +++ b/vulkan/libvulkan/driver.h @@ -134,6 +134,10 @@ VKAPI_ATTR VkResult GetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice phy VKAPI_ATTR void GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); VKAPI_ATTR void GetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); VKAPI_ATTR void GetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); + +VKAPI_ATTR void GetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); +VKAPI_ATTR void GetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +VKAPI_ATTR void GetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); // clang-format on template <typename DispatchableType> diff --git a/vulkan/libvulkan/driver_gen.cpp b/vulkan/libvulkan/driver_gen.cpp index de0ed60673..6549c370b4 100644 --- a/vulkan/libvulkan/driver_gen.cpp +++ b/vulkan/libvulkan/driver_gen.cpp @@ -363,6 +363,27 @@ const ProcHook g_proc_hooks[] = { reinterpret_cast<PFN_vkVoidFunction>(checkedGetPastPresentationTimingGOOGLE), }, { + "vkGetPhysicalDeviceExternalBufferProperties", + ProcHook::INSTANCE, + ProcHook::EXTENSION_CORE_1_1, + reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceExternalBufferProperties), + nullptr, + }, + { + "vkGetPhysicalDeviceExternalFenceProperties", + ProcHook::INSTANCE, + ProcHook::EXTENSION_CORE_1_1, + reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceExternalFenceProperties), + nullptr, + }, + { + "vkGetPhysicalDeviceExternalSemaphoreProperties", + ProcHook::INSTANCE, + ProcHook::EXTENSION_CORE_1_1, + reinterpret_cast<PFN_vkVoidFunction>(GetPhysicalDeviceExternalSemaphoreProperties), + nullptr, + }, + { "vkGetPhysicalDeviceFeatures2", ProcHook::INSTANCE, ProcHook::EXTENSION_CORE_1_1, @@ -555,6 +576,9 @@ ProcHook::Extension GetProcHookExtension(const char* name) { if (strcmp(name, "VK_KHR_bind_memory2") == 0) return ProcHook::KHR_bind_memory2; if (strcmp(name, "VK_KHR_get_physical_device_properties2") == 0) return ProcHook::KHR_get_physical_device_properties2; if (strcmp(name, "VK_KHR_device_group_creation") == 0) return ProcHook::KHR_device_group_creation; + if (strcmp(name, "VK_KHR_external_memory_capabilities") == 0) return ProcHook::KHR_external_memory_capabilities; + if (strcmp(name, "VK_KHR_external_semaphore_capabilities") == 0) return ProcHook::KHR_external_semaphore_capabilities; + if (strcmp(name, "VK_KHR_external_fence_capabilities") == 0) return ProcHook::KHR_external_fence_capabilities; // clang-format on return ProcHook::EXTENSION_UNKNOWN; } @@ -607,6 +631,12 @@ bool InitDriverTable(VkInstance instance, INIT_PROC_EXT(KHR_get_physical_device_properties2, true, instance, GetPhysicalDeviceMemoryProperties2KHR); INIT_PROC(false, instance, GetPhysicalDeviceSparseImageFormatProperties2); INIT_PROC_EXT(KHR_get_physical_device_properties2, true, instance, GetPhysicalDeviceSparseImageFormatProperties2KHR); + INIT_PROC(false, instance, GetPhysicalDeviceExternalBufferProperties); + INIT_PROC_EXT(KHR_external_memory_capabilities, true, instance, GetPhysicalDeviceExternalBufferPropertiesKHR); + INIT_PROC(false, instance, GetPhysicalDeviceExternalSemaphoreProperties); + INIT_PROC_EXT(KHR_external_semaphore_capabilities, true, instance, GetPhysicalDeviceExternalSemaphorePropertiesKHR); + INIT_PROC(false, instance, GetPhysicalDeviceExternalFenceProperties); + INIT_PROC_EXT(KHR_external_fence_capabilities, true, instance, GetPhysicalDeviceExternalFencePropertiesKHR); INIT_PROC(false, instance, EnumeratePhysicalDeviceGroups); INIT_PROC_EXT(KHR_device_group_creation, true, instance, EnumeratePhysicalDeviceGroupsKHR); // clang-format on diff --git a/vulkan/libvulkan/driver_gen.h b/vulkan/libvulkan/driver_gen.h index 1f102a90e9..1aba674c2c 100644 --- a/vulkan/libvulkan/driver_gen.h +++ b/vulkan/libvulkan/driver_gen.h @@ -51,6 +51,9 @@ struct ProcHook { KHR_bind_memory2, KHR_get_physical_device_properties2, KHR_device_group_creation, + KHR_external_memory_capabilities, + KHR_external_semaphore_capabilities, + KHR_external_fence_capabilities, EXTENSION_CORE_1_0, EXTENSION_CORE_1_1, @@ -91,6 +94,12 @@ struct InstanceDriverTable { PFN_vkGetPhysicalDeviceMemoryProperties2KHR GetPhysicalDeviceMemoryProperties2KHR; PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 GetPhysicalDeviceSparseImageFormatProperties2; PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR GetPhysicalDeviceSparseImageFormatProperties2KHR; + PFN_vkGetPhysicalDeviceExternalBufferProperties GetPhysicalDeviceExternalBufferProperties; + PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR GetPhysicalDeviceExternalBufferPropertiesKHR; + PFN_vkGetPhysicalDeviceExternalSemaphoreProperties GetPhysicalDeviceExternalSemaphoreProperties; + PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR GetPhysicalDeviceExternalSemaphorePropertiesKHR; + PFN_vkGetPhysicalDeviceExternalFenceProperties GetPhysicalDeviceExternalFenceProperties; + PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR GetPhysicalDeviceExternalFencePropertiesKHR; PFN_vkEnumeratePhysicalDeviceGroups EnumeratePhysicalDeviceGroups; PFN_vkEnumeratePhysicalDeviceGroupsKHR EnumeratePhysicalDeviceGroupsKHR; // clang-format on diff --git a/vulkan/scripts/driver_generator.py b/vulkan/scripts/driver_generator.py index cf1b6cfaba..566e063a57 100644 --- a/vulkan/scripts/driver_generator.py +++ b/vulkan/scripts/driver_generator.py @@ -41,6 +41,9 @@ _KNOWN_EXTENSIONS = _INTERCEPTED_EXTENSIONS + [ 'VK_KHR_bind_memory2', 'VK_KHR_get_physical_device_properties2', 'VK_KHR_device_group_creation', + 'VK_KHR_external_memory_capabilities', + 'VK_KHR_external_semaphore_capabilities', + 'VK_KHR_external_fence_capabilities', ] # Functions needed at vulkan::driver level. @@ -95,6 +98,18 @@ _NEEDED_COMMANDS = [ 'vkGetPhysicalDeviceMemoryProperties2KHR', 'vkGetPhysicalDeviceSparseImageFormatProperties2', 'vkGetPhysicalDeviceSparseImageFormatProperties2KHR', + + # For promoted VK_KHR_external_memory_capabilities + 'vkGetPhysicalDeviceExternalBufferProperties', + 'vkGetPhysicalDeviceExternalBufferPropertiesKHR', + + # For promoted VK_KHR_external_semaphore_capabilities + 'vkGetPhysicalDeviceExternalSemaphoreProperties', + 'vkGetPhysicalDeviceExternalSemaphorePropertiesKHR', + + # For promoted VK_KHR_external_fence_capabilities + 'vkGetPhysicalDeviceExternalFenceProperties', + 'vkGetPhysicalDeviceExternalFencePropertiesKHR', ] # Functions intercepted at vulkan::driver level. @@ -133,6 +148,15 @@ _INTERCEPTED_COMMANDS = [ 'vkGetPhysicalDeviceQueueFamilyProperties2', 'vkGetPhysicalDeviceMemoryProperties2', 'vkGetPhysicalDeviceSparseImageFormatProperties2', + + # For promoted VK_KHR_external_memory_capabilities + 'vkGetPhysicalDeviceExternalBufferProperties', + + # For promoted VK_KHR_external_semaphore_capabilities + 'vkGetPhysicalDeviceExternalSemaphoreProperties', + + # For promoted VK_KHR_external_fence_capabilities + 'vkGetPhysicalDeviceExternalFenceProperties', ] |