qt-gui: Added GPU device selection functionality

This commit is contained in:
SamuelFontes 2024-08-11 12:55:07 -03:00
parent 2ba3221fc9
commit 0bed4a91b9
3 changed files with 21 additions and 1 deletions

View file

@ -124,6 +124,10 @@ bool vkValidationGpuEnabled() {
return vkValidationGpu;
}
void setGpuId(s32 selectedGpuId) {
gpuId = selectedGpuId;
}
void setScreenWidth(u32 width) {
screenWidth = width;
}
@ -451,6 +455,7 @@ void setDefaultValues() {
vkValidation = false;
rdocEnable = false;
m_language = 1;
gpuId = -1;
}
} // namespace Config

View file

@ -36,6 +36,7 @@ void setNullGpu(bool enable);
void setDumpShaders(bool enable);
void setDumpPM4(bool enable);
void setVblankDiv(u32 value);
void setGpuId(s32 selectedGpuId);
void setScreenWidth(u32 width);
void setScreenHeight(u32 height);
void setFullscreenMode(bool enable);

View file

@ -3,6 +3,7 @@
#include "settings_dialog.h"
#include "ui_settings_dialog.h"
#include "video_core/renderer_vulkan/vk_instance.h"
SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::SettingsDialog) {
ui->setupUi(this);
@ -40,7 +41,10 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Se
// GPU TAB
{
// TODO: Implement graphics device changing
// First options is auto selection -1, so gpuId on the GUI will always have to subtract 1
// when setting and add 1 when getting to select the correct gpu in Qt
connect(ui->graphicsAdapterBox, &QComboBox::currentIndexChanged, this,
[](int index) { Config::setGpuId(index - 1); });
connect(ui->widthSpinBox, &QSpinBox::valueChanged, this,
[](int val) { Config::setScreenWidth(val); });
@ -98,6 +102,16 @@ SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Se
void SettingsDialog::LoadValuesFromConfig() {
ui->consoleLanguageComboBox->setCurrentIndex(Config::GetLanguage());
// Add list of available GPUs
ui->graphicsAdapterBox->addItem("Auto Select"); // -1, auto selection
Vulkan::Instance instance(false, false);
auto physical_devices = instance.GetPhysicalDevices();
for (const vk::PhysicalDevice physical_device : physical_devices) {
const QString name = QString::fromUtf8(physical_device.getProperties().deviceName, -1);
ui->graphicsAdapterBox->addItem(name);
}
ui->graphicsAdapterBox->setCurrentIndex(Config::getGpuId() + 1);
ui->widthSpinBox->setValue(Config::getScreenWidth());
ui->heightSpinBox->setValue(Config::getScreenHeight());
ui->vblankSpinBox->setValue(Config::vblankDiv());