summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorTilka <tilkax@gmail.com>2025-04-02 09:07:44 +0100
committerGitHub <noreply@github.com>2025-04-02 09:07:44 +0100
commitc705e366f0204f7b3a8418ed1967b0cb233f22ce (patch)
tree3981317e060f87280f98ee9f6305042fa1b5f8a6 /Source/Core
parent1b85da9b85e72a555a08138aafcd2d75210ae078 (diff)
parent33a7283d3b281be2d5425217b7325561f2250b7d (diff)
Merge pull request #13478 from jordan-woyak/metal-af
VideoBackends/Metal: Fix anisotropic filtering handling.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/Metal/MTLObjectCache.h12
-rw-r--r--Source/Core/VideoBackends/Metal/MTLObjectCache.mm4
2 files changed, 8 insertions, 8 deletions
diff --git a/Source/Core/VideoBackends/Metal/MTLObjectCache.h b/Source/Core/VideoBackends/Metal/MTLObjectCache.h
index 8404a6db57..18fac51253 100644
--- a/Source/Core/VideoBackends/Metal/MTLObjectCache.h
+++ b/Source/Core/VideoBackends/Metal/MTLObjectCache.h
@@ -44,7 +44,7 @@ struct DepthStencilSelector
struct SamplerSelector
{
- u8 value;
+ u16 value;
SamplerSelector() : value(0) {}
SamplerSelector(SamplerState state)
{
@@ -54,17 +54,17 @@ struct SamplerSelector
(static_cast<u32>(state.tm0.anisotropic_filtering) << 3);
value |= (static_cast<u32>(state.tm0.wrap_u.Value()) +
3 * static_cast<u32>(state.tm0.wrap_v.Value()))
- << 4;
+ << 7;
}
FilterMode MinFilter() const { return static_cast<FilterMode>(value & 1); }
FilterMode MagFilter() const { return static_cast<FilterMode>((value >> 1) & 1); }
FilterMode MipFilter() const { return static_cast<FilterMode>((value >> 2) & 1); }
- WrapMode WrapU() const { return static_cast<WrapMode>((value >> 4) % 3); }
- WrapMode WrapV() const { return static_cast<WrapMode>((value >> 4) / 3); }
- bool AnisotropicFiltering() const { return ((value >> 3) & 1); }
+ WrapMode WrapU() const { return static_cast<WrapMode>((value >> 7) % 3); }
+ WrapMode WrapV() const { return static_cast<WrapMode>((value >> 7) / 3); }
+ u32 AnisotropicFiltering() const { return ((value >> 3) & 0xf); }
bool operator==(const SamplerSelector& other) const { return value == other.value; }
- static constexpr size_t N_VALUES = (1 << 4) * 9;
+ static constexpr size_t N_VALUES = (1 << 7) * 9;
};
class ObjectCache
diff --git a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm
index 2a36530161..97cef130ed 100644
--- a/Source/Core/VideoBackends/Metal/MTLObjectCache.mm
+++ b/Source/Core/VideoBackends/Metal/MTLObjectCache.mm
@@ -173,10 +173,10 @@ MRCOwned<id<MTLSamplerState>> Metal::ObjectCache::CreateSampler(SamplerSelector
[desc setTAddressMode:Convert(sel.WrapV())];
[desc setMaxAnisotropy:1 << sel.AnisotropicFiltering()];
[desc setLabel:MRCTransfer([[NSString alloc]
- initWithFormat:@"%s%s%s %s%s%s", to_string(sel.MinFilter()),
+ initWithFormat:@"%s%s%s %s%s%d", to_string(sel.MinFilter()),
to_string(sel.MagFilter()), to_string(sel.MipFilter()),
to_string(sel.WrapU()), to_string(sel.WrapV()),
- sel.AnisotropicFiltering() ? "(AF)" : ""])];
+ 1 << sel.AnisotropicFiltering()])];
return MRCTransfer([Metal::g_device newSamplerStateWithDescriptor:desc]);
}
}