Move the new driver choice to Developer Tools

This commit is contained in:
Henrik Rydgård
2023-12-14 16:34:55 +01:00
parent 97bd15a81a
commit 663ef40640
2 changed files with 39 additions and 35 deletions
+37 -31
View File
@@ -107,8 +107,16 @@ bool SupportsCustomDriver() {
return android_get_device_api_level() >= 28 && CheckKgslPresent();
}
#else
bool SupportsCustomDriver() {
return false;
}
#endif
static void TriggerRestart(const char *why, bool editThenRestore, const Path &gamePath);
GameSettingsScreen::GameSettingsScreen(const Path &gamePath, std::string gameID, bool editThenRestore)
: TabbedUIDialogScreenWithGameBackground(gamePath), gameID_(gameID), editThenRestore_(editThenRestore) {
prevInflightFrames_ = g_Config.iInflightFrames;
@@ -282,27 +290,6 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
// If we're not the first instance, can't save the setting, and it requires a restart, so...
renderingBackendChoice->SetEnabled(false);
}
#if PPSSPP_PLATFORM(ANDROID) && PPSSPP_ARCH(ARM64)
if (GetGPUBackend() == GPUBackend::VULKAN && SupportsCustomDriver()) {
const Path driverPath = g_Config.internalDataDirectory / "drivers";
std::vector<File::FileInfo> listing;
File::GetFilesInDir(driverPath, &listing);
std::vector<std::string> availableDrivers;
availableDrivers.push_back("Default");
for (auto driver : listing) {
availableDrivers.push_back(driver.name);
}
auto driverChoice = graphicsSettings->Add(new PopupMultiChoiceDynamic(&g_Config.customDriver, gr->T("Current GPU Driver"), availableDrivers, I18NCat::NONE, screenManager()));
driverChoice->OnChoice.Handle(this, &GameSettingsScreen::OnCustomDriverChange);
auto customDriverInstallChoice = graphicsSettings->Add(new Choice(gr->T("Install Custom Driver...")));
customDriverInstallChoice->OnClick.Handle(this, &GameSettingsScreen::OnCustomDriverInstall);
}
#endif
#endif
// Backends that don't allow a device choice will only expose one device.
@@ -1249,18 +1236,18 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) {
vrSettings->Add(new PopupMultiChoice(&g_Config.iCameraPitch, vr->T("Camera type"), cameraPitchModes, 0, 3, I18NCat::NONE, screenManager()));
}
UI::EventReturn GameSettingsScreen::OnCustomDriverChange(UI::EventParams &e) {
UI::EventReturn DeveloperToolsScreen::OnCustomDriverChange(UI::EventParams &e) {
auto di = GetI18NCategory(I18NCat::DIALOG);
screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) {
if (yes) {
TriggerRestart("GameSettingsScreen::CustomDriverYes");
TriggerRestart("GameSettingsScreen::CustomDriverYes", false, gamePath_);
}
}));
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnCustomDriverInstall(UI::EventParams &e) {
UI::EventReturn DeveloperToolsScreen::OnCustomDriverInstall(UI::EventParams &e) {
auto gr = GetI18NCategory(I18NCat::GRAPHICS);
System_BrowseForFile(gr->T("Install Custom Driver..."), BrowseFileType::ANY, [this](const std::string &value, int) {
@@ -1541,16 +1528,16 @@ void GameSettingsScreen::CallbackMemstickFolder(bool yes) {
}
}
void GameSettingsScreen::TriggerRestart(const char *why) {
static void TriggerRestart(const char *why, bool editThenRestore, const Path &gamePath) {
// Extra save here to make sure the choice really gets saved even if there are shutdown bugs in
// the GPU backend code.
g_Config.Save(why);
std::string param = "--gamesettings";
if (editThenRestore_) {
if (editThenRestore) {
// We won't pass the gameID, so don't resume back into settings.
param.clear();
} else if (!gamePath_.empty()) {
param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\"";
} else if (!gamePath.empty()) {
param += " \"" + ReplaceAll(ReplaceAll(gamePath.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\"";
}
// Make sure the new instance is considered the first.
ShutdownInstanceCounter();
@@ -1564,7 +1551,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingBackend(UI::EventParams &e) {
if (g_Config.iGPUBackend != (int)GetGPUBackend()) {
screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) {
if (yes) {
TriggerRestart("GameSettingsScreen::RenderingBackendYes");
TriggerRestart("GameSettingsScreen::RenderingBackendYes", editThenRestore_, gamePath_);
} else {
g_Config.iGPUBackend = (int)GetGPUBackend();
}
@@ -1583,7 +1570,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingDevice(UI::EventParams &e) {
// If the user ends up deciding not to restart, set the config back to the current backend
// so it doesn't get switched by accident.
if (yes) {
TriggerRestart("GameSettingsScreen::RenderingDeviceYes");
TriggerRestart("GameSettingsScreen::RenderingDeviceYes", editThenRestore_, gamePath_);
} else {
std::string *deviceNameSetting = GPUDeviceNameSetting();
if (deviceNameSetting)
@@ -1601,7 +1588,7 @@ UI::EventReturn GameSettingsScreen::OnInflightFramesChoice(UI::EventParams &e) {
if (g_Config.iInflightFrames != prevInflightFrames_) {
screenManager()->push(new PromptScreen(gamePath_, di->T("Changing this setting requires PPSSPP to restart."), di->T("Restart"), di->T("Cancel"), [=](bool yes) {
if (yes) {
TriggerRestart("GameSettingsScreen::InflightFramesYes");
TriggerRestart("GameSettingsScreen::InflightFramesYes", editThenRestore_, gamePath_);
} else {
g_Config.iInflightFrames = prevInflightFrames_;
}
@@ -1815,6 +1802,25 @@ void DeveloperToolsScreen::CreateViews() {
});
}
if (GetGPUBackend() == GPUBackend::VULKAN && SupportsCustomDriver()) {
const Path driverPath = g_Config.internalDataDirectory / "drivers";
std::vector<File::FileInfo> listing;
File::GetFilesInDir(driverPath, &listing);
std::vector<std::string> availableDrivers;
availableDrivers.push_back("Default");
for (auto driver : listing) {
availableDrivers.push_back(driver.name);
}
auto driverChoice = list->Add(new PopupMultiChoiceDynamic(&g_Config.customDriver, gr->T("Current GPU Driver"), availableDrivers, I18NCat::NONE, screenManager()));
driverChoice->OnChoice.Handle(this, &DeveloperToolsScreen::OnCustomDriverChange);
auto customDriverInstallChoice = list->Add(new Choice(gr->T("Install Custom Driver...")));
customDriverInstallChoice->OnClick.Handle(this, &DeveloperToolsScreen::OnCustomDriverInstall);
}
// For now, we only implement GPU driver tests for Vulkan and OpenGL. This is simply
// because the D3D drivers are generally solid enough to not need this type of investigation.
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
+2 -4
View File
@@ -54,8 +54,6 @@ private:
void CreateSystemSettings(UI::ViewGroup *systemSettings);
void CreateVRSettings(UI::ViewGroup *vrSettings);
void TriggerRestart(const char *why);
std::string gameID_;
UI::CheckBox *enableReportsCheckbox_ = nullptr;
UI::Choice *layoutEditorChoice_ = nullptr;
@@ -98,8 +96,6 @@ private:
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
UI::EventReturn OnRenderingDevice(UI::EventParams &e);
UI::EventReturn OnInflightFramesChoice(UI::EventParams &e);
UI::EventReturn OnCustomDriverChange(UI::EventParams &e);
UI::EventReturn OnCustomDriverInstall(UI::EventParams &e);
UI::EventReturn OnCameraDeviceChange(UI::EventParams& e);
UI::EventReturn OnMicDeviceChange(UI::EventParams& e);
UI::EventReturn OnAudioDevice(UI::EventParams &e);
@@ -155,6 +151,8 @@ private:
UI::EventReturn OnFramedumpTest(UI::EventParams &e);
UI::EventReturn OnTouchscreenTest(UI::EventParams &e);
UI::EventReturn OnCopyStatesToRoot(UI::EventParams &e);
UI::EventReturn OnCustomDriverChange(UI::EventParams &e);
UI::EventReturn OnCustomDriverInstall(UI::EventParams &e);
bool allowDebugger_ = false;
bool canAllowDebugger_ = true;