From 5b2e3b92c3895f06508a441f014c5763c81ae333 Mon Sep 17 00:00:00 2001 From: yousifd Date: Mon, 24 Feb 2025 19:11:26 +0300 Subject: [PATCH] Reduce texture sampler state changes in Metal (#3236) --- src/mbgl/mtl/texture2d.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mbgl/mtl/texture2d.cpp b/src/mbgl/mtl/texture2d.cpp index 816ed9a08..d847326ae 100644 --- a/src/mbgl/mtl/texture2d.cpp +++ b/src/mbgl/mtl/texture2d.cpp @@ -21,6 +21,11 @@ Texture2D::~Texture2D() { } gfx::Texture2D& Texture2D::setSamplerConfiguration(const SamplerState& samplerState_) noexcept { + if (samplerState.filter == samplerState_.filter && samplerState.wrapU == samplerState_.wrapU && + samplerState.wrapV == samplerState_.wrapV) { + return *this; + } + samplerState = samplerState_; samplerStateDirty = true; return *this; @@ -216,6 +221,8 @@ void Texture2D::updateSamplerConfiguration() noexcept { ? MTL::SamplerAddressModeClampToEdge : MTL::SamplerAddressModeRepeat); metalSamplerState = context.createMetalSamplerState(samplerDescriptor); + + samplerStateDirty = false; } void Texture2D::bind(RenderPass& renderPass, int32_t location) noexcept {