diff options
| author | 2021-01-16 20:29:09 -0300 | |
|---|---|---|
| committer | 2021-02-13 02:16:21 -0300 | |
| commit | 16f97ded2183c5ef089e97b12409642b1e67ecc7 (patch) | |
| tree | 553d1e31698491135418c493d600a2c636d17e41 | |
| parent | vulkan_instance: Initialize Vulkan instance in a separate thread (diff) | |
| download | yuzu-16f97ded2183c5ef089e97b12409642b1e67ecc7.tar.gz yuzu-16f97ded2183c5ef089e97b12409642b1e67ecc7.tar.xz yuzu-16f97ded2183c5ef089e97b12409642b1e67ecc7.zip | |
vulkan_wrapper: Add interop functions
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.cpp | 30 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_wrapper.h | 12 |
2 files changed, 41 insertions, 1 deletions
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 5e15ad607..d39bbdc70 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp | |||
| @@ -173,6 +173,10 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept { | |||
| 173 | X(vkGetEventStatus); | 173 | X(vkGetEventStatus); |
| 174 | X(vkGetFenceStatus); | 174 | X(vkGetFenceStatus); |
| 175 | X(vkGetImageMemoryRequirements); | 175 | X(vkGetImageMemoryRequirements); |
| 176 | X(vkGetMemoryFdKHR); | ||
| 177 | #ifdef _WIN32 | ||
| 178 | X(vkGetMemoryWin32HandleKHR); | ||
| 179 | #endif | ||
| 176 | X(vkGetQueryPoolResults); | 180 | X(vkGetQueryPoolResults); |
| 177 | X(vkGetSemaphoreCounterValueKHR); | 181 | X(vkGetSemaphoreCounterValueKHR); |
| 178 | X(vkMapMemory); | 182 | X(vkMapMemory); |
| @@ -505,6 +509,32 @@ void ImageView::SetObjectNameEXT(const char* name) const { | |||
| 505 | SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_IMAGE_VIEW, name); | 509 | SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_IMAGE_VIEW, name); |
| 506 | } | 510 | } |
| 507 | 511 | ||
| 512 | int DeviceMemory::GetMemoryFdKHR() const { | ||
| 513 | const VkMemoryGetFdInfoKHR get_fd_info{ | ||
| 514 | .sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR, | ||
| 515 | .pNext = nullptr, | ||
| 516 | .memory = handle, | ||
| 517 | .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR, | ||
| 518 | }; | ||
| 519 | int fd; | ||
| 520 | Check(dld->vkGetMemoryFdKHR(owner, &get_fd_info, &fd)); | ||
| 521 | return fd; | ||
| 522 | } | ||
| 523 | |||
| 524 | #ifdef _WIN32 | ||
| 525 | HANDLE DeviceMemory::GetMemoryWin32HandleKHR() const { | ||
| 526 | const VkMemoryGetWin32HandleInfoKHR get_win32_handle_info{ | ||
| 527 | .sType = VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR, | ||
| 528 | .pNext = nullptr, | ||
| 529 | .memory = handle, | ||
| 530 | .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR, | ||
| 531 | }; | ||
| 532 | HANDLE win32_handle; | ||
| 533 | Check(dld->vkGetMemoryWin32HandleKHR(owner, &get_win32_handle_info, &win32_handle)); | ||
| 534 | return win32_handle; | ||
| 535 | } | ||
| 536 | #endif | ||
| 537 | |||
| 508 | void DeviceMemory::SetObjectNameEXT(const char* name) const { | 538 | void DeviceMemory::SetObjectNameEXT(const char* name) const { |
| 509 | SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_DEVICE_MEMORY, name); | 539 | SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_DEVICE_MEMORY, name); |
| 510 | } | 540 | } |
diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index 0c0e7230d..55c775523 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h | |||
| @@ -185,7 +185,7 @@ struct InstanceDispatch { | |||
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | /// Table holding Vulkan device function pointers. | 187 | /// Table holding Vulkan device function pointers. |
| 188 | struct DeviceDispatch : public InstanceDispatch { | 188 | struct DeviceDispatch : InstanceDispatch { |
| 189 | PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR{}; | 189 | PFN_vkAcquireNextImageKHR vkAcquireNextImageKHR{}; |
| 190 | PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers{}; | 190 | PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers{}; |
| 191 | PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets{}; | 191 | PFN_vkAllocateDescriptorSets vkAllocateDescriptorSets{}; |
| @@ -288,6 +288,10 @@ struct DeviceDispatch : public InstanceDispatch { | |||
| 288 | PFN_vkGetEventStatus vkGetEventStatus{}; | 288 | PFN_vkGetEventStatus vkGetEventStatus{}; |
| 289 | PFN_vkGetFenceStatus vkGetFenceStatus{}; | 289 | PFN_vkGetFenceStatus vkGetFenceStatus{}; |
| 290 | PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements{}; | 290 | PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements{}; |
| 291 | PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR{}; | ||
| 292 | #ifdef _WIN32 | ||
| 293 | PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR{}; | ||
| 294 | #endif | ||
| 291 | PFN_vkGetQueryPoolResults vkGetQueryPoolResults{}; | 295 | PFN_vkGetQueryPoolResults vkGetQueryPoolResults{}; |
| 292 | PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR{}; | 296 | PFN_vkGetSemaphoreCounterValueKHR vkGetSemaphoreCounterValueKHR{}; |
| 293 | PFN_vkMapMemory vkMapMemory{}; | 297 | PFN_vkMapMemory vkMapMemory{}; |
| @@ -673,6 +677,12 @@ class DeviceMemory : public Handle<VkDeviceMemory, VkDevice, DeviceDispatch> { | |||
| 673 | using Handle<VkDeviceMemory, VkDevice, DeviceDispatch>::Handle; | 677 | using Handle<VkDeviceMemory, VkDevice, DeviceDispatch>::Handle; |
| 674 | 678 | ||
| 675 | public: | 679 | public: |
| 680 | int GetMemoryFdKHR() const; | ||
| 681 | |||
| 682 | #ifdef _WIN32 | ||
| 683 | HANDLE GetMemoryWin32HandleKHR() const; | ||
| 684 | #endif | ||
| 685 | |||
| 676 | /// Set object name. | 686 | /// Set object name. |
| 677 | void SetObjectNameEXT(const char* name) const; | 687 | void SetObjectNameEXT(const char* name) const; |
| 678 | 688 | ||