mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
launcher: add GPU selection
This commit is contained in:
@@ -169,7 +169,12 @@ static void VulkanFindPhysicalDevice(vk::Instance instance, vk::SurfaceKHR surfa
|
|||||||
EXIT_NOT_IMPLEMENTED(devices.empty());
|
EXIT_NOT_IMPLEMENTED(devices.empty());
|
||||||
|
|
||||||
if (Config::GetGpuIndex() >= 0) {
|
if (Config::GetGpuIndex() >= 0) {
|
||||||
|
if (static_cast<size_t>(Config::GetGpuIndex()) < devices.size()) {
|
||||||
devices = {devices[Config::GetGpuIndex()]};
|
devices = {devices[Config::GetGpuIndex()]};
|
||||||
|
} else {
|
||||||
|
LOGF("Vulkan GPU index %d is unavailable; selecting automatically\n",
|
||||||
|
Config::GetGpuIndex());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::PhysicalDevice best_device = nullptr;
|
vk::PhysicalDevice best_device = nullptr;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ add_executable(launcher WIN32
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(launcher Qt6::Concurrent Qt6::Network Qt6::Widgets kyty_git_version)
|
target_link_libraries(launcher Qt6::Concurrent Qt6::Network Qt6::Widgets Vulkan::Headers kyty_git_version)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(launcher setupapi)
|
target_link_libraries(launcher setupapi)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -127,13 +127,23 @@
|
|||||||
<property name="toolTip"><string>Optimize shaders for code size or performance</string></property>
|
<property name="toolTip"><string>Optimize shaders for code size or performance</string></property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_gpu">
|
||||||
|
<property name="text"><string>GPU:</string></property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_gpu">
|
||||||
|
<property name="toolTip"><string>Graphics device used by the emulator</string></property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox_fullscreen">
|
<widget class="QCheckBox" name="checkBox_fullscreen">
|
||||||
<property name="toolTip"><string>Run in borderless desktop fullscreen</string></property>
|
<property name="toolTip"><string>Run in borderless desktop fullscreen</string></property>
|
||||||
<property name="text"><string>Fullscreen</string></property>
|
<property name="text"><string>Fullscreen</string></property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox_readback">
|
<widget class="QCheckBox" name="checkBox_readback">
|
||||||
<property name="toolTip"><string>Read back writable linear images</string></property>
|
<property name="toolTip"><string>Read back writable linear images</string></property>
|
||||||
<property name="text"><string>Enable readback</string></property>
|
<property name="text"><string>Enable readback</string></property>
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public:
|
|||||||
QString user_name = "Kyty";
|
QString user_name = "Kyty";
|
||||||
int user_id = Config::DEFAULT_USER_ID;
|
int user_id = Config::DEFAULT_USER_ID;
|
||||||
PresentMode present_mode = PresentMode::Fifo;
|
PresentMode present_mode = PresentMode::Fifo;
|
||||||
|
int gpu_index = -1;
|
||||||
bool fullscreen_enabled = false;
|
bool fullscreen_enabled = false;
|
||||||
bool readback_linear_images = false;
|
bool readback_linear_images = false;
|
||||||
int vblank_frequency = 60;
|
int vblank_frequency = 60;
|
||||||
@@ -121,6 +122,7 @@ public:
|
|||||||
user_name = other.user_name;
|
user_name = other.user_name;
|
||||||
user_id = other.user_id;
|
user_id = other.user_id;
|
||||||
present_mode = other.present_mode;
|
present_mode = other.present_mode;
|
||||||
|
gpu_index = other.gpu_index;
|
||||||
fullscreen_enabled = other.fullscreen_enabled;
|
fullscreen_enabled = other.fullscreen_enabled;
|
||||||
readback_linear_images = other.readback_linear_images;
|
readback_linear_images = other.readback_linear_images;
|
||||||
vblank_frequency = other.vblank_frequency;
|
vblank_frequency = other.vblank_frequency;
|
||||||
@@ -165,6 +167,7 @@ public:
|
|||||||
KYTY_CFG_SET(user_name);
|
KYTY_CFG_SET(user_name);
|
||||||
KYTY_CFG_SET(user_id);
|
KYTY_CFG_SET(user_id);
|
||||||
KYTY_CFG_SET(present_mode);
|
KYTY_CFG_SET(present_mode);
|
||||||
|
KYTY_CFG_SET(gpu_index);
|
||||||
KYTY_CFG_SET(fullscreen_enabled);
|
KYTY_CFG_SET(fullscreen_enabled);
|
||||||
KYTY_CFG_SET(readback_linear_images);
|
KYTY_CFG_SET(readback_linear_images);
|
||||||
KYTY_CFG_SET(vblank_frequency);
|
KYTY_CFG_SET(vblank_frequency);
|
||||||
@@ -200,6 +203,7 @@ public:
|
|||||||
? saved_user_id
|
? saved_user_id
|
||||||
: Config::DEFAULT_USER_ID;
|
: Config::DEFAULT_USER_ID;
|
||||||
KYTY_CFG_GET(present_mode);
|
KYTY_CFG_GET(present_mode);
|
||||||
|
gpu_index = s->value("gpu_index", -1).toInt();
|
||||||
if (EnumToText(present_mode).isEmpty()) {
|
if (EnumToText(present_mode).isEmpty()) {
|
||||||
present_mode = PresentMode::Fifo;
|
present_mode = PresentMode::Fifo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -25,6 +26,8 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QVulkanInstance>
|
||||||
|
#include <QVulkanWindow>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
#include "ui_configuration_edit_dialog.h"
|
#include "ui_configuration_edit_dialog.h"
|
||||||
@@ -163,6 +166,35 @@ void ConfigurationEditDialog::Init(const Configuration& info) {
|
|||||||
m_ui->spinBox_user_id->setValue(info.user_id);
|
m_ui->spinBox_user_id->setValue(info.user_id);
|
||||||
ListInit(m_ui->comboBox_screen_resolution, info.screen_resolution);
|
ListInit(m_ui->comboBox_screen_resolution, info.screen_resolution);
|
||||||
ListInit(m_ui->comboBox_present_mode, info.present_mode);
|
ListInit(m_ui->comboBox_present_mode, info.present_mode);
|
||||||
|
m_ui->comboBox_gpu->clear();
|
||||||
|
m_ui->comboBox_gpu->addItem(tr("Auto"));
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
if (!qEnvironmentVariableIsSet("QT_VULKAN_LIB")) {
|
||||||
|
const auto base = QCoreApplication::applicationDirPath();
|
||||||
|
auto library = base + "/libMoltenVK.dylib";
|
||||||
|
if (!QFileInfo::exists(library)) {
|
||||||
|
library = base + "/../Frameworks/libMoltenVK.dylib";
|
||||||
|
}
|
||||||
|
if (QFileInfo::exists(library)) {
|
||||||
|
qputenv("QT_VULKAN_LIB", library.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
QVulkanInstance instance;
|
||||||
|
instance.setApiVersion(QVersionNumber(1, 3, 0));
|
||||||
|
#if !defined(__APPLE__)
|
||||||
|
instance.setFlags(QVulkanInstance::NoPortabilityDrivers);
|
||||||
|
#endif
|
||||||
|
if (instance.create()) {
|
||||||
|
QVulkanWindow window;
|
||||||
|
window.setVulkanInstance(&instance);
|
||||||
|
for (const auto& device: window.availablePhysicalDevices()) {
|
||||||
|
m_ui->comboBox_gpu->addItem(QString::fromUtf8(device.deviceName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_ui->comboBox_gpu->setCurrentIndex(
|
||||||
|
info.gpu_index >= 0 && info.gpu_index < m_ui->comboBox_gpu->count() - 1 ? info.gpu_index + 1
|
||||||
|
: 0);
|
||||||
m_ui->checkBox_fullscreen->setChecked(info.fullscreen_enabled);
|
m_ui->checkBox_fullscreen->setChecked(info.fullscreen_enabled);
|
||||||
m_ui->checkBox_readback->setChecked(info.readback_linear_images);
|
m_ui->checkBox_readback->setChecked(info.readback_linear_images);
|
||||||
m_ui->spinBox_vblank_frequency->setValue(info.vblank_frequency);
|
m_ui->spinBox_vblank_frequency->setValue(info.vblank_frequency);
|
||||||
@@ -306,6 +338,7 @@ static void UpdateInfo(Configuration& info, Ui::ConfigurationEditDialog& ui) {
|
|||||||
TextToEnum<Configuration::Resolution>(ui.comboBox_screen_resolution->currentText());
|
TextToEnum<Configuration::Resolution>(ui.comboBox_screen_resolution->currentText());
|
||||||
info.present_mode =
|
info.present_mode =
|
||||||
TextToEnum<Configuration::PresentMode>(ui.comboBox_present_mode->currentText());
|
TextToEnum<Configuration::PresentMode>(ui.comboBox_present_mode->currentText());
|
||||||
|
info.gpu_index = ui.comboBox_gpu->currentIndex() - 1;
|
||||||
info.fullscreen_enabled = ui.checkBox_fullscreen->isChecked();
|
info.fullscreen_enabled = ui.checkBox_fullscreen->isChecked();
|
||||||
info.readback_linear_images = ui.checkBox_readback->isChecked();
|
info.readback_linear_images = ui.checkBox_readback->isChecked();
|
||||||
info.vblank_frequency = ui.spinBox_vblank_frequency->value();
|
info.vblank_frequency = ui.spinBox_vblank_frequency->value();
|
||||||
|
|||||||
@@ -229,6 +229,9 @@ static QStringList CreateEmulatorArgs(const Configuration& info) {
|
|||||||
args << "--user-name" << info.user_name;
|
args << "--user-name" << info.user_name;
|
||||||
args << "--user-id" << QString::number(info.user_id);
|
args << "--user-id" << QString::number(info.user_id);
|
||||||
args << "--present-mode" << EnumToText(info.present_mode);
|
args << "--present-mode" << EnumToText(info.present_mode);
|
||||||
|
if (info.gpu_index >= 0) {
|
||||||
|
args << "--gpu" << QString::number(info.gpu_index);
|
||||||
|
}
|
||||||
if (info.fullscreen_enabled) {
|
if (info.fullscreen_enabled) {
|
||||||
args << "--fullscreen";
|
args << "--fullscreen";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user