GFXStateBlockDesc memory leak fix.

This commit is contained in:
Nick-IronTower 2025-06-06 14:52:20 +03:00
parent b4ca6c6e88
commit 01ffdae89a
2 changed files with 7 additions and 3 deletions

View file

@ -292,8 +292,9 @@ GFXStateBlockRef GFXDevice::createStateBlock(const GFXStateBlockDesc& desc)
PROFILE_SCOPE( GFXDevice_CreateStateBlock ); PROFILE_SCOPE( GFXDevice_CreateStateBlock );
U32 hashValue = desc.getHashValue(); U32 hashValue = desc.getHashValue();
if (mCurrentStateBlocks[hashValue]) auto it = mCurrentStateBlocks.find(hashValue);
return mCurrentStateBlocks[hashValue]; if (it != mCurrentStateBlocks.end())
return it->value;
GFXStateBlockRef result = createStateBlockInternal(desc); GFXStateBlockRef result = createStateBlockInternal(desc);
result->registerResourceWithDevice(this); result->registerResourceWithDevice(this);

View file

@ -36,7 +36,7 @@
#include "core/color.h" #include "core/color.h"
#endif #endif
#pragma pack(push, 1)
struct GFXSamplerStateDesc struct GFXSamplerStateDesc
{ {
GFXTextureAddressMode addressModeU; GFXTextureAddressMode addressModeU;
@ -84,8 +84,10 @@ struct GFXSamplerStateDesc
return !dMemcmp(this, &b, sizeof(GFXSamplerStateDesc)); return !dMemcmp(this, &b, sizeof(GFXSamplerStateDesc));
} }
}; };
#pragma pack(pop)
/// GFXStateBlockDesc defines a render state, which is then used to create a GFXStateBlock instance. /// GFXStateBlockDesc defines a render state, which is then used to create a GFXStateBlock instance.
#pragma pack(push, 1)
struct GFXStateBlockDesc struct GFXStateBlockDesc
{ {
// Blending // Blending
@ -189,6 +191,7 @@ struct GFXStateBlockDesc
/// ///
void setColorWrites( bool red, bool green, bool blue, bool alpha ); void setColorWrites( bool red, bool green, bool blue, bool alpha );
}; };
#pragma pack(pop)
class GFXStateBlock : public StrongRefBase, public GFXResource class GFXStateBlock : public StrongRefBase, public GFXResource
{ {