From bf59f3db734054a5fb14364dd42022fc863eeb46 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 22 Oct 2013 13:00:19 +0200 Subject: [PATCH] Add ugly hack setting for PowerVR to disable alpha test Causes glitches but the speedup is truly massive in some games so I relent :/ Please do not report graphics bugs when this is enabled... Future: Maybe remove this setting except on PowerVR? --- Core/Config.cpp | 2 ++ Core/Config.h | 2 +- GPU/GLES/FragmentShaderGenerator.cpp | 3 ++- GPU/GLES/GLES_GPU.cpp | 1 + UI/GameSettingsScreen.cpp | 11 ++++++++++- UI/GameSettingsScreen.h | 1 + assets/shaders/defaultshaders.ini | 3 ++- 7 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index bcdc07a5a9..57f110af6d 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -278,6 +278,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks"); speedhacks->Get("PrescaleUV", &bPrescaleUV, false); + speedhacks->Get("DisableAlphaTest", &bDisableAlphaTest, false); INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str()); bSaveSettings = true; @@ -467,6 +468,7 @@ void Config::Save() { IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks"); speedhacks->Set("PrescaleUV", bPrescaleUV); + speedhacks->Set("DisableAlphaTest", bDisableAlphaTest); if (!iniFile.Save(iniFilename_.c_str())) { ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str()); diff --git a/Core/Config.h b/Core/Config.h index 03f0ebed63..ec1dc33c12 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -165,7 +165,7 @@ public: // * Still has major problems so off by default - need to store tex scale/offset per DeferredDrawCall, // which currently isn't done so if texscale/offset isn't static (like in Tekken 6) things go wrong. bool bPrescaleUV; - + bool bDisableAlphaTest; // Helps PowerVR immensely, breaks some graphics // End GLES hacks. // SystemParam diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index b57cc26c14..34c62e8e8e 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -31,6 +31,7 @@ #include "gfx_es2/gl_state.h" #include "Core/Reporting.h" +#include "Core/Config.h" #include "GPU/GLES/FragmentShaderGenerator.h" #include "GPU/GLES/Framebuffer.h" #include "GPU/ge_constants.h" @@ -324,7 +325,7 @@ void GenerateFragmentShader(char *buffer) { WRITE(p, " vec4 v = v_color0 %s;\n", secondary); } - if (enableAlphaTest) { + if (enableAlphaTest && !g_Config.bDisableAlphaTest) { GEComparison alphaTestFunc = gstate.getAlphaTestFunction(); const char *alphaTestFuncs[] = { "#", "#", " != ", " == ", " >= ", " > ", " <= ", " < " }; // never/always don't make sense if (alphaTestFuncs[alphaTestFunc][0] != '#') { diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 15bc5de829..c10ec81e23 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -1574,6 +1574,7 @@ void GLES_GPU::ClearCacheNextFrame() { void GLES_GPU::Resized() { framebufferManager_.Resized(); + shaderManager_->ClearCache(true); } std::vector GLES_GPU::GetFramebufferList() diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0f34c013ef..6bd7c85a27 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -156,7 +156,9 @@ void GameSettingsScreen::CreateViews() { static const char *texFilters[] = { "Auto", "Nearest", "Linear", "Linear on FMV", }; graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gs->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), gs, screenManager())); - graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings"))); + graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings", "Hack Settings (these WILL cause glitches)"))); + // Maybe hide this on non-PVR? + graphicsSettings->Add(new CheckBox(&g_Config.bDisableAlphaTest, gs->T("Disable Alpha Test (PowerVR speedup)")))->OnClick.Handle(this, &GameSettingsScreen::OnShaderChange); graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test"))); graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write"))); CheckBox *prescale = graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gs->T("Texture Coord Speedhack"))); @@ -309,6 +311,13 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn GameSettingsScreen::OnShaderChange(UI::EventParams &e) { + if (gpu) { + gpu->Resized(); + } + return UI::EVENT_DONE; +} + void DrawBackground(float alpha); UI::EventReturn GameSettingsScreen::OnDumpNextFrameToLog(UI::EventParams &e) { diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 14cdb03278..4adf49c050 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -66,6 +66,7 @@ private: UI::EventReturn OnRenderingMode(UI::EventParams &e); UI::EventReturn OnFullscreenChange(UI::EventParams &e); UI::EventReturn OnResolutionChange(UI::EventParams &e); + UI::EventReturn OnShaderChange(UI::EventParams &e); UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e); // Temporaries to convert bools to int settings diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini index 684db114aa..9d56915f54 100644 --- a/assets/shaders/defaultshaders.ini +++ b/assets/shaders/defaultshaders.ini @@ -27,6 +27,7 @@ Vertex=fxaa.vsh Name=Scanlines Fragment=scanlines.fsh Vertex=fxaa.vsh +OutputResolution=True [Cartoon] Name=Cartoon Fragment=cartoon.fsh @@ -43,4 +44,4 @@ Vertex=aacolor.vsh Name=Spline36 Upscaler Fragment=upscale_spline36.fsh Vertex=upscale_spline36.vsh -OutputResolution=True \ No newline at end of file +OutputResolution=True