From 99458d7797b378936cec42bcf08a3f381225128a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 15 May 2014 22:38:44 -0700 Subject: [PATCH] Avoid forcing nearest/disabling linear if possible. If we know that the test is trivially true, we don't need to worry about the test. May help #4405. --- GPU/GLES/FragmentShaderGenerator.cpp | 4 ++-- GPU/GLES/FragmentShaderGenerator.h | 2 ++ GPU/GLES/TextureCache.cpp | 19 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index 025273d06e4a..90078f7272f8 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -52,7 +52,7 @@ const bool safeDestFactors[16] = { true, //GE_DSTBLEND_FIXB, }; -static bool IsAlphaTestTriviallyTrue() { +bool IsAlphaTestTriviallyTrue() { switch (gstate.getAlphaTestFunction()) { case GE_COMP_NEVER: return false; @@ -215,7 +215,7 @@ StencilValueType ReplaceAlphaWithStencilType() { return STENCIL_VALUE_UNKNOWN; } -static bool IsColorTestTriviallyTrue() { +bool IsColorTestTriviallyTrue() { switch (gstate.getColorTestFunction()) { case GE_COMP_NEVER: return false; diff --git a/GPU/GLES/FragmentShaderGenerator.h b/GPU/GLES/FragmentShaderGenerator.h index 356135ef59de..73c605e310d8 100644 --- a/GPU/GLES/FragmentShaderGenerator.h +++ b/GPU/GLES/FragmentShaderGenerator.h @@ -58,6 +58,8 @@ enum ReplaceAlphaType { REPLACE_ALPHA_DUALSOURCE = 2, }; +bool IsAlphaTestTriviallyTrue(); +bool IsColorTestTriviallyTrue(); StencilValueType ReplaceAlphaWithStencilType(); ReplaceAlphaType ReplaceAlphaWithStencil(); diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 5f53dc88061a..f2e9b7eca1f5 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -26,6 +26,7 @@ #include "GPU/GPUState.h" #include "GPU/GLES/TextureCache.h" #include "GPU/GLES/Framebuffer.h" +#include "GPU/GLES/FragmentShaderGenerator.h" #include "GPU/Common/TextureDecoder.h" #include "Core/Config.h" #include "Core/Host.h" @@ -521,12 +522,18 @@ void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) { } } - if ((g_Config.iTexFiltering == LINEAR && !gstate.isColorTestEnabled() && !gstate.isAlphaTestEnabled()) || (g_Config.iTexFiltering == LINEARFMV && g_iNumVideos)) { + if (g_Config.iTexFiltering == LINEARFMV && g_iNumVideos > 0 && (entry.dim & 0xF) >= 9) { magFilt |= 1; minFilt |= 1; } + if (g_Config.iTexFiltering == LINEAR && (!gstate.isColorTestEnabled() || IsColorTestTriviallyTrue())) { + if (!gstate.isAlphaTestEnabled() || IsAlphaTestTriviallyTrue()) { + magFilt |= 1; + minFilt |= 1; + } + } // Force Nearest when color test enabled and rendering resolution greater than 480x272 - if (g_Config.iTexFiltering == NEAREST || (gstate.isColorTestEnabled() && g_Config.iInternalResolution != 1 && gstate.isModeThrough())) { + if (g_Config.iTexFiltering == NEAREST || ((gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue()) && g_Config.iInternalResolution != 1 && gstate.isModeThrough())) { magFilt &= ~1; minFilt &= ~1; } @@ -878,12 +885,12 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry) { entry->framebuffer->last_frame_used = gpuStats.numFlips; // We need to force it, since we may have set it on a texture before attaching. - UpdateSamplingParams(*entry, true); gstate_c.curTextureWidth = entry->framebuffer->width; gstate_c.curTextureHeight = entry->framebuffer->height; gstate_c.flipTexture = true; gstate_c.textureFullAlpha = entry->framebuffer->format == GE_FORMAT_565; gstate_c.textureSimpleAlpha = false; + UpdateSamplingParams(*entry, true); } else { if (entry->framebuffer->fbo) entry->framebuffer->fbo = 0; @@ -1296,15 +1303,15 @@ void TextureCache::SetTexture(bool force) { float anisotropyLevel = (float) aniso > maxAnisotropyLevel ? maxAnisotropyLevel : (float) aniso; glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropyLevel); + gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL; + gstate_c.textureSimpleAlpha = entry->GetAlphaStatus() != TexCacheEntry::STATUS_ALPHA_UNKNOWN; + UpdateSamplingParams(*entry, true); //glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_ALIGNMENT, 1); - - gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL; - gstate_c.textureSimpleAlpha = entry->GetAlphaStatus() != TexCacheEntry::STATUS_ALPHA_UNKNOWN; } GLenum TextureCache::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const {