mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +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:
parent
0950253ca6
commit
3d60d73f76
@ -60,6 +60,9 @@ public:
|
|||||||
//! Return TRUE if primitive type generates shaded triangulation (to be used in filters).
|
//! Return TRUE if primitive type generates shaded triangulation (to be used in filters).
|
||||||
virtual Standard_Boolean IsFillDrawMode() const { return false; }
|
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.
|
//! Update parameters of the drawable elements.
|
||||||
virtual void SynchronizeAspects() {}
|
virtual void SynchronizeAspects() {}
|
||||||
|
|
||||||
|
@ -207,11 +207,7 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
|||||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||||
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
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] += aNodeIter->elem->EstimatedDataSize();
|
||||||
{
|
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
|
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,15 +225,13 @@ void OpenGl_FrameStats::updateStructures (Standard_Integer theViewId,
|
|||||||
const OpenGl_Group* aGroup = aGroupIter.Value();
|
const OpenGl_Group* aGroup = aGroupIter.Value();
|
||||||
for (const OpenGl_ElementNode* aNodeIter = aGroup->FirstNode(); aNodeIter != NULL; aNodeIter = aNodeIter->next)
|
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))
|
if (const OpenGl_PrimitiveArray* aPrim = dynamic_cast<const OpenGl_PrimitiveArray*> (aNodeIter->elem))
|
||||||
{
|
{
|
||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsNotCulled];
|
||||||
if (theToCountMem)
|
|
||||||
{
|
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->AttributesVbo());
|
|
||||||
myCountersTmp[Graphic3d_FrameStatsCounter_EstimatedBytesGeom] += estimatedDataSize (aPrim->IndexVbo());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aPrim->IsFillDrawMode())
|
if (aPrim->IsFillDrawMode())
|
||||||
{
|
{
|
||||||
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];
|
++myCountersTmp[Graphic3d_FrameStatsCounter_NbElemsFillNotCulled];
|
||||||
|
@ -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
|
// function : Render
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -58,6 +58,9 @@ public:
|
|||||||
//! Release OpenGL resources (VBOs)
|
//! Release OpenGL resources (VBOs)
|
||||||
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) 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;
|
||||||
|
|
||||||
//! Return true if VBOs initialization has been performed.
|
//! Return true if VBOs initialization has been performed.
|
||||||
//! VBO initialization is performed during first Render() call.
|
//! VBO initialization is performed during first Render() call.
|
||||||
//! Notice that this flag does not indicate VBOs validity.
|
//! Notice that this flag does not indicate VBOs validity.
|
||||||
|
@ -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
|
// function : StringSize
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -68,6 +68,9 @@ public:
|
|||||||
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
|
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
|
||||||
Standard_EXPORT virtual void Release (OpenGl_Context* theContext) 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
|
public: //! @name methods for compatibility with layers
|
||||||
|
|
||||||
//! Empty constructor
|
//! Empty constructor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user