View Issue Details

IDProjectCategoryView StatusLast Update
0023028Open CASCADEOCCT:Visualizationpublic2015-10-23 20:51
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformAOSL 
Product Version6.5.2 
Target Version6.9.1Fixed in Version6.9.1 
Summary0023028: Visualization, TKOpenGl - eliminate global static variables
DescriptionCurrent implementation exploits the fact that only one graphic driver instance can be used in application and a lot of static variables and collections are placed in global scope.

However there are no any protection from creation of multiple instance and in this case behaviour of TKOpenGl module become undefined.

For example shared instance 'Handle(OpenGl_Display) openglDisplay' is nullified on Graphic3d_{WNT}GraphicDevice destruction and means memory corruption if there any other Graphic3d_{WNT}GraphicDevice instance exists and used.

As a side-effect of this problem, currently OpenGl_Window instances are never destroyed, to keep GL rendering contexts for proper GL resource deallocation.

This is suggested either:
- To move all global variables into OpenGl_GraphicDriver definition (user will be responsible for usage of multiple instances / sharing common instance);
- Make OpenGl_GraphicDriver singleton (protect usage of TKOpenGl library in undesigned manner).
Steps To ReproduceN/A
TagsNo tags attached.
Test case numberNot needed

Relationships

related to 0022819 closedbugmaster Open CASCADE Redesign of OpenGl driver 
related to 0024847 closedapn Open CASCADE CLang warnings -Wdeprecated-writable-strings in OpenGl_Display 
related to 0024291 closedapn Open CASCADE Visualization - move Z-buffer trihedron presentation from TKOpenGl to TKV3d 
related to 0025789 closedbugmaster Open CASCADE Visualization - get rid of obsolete 2d layers implementation 
related to 0025382 closedkgv Open CASCADE Visualization, TKOpenGl - improved video recording capability 
parent of 0023544 closedkgv Open CASCADE Texture management in TKOpenGl should be redesigned 
parent of 0024131 closedbugmaster Open CASCADE TKOpenGL redesign GPU memory management for markers presentation 
parent of 0024228 closedabv Open CASCADE TKOpenGL - destroy GL context at view close 

Activities

kgv

2012-03-20 11:59

developer   ~0020044

Notice there also regression related to this bug introduced by 0022819 patch:

OpenGl_telem_view.cxx, line 71
> /* prp between front and back planes */
> if (!openglDisplay.IsNull() || !openglDisplay->Walkthrough())
Wrong condition followed by NULL handle access if shared openglDisplay instance is NULL.

kgv

2013-11-02 23:06

developer   ~0026435

OpenGl_Display is no more global since 0024228.
However there are still several global variables like
static float  mAmb[4];

in OpenGl_Workspace::UpdateMaterial().

kgv

2014-04-23 10:09

developer   ~0029028

Last edited: 2015-03-31 15:00

Remaining artifacts,

in OpenGl_CappingAlgo::RenderCapping():
  static Handle(OpenGl_CappingAlgoFilter) aCappingFilter

should be moved outside function body;

in OpenGl_CappingAlgo.hxx:
  static Handle(OpenGl_RenderFilter) myRenderFilter;
  static OpenGl_AspectFace myFrontCulling;
  static OpenGl_AspectFace myNoneCulling;
  static Standard_Boolean myIsInit;


in OpenGl_AspectFace.cxx:
  static OPENGL_SURF_PROP THE_DEFAULT_MATERIAL
  static TEL_POFFSET_PARAM THE_DEFAULT_POFFSET

seems to be constants;

in OpenGl_GraphicDriver_Layer.cxx:
static Standard_Boolean TheLayerIsOpen = Standard_False;
static OpenGl_LAYER_PROP TheLayerProp;

should be removed within 0025789.

in OpenGl_Trihedron.cxx:
static TEL_COLOUR theXColor = {{ 1.F, 0.F, 0.F, 0.6F }};
static TEL_COLOUR theYColor = {{ 0.F, 1.F, 0.F, 0.6F }};
static TEL_COLOUR theZColor = {{ 0.F, 0.F, 1.F, 0.6F }};
static float theRatio = 0.8f;
static float theDiameter = 0.05f;
static int   theNbFacettes = 12;

should be removed within #0025974.

