Skip to content

Commit

Permalink
Reduce texture sampler state changes in Metal (#3236)
Browse files Browse the repository at this point in the history
  • Loading branch information
yousifd authored Feb 24, 2025
1 parent 8e1753c commit 5b2e3b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mbgl/mtl/texture2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5b2e3b9

Please sign in to comment.