Centralize sampling params and test optimizations.

This commit is contained in:
Unknown W. Brackets committed 2015-09-13 06:38:07 -07:00
1 parent 4815046ba6
commit e1df8fc45f
17 files changed
+197 -323

No files matched your search

-47
View File
@@ -660,53 +660,6 @@ static const GLuint MagFiltGL[2] = {
GL_LINEAR
};
void TextureCache::GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, int 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 == LINEARFMV && g_iNumVideos > 0 && (gstate.getTextureDimension(0) & 0xF) >= 9) {
magFilt |= 1;
minFilt |= 1;
}
if (g_Config.iTexFiltering == LINEAR && (!gstate.isColorTestEnabled() || IsColorTestTriviallyTrue())) {
// TODO: IsAlphaTestTriviallyTrue() is unsafe here. vertexFullAlpha is not calculated yet.
if (!gstate.isAlphaTestEnabled() || IsAlphaTestTriviallyTrue()) {
magFilt |= 1;
minFilt |= 1;
}
}
bool forceNearest = g_Config.iTexFiltering == 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;
}
}
// This should not have to be done per texture! OpenGL is silly yo
void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) {
int minFilt;