0024309: TKOpenGl - Delay release of GLSL resources
authorkgv <kgv@opencascade.com>
Fri, 1 Nov 2013 17:33:17 +0000 (21:33 +0400)
committerabv <abv@opencascade.com>
Tue, 5 Nov 2013 05:19:37 +0000 (09:19 +0400)
src/OpenGl/OpenGl_AspectFace.cxx
src/OpenGl/OpenGl_ShaderManager.cxx
src/OpenGl/OpenGl_ShaderProgram.hxx

index f7f9a79..aaf95eb 100644 (file)
@@ -405,7 +405,7 @@ void OpenGl_AspectFace::Release (const Handle(OpenGl_Context)& theContext)
       else
       {
         myResources.Texture.Nullify(); // we need nullify all handles before ReleaseResource() call
       else
       {
         myResources.Texture.Nullify(); // we need nullify all handles before ReleaseResource() call
-        theContext->ReleaseResource (myResources.TextureId);
+        theContext->ReleaseResource (myResources.TextureId, Standard_True);
       }
     }
     myResources.Texture.Nullify();
       }
     }
     myResources.Texture.Nullify();
index cff325c..6b0419d 100644 (file)
@@ -68,7 +68,10 @@ void OpenGl_ShaderManager::Create (const Handle(Graphic3d_ShaderProgram)& thePro
   theShareKey = theProxy->GetId();
   if (myContext->GetResource<Handle(OpenGl_ShaderProgram)> (theShareKey, theProgram))
   {
   theShareKey = theProxy->GetId();
   if (myContext->GetResource<Handle(OpenGl_ShaderProgram)> (theShareKey, theProgram))
   {
-    theProgram->Share();
+    if (theProgram->Share())
+    {
+      myProgramList.Append (theProgram);
+    }
     return;
   }
 
     return;
   }
 
@@ -118,7 +121,7 @@ void OpenGl_ShaderManager::Unregister (TCollection_AsciiString&      theShareKey
   else
   {
     theProgram.Nullify();
   else
   {
     theProgram.Nullify();
-    myContext->ReleaseResource (anID);
+    myContext->ReleaseResource (anID, Standard_True);
   }
 }
 
   }
 }
 
index 51b09d8..b97ec3a 100644 (file)
@@ -493,9 +493,10 @@ protected:
 
   //! Increments counter of users.
   //! Used by OpenGl_ShaderManager.
 
   //! Increments counter of users.
   //! Used by OpenGl_ShaderManager.
-  void Share()
+  //! @return true when resource has been restored from delayed release queue
+  bool Share()
   {
   {
-    ++myShareCount;
+    return ++myShareCount == 1;
   }
 
   //! Decrements counter of users.
   }
 
   //! Decrements counter of users.