mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 14:35:19 +00:00
Getting list of GPU only when application starts
This commit is contained in:
parent
0bed4a91b9
commit
8238b80838
@ -16,6 +16,7 @@
|
|||||||
#include "game_install_dialog.h"
|
#include "game_install_dialog.h"
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -39,6 +40,7 @@ bool MainWindow::Init() {
|
|||||||
CreateConnects();
|
CreateConnects();
|
||||||
SetLastUsedTheme();
|
SetLastUsedTheme();
|
||||||
SetLastIconSizeBullet();
|
SetLastIconSizeBullet();
|
||||||
|
GetPhysicalDevices();
|
||||||
// show ui
|
// show ui
|
||||||
setMinimumSize(350, minimumSizeHint().height());
|
setMinimumSize(350, minimumSizeHint().height());
|
||||||
setWindowTitle(QString::fromStdString("shadPS4 v" + std::string(Common::VERSION)));
|
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() {
|
void MainWindow::CreateConnects() {
|
||||||
connect(this, &MainWindow::WindowResized, this, &MainWindow::HandleResize);
|
connect(this, &MainWindow::WindowResized, this, &MainWindow::HandleResize);
|
||||||
connect(ui->mw_searchbar, &QLineEdit::textChanged, this, &MainWindow::SearchGameTable);
|
connect(ui->mw_searchbar, &QLineEdit::textChanged, this, &MainWindow::SearchGameTable);
|
||||||
@ -187,7 +200,7 @@ void MainWindow::CreateConnects() {
|
|||||||
&MainWindow::StartGame);
|
&MainWindow::StartGame);
|
||||||
|
|
||||||
connect(ui->settingsButton, &QPushButton::clicked, this, [this]() {
|
connect(ui->settingsButton, &QPushButton::clicked, this, [this]() {
|
||||||
auto settingsDialog = new SettingsDialog(this);
|
auto settingsDialog = new SettingsDialog(this, &m_physical_devices);
|
||||||
settingsDialog->exec();
|
settingsDialog->exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ private:
|
|||||||
void CreateActions();
|
void CreateActions();
|
||||||
void CreateRecentGameActions();
|
void CreateRecentGameActions();
|
||||||
void CreateDockWindows();
|
void CreateDockWindows();
|
||||||
|
void GetPhysicalDevices();
|
||||||
void LoadGameLists();
|
void LoadGameLists();
|
||||||
void CreateConnects();
|
void CreateConnects();
|
||||||
void SetLastUsedTheme();
|
void SetLastUsedTheme();
|
||||||
@ -79,6 +80,9 @@ private:
|
|||||||
QScopedPointer<ElfViewer> m_elf_viewer;
|
QScopedPointer<ElfViewer> m_elf_viewer;
|
||||||
// Status Bar.
|
// Status Bar.
|
||||||
QScopedPointer<QStatusBar> statusBar;
|
QScopedPointer<QStatusBar> statusBar;
|
||||||
|
// Available GPU devices
|
||||||
|
std::vector<QString> m_physical_devices;
|
||||||
|
|
||||||
|
|
||||||
PSF psf;
|
PSF psf;
|
||||||
|
|
||||||
|
@ -3,15 +3,20 @@
|
|||||||
|
|
||||||
#include "settings_dialog.h"
|
#include "settings_dialog.h"
|
||||||
#include "ui_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->setupUi(this);
|
||||||
ui->tabWidgetSettings->setUsesScrollButtons(false);
|
ui->tabWidgetSettings->setUsesScrollButtons(false);
|
||||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::StandardButton::Close)->setFocus();
|
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();
|
LoadValuesFromConfig();
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
|
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() {
|
void SettingsDialog::LoadValuesFromConfig() {
|
||||||
ui->consoleLanguageComboBox->setCurrentIndex(Config::GetLanguage());
|
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->graphicsAdapterBox->setCurrentIndex(Config::getGpuId() + 1);
|
||||||
ui->widthSpinBox->setValue(Config::getScreenWidth());
|
ui->widthSpinBox->setValue(Config::getScreenWidth());
|
||||||
ui->heightSpinBox->setValue(Config::getScreenHeight());
|
ui->heightSpinBox->setValue(Config::getScreenHeight());
|
||||||
|
@ -16,7 +16,8 @@ class SettingsDialog;
|
|||||||
class SettingsDialog : public QDialog {
|
class SettingsDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SettingsDialog(QWidget* parent = nullptr);
|
explicit SettingsDialog(QWidget* parent = nullptr,
|
||||||
|
std::vector<QString>* physical_devices = nullptr);
|
||||||
~SettingsDialog();
|
~SettingsDialog();
|
||||||
|
|
||||||
int exec() override;
|
int exec() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user