From 2b6d5b07c1a274d9aa5cf459e0aa02715c1c7693 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 18 Feb 2024 19:00:50 -0300 Subject: [PATCH] Fix potential crash when setting a datablock to have no textures As a precondition, the datablock must've had textures before, the datablock ended up fully loaded and baked with textures, and not be running on OpenGL. --- .../Hlms/Common/include/OgreHlmsTextureBaseClass.inl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Components/Hlms/Common/include/OgreHlmsTextureBaseClass.inl b/Components/Hlms/Common/include/OgreHlmsTextureBaseClass.inl index 47f56fb08d7..d10af2a3f88 100644 --- a/Components/Hlms/Common/include/OgreHlmsTextureBaseClass.inl +++ b/Components/Hlms/Common/include/OgreHlmsTextureBaseClass.inl @@ -288,9 +288,15 @@ namespace Ogre else if( !mSamplersDescSet || *mSamplersDescSet != baseSampler ) { if( mSamplersDescSet ) + { hlmsManager->destroyDescriptorSetSampler( mSamplersDescSet ); - mSamplersDescSet = hlmsManager->getDescriptorSetSampler( baseSampler ); - needsRecalculateHash = true; + mSamplersDescSet = 0; + } + if( !baseSampler.mSamplers.empty() ) + { + mSamplersDescSet = hlmsManager->getDescriptorSetSampler( baseSampler ); + needsRecalculateHash = true; + } } return needsRecalculateHash;