From 11d17e1db37efc5813fdc1936a5381de0b01a066 Mon Sep 17 00:00:00 2001 From: Ben Doherty Date: Tue, 16 Aug 2022 10:46:35 -0700 Subject: [PATCH] Fix SamplerGroup update issue (#5928) --- filament/backend/src/SamplerGroup.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/filament/backend/src/SamplerGroup.cpp b/filament/backend/src/SamplerGroup.cpp index c3e720f713..fa6d028d19 100644 --- a/filament/backend/src/SamplerGroup.cpp +++ b/filament/backend/src/SamplerGroup.cpp @@ -41,11 +41,12 @@ SamplerGroup& SamplerGroup::operator=(const SamplerGroup& rhs) noexcept { void SamplerGroup::setSampler(size_t index, SamplerDescriptor sampler) noexcept { if (UTILS_LIKELY(index < mBuffer.size())) { - if (mBuffer[index].s.u != sampler.s.u || mBuffer[index].t != sampler.t) { - // it's a big deal to mutate a sampler group, so we avoid doing it. - mBuffer[index] = sampler; - mDirty = true; - } + // We cannot compare two texture handles to determine if an update is needed. Texture + // handles are (quickly) recycled and therefore can't be used for that purpose. e.g. if a + // texture is destroyed, its handle could be reused quickly by another texture. + // TODO: find a way to avoid marking dirty if the texture does not change. + mBuffer[index] = sampler; + mDirty = true; } }