mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 03:54:45 +00:00
Getting list of GPU only when application starts
This commit is contained in:
parent
0bed4a91b9
commit
8238b80838
4 changed files with 27 additions and 13 deletions
|
@ -16,6 +16,7 @@
|
|||
#include "game_install_dialog.h"
|
||||
#include "main_window.h"
|
||||
#include "settings_dialog.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
@ -39,6 +40,7 @@ bool MainWindow::Init() {
|
|||
CreateConnects();
|
||||
SetLastUsedTheme();
|
||||
SetLastIconSizeBullet();
|
||||
GetPhysicalDevices();
|
||||
// show ui
|
||||
setMinimumSize(350, minimumSizeHint().height());
|
||||
setWindowTitle(QString::fromStdString("shadPS4 v" + std::string(Common::VERSION)));
|
||||
|
@ -158,6 +160,17 @@ void MainWindow::LoadGameLists() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::GetPhysicalDevices() {
|
||||
if (m_physical_devices.size() == 0) {
|
||||
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);
|
||||
m_physical_devices.push_back(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::CreateConnects() {
|
||||
connect(this, &MainWindow::WindowResized, this, &MainWindow::HandleResize);
|
||||
connect(ui->mw_searchbar, &QLineEdit::textChanged, this, &MainWindow::SearchGameTable);
|
||||
|
@ -187,7 +200,7 @@ void MainWindow::CreateConnects() {
|
|||
&MainWindow::StartGame);
|
||||
|
||||
connect(ui->settingsButton, &QPushButton::clicked, this, [this]() {
|
||||
auto settingsDialog = new SettingsDialog(this);
|
||||
auto settingsDialog = new SettingsDialog(this, &m_physical_devices);
|
||||
settingsDialog->exec();
|
||||
});
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
void CreateActions();
|
||||
void CreateRecentGameActions();
|
||||
void CreateDockWindows();
|
||||
void GetPhysicalDevices();
|
||||
void LoadGameLists();
|
||||
void CreateConnects();
|
||||
void SetLastUsedTheme();
|
||||
|
@ -79,6 +80,9 @@ private:
|
|||
QScopedPointer<ElfViewer> m_elf_viewer;
|
||||
// Status Bar.
|
||||
QScopedPointer<QStatusBar> statusBar;
|
||||
// Available GPU devices
|
||||
std::vector<QString> m_physical_devices;
|
||||
|
||||
|
||||
PSF psf;
|
||||
|
||||
|
|
|
@ -3,15 +3,20 @@
|
|||
|
||||
#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) {
|
||||
SettingsDialog::SettingsDialog(QWidget* parent, std::vector<QString>* physical_devices) : QDialog(parent), ui(new Ui::SettingsDialog) {
|
||||
ui->setupUi(this);
|
||||
ui->tabWidgetSettings->setUsesScrollButtons(false);
|
||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
|
||||
|
||||
// Add list of available GPUs
|
||||
ui->graphicsAdapterBox->addItem("Auto Select"); // -1, auto selection
|
||||
for (auto device = physical_devices->begin(); device != physical_devices->end(); ++device) {
|
||||
ui->graphicsAdapterBox->addItem(*device);
|
||||
}
|
||||
|
||||
LoadValuesFromConfig();
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
|
||||
|
@ -102,15 +107,6 @@ 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());
|
||||
|
|
|
@ -16,7 +16,8 @@ class SettingsDialog;
|
|||
class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsDialog(QWidget* parent = nullptr);
|
||||
explicit SettingsDialog(QWidget* parent = nullptr,
|
||||
std::vector<QString>* physical_devices = nullptr);
|
||||
~SettingsDialog();
|
||||
|
||||
int exec() override;
|
||||
|
|
Loading…
Add table
Reference in a new issue