Merge pull request #10486 from lat9nq/vk-device-find-once
yuzu-qt: Load Vulkan device info at startupmaster
commit
af7f3f078c
@ -0,0 +1,58 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#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"
|
||||||
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
|
#include "yuzu/qt_common.h"
|
||||||
|
#include "yuzu/vk_device_info.h"
|
||||||
|
|
||||||
|
class QWindow;
|
||||||
|
|
||||||
|
namespace VkDeviceInfo {
|
||||||
|
Record::Record(std::string_view name_, const std::vector<VkPresentModeKHR>& 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<Record>& 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<VkPhysicalDevice> 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<VkPresentModeKHR> 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
|
@ -0,0 +1,36 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "vulkan/vulkan_core.h"
|
||||||
|
|
||||||
|
class QWindow;
|
||||||
|
|
||||||
|
namespace Settings {
|
||||||
|
enum class VSyncMode : u32;
|
||||||
|
}
|
||||||
|
// #include "common/settings.h"
|
||||||
|
|
||||||
|
namespace VkDeviceInfo {
|
||||||
|
// Short class to record Vulkan driver information for configuration purposes
|
||||||
|
class Record {
|
||||||
|
public:
|
||||||
|
explicit Record(std::string_view name, const std::vector<VkPresentModeKHR>& vsync_modes,
|
||||||
|
bool is_intel_proprietary);
|
||||||
|
~Record();
|
||||||
|
|
||||||
|
const std::string name;
|
||||||
|
const std::vector<VkPresentModeKHR> vsync_support;
|
||||||
|
const bool is_intel_proprietary;
|
||||||
|
};
|
||||||
|
|
||||||
|
void PopulateRecords(std::vector<Record>& records, QWindow* window);
|
||||||
|
} // namespace VkDeviceInfo
|
Loading…
Reference in New Issue