1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

@@ -27,9 +27,6 @@
#include <stdio.h>
#include <stdlib.h>
static Standard_Integer enableArray = 1;
static Standard_Boolean interleavedArray = Standard_False;
Graphic3d_ArrayOfPrimitives :: Graphic3d_ArrayOfPrimitives (
const Graphic3d_TypeOfPrimitiveArray aType,
const Standard_Integer maxVertexs,
@@ -99,14 +96,6 @@ Graphic3d_ArrayOfPrimitives :: Graphic3d_ArrayOfPrimitives (
myPrimitiveArray->num_bounds = 0;
myPrimitiveArray->num_vertexs = 0;
myPrimitiveArray->num_edges = 0;
myPrimitiveArray->VBOEnabled = -1;
myPrimitiveArray->flagBufferVBO = -1;
myPrimitiveArray->contextId = 0;
for( int i =0 ; i < VBOMaxType ; i++){
myPrimitiveArray->bufferVBO[i] = 0;
}
}
void Graphic3d_ArrayOfPrimitives::Destroy ( ){
@@ -159,40 +148,15 @@ void Graphic3d_ArrayOfPrimitives::Destroy ( ){
}
void Graphic3d_ArrayOfPrimitives::Enable() {
enableArray = 1;
///
}
void Graphic3d_ArrayOfPrimitives::Disable() {
enableArray = -1;
///
}
Standard_Boolean Graphic3d_ArrayOfPrimitives::IsEnable() {
if( enableArray == 0 ) {
OSD_Environment csf(TCollection_AsciiString("CSF_USE_ARRAY_OF_PRIMITIVES"));
TCollection_AsciiString value = csf.Value();
enableArray = -1;
if( value.Length() > 0 ) {
if( value.IsIntegerValue() ) {
enableArray = value.IntegerValue();
if( enableArray > 1 ) {
enableArray = 1;
} else interleavedArray = Standard_False;
}
}
#if TRACE > 0
if( enableArray > 0 ) {
if( interleavedArray )
cout << " ! ENABLE to use Interleaved arrays of primitives" << endl;
else
cout << " ! ENABLE to use Single arrays of primitives" << endl;
} else
cout << " ! DISABLE to use arrays of primitives" << endl;
#endif
}
if( enableArray > 0 ) return Standard_True;
return Standard_False;
return Standard_True;
}
Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(

View File

@@ -232,13 +232,6 @@ void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction)
MyCStructure.ContainsFacet = 0;
// clean groups in graphics driver at first
if (WithDestruction)
{
// clean and empty each group
Standard_Integer Length = MyGroups.Length();
for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
MyGroups.ChangeValue (aGrId)->Clear();
}
GraphicClear (WithDestruction);
// only then remove group references
@@ -722,31 +715,31 @@ Standard_Boolean Graphic3d_Structure::IsInfinite () const {
}
void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction) {
void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction)
{
// clean and empty each group
Standard_Integer Length = MyGroups.Length();
for (Standard_Integer aGrId = 1; aGrId <= Length; ++aGrId)
{
MyGroups.ChangeValue (aGrId)->Clear();
}
if (WithDestruction)
{
/*
* Dans ce cas l'appelant dans faire :
* void Prs3d_Presentation::Clear () {
* Graphic3d_Structure::Clear ();
* myCurrentGroup = new Graphic3d_Group (this);
* }
*/
while (!MyGroups.IsEmpty())
{
Handle(Graphic3d_Group) aGroup = MyGroups.First();
aGroup->Remove();
}
MyGraphicDriver->ClearStructure (MyCStructure);
else {
/*
* Dans ce cas l'appelant dans faire :
* void Prs3d_Presentation::Clear () {
* Graphic3d_Structure::Clear ();
* // myCurrentGroup = new Graphic3d_Group (this);
* }
*/
Standard_Integer Length = MyGroups.Length ();
for (Standard_Integer i=1; i<=Length; i++)
(MyGroups.Value (i))->Clear ();
}
}
void Graphic3d_Structure::GraphicConnect (const Handle(Graphic3d_Structure)& ADaughter) {