From 453b24eb202a0239b6d4147c864741897035011d Mon Sep 17 00:00:00 2001 From: psucien Date: Sun, 28 Apr 2024 01:19:04 +0200 Subject: [PATCH] config: option to select gpu for vk device --- src/common/config.cpp | 11 +++++++++-- src/common/config.h | 1 + src/video_core/renderer_vulkan/renderer_vulkan.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 6040df53..e1363c17 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -12,6 +12,7 @@ namespace Config { bool isNeo = false; u32 screenWidth = 1280; u32 screenHeight = 720; +u32 gpuId = 0; // Vulkan physical device no std::string logFilter; std::string logType = "sync"; bool isDebugDump = false; @@ -32,6 +33,10 @@ u32 getScreenHeight() { return screenHeight; } +u32 getGpuId() { + return gpuId; +} + std::string getLogFilter() { return logFilter; } @@ -76,8 +81,9 @@ void load(const std::filesystem::path& path) { if (generalResult.is_ok()) { auto general = generalResult.unwrap(); - screenWidth = toml::find_or(general, "screenWidth", false); - screenHeight = toml::find_or(general, "screenHeight", false); + screenWidth = toml::find_or(general, "screenWidth", screenWidth); + screenHeight = toml::find_or(general, "screenHeight", screenHeight); + gpuId = toml::find_or(general, "gpuId", 0); } } if (data.contains("Debug")) { @@ -119,6 +125,7 @@ void save(const std::filesystem::path& path) { data["General"]["isPS4Pro"] = isNeo; data["General"]["logFilter"] = logFilter; data["General"]["logType"] = logType; + data["GPU"]["gpuId"] = gpuId; data["GPU"]["screenWidth"] = screenWidth; data["GPU"]["screenHeight"] = screenHeight; data["Debug"]["DebugDump"] = isDebugDump; diff --git a/src/common/config.h b/src/common/config.h index b69c43b4..529fc230 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -16,6 +16,7 @@ std::string getLogType(); u32 getScreenWidth(); u32 getScreenHeight(); +u32 getGpuId(); bool debugDump(); bool isLleLibc(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index c837f808..7ab241c4 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "sdl_window.h" +#include "common/config.h" #include "video_core/renderer_vulkan/renderer_vulkan.h" #include @@ -57,7 +58,7 @@ bool CanBlitToSwapchain(const vk::PhysicalDevice physical_device, vk::Format for } RendererVulkan::RendererVulkan(Frontend::WindowSDL& window_) - : window{window_}, instance{window, 0}, scheduler{instance}, swapchain{instance, window}, + : window{window_}, instance{window, Config::getGpuId()}, scheduler{instance}, swapchain{instance, window}, texture_cache{instance, scheduler} { const u32 num_images = swapchain.GetImageCount(); const vk::Device device = instance.GetDevice();