//! 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() {}
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();
}
}
}
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];
}
}
+// =======================================================================
+// 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 :
//! 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.
}
}
+// =======================================================================
+// 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 :
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