DiscussionsIssue archiveOCCT:Visualization

Archived issue #0026149

Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag

Open CASCADEOCCT:Visualizationclosed44 public notes

Search issues

Description

There are several issues in current Depth-buffer clearing logic within Z-layers list:
- Graphic3d_ZLayerDepthWrite flag might be erroneously overwritten within the layer.
- Depth clearing state is not well-handled in TKOpenGl. In particular, it might perform redundant clearing (Depth buffer is cleared automatically with Color buffer at the very beginning of the redrawing, this is why Graphic3d_ZLayerId_Default has no Graphic3d_ZLayerDepthClear flag - just for optimization. Another issue is that within OpenGl_LayerList::Render() empty layers are not drawn at all which might lead to the case when sequence of Z-layers with clear/no-clear rules will not clear buffer before the second layer since the first one is empty:
      const OpenGl_Layer& aLayer = anIts.Value();
      if (aLayer.NbStructures() < 1)
      {


It is considered to revise this logic to ensure Depth-clearing consistency as well as preserving optimization (to avoid clearing when it is not necessary).

Steps to reproduce

test/bugs/vis/bug26149

Public activity

44 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Thu Apr 30 12:13:11 2015 +0300

    0026149: Visualization - depth buffer should be cleared after bottom layer by default
    
    Depth buffer now is cleared after bottom layer.
02Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
03Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
04Commenter 4
Dear Kirill,
Please review branch CR26149.
05Author
-    const OpenGl_Layer& aLayer = anIts.Value();
+    OpenGl_Layer aLayer = anIts.Value();

it is not applicable to copy entire layer with all structures during iteration!

+      aLayer.SetLayerSettings (aSettings);

it looks inconvenient to modify layer settings - please consider passing changes as arguments.
06Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
07Commenter 7
Dear Kirill,
Please review branch CR26149.
08Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
09Author
Dear Ivan,

the patch is incorrect due to false root-cause detection.
The original problem comes not from the fact that Depth buffer is not cleared after Graphic3d_ZLayerId_BotOSD layer before Graphic3d_ZLayerId_Default (which should be logically OK), but from the fact that rendering into Graphic3d_ZLayerId_BotOSD layer affects Depth buffer at all while it's default settings should prevent this (no Graphic3d_ZLayerDepthWrite flag).

The most likely source of this misbehavior is:
void OpenGl_Workspace::updateMaterial (const int theFlag)
...
      glDepthMask (GL_TRUE);
10Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Fri May 22 13:42:11 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    Added new flag myUseDepthWrite in OpenGl_Workspace to control writing in depth buffer. Method updateMaterial() was changed to prevent influence on depth buffer without certain flags.
11Commenter 11
Dear Kirill,
Please review branch CR26149_1.
12Author
+  theWorkspace->UseDepthWrite() = IsSettingEnabled (Graphic3d_ZLayerDepthWrite) ? GL_TRUE : GL_FALSE;

the Boolean conversion is redundant here and incorrect.

+ Standard_Boolean       myUseDepthWrite;

new field should be initialized in constructor.
Please also set this variable at the very beginning of scene rendering and in redrawImmediate() after Z-layers rendering.
13Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Tue May 26 13:21:22 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    Added new flag myUseDepthWrite in OpenGl_Workspace to control writing in depth buffer. Method updateMaterial() was changed to prevent influence on depth buffer without certain flags.
14Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
15Commenter 15
Dear Kirill,
Please review branch CR26149_2.
16Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
17Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Thu May 28 12:58:01 2015 +0300

    Cosmetic fixes.

18Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Fri May 29 10:18:09 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    OpenGl_Workspace::updateMaterial() - do not activate writing into Depth buffer without Graphic3d_ZLayerDepthWrite flag.
    Add method OpenGl_Workspace::UseDepthWrite() to track glDepthMask() state.
    
    Drop the following outdated API methods conflicting with Z-layers API:
    - V3d_View::EnableDepthTest(), V3d_View::IsDepthTestEnabled()
    - Visual3d_View::ZBufferIsActivated(), Visual3d_View::SetZBufferActivity(), Visual3d_View::EnableDepthTest(), Visual3d_View::IsDepthTestEnabled()
    - Graphic3d_GraphicDriver::SetDepthTestEnabled(), Graphic3d_GraphicDriver::IsDepthTestEnabled()
    
    Activate Z-buffer by default, and manage it state only by Z-layer flags.
19Author
Please test the patch in branch CR26149_3.
20Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
21Commenter 21
Dear Commenter 1,
Branch CR26149_3 was rebased on current master of occt git-repository.
[revision removed]
22Commenter 22
Dear Commenter 1,
Branch CR26149_3 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]

There are following compilation errors:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26149-3-master/job/CR26149-3-master_build_occt_linux/2/parsed_console/

../../../../src/OpenGl/OpenGl_View_2.cxx: In member function 'void OpenGl_View::DrawBackground(const Handle_OpenGl_Workspace&)':
../../../../src/OpenGl/OpenGl_View_2.cxx:170:3: error: expected ',' or ';' before 'if'
../../../../src/OpenGl/OpenGl_View_2.cxx:244:5: error: expected ';' before 'aCtx'
make[2]: *** [OpenGl_View_2.lo] Error 1
23Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Mon Jun 1 15:20:30 2015 +0300

    fix misprints

24Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Mon Jun 1 15:24:02 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    OpenGl_Workspace::updateMaterial() - do not activate writing into Depth buffer without Graphic3d_ZLayerDepthWrite flag.
    Add method OpenGl_Workspace::UseDepthWrite() to track glDepthMask() state.
    
    Drop the following outdated API methods conflicting with Z-layers API:
    - V3d_View::EnableDepthTest(), V3d_View::IsDepthTestEnabled()
    - Visual3d_View::ZBufferIsActivated(), Visual3d_View::SetZBufferActivity(), Visual3d_View::EnableDepthTest(), Visual3d_View::IsDepthTestEnabled()
    - Graphic3d_GraphicDriver::SetDepthTestEnabled(), Graphic3d_GraphicDriver::IsDepthTestEnabled()
    
    Activate Z-buffer by default, and manage it state only by Z-layer flags.
25Author
Please test branch CR26149_4 with fixed misprints.
26Commenter 26
Dear Commenter 1,
Branch CR26149_4 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]

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/Improvements:
No regressions/differences

