summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authorMarkus Wick <markus@selfnet.de>2018-01-06 10:50:25 +0100
committerMarkus Wick <markus@selfnet.de>2018-01-17 09:02:36 +0100
commitcb7eede193b1644b58fdfaf03925d483832dddae (patch)
tree77edf944ca5db6f158b01756a6206d645619d233 /Source/Core/VideoCommon/VertexManagerBase.cpp
parent2a43f41acec1d79865f3a1c4e951eaf766d0fec1 (diff)
VideoCommon: Apply custom texture scale for arbitrary mipmaps.
We want to get the same mipmap level. And if the IR and the custom texture upscaling fits, we don't need to modify the LOD bias.
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 97f508fca4..44ff88b633 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -12,6 +12,8 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
+#include "Common/MathUtil.h"
+
#include "Core/ConfigManager.h"
#include "VideoCommon/BPMemory.h"
@@ -209,7 +211,8 @@ std::pair<size_t, size_t> VertexManagerBase::ResetFlushAspectRatioCount()
return val;
}
-static void SetSamplerState(u32 index, bool custom_tex, bool has_arbitrary_mips)
+static void SetSamplerState(u32 index, float custom_tex_scale, bool custom_tex,
+ bool has_arbitrary_mips)
{
const FourTexUnits& tex = bpmem.tex[index / 4];
const TexMode0& tm0 = tex.texMode0[index % 4];
@@ -257,8 +260,9 @@ static void SetSamplerState(u32 index, bool custom_tex, bool has_arbitrary_mips)
// 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
// distance they kick in at is important to preserve at any resolution.
- state.lod_bias =
- state.lod_bias + std::log2(static_cast<float>(g_renderer->GetEFBScale())) * 256.f;
+ // 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 = MathUtil::Clamp<s64>(state.lod_bias + lod_offset, -32768, 32767);
// Anisotropic also pushes mips farther away so it cannot be used either
state.anisotropic_filtering = 0;
@@ -335,7 +339,8 @@ void VertexManagerBase::Flush()
if (tentry)
{
- SetSamplerState(i, tentry->is_custom_tex, tentry->has_arbitrary_mips);
+ float custom_tex_scale = tentry->GetWidth() / float(tentry->native_width);
+ SetSamplerState(i, custom_tex_scale, tentry->is_custom_tex, tentry->has_arbitrary_mips);
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height);
}
else