in OpenGl_Workspace_Raytrace.cxx:
TCollection_AsciiString OpenGl_Workspace::ShaderSource::Source() const
{
  static const TCollection_AsciiString aVersion = "#version 140";

to be moved outside the function body;

in OpenGl_AVIWriter.hxx:
  static OpenGl_AVIWriter       * MyAVIWriterInstance;

should be removed within 0025382.

in OpenGl_ShaderProgram.hxx:
  static OpenGl_VariableSetterSelector mySetterSelector;


git

2015-04-09 10:35

administrator   ~0039470

Branch CR23028 has been created by isk.

SHA-1: f8ce720a55d17fea4306329d316f4da0d2380fbf


Detailed log of new commits:

Author: isk
Date: Wed Apr 8 17:28:39 2015 +0300

    0023028: Visualization, TKOpenGl - eliminate global static variables

git

2015-04-10 13:33

administrator   ~0039564

Branch CR23028_1 has been created by isk.

SHA-1: ad92c951403f0fb287db54bc4db080ce2e0b169a


Detailed log of new commits:

Author: isk
Date: Fri Apr 10 13:28:45 2015 +0300

    0023028: Visualization, TKOpenGl - eliminate global static variables

git

2015-04-27 16:59

administrator   ~0040292

Branch CR23028_2 has been created by isk.

SHA-1: defca5bf4b63c3ce2a257d32abc9091e15a2a098


Detailed log of new commits:

Author: isk
Date: Mon Apr 27 16:59:04 2015 +0300

    Remove static variables from OpenGl_CappingAlgo

kgv

2015-04-28 11:19

developer   ~0040316

-  static Handle(OpenGl_CappingAlgoFilter) aCappingFilter = new OpenGl_CappingAlgoFilter();
-  Handle(OpenGl_RenderFilter) aRenderFilter = theWorkspace->GetRenderFilter();
+  Handle(OpenGl_CappingAlgoFilter) aCappingFilter = new OpenGl_CappingAlgoFilter();
+  Handle(OpenGl_RenderFilter)      aRenderFilter  = theWorkspace->GetRenderFilter();
   theWorkspace->SetRenderFilter (aCappingFilter);
 
+  // create empty culling
+  OpenGl_AspectFace aCulling;

please preserve optimizations in new code; default filters and aspects can be stored in OpenGl_Workspace.

git

2015-04-29 10:57

administrator   ~0040400

Branch CR23028_2 has been updated by isk.

SHA-1: cb8f81cd21d9830e417e47ad7e52ece28b0626d9


Detailed log of new commits:

Author: isk
Date: Wed Apr 29 10:56:19 2015 +0300

    Default CappinAlgo filters and aspects are stored in OpenGl_Workspace.

git

2015-04-29 15:09

administrator   ~0040416

Branch CR23028_2 has been updated by isk.

SHA-1: 84a4673deac076f9ac22a7f1fd226d28e49b363b


Detailed log of new commits:

Author: isk
Date: Wed Apr 29 15:08:39 2015 +0300

    Static variables in OpenGl_View_2.cxx is deleted.
    Default ambient and spot are stored in OpenGl_Workspace.

git

2015-04-29 16:08

administrator   ~0040430

Branch CR23028_2 has been updated by isk.

SHA-1: 1628a389f88e817ff26f8c374b79b260a57e1f47


Detailed log of new commits:

Author: isk
Date: Wed Apr 29 16:08:27 2015 +0300

    Cosmetics

git

2015-06-08 10:28

administrator   ~0042011

Branch CR23028_3 has been created by isk.

SHA-1: 7f383da677decb735114866225aca21c41f51303


Detailed log of new commits:

Author: isk
Date: Mon Jun 8 10:17:01 2015 +0300

    0023028: Visualization, TKOpenGl - eliminate global static variables

isk

2015-06-08 10:29

developer   ~0042012

Dear Kirill,
please review the branch CR23028_3.

git

2015-06-22 14:58

administrator   ~0042309

Branch CR23028_4 has been created by kgv.

SHA-1: 9715d30fb20e0b7c86b2f28c00af98e16fde16e3


Detailed log of new commits:

Author: isk
Date: Mon Jun 22 14:57:45 2015 +0300

    0025305: Visualization, TKOpenGl - support stipple line aspects within built-in GLSL programs
    
    OpenGl_LineAttributes - drop display lists for stipple lines.
    OpenGl_Context - add methods OpenGl_Context::SetTypeOfLine() and OpenGl_Context::SetLineWidth() to setup line aspects.
    OpenGl_ShaderManager::prepareStdProgramFlat() - support new bit OpenGl_PO_StippleLine.
    
    vaspects command - add -setlinetype option.

kgv

2015-06-22 14:59

developer   ~0042310

Please test the patch in branch CR23028_4.

git

2015-06-22 15:01

administrator   ~0042311

Branch CR23028_4 has been updated forcibly by kgv.

SHA-1: bcd7dd5c35383086e76c77c1d9a490fad6f3b840

apv

2015-06-23 11:43

tester   ~0042332

Dear BugMaster,

Branch CR23028_4 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: bcd7dd5c35383086e76c77c1d9a490fad6f3b840

Number of compiler warnings:
occt component:
   Linux: 25 (25 on master)
   Windows: 0 (0 on master)
products component:
   Linux: 37 (37 on master)
   Windows: 0 (0 on master)

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 97570995 / 97808123 [-0.24%]
Total CPU difference: 18207.119999999763 / 18376.230000000123 [-0.92%]

Testing on Windows:
Total MEMORY difference: 56913676 / 56863564 [+0.09%]
Total CPU difference: 17806.125741098847 / 17659.42240069884 [+0.83%]

git

2015-06-25 13:49

administrator   ~0042444

Branch CR23028_5 has been created by kgv.

SHA-1: bf2bae5ecda5f62a60ac032dd58370cc6847459d


Detailed log of new commits:

Author: isk
Date: Mon Jun 22 15:01:37 2015 +0300

    0023028: Visualization, TKOpenGl - eliminate global static variables
    
    OpenGl_CappingAlgo - move global variables to OpenGl_Workspace class fields.
    OpenGl_View::ShaderSource::Source() - drop static for local variable.
    OpenGl_Window - drop redundant global constant THE_DEFAULT_BG_COLOR.

git

2015-07-27 13:29

administrator   ~0043462

Branch CR23028 has been deleted by kgv.

SHA-1: f8ce720a55d17fea4306329d316f4da0d2380fbf

git

2015-07-27 13:29

administrator   ~0043463

Branch CR23028_1 has been deleted by kgv.

SHA-1: ad92c951403f0fb287db54bc4db080ce2e0b169a

git

2015-07-27 13:29

administrator   ~0043464

Branch CR23028_2 has been deleted by kgv.

SHA-1: 1628a389f88e817ff26f8c374b79b260a57e1f47

git

2015-07-27 13:33

administrator   ~0043482

Branch CR23028_3 has been deleted by kgv.

SHA-1: 7f383da677decb735114866225aca21c41f51303

git

2015-07-27 13:39

administrator   ~0043514

Branch CR23028_4 has been deleted by kgv.

SHA-1: bcd7dd5c35383086e76c77c1d9a490fad6f3b840

git

2015-07-27 13:39

administrator   ~0043515

Branch CR23028_5 has been deleted by kgv.

SHA-1: bf2bae5ecda5f62a60ac032dd58370cc6847459d

Related Changesets

occt: master f8ae3605

2015-06-22 12:01:37

isk


Committer: bugmaster Details Diff
0023028: Visualization, TKOpenGl - eliminate global static variables

OpenGl_CappingAlgo - move global variables to OpenGl_Workspace class fields.
OpenGl_View::ShaderSource::Source() - drop static for local variable.
OpenGl_Window - drop redundant global constant THE_DEFAULT_BG_COLOR.
Affected Issues
0023028
mod - src/OpenGl/OpenGl_CappingAlgo.cxx Diff File
mod - src/OpenGl/OpenGl_CappingAlgo.hxx Diff File
mod - src/OpenGl/OpenGl_CappingPlaneResource.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver_Layer.cxx Diff File
mod - src/OpenGl/OpenGl_Matrix.cxx Diff File
mod - src/OpenGl/OpenGl_Matrix.hxx Diff File
mod - src/OpenGl/OpenGl_View.cxx Diff File
mod - src/OpenGl/OpenGl_View_Raytrace.cxx Diff File
mod - src/OpenGl/OpenGl_Window.cxx Diff File
mod - src/OpenGl/OpenGl_Window_1.mm Diff File
mod - src/OpenGl/OpenGl_Workspace.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace.hxx Diff File

Issue History

Date Modified Username Field Change
2012-03-20 11:51 kgv New Issue
2012-03-20 11:51 kgv Assigned To => san
2012-03-20 11:53 kgv Relationship added related to 0022819
2012-03-20 11:59 kgv Note Added: 0020044
2012-03-22 14:39 kgv Status new => resolved
2012-03-22 14:40 kgv Assigned To san => kgv
2012-03-22 14:40 kgv Status resolved => assigned
2012-10-21 11:48 abv Target Version 6.5.4 => 6.6.0
2012-11-12 13:08 kgv Relationship added parent of 0023544
2013-02-22 10:46 kgv Target Version 6.6.0 => 6.7.0
2013-03-22 17:03 san Description Updated
2013-08-27 20:53 kgv Relationship added parent of 0024131
2013-10-06 13:09 kgv Relationship added parent of 0024228
2013-11-02 23:06 kgv Note Added: 0026435
2013-12-12 10:49 san Target Version 6.7.0 => 6.7.1
2014-04-04 18:32 abv Target Version 6.7.1 => 6.8.0
2014-04-23 10:09 kgv Note Added: 0029028
2014-04-23 10:10 kgv Relationship added related to 0024847
2014-04-23 10:16 kgv Relationship added related to 0024291
2014-09-29 22:33 kgv Target Version 6.8.0 => 7.1.0
2014-09-29 22:33 kgv Summary TKOpenGl eliminate global static variables => Visualization, TKOpenGl - eliminate global static variables
2015-03-31 14:49 kgv Relationship added related to 0025789
2015-03-31 14:53 kgv Relationship added related to 0025382
2015-03-31 15:00 kgv Note Edited: 0029028
2015-04-08 08:13 kgv Assigned To kgv => isk
2015-04-09 10:35 git Note Added: 0039470
2015-04-09 10:36 isk Assigned To isk => kgv
2015-04-09 10:36 isk Status assigned => resolved
2015-04-09 10:36 isk Steps to Reproduce Updated
2015-04-10 13:33 git Note Added: 0039564
2015-04-10 13:33 kgv Assigned To kgv => isz
2015-04-10 13:33 kgv Status resolved => assigned
2015-04-10 13:34 kgv Assigned To isz => isk
2015-04-27 16:59 git Note Added: 0040292
2015-04-28 11:19 kgv Note Added: 0040316
2015-04-29 10:57 git Note Added: 0040400
2015-04-29 15:09 git Note Added: 0040416
2015-04-29 16:08 git Note Added: 0040430
2015-06-05 15:17 isk Assigned To isk => kgv
2015-06-05 15:17 isk Assigned To kgv => isk
2015-06-08 10:28 git Note Added: 0042011
2015-06-08 10:29 isk Note Added: 0042012
2015-06-08 10:29 isk Assigned To isk => kgv
2015-06-08 10:29 isk Status assigned => resolved
2015-06-22 14:58 git Note Added: 0042309
2015-06-22 14:59 kgv Note Added: 0042310
2015-06-22 14:59 kgv Assigned To kgv => bugmaster
2015-06-22 14:59 kgv Status resolved => reviewed
2015-06-22 14:59 kgv Target Version 7.1.0 => 7.0.0
2015-06-22 15:01 git Note Added: 0042311
2015-06-22 16:01 apv Assigned To bugmaster => apv
2015-06-23 11:42 apv Test case number => Not needed
2015-06-23 11:43 apv Note Added: 0042332
2015-06-23 11:43 apv Assigned To apv => bugmaster
2015-06-23 11:43 apv Status reviewed => tested
2015-06-25 13:49 git Note Added: 0042444
2015-06-26 13:42 bugmaster Changeset attached => occt master f8ae3605
2015-06-26 13:42 bugmaster Status tested => verified
2015-06-26 13:42 bugmaster Resolution open => fixed
2015-07-27 13:29 git Note Added: 0043462
2015-07-27 13:29 git Note Added: 0043463
2015-07-27 13:29 git Note Added: 0043464
2015-07-27 13:33 git Note Added: 0043482
2015-07-27 13:39 git Note Added: 0043514
2015-07-27 13:39 git Note Added: 0043515
2015-08-26 11:14 abv Target Version 7.0.0 => 6.9.1
2015-10-16 14:56 aiv Status verified => closed
2015-10-23 20:51 aiv Fixed in Version => 6.9.1