From a1aac7922462e0dcc640d1829d069c42f6010edf Mon Sep 17 00:00:00 2001 From: raven02 Date: Thu, 5 Sep 2013 20:51:17 +0800 Subject: [PATCH 1/2] Toggle option "Disable Stencil Test" & "Always Depth Write" --- Core/Config.cpp | 4 ++++ Core/Config.h | 2 ++ GPU/GLES/StateMapping.cpp | 11 +++++++---- UI/GameSettingsScreen.cpp | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index bb958935c..964419510 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -163,6 +163,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) graphics->Get("TexScalingType", &iTexScalingType, 0); graphics->Get("TexDeposterize", &bTexDeposterize, false); graphics->Get("VSyncInterval", &bVSync, false); + graphics->Get("DisableStencilTest", &bDisableStencilTest, false); + graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Get("Enable", &bEnableSound, true); @@ -315,6 +317,8 @@ void Config::Save() { graphics->Set("TexScalingType", iTexScalingType); graphics->Set("TexDeposterize", bTexDeposterize); graphics->Set("VSyncInterval", bVSync); + graphics->Set("DisableStencilTest", bDisableStencilTest); + graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite); IniFile::Section *sound = iniFile.GetOrCreateSection("Sound"); sound->Set("Enable", bEnableSound); diff --git a/Core/Config.h b/Core/Config.h index f98545acc..cda80aaa5 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -92,6 +92,8 @@ public: int iCurrentStateSlot; bool bEnableCheats; bool bReloadCheats; + bool bDisableStencilTest; + bool bAlwaysDepthWrite; // Sound bool bEnableSound; diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index a5c1d802e..32dc66551 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -228,6 +228,9 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.blendEquation.set(eqLookup[blendFuncEq]); } + bool alwaysDepthWrite = g_Config.bAlwaysDepthWrite; + bool enableStencilTest = !g_Config.bDisableStencilTest; + // Dither if (gstate.isDitherEnabled()) { glstate.dither.enable(); @@ -247,7 +250,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { // Depth Test glstate.depthTest.enable(); glstate.depthFunc.set(GL_ALWAYS); - glstate.depthWrite.set(gstate.isClearModeDepthWriteEnabled() ? GL_TRUE : GL_FALSE); + glstate.depthWrite.set(gstate.isClearModeDepthWriteEnabled() || alwaysDepthWrite ? GL_TRUE : GL_FALSE); // Color Test bool colorMask = gstate.isClearModeColorMask(); @@ -255,7 +258,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask); // Stencil Test - if (alphaMask) { + if (alphaMask && enableStencilTest) { glstate.stencilTest.enable(); glstate.stencilOp.set(GL_REPLACE, GL_REPLACE, GL_REPLACE); glstate.stencilFunc.set(GL_ALWAYS, 0, 0xFF); @@ -284,7 +287,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { if (gstate.isDepthTestEnabled()) { glstate.depthTest.enable(); glstate.depthFunc.set(ztests[gstate.getDepthTestFunction()]); - glstate.depthWrite.set(gstate.isDepthWriteEnabled() ? GL_TRUE : GL_FALSE); + glstate.depthWrite.set(gstate.isDepthWriteEnabled() || alwaysDepthWrite ? GL_TRUE : GL_FALSE); } else glstate.depthTest.disable(); @@ -297,7 +300,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) { glstate.colorMask.set(rmask, gmask, bmask, amask); // Stencil Test - if (gstate.isStencilTestEnabled()) { + if (gstate.isStencilTestEnabled() && enableStencilTest) { glstate.stencilTest.enable(); glstate.stencilFunc.set(ztests[gstate.getStencilTestFunction()], gstate.getStencilTestRef(), diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 8a00e05b4..aa569eb5b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -293,6 +293,10 @@ 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, 4, gs, screenManager())); + graphicsSettings->Add(new ItemHeader(gs->T("Hack Setting"))); + graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test"))); + graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write"))); + // Developer tools are not accessible ingame, so it goes here graphicsSettings->Add(new ItemHeader(gs->T("Debugging"))); Choice *dump = graphicsSettings->Add(new Choice(gs->T("Dump next frame to log"))); From 1c583093f39bdfd57219a0b36ef7413830ae77f4 Mon Sep 17 00:00:00 2001 From: raven02 Date: Fri, 6 Sep 2013 16:08:03 +0800 Subject: [PATCH 2/2] Change item-name to "Hack Settings" --- UI/GameSettingsScreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index aa569eb5b..b80e77cae 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -293,7 +293,7 @@ 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, 4, gs, screenManager())); - graphicsSettings->Add(new ItemHeader(gs->T("Hack Setting"))); + graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings"))); graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test"))); graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gs->T("Always Depth Write")));