TextureCache: Add automatic anisotropic filtering and refactor code.

This commit is contained in:
Fernando Sahmkow 2021-11-16 23:07:17 +01:00
parent 5230378709
commit 282e04bffb
5 changed files with 22 additions and 16 deletions

View file

@ -1201,13 +1201,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const TSCEntry& config) {
glSamplerParameterfv(handle, GL_TEXTURE_BORDER_COLOR, config.BorderColor().data());
if (GLAD_GL_ARB_texture_filter_anisotropic || GLAD_GL_EXT_texture_filter_anisotropic) {
const f32 setting_anisotropic =
static_cast<f32>(1U << Settings::values.max_anisotropy.GetValue());
const f32 game_anisotropic = std::clamp(config.MaxAnisotropy(), 1.0f, 16.0f);
const bool aument_anisotropic =
game_anisotropic > 1.0f || config.mipmap_filter == TextureMipmapFilter::Linear;
const f32 max_anisotropy =
aument_anisotropic ? std::max(game_anisotropic, setting_anisotropic) : game_anisotropic;
const f32 max_anisotropy = std::clamp(config.MaxAnisotropy(), 1.0f, 16.0f);
glSamplerParameterf(handle, GL_TEXTURE_MAX_ANISOTROPY, max_anisotropy);
} else {
LOG_WARNING(Render_OpenGL, "GL_ARB_texture_filter_anisotropic is required");