diff options
| author | Matthew Parlane <parlane@gmail.com> | 2013-02-09 20:13:11 +1300 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2013-02-09 20:13:11 +1300 |
| commit | 3d480c088fa27c6dcadef40042a0e8deb3093985 (patch) | |
| tree | ab6b184b074261f608dff9b06b5a6e2e6bf52b30 /Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | |
| parent | e62c9b0619a42f6e551ba928560fcb825b6ac9c5 (diff) | |
| parent | a11827cdf0ccc55b9a3f6259a27a9324e24cd018 (diff) | |
Merge branch 'master' into wii-network
Conflicts:
Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp')
| -rw-r--r-- | Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 81 |
1 files changed, 31 insertions, 50 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 1c43ed1d59..bf6f6d1ef2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -58,24 +58,6 @@ namespace OGL static u32 s_TempFramebuffer = 0; -static const GLint c_MinLinearFilter[8] = { - GL_NEAREST, - GL_NEAREST_MIPMAP_NEAREST, - GL_NEAREST_MIPMAP_LINEAR, - GL_NEAREST, - GL_LINEAR, - GL_LINEAR_MIPMAP_NEAREST, - GL_LINEAR_MIPMAP_LINEAR, - GL_LINEAR, -}; - -static const GLint c_WrapSettings[4] = { - GL_CLAMP_TO_EDGE, - GL_REPEAT, - GL_MIRRORED_REPEAT, - GL_REPEAT, -}; - bool SaveTexture(const char* filename, u32 textarget, u32 tex, int virtual_width, int virtual_height, unsigned int level) { int width = std::max(virtual_width >> level, 1); @@ -201,7 +183,7 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width, } void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, - unsigned int expanded_width, unsigned int level, bool autogen_mips) + unsigned int expanded_width, unsigned int level) { //glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); @@ -212,16 +194,7 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height, if (expanded_width != width) glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width); - if (bHaveMipMaps && autogen_mips) - { - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp); - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); - } - else - { - glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp); - } + glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp); if (expanded_width != width) glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); @@ -357,35 +330,43 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, const TexMode1 &newmode1) { - // TODO: not used anywhere - TexMode0 mode = newmode; - //mode1 = newmode1; + const GLint c_MinLinearFilter[8] = + { + GL_NEAREST, + GL_NEAREST_MIPMAP_NEAREST, + GL_NEAREST_MIPMAP_LINEAR, + GL_NEAREST, + GL_LINEAR, + GL_LINEAR_MIPMAP_NEAREST, + GL_LINEAR_MIPMAP_LINEAR, + GL_LINEAR, + }; + const GLint c_WrapSettings[4] = + { + GL_CLAMP_TO_EDGE, + GL_REPEAT, + GL_MIRRORED_REPEAT, + GL_REPEAT, + }; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - (newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST); + int filt = newmode.min_filter; + if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4) + filt += 4; // take equivalent forced linear - if (bHaveMipMaps) - { - // TODO: not used anywhere - if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4) - mode.min_filter += 4; // take equivalent forced linear - - int filt = newmode.min_filter; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, newmode1.min_lod >> 4); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, newmode1.max_lod >> 4); - glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, (newmode.lod_bias / 32.0f)); - } - else - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - (g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, newmode1.min_lod / 16.f); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, newmode1.max_lod / 16.f); + glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, (s32)newmode.lod_bias / 32.0f); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c_WrapSettings[newmode.wrap_s]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]); + // TODO: Reset anisotrop when changed to 1 if (g_Config.iMaxAnisotropy >= 1) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - (float)(1 << g_ActiveConfig.iMaxAnisotropy)); + (float)(1 << g_ActiveConfig.iMaxAnisotropy)); } TextureCache::~TextureCache() |
