1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0023226: Extend OpenGl_Context to store map of shared GPU resources

OpenGl_Resource was slightly corrected and OpenGl_Element was extended
with Release method to manage GPU resources.

OpenGl_PrimitiveArray now uses new OpenGl_VertexBuffer class (requires OpenGL 1.5+).
Strange workarounds for feedback mode were removed.

OpenGl_Context now provides access to shared GPU resources
and manages resources queue for delayed release
(replaces functionality of removed OpenGl_ResourceCleaner).
Loaded GL_ARB_texture_buffer_object and GL_ARB_draw_instanced extensions.

Global maps of views, workspaces and structures
were moved to OpenGl_GraphicDriver members.
UserDrawCallback() function moved to OpenGl_GraphicDriver methods.

Aspect_GraphicCallbackStruct now holds handle of OpenGl_Context
instead of system-dependent pointers to GL context definition.

New classes NCollection_Vec2, NCollection_Vec3 and NCollection_Vec4
implements interface to low-level data (points, vertices, colors) in GLSL-style.
Removed EnableVBO argument from vdrawparray Draw Harness command
Corrected compilation errors
Fixed wrong argument in Index VBO initialization
Fixed several cases of incorrect memory management in TKV3d

Visual3d_ViewManager::Remove()
Destroy structures before last view removed for correct GPU resources management.

Graphic3d_Structure::GraphicClear()
Remove groups to avoid usage of dead OpenGl_Group pointers.

V3d_View::Remove()
Fixed mistake in #0000280 patch.
Small correction
Fixed OCC280 test command

Replace removed view within created one in ViewerTest EventManager.
ViewerTest, do not create unused 3D view

In current design NIS_View always created and used for both - NIS objects and AIS objects.
This commit is contained in:
kgv
2012-07-13 15:51:16 +04:00
parent 400933675f
commit 5e27df788d
74 changed files with 3005 additions and 1593 deletions

View File

@@ -36,7 +36,7 @@ OpenGl_Group::OpenGl_Group ()
OpenGl_Group::~OpenGl_Group()
{
Clear();
Release (Handle(OpenGl_Context)());
}
/*----------------------------------------------------------------------*/
@@ -130,63 +130,25 @@ void OpenGl_Group::AddElement (const TelType AType, OpenGl_Element *AElem )
/*----------------------------------------------------------------------*/
void OpenGl_Group::Clear ()
{
if (myAspectLine)
{
// Delete line context
delete myAspectLine;
myAspectLine = NULL;
}
if (myAspectFace)
{
// Delete face context
delete myAspectFace;
myAspectFace = NULL;
}
if (myAspectMarker)
{
// Delete marker context
delete myAspectMarker;
myAspectMarker = NULL;
}
if (myAspectText)
{
// Delete text context
delete myAspectText;
myAspectText = NULL;
}
// Delete elements
while (myFirst)
{
OpenGl_ElementNode *next = myFirst->next;
delete myFirst->elem;
delete myFirst;
myFirst = next;
}
myLast = NULL;
}
/*----------------------------------------------------------------------*/
void OpenGl_Group::RemovePrimitiveArray (CALL_DEF_PARRAY *APArray)
void OpenGl_Group::RemovePrimitiveArray (const Handle(OpenGl_Context)& theGlCtx,
CALL_DEF_PARRAY* thePArray)
{
OpenGl_ElementNode *prevnode = NULL, *node = myFirst;
while (node)
while (node != NULL)
{
if (node->type == TelParray)
{
CALL_DEF_PARRAY *aCurPArray = ((const OpenGl_PrimitiveArray *)node->elem)->PArray();
CALL_DEF_PARRAY* aCurPArray = ((const OpenGl_PrimitiveArray* )node->elem)->PArray();
// validate for correct pointer
if (aCurPArray->num_bounds == APArray->num_bounds &&
aCurPArray->num_edges == APArray->num_edges &&
aCurPArray->num_vertexs == APArray->num_vertexs &&
aCurPArray->type == APArray->type)
if (aCurPArray->num_bounds == thePArray->num_bounds &&
aCurPArray->num_edges == thePArray->num_edges &&
aCurPArray->num_vertexs == thePArray->num_vertexs &&
aCurPArray->type == thePArray->type)
{
(prevnode? prevnode->next : myFirst) = node->next;
(prevnode ? prevnode->next : myFirst) = node->next;
if (!myFirst) myLast = NULL;
delete node->elem;
OpenGl_Element::Destroy (theGlCtx, node->elem);
delete node;
break;
}
@@ -294,4 +256,20 @@ void OpenGl_Group::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
AWorkspace->SetAspectText(aspect_text);
}
/*----------------------------------------------------------------------*/
void OpenGl_Group::Release (const Handle(OpenGl_Context)& theGlCtx)
{
// Delete elements
while (myFirst != NULL)
{
OpenGl_ElementNode* aNext = myFirst->next;
OpenGl_Element::Destroy (theGlCtx, myFirst->elem);
delete myFirst;
myFirst = aNext;
}
myLast = NULL;
OpenGl_Element::Destroy (theGlCtx, myAspectLine);
OpenGl_Element::Destroy (theGlCtx, myAspectFace);
OpenGl_Element::Destroy (theGlCtx, myAspectMarker);
OpenGl_Element::Destroy (theGlCtx, myAspectText);
}