diff options
| author | 2020-03-31 21:26:22 -0300 | |
|---|---|---|
| committer | 2020-03-31 21:32:08 -0300 | |
| commit | 5c90d060d800ee6d26ce107ff7ff83b661911295 (patch) | |
| tree | 68c3fae672070573c904e640d5c897bfbf32faa5 /src | |
| parent | renderer_vulkan/wrapper: Add device handle (diff) | |
| download | yuzu-5c90d060d800ee6d26ce107ff7ff83b661911295.tar.gz yuzu-5c90d060d800ee6d26ce107ff7ff83b661911295.tar.xz yuzu-5c90d060d800ee6d26ce107ff7ff83b661911295.zip | |
renderer_vulkan/wrapper: Add physical device handle
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/wrapper.cpp | 83 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/wrapper.h | 40 |
2 files changed, 123 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/wrapper.cpp b/src/video_core/renderer_vulkan/wrapper.cpp index 0795fbcc6..242cfff6e 100644 --- a/src/video_core/renderer_vulkan/wrapper.cpp +++ b/src/video_core/renderer_vulkan/wrapper.cpp | |||
| @@ -650,4 +650,87 @@ void Device::UpdateDescriptorSets(Span<VkWriteDescriptorSet> writes, | |||
| 650 | dld->vkUpdateDescriptorSets(handle, writes.size(), writes.data(), copies.size(), copies.data()); | 650 | dld->vkUpdateDescriptorSets(handle, writes.size(), writes.data(), copies.size(), copies.data()); |
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | VkPhysicalDeviceProperties PhysicalDevice::GetProperties() const noexcept { | ||
| 654 | VkPhysicalDeviceProperties properties; | ||
| 655 | dld->vkGetPhysicalDeviceProperties(physical_device, &properties); | ||
| 656 | return properties; | ||
| 657 | } | ||
| 658 | |||
| 659 | void PhysicalDevice::GetProperties2KHR(VkPhysicalDeviceProperties2KHR& properties) const noexcept { | ||
| 660 | dld->vkGetPhysicalDeviceProperties2KHR(physical_device, &properties); | ||
| 661 | } | ||
| 662 | |||
| 663 | VkPhysicalDeviceFeatures PhysicalDevice::GetFeatures() const noexcept { | ||
| 664 | VkPhysicalDeviceFeatures2KHR features2; | ||
| 665 | features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; | ||
| 666 | features2.pNext = nullptr; | ||
| 667 | dld->vkGetPhysicalDeviceFeatures2KHR(physical_device, &features2); | ||
| 668 | return features2.features; | ||
| 669 | } | ||
| 670 | |||
| 671 | void PhysicalDevice::GetFeatures2KHR(VkPhysicalDeviceFeatures2KHR& features) const noexcept { | ||
| 672 | dld->vkGetPhysicalDeviceFeatures2KHR(physical_device, &features); | ||
| 673 | } | ||
| 674 | |||
| 675 | VkFormatProperties PhysicalDevice::GetFormatProperties(VkFormat format) const noexcept { | ||
| 676 | VkFormatProperties properties; | ||
| 677 | dld->vkGetPhysicalDeviceFormatProperties(physical_device, format, &properties); | ||
| 678 | return properties; | ||
| 679 | } | ||
| 680 | |||
| 681 | std::vector<VkExtensionProperties> PhysicalDevice::EnumerateDeviceExtensionProperties() const { | ||
| 682 | u32 num; | ||
| 683 | dld->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &num, nullptr); | ||
| 684 | std::vector<VkExtensionProperties> properties(num); | ||
| 685 | dld->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &num, properties.data()); | ||
| 686 | return properties; | ||
| 687 | } | ||
| 688 | |||
| 689 | std::vector<VkQueueFamilyProperties> PhysicalDevice::GetQueueFamilyProperties() const { | ||
| 690 | u32 num; | ||
| 691 | dld->vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &num, nullptr); | ||
| 692 | std::vector<VkQueueFamilyProperties> properties(num); | ||
| 693 | dld->vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &num, properties.data()); | ||
| 694 | return properties; | ||
| 695 | } | ||
| 696 | |||
| 697 | bool PhysicalDevice::GetSurfaceSupportKHR(u32 queue_family_index, VkSurfaceKHR surface) const { | ||
| 698 | VkBool32 supported; | ||
| 699 | Check(dld->vkGetPhysicalDeviceSurfaceSupportKHR(physical_device, queue_family_index, surface, | ||
| 700 | &supported)); | ||
| 701 | return supported == VK_TRUE; | ||
| 702 | } | ||
| 703 | |||
| 704 | VkSurfaceCapabilitiesKHR PhysicalDevice::GetSurfaceCapabilitiesKHR(VkSurfaceKHR surface) const | ||
| 705 | noexcept { | ||
| 706 | VkSurfaceCapabilitiesKHR capabilities; | ||
| 707 | Check(dld->vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface, &capabilities)); | ||
| 708 | return capabilities; | ||
| 709 | } | ||
| 710 | |||
| 711 | std::vector<VkSurfaceFormatKHR> PhysicalDevice::GetSurfaceFormatsKHR(VkSurfaceKHR surface) const { | ||
| 712 | u32 num; | ||
| 713 | Check(dld->vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &num, nullptr)); | ||
| 714 | std::vector<VkSurfaceFormatKHR> formats(num); | ||
| 715 | Check( | ||
| 716 | dld->vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &num, formats.data())); | ||
| 717 | return formats; | ||
| 718 | } | ||
| 719 | |||
| 720 | std::vector<VkPresentModeKHR> PhysicalDevice::GetSurfacePresentModesKHR( | ||
| 721 | VkSurfaceKHR surface) const { | ||
| 722 | u32 num; | ||
| 723 | Check(dld->vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &num, nullptr)); | ||
| 724 | std::vector<VkPresentModeKHR> modes(num); | ||
| 725 | Check(dld->vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &num, | ||
| 726 | modes.data())); | ||
| 727 | return modes; | ||
| 728 | } | ||
| 729 | |||
| 730 | VkPhysicalDeviceMemoryProperties PhysicalDevice::GetMemoryProperties() const noexcept { | ||
| 731 | VkPhysicalDeviceMemoryProperties properties; | ||
| 732 | dld->vkGetPhysicalDeviceMemoryProperties(physical_device, &properties); | ||
| 733 | return properties; | ||
| 734 | } | ||
| 735 | |||
| 653 | } // namespace Vulkan::vk | 736 | } // namespace Vulkan::vk |
diff --git a/src/video_core/renderer_vulkan/wrapper.h b/src/video_core/renderer_vulkan/wrapper.h index 6ac5a8f59..5d6a0227a 100644 --- a/src/video_core/renderer_vulkan/wrapper.h +++ b/src/video_core/renderer_vulkan/wrapper.h | |||
| @@ -749,4 +749,44 @@ public: | |||
| 749 | } | 749 | } |
| 750 | }; | 750 | }; |
| 751 | 751 | ||
| 752 | class PhysicalDevice { | ||
| 753 | public: | ||
| 754 | constexpr PhysicalDevice() noexcept = default; | ||
| 755 | |||
| 756 | constexpr PhysicalDevice(VkPhysicalDevice physical_device, const InstanceDispatch& dld) noexcept | ||
| 757 | : physical_device{physical_device}, dld{&dld} {} | ||
| 758 | |||
| 759 | constexpr operator VkPhysicalDevice() const noexcept { | ||
| 760 | return physical_device; | ||
| 761 | } | ||
| 762 | |||
| 763 | VkPhysicalDeviceProperties GetProperties() const noexcept; | ||
| 764 | |||
| 765 | void GetProperties2KHR(VkPhysicalDeviceProperties2KHR&) const noexcept; | ||
| 766 | |||
| 767 | VkPhysicalDeviceFeatures GetFeatures() const noexcept; | ||
| 768 | |||
| 769 | void GetFeatures2KHR(VkPhysicalDeviceFeatures2KHR&) const noexcept; | ||
| 770 | |||
| 771 | VkFormatProperties GetFormatProperties(VkFormat) const noexcept; | ||
| 772 | |||
| 773 | std::vector<VkExtensionProperties> EnumerateDeviceExtensionProperties() const; | ||
| 774 | |||
| 775 | std::vector<VkQueueFamilyProperties> GetQueueFamilyProperties() const; | ||
| 776 | |||
| 777 | bool GetSurfaceSupportKHR(u32 queue_family_index, VkSurfaceKHR) const; | ||
| 778 | |||
| 779 | VkSurfaceCapabilitiesKHR GetSurfaceCapabilitiesKHR(VkSurfaceKHR) const noexcept; | ||
| 780 | |||
| 781 | std::vector<VkSurfaceFormatKHR> GetSurfaceFormatsKHR(VkSurfaceKHR) const; | ||
| 782 | |||
| 783 | std::vector<VkPresentModeKHR> GetSurfacePresentModesKHR(VkSurfaceKHR) const; | ||
| 784 | |||
| 785 | VkPhysicalDeviceMemoryProperties GetMemoryProperties() const noexcept; | ||
| 786 | |||
| 787 | private: | ||
| 788 | VkPhysicalDevice physical_device = nullptr; | ||
| 789 | const InstanceDispatch* dld = nullptr; | ||
| 790 | }; | ||
| 791 | |||
| 752 | } // namespace Vulkan::vk | 792 | } // namespace Vulkan::vk |