From 6296e4442515084bc95aa520f0e71c4191160693 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 4 Apr 2021 23:48:23 -0300 Subject: [PATCH] metal: fix clampzero wrap mode. --- src/modules/graphics/metal/Graphics.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/metal/Graphics.mm b/src/modules/graphics/metal/Graphics.mm index 509bbcbfb..23aa90113 100644 --- a/src/modules/graphics/metal/Graphics.mm +++ b/src/modules/graphics/metal/Graphics.mm @@ -643,6 +643,11 @@ void Graphics::submitBlitEncoder() } } +static bool isClampOne(SamplerState::WrapMode w) +{ + return w == SamplerState::WRAP_CLAMP_ONE; +} + id Graphics::getCachedSampler(const SamplerState &s) { @autoreleasepool { uint64 key = s.toKey(); @@ -662,8 +667,11 @@ id Graphics::getCachedSampler(const SamplerState &s) desc.tAddressMode = getMTLSamplerAddressMode(s.wrapV); desc.rAddressMode = getMTLSamplerAddressMode(s.wrapW); - if (@available(macOS 10.12, iOS 10.14, *)) - desc.borderColor = MTLSamplerBorderColorOpaqueWhite; + if (isClampOne(s.wrapU) || isClampOne(s.wrapV) || isClampOne(s.wrapW)) + { + if (@available(macOS 10.12, iOS 10.14, *)) + desc.borderColor = MTLSamplerBorderColorOpaqueWhite; + } desc.lodMinClamp = s.minLod; desc.lodMaxClamp = s.maxLod;