]> OCCT Git - occt.git/commitdiff
0032221: Visualization, TKD3DHost - fix memory leak within D3DHost_FrameBuffer::Release()
authorkgv <kgv@opencascade.com>
Wed, 17 Mar 2021 06:54:27 +0000 (09:54 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 17 Mar 2021 16:55:44 +0000 (19:55 +0300)
D3DHost_FrameBuffer - added missing color texture release within FBO destruction.
OpenGl_View::RedrawImmediate() - fixed unexpected window buffer swap while rendering into offscreen myFBO.

src/D3DHost/D3DHost_FrameBuffer.cxx
src/D3DHost/D3DHost_View.cxx
src/D3DHost/D3DHost_View.hxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View.hxx

index 25e4afb877a1022e67ca0705a7aada5bf7639b59..35120490a10bfd9a1bb0a43573903b812eddb5b3 100644 (file)
@@ -245,6 +245,7 @@ Standard_Boolean D3DHost_FrameBuffer::registerD3dBuffer (const Handle(OpenGl_Con
     return Standard_False;
   }
 
+  myIsOwnColor = true;
   myColorTextures (0)->Release (theCtx.operator->());
   myColorTextures (0)->Create  (theCtx);
 
index cf573e7664980d15cc3975b1b98d5349cadac0d4..a699f8d45a872b79cd4021f0991390df5ae09f1b 100644 (file)
@@ -87,11 +87,7 @@ D3DHost_View::D3DHost_View (const Handle(Graphic3d_StructureManager)& theMgr,
 // =======================================================================
 D3DHost_View::~D3DHost_View()
 {
-  if (!myD3dWglFbo.IsNull())
-  {
-    myD3dWglFbo->Release (myWorkspace->GetGlContext().operator->());
-    myD3dWglFbo.Nullify();
-  }
+  ReleaseGlResources (NULL);
   if (myD3dDevice != NULL)
   {
     myD3dDevice->Release();
@@ -104,6 +100,20 @@ D3DHost_View::~D3DHost_View()
   }
 }
 
+// =======================================================================
+// function : ReleaseGlResources
+// purpose  :
+// =======================================================================
+void D3DHost_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
+{
+  if (!myD3dWglFbo.IsNull())
+  {
+    myD3dWglFbo->Release (theCtx.get());
+    myD3dWglFbo.Nullify();
+  }
+  OpenGl_View::ReleaseGlResources (theCtx);
+}
+
 // =======================================================================
 // function : D3dColorSurface
 // purpose  :
index baa599979f1f6369929884226efb48ca4341d5c6..39c307851a3baaed1d9b842e8b342e614162d83d 100644 (file)
@@ -40,6 +40,9 @@ public:
   //! Default destructor.
   Standard_EXPORT virtual ~D3DHost_View();
 
+  //! Release OpenGL resources.
+  Standard_EXPORT virtual void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx) Standard_OVERRIDE;
+
   //! Creates and maps rendering window to the view.
   //! @param theWindow [in] the window.
   //! @param theContext [in] the rendering context. If NULL the context will be created internally.
index 57191a1d08dd98ad42ccd831da267e67ef471d0c..3f6b63bad8187ce1cb777c7472f4335ea42f1f15 100644 (file)
@@ -1847,6 +1847,7 @@ void OpenGl_View::RedrawImmediate()
                               Standard_True) || toSwap;
     if (aStereoMode == Graphic3d_StereoMode_SoftPageFlip
     &&  toSwap
+    &&  myFBO.get() == NULL
     && !aCtx->caps->buffersNoSwap)
     {
       aCtx->SwapBuffers();
@@ -1914,7 +1915,9 @@ void OpenGl_View::RedrawImmediate()
     aCtx->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
   }
 
-  if (toSwap && !aCtx->caps->buffersNoSwap)
+  if (toSwap
+  &&  myFBO.get() == NULL
+  && !aCtx->caps->buffersNoSwap)
   {
     aCtx->SwapBuffers();
   }
index 5a8d6f0270e76d4c612ef9ad9476a9666d3486a8..583bc2cfffd14aa91b0b14274336395e7313797f 100644 (file)
@@ -84,7 +84,7 @@ public:
   Standard_EXPORT virtual ~OpenGl_View();
 
   //! Release OpenGL resources.
-  Standard_EXPORT void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
+  Standard_EXPORT virtual void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
 
   //! Deletes and erases the view.
   Standard_EXPORT virtual void Remove() Standard_OVERRIDE;