From 8a6e288fccd854ac88b61099236016a7eba85b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 17 Aug 2023 20:16:04 +0200 Subject: [PATCH] Add checkboxes in developer tools to allow disabling ubershaders. Might be helpful to diagnose performance problems on user devices. Additionally, moves the texture replacement controls to the top. They should probably be moved somewhere else entirely... See #17918 --- Core/Config.cpp | 3 +++ Core/Config.h | 2 ++ GPU/D3D11/GPU_D3D11.cpp | 2 -- GPU/GLES/GPU_GLES.cpp | 10 ++++---- GPU/GPUCommonHW.cpp | 7 +++++- GPU/Vulkan/GPU_Vulkan.cpp | 4 --- UI/GameSettingsScreen.cpp | 53 +++++++++++++++++++++++++-------------- assets/lang/en_US.ini | 7 ++++-- 8 files changed, 55 insertions(+), 33 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 3a9e62dc29..2bffb81763 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -633,6 +633,9 @@ static const ConfigSetting graphicsSettings[] = { ConfigSetting("ShaderCache", &g_Config.bShaderCache, true, CfgFlag::DONT_SAVE), // Doesn't save. Ini-only. ConfigSetting("GpuLogProfiler", &g_Config.bGpuLogProfiler, false, CfgFlag::DEFAULT), + + ConfigSetting("UberShaderVertex", &g_Config.bUberShaderVertex, true, CfgFlag::DEFAULT), + ConfigSetting("UberShaderFragment", &g_Config.bUberShaderFragment, true, CfgFlag::DEFAULT), }; static const ConfigSetting soundSettings[] = { diff --git a/Core/Config.h b/Core/Config.h index eeb6d51f2f..fa6be416bb 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -213,6 +213,8 @@ public: int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High bool bHardwareTessellation; bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times. + bool bUberShaderVertex; + bool bUberShaderFragment; std::vector vPostShaderNames; // Off for chain end (only Off for no shader) std::map mPostShaderSetting; diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 8b8a430e6d..c92b8ad2f5 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -108,8 +108,6 @@ u32 GPU_D3D11::CheckGPUFeatures() const { features |= GPU_USE_16BIT_FORMATS; } - features |= GPU_USE_FRAGMENT_UBERSHADER; - return CheckGPUFeaturesLate(features); } diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index c59ca74aa8..8c4e354a70 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -177,6 +177,11 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_SINGLE_PASS_STEREO; } + if (!gl_extensions.GLES3) { + // Heuristic. + features &= ~GPU_USE_FRAGMENT_UBERSHADER; + } + features = CheckGPUFeaturesLate(features); if (draw_->GetBugs().Has(Draw::Bugs::ADRENO_RESOURCE_DEADLOCK) && g_Config.bVendorBugChecksEnabled) { @@ -193,11 +198,6 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_ROUND_DEPTH_TO_16BIT; } } - - if (gl_extensions.GLES3) { - features |= GPU_USE_FRAGMENT_UBERSHADER; - } - return features; } diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index 701cfb1651..3929929ed6 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -611,7 +611,7 @@ u32 GPUCommonHW::CheckGPUFeatures() const { features |= GPU_USE_FRAMEBUFFER_FETCH; } - if (draw_->GetShaderLanguageDesc().bitwiseOps) { + if (draw_->GetShaderLanguageDesc().bitwiseOps && g_Config.bUberShaderVertex) { features |= GPU_USE_LIGHT_UBERSHADER; } @@ -624,6 +624,11 @@ u32 GPUCommonHW::CheckGPUFeatures() const { features |= GPU_USE_ACCURATE_DEPTH; } + // Some backends will turn this off again in the calling function. + if (g_Config.bUberShaderFragment) { + features |= GPU_USE_FRAGMENT_UBERSHADER; + } + return features; } diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 7c66a7a170..b4734dc2d3 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -285,10 +285,6 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { } } - // Only a few low-power GPUs should probably avoid this. - // Let's figure that out later. - features |= GPU_USE_FRAGMENT_UBERSHADER; - // Attempt to workaround #17386 if (draw_->GetBugs().Has(Draw::Bugs::UNIFORM_INDEXING_BROKEN)) { features &= ~GPU_USE_LIGHT_UBERSHADER; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5c030e9004..110c74f070 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1637,6 +1637,26 @@ void DeveloperToolsScreen::CreateViews() { LinearLayout *list = settingsScroll->Add(new LinearLayoutList(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); list->SetSpacing(0); + + list->Add(new ItemHeader(dev->T("Texture Replacement"))); + list->Add(new CheckBox(&g_Config.bSaveNewTextures, dev->T("Save new textures"))); + list->Add(new CheckBox(&g_Config.bReplaceTextures, dev->T("Replace textures"))); + + Choice *createTextureIni = list->Add(new Choice(dev->T("Create/Open textures.ini file for current game"))); + createTextureIni->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile); + createTextureIni->SetEnabledFunc([&] { + if (!PSP_IsInited()) + return false; + + // Disable the choice to Open/Create if the textures.ini file already exists, and we can't open it due to platform support limitations. + if (!System_GetPropertyBool(SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR)) { + if (hasTexturesIni_ == HasIni::MAYBE) + hasTexturesIni_ = TextureReplacer::IniExists(g_paramSFO.GetDiscID()) ? HasIni::YES : HasIni::NO; + return hasTexturesIni_ != HasIni::YES; + } + return true; + }); + list->Add(new ItemHeader(sy->T("General"))); bool canUseJit = true; @@ -1697,27 +1717,22 @@ void DeveloperToolsScreen::CreateViews() { if (GetGPUBackend() == GPUBackend::VULKAN) { list->Add(new CheckBox(&g_Config.bGpuLogProfiler, dev->T("GPU log profiler"))); } - list->Add(new ItemHeader(dev->T("Texture Replacement"))); - list->Add(new CheckBox(&g_Config.bSaveNewTextures, dev->T("Save new textures"))); - list->Add(new CheckBox(&g_Config.bReplaceTextures, dev->T("Replace textures"))); - - Choice *createTextureIni = list->Add(new Choice(dev->T("Create/Open textures.ini file for current game"))); - createTextureIni->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile); - createTextureIni->SetEnabledFunc([&] { - if (!PSP_IsInited()) - return false; - - // Disable the choice to Open/Create if the textures.ini file already exists, and we can't open it due to platform support limitations. - if (!System_GetPropertyBool(SYSPROP_SUPPORTS_OPEN_FILE_IN_EDITOR)) { - if (hasTexturesIni_ == HasIni::MAYBE) - hasTexturesIni_ = TextureReplacer::IniExists(g_paramSFO.GetDiscID()) ? HasIni::YES : HasIni::NO; - return hasTexturesIni_ != HasIni::YES; - } - return true; - }); Draw::DrawContext *draw = screenManager()->getDrawContext(); + list->Add(new ItemHeader(dev->T("Ubershaders"))); + if (draw->GetShaderLanguageDesc().bitwiseOps && !draw->GetBugs().Has(Draw::Bugs::UNIFORM_INDEXING_BROKEN)) { + // If the above if fails, the checkbox is redundant since it'll be force disabled anyway. + list->Add(new CheckBox(&g_Config.bUberShaderVertex, dev->T("Vertex"))); + } +#if !PPSSPP_PLATFORM(UWP) + if (g_Config.iGPUBackend != (int)GPUBackend::OPENGL || gl_extensions.GLES3) { +#else + { +#endif + list->Add(new CheckBox(&g_Config.bUberShaderFragment, dev->T("Fragment"))); + } + // Experimental, will move to main graphics settings later. bool multiViewSupported = draw->GetDeviceCaps().multiViewSupported; @@ -1725,7 +1740,7 @@ void DeveloperToolsScreen::CreateViews() { return g_Config.bStereoRendering && multiViewSupported; }; - if (draw->GetDeviceCaps().multiViewSupported) { + if (multiViewSupported) { list->Add(new ItemHeader(gr->T("Stereo rendering"))); list->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering"))); std::vector stereoShaderNames; diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index c8ee58af06..6dbb175f3d 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -296,9 +296,11 @@ xBRZ = &xBRZ [Developer] Allocator Viewer = Allocator viewer (Vulkan) Allow remote debugger = Allow remote debugger +Audio Debug = Audio Debug Backspace = Backspace Block address = Block address By Address = By address +Control Debug = Control Debug Copy savestates to memstick root = Copy save states to Memory Stick root Create/Open textures.ini file for current game = Create/Open textures.ini file for current game Current = Current @@ -311,6 +313,7 @@ Dump next frame to log = Dump next frame to log Enable driver bug workarounds = Enable driver bug workarounds Enable Logging = Enable debug logging Enter address = Enter address +Fragment = Fragment FPU = FPU Framedump tests = Framedump tests Frame Profiler = Frame profiler @@ -344,10 +347,10 @@ Stats = Stats System Information = System information Texture ini file created = Texture ini file created Texture Replacement = Texture replacement -Audio Debug = Audio Debug -Control Debug = Control Debug Toggle Freeze = Toggle freeze Touchscreen Test = Touchscreen test +Ubershaders = Ubershaders +Vertex = Vertex VFPU = VFPU [Dialog]