diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp index 558851694a..c9475eef14 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp @@ -159,6 +159,8 @@ void plGLDevice::Shutdown() { if (fImpl) fImpl->Shutdown(); + + delete fImpl; } void plGLDevice::SetRenderTarget(plRenderTarget* target) diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.h b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.h index e4deb36dfa..ff3d553f90 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.h +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.h @@ -64,6 +64,8 @@ class plGLDeviceImpl : fWindow(window), fDevice(device) {}; public: + virtual ~plGLDeviceImpl() { }; + virtual void Shutdown() = 0; virtual bool BeginRender(ST::string& error) = 0; virtual bool EndRender(ST::string& error) = 0; diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRef.h b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRef.h index 8936e70a20..a404e94bfd 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRef.h +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRef.h @@ -222,7 +222,7 @@ class plGLRenderTargetRef: public plGLTextureRef virtual ~plGLRenderTargetRef(); - void Release(); + void Release() override; virtual void SetOwner(plRenderTarget* targ) { fOwner = (plBitmap*)targ; } }; diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRefs.cpp b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRefs.cpp index 0adce49552..21330c3672 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRefs.cpp +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLDeviceRefs.cpp @@ -39,13 +39,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com Mead, WA 99021 *==LICENSE==*/ -#include "plPipeline/hsWinRef.h" #include "plGLPipeline.h" #include "plGLDeviceRef.h" #include "plProfile.h" -#include "plStatusLog/plStatusLog.h" plProfile_Extern(MemVertex); plProfile_Extern(MemIndex); @@ -105,6 +103,11 @@ void plGLVertexBufferRef::Release() glDeleteBuffers(1, &fRef); fRef = 0; } + + if (fData) { + delete[] fData; + } + SetDirty(true); } diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLMaterialShaderRef.cpp b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLMaterialShaderRef.cpp index 8b6eeff586..452f730b37 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLMaterialShaderRef.cpp +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLMaterialShaderRef.cpp @@ -407,8 +407,8 @@ void plGLMaterialShaderRef::ICompile() LOG_GL_ERROR_CHECK("Create Program failed"); if (plGLVersion() >= 43) { - const char* name = ST::format("hsGMaterial::{}", fMaterial->GetKeyName()).c_str(); - glObjectLabel(GL_PROGRAM, fRef, strlen(name), name); + ST::string name = ST::format("hsGMaterial::{}", fMaterial->GetKeyName()); + glObjectLabel(GL_PROGRAM, fRef, strlen(name.c_str()), name.c_str()); } glAttachShader(fRef, fVertShaderRef); diff --git a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLPipeline.cpp b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLPipeline.cpp index 51fa286f2a..e8d2deb5c9 100644 --- a/Sources/Plasma/FeatureLib/pfGLPipeline/plGLPipeline.cpp +++ b/Sources/Plasma/FeatureLib/pfGLPipeline/plGLPipeline.cpp @@ -205,9 +205,15 @@ plGLPipeline::~plGLPipeline() if (plGLPlateManager* pm = static_cast(fPlateMgr)) pm->IReleaseGeometry(); + delete fPlateMgr; + fPlateMgr = nullptr; + while (fTextFontRefList) delete fTextFontRefList; + delete fDebugTextMgr; + fDebugTextMgr = nullptr; + fDevice.Shutdown(); } @@ -736,6 +742,7 @@ void plGLPipeline::RenderSpans(plDrawableSpans* ice, const std::vector& if (mRef == nullptr) { mRef = new plGLMaterialShaderRef(material, this); material->SetDeviceRef(mRef); + hsRefCnt_SafeUnRef(mRef); } if (!mRef->IsLinked()) @@ -1482,6 +1489,7 @@ void plGLPipeline::IDrawPlate(plPlate* plate) if (mRef == nullptr) { mRef = new plGLMaterialShaderRef(material, this); material->SetDeviceRef(mRef); + hsRefCnt_SafeUnRef(mRef); } if (!mRef->IsLinked()) diff --git a/Sources/Plasma/PubUtilLib/plPipeline/pl3DPipeline.h b/Sources/Plasma/PubUtilLib/plPipeline/pl3DPipeline.h index d18a06d3d6..f5931a4210 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/pl3DPipeline.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/pl3DPipeline.h @@ -1059,6 +1059,24 @@ pl3DPipeline::~pl3DPipeline() while (fActiveLights) UnRegisterLight(fActiveLights); + while (fVtxBuffRefList) { + typename DeviceType::VertexBufferRef* ref = fVtxBuffRefList; + ref->Release(); + ref->Unlink(); + } + + while (fIdxBuffRefList) { + typename DeviceType::IndexBufferRef* ref = fIdxBuffRefList; + ref->Release(); + ref->Unlink(); + } + + while (fTextureRefList) { + typename DeviceType::TextureRef* ref = fTextureRefList; + ref->Release(); + ref->Unlink(); + } + IReleaseAvRTPool(); IClearClothingOutfits(&fClothingOutfits); IClearClothingOutfits(&fPrevClothingOutfits); diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plNullPipeline.h b/Sources/Plasma/PubUtilLib/plPipeline/plNullPipeline.h index 846b2e3edb..4ad36caf02 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plNullPipeline.h +++ b/Sources/Plasma/PubUtilLib/plPipeline/plNullPipeline.h @@ -56,7 +56,9 @@ class plNullPipelineDevice uint32_t fVertexSize; uint32_t fFormat; + void Release() { } void Link(NullDeviceRef** back) { } + void Unlink() { } bool IsLinked() { return true; } bool Volatile() const { return false; } };