소스 검색

Merge pull request #1494 from Nick-IronTower/development

Fixed major memory leak in GFXDevice::createStateBlock()
Brian Roberts 3 달 전
부모
커밋
432d914e9d
2개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 2
      Engine/source/gfx/gfxDevice.cpp
  2. 4 1
      Engine/source/gfx/gfxStateBlock.h

+ 3 - 2
Engine/source/gfx/gfxDevice.cpp

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

+ 4 - 1
Engine/source/gfx/gfxStateBlock.h

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