From 14f7dbade88da108bf135aaeaaead9b14c654a14 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 29 Dec 2020 20:30:57 +0100 Subject: [PATCH] fix custom pipes mem leak --- src/core/Game.cpp | 14 ++++++++++++++ src/core/main.cpp | 15 +-------------- src/extras/custompipes_d3d9.cpp | 9 +++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/core/Game.cpp b/src/core/Game.cpp index ff87b95a..7961b981 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -274,12 +274,26 @@ CGame::InitialiseRenderWare(void) CPlayerSkin::Initialise(); #endif +#ifdef EXTENDED_PIPELINES + CustomPipes::CustomPipeInit(); // need Scene.world for this +#endif +#ifdef SCREEN_DROPLETS + ScreenDroplets::InitDraw(); +#endif + return (true); } // missing altogether on PS2 void CGame::ShutdownRenderWare(void) { +#ifdef SCREEN_DROPLETS + ScreenDroplets::Shutdown(); +#endif +#ifdef EXTENDED_PIPELINES + CustomPipes::CustomPipeShutdown(); +#endif + CMBlur::MotionBlurClose(); DestroySplashScreen(); CHud::Shutdown(); diff --git a/src/core/main.cpp b/src/core/main.cpp index 4b70a153..6e047b19 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -480,14 +480,7 @@ Initialise3D(void *param) DebugMenuInit(); DebugMenuPopulate(); #endif // !DEBUGMENU - bool ret = CGame::InitialiseRenderWare(); -#ifdef EXTENDED_PIPELINES - CustomPipes::CustomPipeInit(); // need Scene.world for this -#endif -#ifdef SCREEN_DROPLETS - ScreenDroplets::InitDraw(); -#endif - return ret; + return CGame::InitialiseRenderWare(); } return (FALSE); @@ -496,12 +489,6 @@ Initialise3D(void *param) static void Terminate3D(void) { -#ifdef SCREEN_DROPLETS - ScreenDroplets::Shutdown(); -#endif -#ifdef EXTENDED_PIPELINES - CustomPipes::CustomPipeShutdown(); -#endif CGame::ShutdownRenderWare(); #ifdef DEBUGMENU DebugMenuShutdown(); diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index 27006c6a..e670fc93 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -171,6 +171,9 @@ DestroyVehiclePipe(void) rw::d3d::destroyVertexShader(neoVehicle_VS); neoVehicle_VS = nil; + rw::d3d::destroyPixelShader(neoVehicle_PS); + neoVehicle_PS = nil; + ((rw::d3d9::ObjPipeline*)vehiclePipe)->destroy(); vehiclePipe = nil; } @@ -362,6 +365,12 @@ CreateGlossPipe(void) void DestroyGlossPipe(void) { + rw::d3d::destroyVertexShader(neoGloss_VS); + neoGloss_VS = nil; + + rw::d3d::destroyPixelShader(neoGloss_PS); + neoGloss_PS = nil; + ((rw::d3d9::ObjPipeline*)glossPipe)->destroy(); glossPipe = nil; }