1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0031394: Visualization, TKOpenGl - define OpenGl_Element::EstimatedDataSize() interface

OpenGl_FrameStats::updateStructures() now relies on OpenGl_Element inteface
instead of handling OpenGl_PrimitiveArray specifically
for collecting Graphic3d_FrameStatsCounter_EstimatedBytesGeom counter.
OpenGl_PrimitiveArray and OpenGl_Text implement new interface.
This commit is contained in:
kgv 2020-02-25 14:00:31 +03:00 committed by bugmaster
parent 0950253ca6
commit 3d60d73f76
6 changed files with 57 additions and 11 deletions

View File

@ -60,6 +60,9 @@ public:
//! Return TRUE if primitive type generates shaded triangulation (to be used in filters).
virtual Standard_Boolean IsFillDrawMode() const { return false; }
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
virtual Standard_Size EstimatedDataSize() const { return 0; }
//! Update parameters of the drawable elements.
virtual void SynchronizeAspects() {}

View File

@ -207,11 +207,7 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
const OpenGl_Group* aGroup = aGroupIter.Value();
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
{
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
{
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
}
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += aNodeIter->elem->EstimatedDataSize();
}
}
}
@ -229,15 +225,13 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
const OpenGl_Group* aGroup = aGroupIter.Value();
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
{
if (theToCountMem)
{
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += aNodeIter->elem->EstimatedDataSize();
}
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
{
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
if (theToCountMem)
{
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
}
if (aPrim->IsFillDrawMode())
{
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];

View File

@ -758,6 +758,24 @@ void OpenGl_PrimitiveArray::Release (OpenGl_Context* theContext)
}
}
// =======================================================================
// function : EstimatedDataSize
// purpose :
// =======================================================================
Standard_Size OpenGl_PrimitiveArray::EstimatedDataSize() const
{
Standard_Size aSize = 0;
if (!myVboAttribs.IsNull())
{
aSize += myVboAttribs->EstimatedDataSize();
}
if (!myVboIndices.IsNull())
{
aSize += myVboIndices->EstimatedDataSize();
}
return aSize;
}
// =======================================================================
// function : Render
// purpose :

View File

@ -58,6 +58,9 @@ public:
//! Release OpenGL resources (VBOs)
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
//! Return true if VBOs initialization has been performed.
//! VBO initialization is performed during first Render() call.
//! Notice that this flag does not indicate VBOs validity.

View File

@ -206,6 +206,31 @@ void OpenGl_Text::Release (OpenGl_Context* theCtx)
}
}
// =======================================================================
// function : EstimatedDataSize
// purpose :
// =======================================================================
Standard_Size OpenGl_Text::EstimatedDataSize() const
{
Standard_Size aSize = 0;
for (Standard_Integer anIter = myVertsVbo.Lower(); anIter <= myVertsVbo.Upper(); ++anIter)
{
if (const Handle(OpenGl_VertexBuffer)& aVerts = myVertsVbo.Value (anIter))
{
aSize += aVerts->EstimatedDataSize();
}
if (const Handle(OpenGl_VertexBuffer)& aTCrds = myTCrdsVbo.Value (anIter))
{
aSize += aTCrds->EstimatedDataSize();
}
}
if (!myBndVertsVbo.IsNull())
{
aSize += myBndVertsVbo->EstimatedDataSize();
}
return aSize;
}
// =======================================================================
// function : StringSize
// purpose :

View File

@ -68,6 +68,9 @@ public:
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
//! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Standard_EXPORT virtual Standard_Size EstimatedDataSize() const Standard_OVERRIDE;
public: //! @name methods for compatibility with layers
//! Empty constructor