From 3096f77ba09fe3510a785e073602a8a829a02d9e Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 8 Aug 2021 11:05:32 -0700 Subject: [PATCH] Eliminate SamplerCommon::AreBpTexMode0MipmapsEnabled This was added in 0b9a72a62d38481ff08f742b2318d07f29ff5dff but became irrelevant in 70f9fc4e7526fc9cfc008a43cd33229f62be99b6 as the check is now self-explanatory due to a rejiggering of the bitfields. --- Source/Core/VideoBackends/Software/TextureSampler.cpp | 3 +-- Source/Core/VideoCommon/RenderState.cpp | 7 ++++--- Source/Core/VideoCommon/SamplerCommon.h | 7 ------- Source/Core/VideoCommon/TextureCacheBase.cpp | 9 ++++----- Source/Core/VideoCommon/TextureInfo.cpp | 3 +-- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Source/Core/VideoBackends/Software/TextureSampler.cpp b/Source/Core/VideoBackends/Software/TextureSampler.cpp index 064e9df41c..0ba340c33a 100644 --- a/Source/Core/VideoBackends/Software/TextureSampler.cpp +++ b/Source/Core/VideoBackends/Software/TextureSampler.cpp @@ -11,7 +11,6 @@ #include "Core/HW/Memmap.h" #include "VideoCommon/BPMemory.h" -#include "VideoCommon/SamplerCommon.h" #include "VideoCommon/TextureDecoder.h" #define ALLOW_MIPMAP 1 @@ -79,7 +78,7 @@ void Sample(s32 s, s32 t, s32 lod, bool linear, u8 texmap, u8* sample) const s32 lodFract = lod & 0xf; - if (lod > 0 && SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0)) + if (lod > 0 && tm0.mipmap_filter != MipMode::None) { // use mipmap baseMip = lod >> 4; diff --git a/Source/Core/VideoCommon/RenderState.cpp b/Source/Core/VideoCommon/RenderState.cpp index 358c99974e..85b3dc68c1 100644 --- a/Source/Core/VideoCommon/RenderState.cpp +++ b/Source/Core/VideoCommon/RenderState.cpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "VideoCommon/RenderState.h" + #include #include -#include "VideoCommon/SamplerCommon.h" + #include "VideoCommon/TextureConfig.h" void RasterizationState::Generate(const BPMemory& bp, PrimitiveType primitive_type) @@ -235,9 +236,9 @@ void SamplerState::Generate(const BPMemory& bp, u32 index) mag_filter = tm0.mag_filter == FilterMode::Linear ? Filter::Linear : Filter::Point; // If mipmaps are disabled, clamp min/max lod - max_lod = SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0) ? tm1.max_lod.Value() : 0; + max_lod = tm0.mipmap_filter != MipMode::None ? tm1.max_lod.Value() : 0; min_lod = std::min(max_lod.Value(), static_cast(tm1.min_lod)); - lod_bias = SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0) ? tm0.lod_bias * (256 / 32) : 0; + lod_bias = tm0.mipmap_filter != MipMode::None ? tm0.lod_bias * (256 / 32) : 0; // Address modes // Hardware testing indicates that wrap_mode set to 3 behaves the same as clamp. diff --git a/Source/Core/VideoCommon/SamplerCommon.h b/Source/Core/VideoCommon/SamplerCommon.h index 2b09393169..ec15f07026 100644 --- a/Source/Core/VideoCommon/SamplerCommon.h +++ b/Source/Core/VideoCommon/SamplerCommon.h @@ -17,11 +17,4 @@ constexpr bool IsBpTexMode0PointFiltering(const T& tm0) { return tm0.min_filter == FilterMode::Near && tm0.mag_filter == FilterMode::Near; } - -// Check if the minification filter has mipmap based filtering modes enabled. -template -constexpr bool AreBpTexMode0MipmapsEnabled(const T& tm0) -{ - return tm0.mipmap_filter != MipMode::None; -} } // namespace SamplerCommon diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 0f66284180..ff15a755ba 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -979,9 +979,8 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, { state.min_filter = SamplerState::Filter::Linear; state.mag_filter = SamplerState::Filter::Linear; - state.mipmap_filter = SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0) ? - SamplerState::Filter::Linear : - SamplerState::Filter::Point; + state.mipmap_filter = tm0.mipmap_filter != MipMode::None ? SamplerState::Filter::Linear : + SamplerState::Filter::Point; } // Custom textures may have a greater number of mips @@ -1000,7 +999,7 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, // disabling anisotropy, or changing the anisotropic algorithm employed. state.min_filter = SamplerState::Filter::Linear; state.mag_filter = SamplerState::Filter::Linear; - if (SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0)) + if (tm0.mipmap_filter != MipMode::None) state.mipmap_filter = SamplerState::Filter::Linear; state.anisotropic_filtering = 1; } @@ -1009,7 +1008,7 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex, state.anisotropic_filtering = 0; } - if (has_arbitrary_mips && SamplerCommon::AreBpTexMode0MipmapsEnabled(tm0)) + if (has_arbitrary_mips && tm0.mipmap_filter != MipMode::None) { // Apply a secondary bias calculated from the IR scale to pull inwards mipmaps // that have arbitrary contents, eg. are used for fog effects where the diff --git a/Source/Core/VideoCommon/TextureInfo.cpp b/Source/Core/VideoCommon/TextureInfo.cpp index 6959b95534..696f5b904c 100644 --- a/Source/Core/VideoCommon/TextureInfo.cpp +++ b/Source/Core/VideoCommon/TextureInfo.cpp @@ -9,7 +9,6 @@ #include "Common/Align.h" #include "Core/HW/Memmap.h" #include "VideoCommon/BPMemory.h" -#include "VideoCommon/SamplerCommon.h" #include "VideoCommon/TextureDecoder.h" TextureInfo TextureInfo::FromStage(u32 stage) @@ -28,7 +27,7 @@ TextureInfo TextureInfo::FromStage(u32 stage) const u8* tlut_ptr = &texMem[tlutaddr]; std::optional mip_count; - const bool has_mipmaps = SamplerCommon::AreBpTexMode0MipmapsEnabled(tex.texMode0); + const bool has_mipmaps = tex.texMode0.mipmap_filter != MipMode::None; if (has_mipmaps) { mip_count = (tex.texMode1.max_lod + 0xf) / 0x10;