From fc0c4db20d4161984a960a689afa0a08a5a4b401 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 28 May 2023 21:46:02 +0000 Subject: yuzu-qt: Load Vulkan device info at startup Loading it when the configuration opens now incurs a noticeable delay. We also don't need to rediscover the same data repeatedly each time the configuration opens. Moves vulkan device info discovery to yuzu's startup as opposed to the configure_graphics constructor. --- src/yuzu/vk_device_info.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/yuzu/vk_device_info.cpp (limited to 'src/yuzu/vk_device_info.cpp') diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp new file mode 100644 index 000000000..2b967e4b8 --- /dev/null +++ b/src/yuzu/vk_device_info.cpp @@ -0,0 +1,53 @@ +#include "video_core/vulkan_common/vulkan_device.h" + +#include +#include "common/dynamic_library.h" +#include "video_core/vulkan_common/vulkan_instance.h" +#include "video_core/vulkan_common/vulkan_library.h" +#include "video_core/vulkan_common/vulkan_surface.h" +#include "video_core/vulkan_common/vulkan_wrapper.h" +#include "yuzu/qt_common.h" +#include "yuzu/vk_device_info.h" + +namespace VkDeviceInfo { +Record::Record(std::string_view name_, const std::vector& vsync_modes_, + bool is_intel_proprietary_) + : name{name_}, vsync_support{vsync_modes_}, is_intel_proprietary{is_intel_proprietary_} {} + +Record::~Record() = default; + +void PopulateRecords(std::vector& records, QWindow* window) try { + using namespace Vulkan; + + auto wsi = QtCommon::GetWindowSystemInfo(window); + + vk::InstanceDispatch dld; + const auto library = OpenLibrary(); + const vk::Instance instance = CreateInstance(*library, dld, VK_API_VERSION_1_1, wsi.type); + const std::vector physical_devices = instance.EnumeratePhysicalDevices(); + vk::SurfaceKHR surface = CreateSurface(instance, wsi); + + records.clear(); + records.reserve(physical_devices.size()); + for (const VkPhysicalDevice device : physical_devices) { + const auto physical_device = vk::PhysicalDevice(device, dld); + const std::string name = physical_device.GetProperties().deviceName; + const std::vector present_modes = + physical_device.GetSurfacePresentModesKHR(*surface); + + VkPhysicalDeviceDriverProperties driver_properties{}; + driver_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES; + driver_properties.pNext = nullptr; + VkPhysicalDeviceProperties2 properties{}; + properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; + properties.pNext = &driver_properties; + dld.vkGetPhysicalDeviceProperties2(physical_device, &properties); + + records.push_back(VkDeviceInfo::Record(name, present_modes, + driver_properties.driverID == + VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS)); + } +} catch (const Vulkan::vk::Exception& exception) { + LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); +} +} // namespace VkDeviceInfo -- cgit v1.2.3 From f9fc9960831da51a417704ed5b41e8705b0c05f1 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 28 May 2023 21:52:12 +0000 Subject: vk_device_info: Add SPDX data --- src/yuzu/vk_device_info.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/yuzu/vk_device_info.cpp') diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp index 2b967e4b8..2f3a46ebf 100644 --- a/src/yuzu/vk_device_info.cpp +++ b/src/yuzu/vk_device_info.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + #include "video_core/vulkan_common/vulkan_device.h" #include -- cgit v1.2.3 From 013c34cb321873eca0c4bfc7e2347c52bb09ed9a Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 28 May 2023 23:24:08 -0400 Subject: vk_device_info: Clean up includes [IWYU] --- src/yuzu/vk_device_info.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/yuzu/vk_device_info.cpp') diff --git a/src/yuzu/vk_device_info.cpp b/src/yuzu/vk_device_info.cpp index 2f3a46ebf..9bd1ec686 100644 --- a/src/yuzu/vk_device_info.cpp +++ b/src/yuzu/vk_device_info.cpp @@ -1,10 +1,10 @@ // SPDX-FileCopyrightText: 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "video_core/vulkan_common/vulkan_device.h" - +#include #include #include "common/dynamic_library.h" +#include "common/logging/log.h" #include "video_core/vulkan_common/vulkan_instance.h" #include "video_core/vulkan_common/vulkan_library.h" #include "video_core/vulkan_common/vulkan_surface.h" @@ -12,6 +12,8 @@ #include "yuzu/qt_common.h" #include "yuzu/vk_device_info.h" +class QWindow; + namespace VkDeviceInfo { Record::Record(std::string_view name_, const std::vector& vsync_modes_, bool is_intel_proprietary_) -- cgit v1.2.3