Reduce texture sampler state changes in Metal (#3236)

This commit is contained in:
yousifd
2025-02-24 19:11:26 +03:00
committed by GitHub
parent 8e1753c6f6
commit 5b2e3b92c3

View File

@@ -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 {