summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureCacheBase.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-08-08 21:11:50 -0700
committerPokechu22 <Pokechu022@gmail.com>2021-11-17 20:04:34 -0800
commit4a9b26de86aa7e99af51016e07a755968b8777e0 (patch)
treec8b81ec25625e1d33d3b5a89e76329cf02d25e12 /Source/Core/VideoCommon/TextureCacheBase.cpp
parent9ef228503abe24820985e431ef942c6ebb312442 (diff)
VideoCommon: Expose SamplerState to shaders
The benefit to exposing this over the raw BP state is that adjustments Dolphin makes, such as LOD biases from arbitrary mipmap detection, will work properly.
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index 0127137c8d..10b088283d 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -988,15 +988,15 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex,
// Force texture filtering config option.
if (g_ActiveConfig.bForceFiltering)
{
- state.min_filter = SamplerState::Filter::Linear;
- state.mag_filter = SamplerState::Filter::Linear;
- state.mipmap_filter = tm0.mipmap_filter != MipMode::None ? SamplerState::Filter::Linear :
- SamplerState::Filter::Point;
+ state.tm0.min_filter = FilterMode::Linear;
+ state.tm0.mag_filter = FilterMode::Linear;
+ state.tm0.mipmap_filter =
+ tm0.mipmap_filter != MipMode::None ? FilterMode::Linear : FilterMode::Near;
}
// Custom textures may have a greater number of mips
if (custom_tex)
- state.max_lod = 255;
+ state.tm1.max_lod = 255;
// Anisotropic filtering option.
if (g_ActiveConfig.iMaxAnisotropy != 0 && IsAnisostropicEnhancementSafe(tm0))
@@ -1008,15 +1008,15 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex,
// Letting the game set other combinations will have varying arbitrary results;
// possibly being interpreted as equal to bilinear/trilinear, implicitly
// disabling anisotropy, or changing the anisotropic algorithm employed.
- state.min_filter = SamplerState::Filter::Linear;
- state.mag_filter = SamplerState::Filter::Linear;
+ state.tm0.min_filter = FilterMode::Linear;
+ state.tm0.mag_filter = FilterMode::Linear;
if (tm0.mipmap_filter != MipMode::None)
- state.mipmap_filter = SamplerState::Filter::Linear;
- state.anisotropic_filtering = 1;
+ state.tm0.mipmap_filter = FilterMode::Linear;
+ state.tm0.anisotropic_filtering = true;
}
else
{
- state.anisotropic_filtering = 0;
+ state.tm0.anisotropic_filtering = false;
}
if (has_arbitrary_mips && tm0.mipmap_filter != MipMode::None)
@@ -1025,14 +1025,15 @@ static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex,
// that have arbitrary contents, eg. are used for fog effects where the
// distance they kick in at is important to preserve at any resolution.
// Correct this with the upscaling factor of custom textures.
- s64 lod_offset = std::log2(g_renderer->GetEFBScale() / custom_tex_scale) * 256.f;
- state.lod_bias = std::clamp<s64>(state.lod_bias + lod_offset, -32768, 32767);
+ s32 lod_offset = std::log2(g_renderer->GetEFBScale() / custom_tex_scale) * 256.f;
+ state.tm0.lod_bias = std::clamp<s32>(state.tm0.lod_bias + lod_offset, -32768, 32767);
// Anisotropic also pushes mips farther away so it cannot be used either
- state.anisotropic_filtering = 0;
+ state.tm0.anisotropic_filtering = false;
}
g_renderer->SetSamplerState(index, state);
+ PixelShaderManager::SetSamplerState(index, state.tm0.hex, state.tm1.hex);
}
void TextureCacheBase::BindTextures(BitSet32 used_textures)