Testing cases:
http://occt-tests/CR26149-4-master-occt-64/Debian70-64/bugs/vis/bug26149.html
http://occt-tests/CR26149-4-master-occt-64/Windows-64-VC10/bugs/vis/bug26149.html
bugs vis bug26149: OK

Testing on Linux:
occt component :
Total MEMORY difference: 97092391 / 96680788 [+0.43%]
Total CPU difference: 18740.81000000005 / 18441.46000000009 [+1.62%]
products component :
Total MEMORY difference: 23998843 / 24082869 [-0.35%]
Total CPU difference: 7847.550000000031 / 7841.8200000000215 [+0.07%]

Testing on Windows:
occt component :
Total MEMORY difference: 57034753 / 56961596 [+0.13%]
Total CPU difference: 17364.315308998885 / 17471.08239339882 [-0.61%]
products component :
Total MEMORY difference: 15395240 / 15399387 [-0.03%]
Total CPU difference: 6140.168159799967 / 6256.747707099968 [-1.86%]

There are following differences in images found by testdiff.
http://occt-tests/CR26149-4-master-occt-64/Debian70-64/diff-Debian70-64.html
http://occt-tests/CR26149-4-master-occt-64/Windows-64-VC10/diff-Windows-64-VC10.html
IMAGE v3d materials bug24872_1: bug24872_1.png differs
IMAGE v3d materials bug24855: bug24855.png differs
IMAGE caf presentation F3: F3.png differs
IMAGE caf presentation F4: F4.png differs
IMAGE caf presentation F2: F2.png differs
IMAGE demo samples materials: materials.png differs
IMAGE bugs vis bug22819: bug22819_Driver1_Viewer1_View1.png differs
IMAGE bugs vis bug173_3: bug173_3_Driver1_Viewer1_View1.png differs
IMAGE bugs vis buc60740: buc60740_Driver1_Viewer1_View1.png differs
IMAGE bugs vis bug6145: bug6145_Driver1_Viewer1_View1.png differs
IMAGE bugs vis bug591: bug591_Driver1_Viewer1_View1.png differs
IMAGE bugs vis bug544: bug544_Driver1_Viewer1_View1.png differs
IMAGE bugs modalg_6 bug26180: bug26180_2.png differs
IMAGE bugs modalg_6 bug26180: bug26180_1.png differs
27Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mkv
Date: Tue Jun 2 15:43:41 2015 +0300

    Small correction ot test case for issue CR26149

28Commenter 28
Dear kgv,
could you please review following test case
bugs vis bug26149: OK - (big font in image)
29Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Tue Jun 2 16:10:08 2015 +0300

    OpenGl_Workspace::updateMaterial() - correct condition for transparent materials

30Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Tue Jun 2 16:11:50 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    OpenGl_Workspace::updateMaterial() - do not activate writing into Depth buffer without Graphic3d_ZLayerDepthWrite flag.
    Add method OpenGl_Workspace::UseDepthWrite() to track glDepthMask() state.
    
    Drop the following outdated API methods conflicting with Z-layers API:
    - V3d_View::EnableDepthTest(), V3d_View::IsDepthTestEnabled()
    - Visual3d_View::ZBufferIsActivated(), Visual3d_View::SetZBufferActivity(), Visual3d_View::EnableDepthTest(), Visual3d_View::IsDepthTestEnabled()
    - Graphic3d_GraphicDriver::SetDepthTestEnabled(), Graphic3d_GraphicDriver::IsDepthTestEnabled()
    
    Activate Z-buffer by default, and manage it state only by Z-layer flags.
31Author
Please test updated patch CR26149_5 which should fix image regressions on transparent objects.

> could you please review following test case
> bugs vis bug26149: OK - (big font in image)
test case has been taken from bug25783_1, so the image is OK.
32Commenter 32
Dear Commenter 1,
Branch CR26149_5 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]

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/Improvements:
No regressions/differences

Testing cases:
http://occt-tests/CR26149-5-master-occt-64/Debian70-64/bugs/vis/bug26149.html
http://occt-tests/CR26149-5-master-occt-64/Windows-64-VC10/bugs/vis/bug26149.html
bugs vis bug26149: OK

Testing on Linux:
occt component :
Total MEMORY difference: 96148260 / 96726615 [-0.60%]
Total CPU difference: 18290.649999999918 / 18391.330000000093 [-0.55%]
products component :
Total MEMORY difference: 24002088 / 24073311 [-0.30%]
Total CPU difference: 7708.360000000017 / 7840.410000000022 [-1.68%]

Testing on Windows:
occt component :
Total MEMORY difference: 56768900 / 56745671 [+0.04%]
Total CPU difference: 17316.922205199087 / 17309.590158198847 [+0.04%]
products component :
Total MEMORY difference: 15388942 / 15393011 [-0.03%]
Total CPU difference: 6144.645388499968 / 6255.468498899967 [-1.77%]

There are no differences in images found by testdiff.
33Commenter 33
Dear Commenter 1,
There are following errors durung products_csharp_samples_windows compilation:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26149-5-master/job/CR26149-5-master_build_products_csharp_samples_windows/1/parsed_console/
1>occcsharp_wrap.obj : error LNK2019: unresolved external symbol "public: void __cdecl V3d_View::EnableDepthTest(unsigned int)const " (?EnableDepthTest@V3d_View@@QEBAXI@Z) referenced in function CSharp_V3d_View_EnableDepthTest__SWIG_0
1>occcsharp_wrap.obj : error LNK2019: unresolved external symbol "public: unsigned int __cdecl V3d_View::IsDepthTestEnabled(void)const " (?IsDepthTestEnabled@V3d_View@@QEBAIXZ) referenced in function CSharp_V3d_View_IsDepthTestEnabled
1>..\win64\vc10\bin\OCCwrapCSharp.dll : fatal error LNK1120: 2 unresolved externals
34Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jun 3 09:55:35 2015 +0300

    V3d_View.cdl - remove removed methods

35Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: isz
Date: Wed Jun 3 09:58:10 2015 +0300

    0026149: Visualization - depth buffer should not be written within Z-layers without Graphic3d_ZLayerDepthWrite flag
    
    OpenGl_Workspace::updateMaterial() - do not activate writing into Depth buffer without Graphic3d_ZLayerDepthWrite flag.
    Add method OpenGl_Workspace::UseDepthWrite() to track glDepthMask() state.
    
    Drop the following outdated API methods conflicting with Z-layers API:
    - V3d_View::EnableDepthTest(), V3d_View::IsDepthTestEnabled()
    - Visual3d_View::ZBufferIsActivated(), Visual3d_View::SetZBufferActivity(), Visual3d_View::EnableDepthTest(), Visual3d_View::IsDepthTestEnabled()
    - Graphic3d_GraphicDriver::SetDepthTestEnabled(), Graphic3d_GraphicDriver::IsDepthTestEnabled()
    
    Activate Z-buffer by default, and manage it state only by Z-layer flags.
36Author
Please check compilation of the patch in branch CR26149_6, regression testing is not needed.
37Commenter 37
Dear Commenter 1,
Branch CR26149_6 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms on Release mode.
[revision removed]

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)

products_csharp_samples_windows was compiled without errors.

Branch CR26149_6 is TESTED.
38Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
39Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
40Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
41Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
42Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
43Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]
44Commenter 2
Branch [archived branch] has been deleted by Author.

[revision removed]

Related records