0030135: Visualization, TKOpenGl - frame statistics do not include information about... IR-2018-09-14 OCCT_VC2017_73
authorkgv <kgv@opencascade.com>
Thu, 13 Sep 2018 14:34:08 +0000 (17:34 +0300)
committerapn <apn@opencascade.com>
Fri, 14 Sep 2018 12:51:52 +0000 (15:51 +0300)
OpenGl_FrameStats now takes into account OpenGl_Structure::InstancedStructure().
OpenGl_View::renderStructs() - fixed resetting non-culled structure counters.

src/OpenGl/OpenGl_FrameStats.cxx
src/OpenGl/OpenGl_View_Redraw.cxx

index c321dab..f1189cd 100644 (file)
@@ -399,128 +399,132 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
   for (OpenGl_IndexedMapOfStructure::Iterator aStructIter (theStructures); aStructIter.More(); aStructIter.Next())
   {
     const OpenGl_Structure* aStruct = aStructIter.Value();
-    if (aStruct->IsCulled()
-    || !aStruct->IsVisible (theViewId))
+    const bool isStructHidden = aStruct->IsCulled()
+                            || !aStruct->IsVisible (theViewId);
+    for (; aStruct != NULL; aStruct = aStruct->InstancedStructure())
     {
-      if (theToCountMem)
+      if (isStructHidden)
       {
-        for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
+        if (theToCountMem)
         {
-          const OpenGl_Group* aGroup = aGroupIter.Value();
-          for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+          for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
           {
-            if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
+            const OpenGl_Group* aGroup = aGroupIter.Value();
+            for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
             {
-              myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
-              myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
+              if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
+              {
+                myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
+                myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
+              }
             }
           }
         }
+        continue;
       }
-      continue;
-    }
 
-    myCountersTmp[Counter_NbGroupsNotCulled] += aStruct->Groups().Size();
-    if (!theToCountElems)
-    {
-      continue;
-    }
+      myCountersTmp[Counter_NbGroupsNotCulled] += aStruct->Groups().Size();
+      if (!theToCountElems)
+      {
+        continue;
+      }
 
-    for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
-    {
-      const OpenGl_Group* aGroup = aGroupIter.Value();
-      for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
+      for (OpenGl_Structure::GroupIterator aGroupIter (aStruct->Groups()); aGroupIter.More(); aGroupIter.Next())
       {
-        if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
+        const OpenGl_Group* aGroup = aGroupIter.Value();
+        for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
         {
-          ++myCountersTmp[Counter_NbElemsNotCulled];
-          if (theToCountMem)
-          {
-            myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
-            myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
-          }
-
-          if (aPrim->IsFillDrawMode())
+          if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
           {
-            ++myCountersTmp[Counter_NbElemsFillNotCulled];
-            if (!theToCountTris)
+            ++myCountersTmp[Counter_NbElemsNotCulled];
+            if (theToCountMem)
             {
-              continue;
-            }
-
-            const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
-            if (anAttribs.IsNull()
-            || !anAttribs->IsValid())
-            {
-              continue;
+              myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
+              myCountersTmp[Counter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
             }
 
-            const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
-            const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
-            const Standard_Integer aNbBounds  = !aPrim->Bounds().IsNull() ? aPrim->Bounds()->NbBounds : 1;
-            switch (aPrim->DrawMode())
+            if (aPrim->IsFillDrawMode())
             {
-              case GL_TRIANGLES:
-              {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 3;
-                break;
-              }
-              case GL_TRIANGLE_STRIP:
-              case GL_TRIANGLE_FAN:
-              {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices - 2 * aNbBounds;
-                break;
-              }
-              case GL_TRIANGLES_ADJACENCY:
+              ++myCountersTmp[Counter_NbElemsFillNotCulled];
+              if (!theToCountTris)
               {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 6;
-                break;
+                continue;
               }
-              case GL_TRIANGLE_STRIP_ADJACENCY:
-              {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
-                break;
-              }
-            #if !defined(GL_ES_VERSION_2_0)
-              case GL_QUADS:
+
+              const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
+              if (anAttribs.IsNull()
+              || !anAttribs->IsValid())
               {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 2;
-                break;
+                continue;
               }
-              case GL_QUAD_STRIP:
+
+              const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
+              const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
+              const Standard_Integer aNbBounds  = !aPrim->Bounds().IsNull() ? aPrim->Bounds()->NbBounds : 1;
+              switch (aPrim->DrawMode())
               {
-                myCountersTmp[Counter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
-                break;
+                case GL_TRIANGLES:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 3;
+                  break;
+                }
+                case GL_TRIANGLE_STRIP:
+                case GL_TRIANGLE_FAN:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices - 2 * aNbBounds;
+                  break;
+                }
+                case GL_TRIANGLES_ADJACENCY:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 6;
+                  break;
+                }
+                case GL_TRIANGLE_STRIP_ADJACENCY:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices - 4 * aNbBounds;
+                  break;
+                }
+              #if !defined(GL_ES_VERSION_2_0)
+                case GL_QUADS:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += aNbIndices / 2;
+                  break;
+                }
+                case GL_QUAD_STRIP:
+                {
+                  myCountersTmp[Counter_NbTrianglesNotCulled] += (aNbIndices / 2 - aNbBounds) * 2;
+                  break;
+                }
+              #endif
               }
-            #endif
             }
-          }
-          else if (aPrim->DrawMode() == GL_POINTS)
-          {
-            ++myCountersTmp[Counter_NbElemsPointNotCulled];
-            if (theToCountTris)
+            else if (aPrim->DrawMode() == GL_POINTS)
             {
-              const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
-              if (!anAttribs.IsNull()
-                && anAttribs->IsValid())
+              ++myCountersTmp[Counter_NbElemsPointNotCulled];
+              if (theToCountTris)
               {
-                const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
-                const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
-                myCountersTmp[Counter_NbPointsNotCulled] += aNbIndices;
+                const Handle(OpenGl_VertexBuffer)& anAttribs = aPrim->AttributesVbo();
+                if (!anAttribs.IsNull()
+                  && anAttribs->IsValid())
+                {
+                  const Handle(OpenGl_VertexBuffer)& anIndices = aPrim->IndexVbo();
+                  const Standard_Integer aNbIndices = !anIndices.IsNull() ? anIndices->GetElemsNb() : anAttribs->GetElemsNb();
+                  myCountersTmp[Counter_NbPointsNotCulled] += aNbIndices;
+                }
               }
             }
+            else
+            {
+              ++myCountersTmp[Counter_NbElemsLineNotCulled];
+            }
           }
-          else
+          else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
           {
-            ++myCountersTmp[Counter_NbElemsLineNotCulled];
+            (void )aText;
+            ++myCountersTmp[Counter_NbElemsNotCulled];
+            ++myCountersTmp[Counter_NbElemsTextNotCulled];
           }
         }
-        else if (const OpenGl_Text* aText = dynamic_cast<const OpenGl_Text*> (aNodeIter->elem))
-        {
-          (void )aText;
-          ++myCountersTmp[Counter_NbElemsNotCulled];
-          ++myCountersTmp[Counter_NbElemsTextNotCulled];
-        }
       }
     }
   }
index 6db6934..ff5ce5a 100644 (file)
@@ -1071,6 +1071,7 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
                                  OpenGl_FrameBuffer*          theOitAccumFbo,
                                  const Standard_Boolean       theToDrawImmediate)
 {
+  myZLayers.UpdateCulling (myWorkspace, theToDrawImmediate);
   if ( myZLayers.NbStructures() <= 0 )
     return;
 
@@ -1080,8 +1081,6 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection,
     myRaytraceInitStatus == OpenGl_RT_FAIL ||
     aCtx->IsFeedback();
 
-  myZLayers.UpdateCulling (myWorkspace, theToDrawImmediate);
-
   if (!toRenderGL)
   {
     toRenderGL = !initRaytraceResources (aCtx) ||