// Copyright (c) 2013- PPSSPP Project. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, version 2.0 or later versions. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License 2.0 for more details. // A copy of the GPL 2.0 should have been included with the program. // If not, see http://www.gnu.org/licenses/ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "Core/Config.h" #include "GPU/Common/GPUStateUtils.h" #include "GPU/Common/TextureCacheCommon.h" #include "GPU/GPUState.h" // Ugly. extern int g_iNumVideos; TextureCacheCommon::~TextureCacheCommon() {} bool TextureCacheCommon::SetOffsetTexture(u32 offset) { return false; } void TextureCacheCommon::GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, u8 maxLevel) { minFilt = gstate.texfilter & 0x7; magFilt = (gstate.texfilter>>8) & 1; sClamp = gstate.isTexCoordClampedS(); tClamp = gstate.isTexCoordClampedT(); bool noMip = (gstate.texlevel & 0xFFFFFF) == 0x000001 || (gstate.texlevel & 0xFFFFFF) == 0x100001 ; // Fix texlevel at 0 if (maxLevel == 0) { // Enforce no mip filtering, for safety. minFilt &= 1; // no mipmaps yet lodBias = 0.0f; } else { // Texture lod bias should be signed. lodBias = (float)(int)(s8)((gstate.texlevel >> 16) & 0xFF) / 16.0f; } if (g_Config.iTexFiltering == TEX_FILTER_LINEAR_VIDEO && g_iNumVideos > 0 && (gstate.getTextureDimension(0) & 0xF) >= 9) { magFilt |= 1; minFilt |= 1; } if (g_Config.iTexFiltering == TEX_FILTER_LINEAR && (!gstate.isColorTestEnabled() || IsColorTestTriviallyTrue())) { if (!gstate.isAlphaTestEnabled() || IsAlphaTestTriviallyTrue()) { magFilt |= 1; minFilt |= 1; } } bool forceNearest = g_Config.iTexFiltering == TEX_FILTER_NEAREST; // Force Nearest when color test enabled and rendering resolution greater than 480x272 if ((gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue()) && g_Config.iInternalResolution != 1 && gstate.isModeThrough()) { // Some games use 0 as the color test color, which won't be too bad if it bleeds. // Fuchsia and green, etc. are the problem colors. if (gstate.getColorTestRef() != 0) { forceNearest = true; } } if (forceNearest) { magFilt &= ~1; minFilt &= ~1; } if (!g_Config.bMipMap || noMip) { minFilt &= 1; } }