Merge pull request #3646 from raven02/patch-17

Toggle option "Disable Stencil Test" & "Always Depth Write"
This commit is contained in:
Henrik Rydgård 2013-09-09 00:06:00 -07:00
commit 74418c13bf
4 changed files with 17 additions and 4 deletions

View File

@ -167,6 +167,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);
@ -322,6 +324,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);

View File

@ -92,6 +92,8 @@ public:
int iCurrentStateSlot;
bool bEnableCheats;
bool bReloadCheats;
bool bDisableStencilTest;
bool bAlwaysDepthWrite;
// Sound
bool bEnableSound;

View File

@ -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(),

View File

@ -154,6 +154,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 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")));
// 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")));