View Issue Details

IDProjectCategoryView StatusLast Update
0030476Open CASCADEOCCT:Visualizationpublic2020-11-13 14:59
Reporterkgv Assigned Toapn  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version7.1.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results
DescriptionActivation of Graphic3d_RenderingParams::AdaptiveScreenSampling option leads to unstable results of Path Tracing algorithm. As result, Jenkins tests show regular screenshots deviations.

Note that for some reason, specifying 1024x1024 rendering resolution does not have this side effect.

In addition, the algorithm relies on GL_NV_shader_atomic_float extension,
which is currently implemented only on NVIDIA hardware, limiting AdaptiveScreenSampling usability.
Steps To Reproduce
pload VISUALIZATION
vclear;vclose ALL;vinit View1 -width 512 -height 512
test v3d raytrace dof_mono 1
vrenderparams -iss 1
#vrenderparams -issd 1
set aZoom 1
vfit;vzoom $aZoom
vdump a.png
vfps 10
vdump a10.png
vfps 50
vdump a50.png
vfit;vzoom $aZoom
vdump b.png
vfps 10
vdump b10.png
vfps 50
vdump b50.png
diffimage a.png b.png d.png
diffimage a10.png b10.png d10.png
diffimage a50.png b50.png d50.png



pload VISUALIZATION
#set aSize 256
#set aSize 409
#set aSize 512
set aSize 1024
vclear;vclose ALL;vinit View1 -width $aSize -height $aSize
test v3d raytrace dof_mono 1
vrenderparams -iss 1

set aZoom 1
vfit -noupdate; if { $aZoom != 1 } { vzoom $aZoom }
vinit -cloneActive View2
vfit -noupdate; if { $aZoom != 1 } { vzoom $aZoom }
for {set i 0} {$i < 50} {incr i} { puts "\n >> View1 $i"; vactivate View1; vdump a$i.png; puts " >> View2 $i"; vactivate View2; vdump b$i.png; set aDiff [diffimage a$i.png b$i.png d$i.png]; if { $aDiff != 0 } { break; } }



pload MODELING VISUALIZATION
vgldebug -glslWarn 1; vcaps -vsync 0
box bl 0 0 0 0.1 3 3
box br 0 3 0 3 0.1 3
box bt 0 0 3 3 3 0.1
box bg 0 0 0 3 3 0.1
box bn 2 2.5 1 0.1 0.1 0.1
#set aSizeX 409; set aSizeY 409
set aSizeX 1920; set aSizeY 1080
#set aSizeX 1024; set aSizeY 1024
#set aSizeX 2048; set aSizeY 1024
set aParamsIss0 "-rayTrace -gi -iss 0 -issAtomic 0"
set aParamsIss1 "-rayTrace -gi -iss 1 -issAtomic 0"
set aParamsIss2 "-rayTrace -gi -iss 1 -issAtomic 1"

vclear; vclose ALL; vinit v1 -width $aSizeX -height $aSizeY
vglinfo
set aVend [lindex [string tolower [vglinfo vendor]] 0]

set aResFolder1 ../${aVend}_${aSizeX}x${aSizeY}_iss0
set aResFolder2 ../${aVend}_${aSizeX}x${aSizeY}_iss1
set aResFolder3 ../${aVend}_${aSizeX}x${aSizeY}_iss2
if {[file exists "$aResFolder1"] == 1} { file delete -force $aResFolder1 }
if {[file exists "$aResFolder2"] == 1} { file delete -force $aResFolder2 }
if {[file exists "$aResFolder3"] == 1} { file delete -force $aResFolder3 }
file mkdir "$aResFolder1"
file mkdir "$aResFolder2"
file mkdir "$aResFolder3"

vlight -clear -add positional -global -head 0 -pos 0.5 1 1 -sm 0.06 -int 250.0
vdisplay -dispMode 1 bl br bt bg bn; vfit;
vaspects bl -setMaterial PLASTIC
vaspects br -setMaterial PLASTIC
vaspects bt -setMaterial GLASS
vaspects bg -setMaterial SILVER
vaspects bn -setMaterial NEON
vraytrace 1; vrenderparams -gi

#vrenderparams -iss 1

#proc myDump {img} { vdump ${img}_1.png; vdump ${img}_2.png; vfps 7; vdump ${img}_10.png; vfps 89; vdump ${img}_100.png; vfps 99; vdump ${img}_200.png; vfps 99; vdump ${img}_300.png; vfps 99; vdump ${img}_400.png; vfps 99; vdump ${img}_500.png }
proc myDump {img} { vdump ${img}_1.png; vdump ${img}_2.png; vfps 7; vdump ${img}_10.png; vfps 89; vdump ${img}_100.png; }
vrenderparams {*}$aParamsIss0; vfit; myDump $aResFolder1/image
vrenderparams {*}$aParamsIss1; vfit; myDump $aResFolder2/image
vrenderparams {*}$aParamsIss2; vfit; myDump $aResFolder3/image

vrenderparams {*}$aParamsIss0; vfit; chrono t1 restart; vfps -time 10; chrono t1 show
vrenderparams {*}$aParamsIss1; vfit; chrono t2 restart; vfps -time 10; chrono t2 show
vrenderparams {*}$aParamsIss2; vfit; chrono t3 restart; vfps -time 10; chrono t3 show
vmemgpu
meminfo
vstatprofiler geomMem textureMem frameMem
TagsNo tags attached.
Test case numberNot needed

Relationships

has duplicate 0029450 closedbugmaster Open CASCADE Constantly repeated difference in images of tests "v3d raytrace" 
related to 0030483 closedapn Open CASCADE Visualization, Path Tracing - make Tile Size configurable 
child of 0027607 closedkgv Open CASCADE Visualization - Implement adaptive screen space sampling in path tracing 

Activities

git

2019-02-05 11:20

administrator   ~0082032

Branch CR30476 has been created by kgv.

SHA-1: 9f362a686b88d691bf485f00d0c6396263949bb0


Detailed log of new commits:

Author: kgv
Date: Tue Feb 5 11:15:50 2019 +0300

    0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results

git

2019-02-05 23:17

administrator   ~0082042

Branch CR30476 has been updated by kgv.

SHA-1: 2027cfb985868f5d9dd35a1a21166c6b1b049e68


Detailed log of new commits:

Author: kgv
Date: Tue Feb 5 23:12:37 2019 +0300

    # debug

git

2019-02-06 19:26

administrator   ~0082054

Branch CR30476_1 has been created by kgv.

SHA-1: 4691bc1e45b67c535f7d157559080c2a49b6be7b


Detailed log of new commits:

Author: kgv
Date: Wed Feb 6 19:21:23 2019 +0300

    0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results
    
    OpenGl_TileSampler has been refactored to better describe its logic and solve bugs:
    - Tile size is now recomputed based on desired number of tiles instead of hard-coded number 32.
    - Offset image now defines tile index instead of offset to tile origin.
    - Added 2D array defining the number of times to sample tile for straight-forward debugging.
    
    OpenGl_View::initRaytraceResources() now relies on tile properties of OpenGl_TileSampler
    instead of computing numbers of unknown purpose / unclear logic.
    OpenGl_View::runPathtrace() has been split into two methods per rendering stage.
    
    Added Image_PixMapTypedData template class allowing to work with image data of known pixel format.

git

2019-02-06 20:55

administrator   ~0082058

Branch CR30476_1 has been updated by kgv.

SHA-1: 61631c64052faac3282ca1736b22200e80686c0d


Detailed log of new commits:

Author: kgv
Date: Wed Feb 6 20:50:43 2019 +0300

    # debug 3

git

2019-02-06 23:16

administrator   ~0082059

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 35c63e65d545335d2085b1b86a14b21c00be23af

git

2019-02-07 11:55

administrator   ~0082061

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 2d4e3889d779bda9fb573f6e7f71d39396fbd7f2

git

2019-02-07 16:03

administrator   ~0082066

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 473d17bb1014cd67428cce53a6e657f6dc335158

git

2019-02-07 16:06

administrator   ~0082068

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 46ea82372095e9f783cfa247db223c9d5b236adf

git

2019-02-07 17:33

administrator   ~0082074

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: f53025b37a84e0327010fb55e8da5928f833db56

git

2019-02-08 10:54

administrator   ~0082080

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 79f60ffe8da05ede0f18b3846ddfa13bac470253

git

2019-02-08 10:56

administrator   ~0082081

Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 92326a8b0d637f48c6a5656f71e07360775df17c

git

2019-02-08 14:49

administrator   ~0082084

Branch CR30476_2 has been created by kgv.

SHA-1: 586a44a0651d2daee5bc2877b4c6e442f13a7e85


Detailed log of new commits:

Author: kgv
Date: Thu Feb 7 16:02:01 2019 +0300

    # debug 4

git

2019-02-08 15:55

administrator   ~0082086

Branch CR30476_2 has been updated forcibly by kgv.

SHA-1: e6dbfff9b140ea242c975392b8eaa4f2e39e56eb

git

2019-02-08 16:02

administrator   ~0082087

Branch CR30476_2 has been updated forcibly by kgv.

SHA-1: c7643957b571877cbfd34095234c01668c09c421

git

2019-02-08 19:48

administrator   ~0082100

Branch CR30476_3 has been created by kgv.

SHA-1: d170a9fe43688370054d9645fbe0795f046ce656


Detailed log of new commits:

Author: kgv
Date: Thu Feb 7 16:02:01 2019 +0300

    0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results
    
    OpenGl_View::runPathtrace() has been extended with alternative multi-pass
    Adaptive Screen Sampling mode, not relying on atomic floating point operations.
    Although atomic operations on floats allows single-pass rendering,
    such operations leads to instability in case of different calculation order.
    Atomic float operations are also currently supported only by single GPU vendor.
    
    Fixed GLSL compilation on Intel drivers (follow ARB_shader_image_load_store
    specs rather than EXT_shader_image_load_store).
    
    Graphic3d_RenderingParams::AdaptiveScreenSamplingAtomic option has been added
    to activate 1-pass Adaptive Screen Sampling mode when supported by hardware.
    
    vfps command has been extended with -duration argument allowing to limit command execution time.

git

2019-02-08 19:53

administrator   ~0082101

Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: e68ed8b82559dae92f06ff14f4355a3f924fb12c

kgv

2019-02-08 20:01

developer   ~0082102

Last edited: 2019-02-08 23:27

Numbers on average scene (v3d/raytrace/dof_mono),
window resized to 1920x1080, vfps -time 10.

GeForce 1060:
> vrenderparams -iss 0 -issAtomic 0; vfit; vfps -time 10
FPS: 15.653285119555047
CPU: 16.719745222929937 msec
MRays/sec (upper bound): 586.66008102473188

> vrenderparams -iss 1 -issAtomic 0; vfit; vfps -time 10
FPS: 9.3303997081068459
CPU: 30.418882978723406 msec
MRays/sec (upper bound): 349.68845242031165

> vrenderparams -iss 1 -issAtomic 1; vfit; vfps -time 10
FPS: 9.6533894875911699
CPU: 26.739690721649485 msec
MRays/sec (upper bound): 361.79359257173689

So that ISS drops downs FPS by 40%, but for the same time image quality is usually better for the critical parts of scene.

Atomic float operations is slightly faster for this scene.
but in the worst case ISS without atomic operations drops down performance more significantly, so that atomic is preferred when available (although it is possible trying to optimized non-atomic way).

AMD Radeon R9 380
> vrenderparams -iss 0 -issAtomic 0; vfit; vfps -time 10
FPS: 10.034577285187424
CPU: 0.46410891089108908 msec
MRays/sec (upper bound): 391.87833980296745

> vrenderparams -iss 1 -issAtomic 0; vfit; vfps -time 10
FPS: 6.1594992622067251
CPU: 0.49603174603174599 msec
MRays/sec (upper bound): 240.54569278710679

The same 39% drop down.
Atomic float operations are unavailable on Radeon.

AMD Radeon RX Vega
> vrenderparams -iss 0; vfps -time 10
FPS: 25.255801545472011
CPU: 0.55583003952569177 msec
MRays/sec (upper bound): 946.5470326418183

> vrenderparams -iss 1; vfps -time 10
FPS: 10.593830112556274
CPU: 0.73014018691588778 msec
MRays/sec (upper bound): 397.03980249042905

ISS drops FPS by 58%, which is much more noticeable than on slower Radeon GPU (in worst scenario the drop is several times).
However, tests simulating issAtomic (without actual atomic operations, hence producing invalid result) does not show much better times.

It should be noted, that in degenerated cases FPS drop down is actually expected: fragments with no/simple ray intersections can be passed by GPU much faster than main/critical geometry. So that without ISS such fragments will be processed faster increasing Rays/s and FPS counters (e.g. when such simple geometry covers significant part of the scene), while ISS will put GPU processing tiles with complex geometry several times leading to lower Rays/s and FPS counters. So that the real benefit of ISS should be counted by comparing final quality per second meter, which is more difficult to count (hence, vfps -time argument has been introduced to prepare screenshots at different timestamps rather than at different frame counters).

kgv

2019-02-08 20:08

developer   ~0082104

Patch is ready for review.

git

2019-02-11 12:21

administrator   ~0082118

Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: ea9a867861d686f24abefba9d7c508163b13ac38

git

2019-02-11 12:42

administrator   ~0082119

Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: 2c7b0c24895f344297734cf3d2bd7f94d8c20f24

git

2019-02-11 12:44

administrator   ~0082121

Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: 56b13e3c92a2fbabc97d6cd1cbd30f2ec238a0e4

git

2019-02-11 17:38

administrator   ~0082132

Branch CR30476_4 has been created by kgv.

SHA-1: 72e9dc8f6b07043b2656b29513774406efb3867e


Detailed log of new commits:

Author: kgv
Date: Mon Feb 11 17:34:13 2019 +0300

    0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results
    
    OpenGl_View::runPathtrace() has been extended with alternative multi-pass
    Adaptive Screen Sampling mode, not relying on atomic floating point operations.
    Although atomic operations on floats allows single-pass rendering,
    such operations leads to instability in case of different calculation order.
    Atomic float operations are also currently supported only by single GPU vendor.
    
    Fixed GLSL compilation on Intel drivers (follow ARB_shader_image_load_store
    specs rather than EXT_shader_image_load_store).
    
    Graphic3d_RenderingParams::AdaptiveScreenSamplingAtomic option has been added
    to activate 1-pass Adaptive Screen Sampling mode when supported by hardware.
    
    vfps command has been extended with -duration argument allowing to limit command execution time.
    vactivate command has been extended with -noUpdate argument.
    
    # Conflicts:
    # src/OpenGl/OpenGl_TileSampler.cxx
    # src/OpenGl/OpenGl_TileSampler.hxx
    # src/OpenGl/OpenGl_View_Raytrace.cxx

git

2019-02-11 18:05

administrator   ~0082134

Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 5268d8cb0873ff24a146696f8e15b21f7f82c84d

git

2019-02-11 18:14

administrator   ~0082135

Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: d23a036567db55c09923eae1acec45e6dc53bb14

git

2019-02-11 18:17

administrator   ~0082136

Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 8ca4105d42701540b7298a93dcd0090fa84c0ca0

git

2019-02-12 09:32

administrator   ~0082143

Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 51a71b9d2ded8b2990aae45ea74a5f046f3c44d9

osa

2019-02-15 17:35

developer   ~0082201

Reviewed without remarks

git

2019-03-05 13:46

administrator   ~0082631

Branch CR30476 has been deleted by kgv.

SHA-1: 2027cfb985868f5d9dd35a1a21166c6b1b049e68

git

2019-03-05 13:46

administrator   ~0082632

Branch CR30476_1 has been deleted by kgv.

SHA-1: 92326a8b0d637f48c6a5656f71e07360775df17c

git

2019-03-05 13:46

administrator   ~0082633

Branch CR30476_2 has been deleted by kgv.

SHA-1: c7643957b571877cbfd34095234c01668c09c421

git

2019-03-05 13:46

administrator   ~0082634

Branch CR30476_3 has been deleted by kgv.

SHA-1: 56b13e3c92a2fbabc97d6cd1cbd30f2ec238a0e4

git

2019-03-05 13:46

administrator   ~0082635

Branch CR30476_4 has been deleted by kgv.

SHA-1: 51a71b9d2ded8b2990aae45ea74a5f046f3c44d9

Related Changesets

occt: master e084dbbc

2019-02-11 15:00:35

kgv


Committer: apn Details Diff
0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results

OpenGl_View::runPathtrace() has been extended with alternative multi-pass
Adaptive Screen Sampling mode, not relying on atomic floating point operations.
Although atomic operations on floats allows single-pass rendering,
such operations leads to instability in case of different calculation order.
Atomic float operations are also currently supported only by single GPU vendor.

Fixed GLSL compilation on Intel drivers (follow ARB_shader_image_load_store
specs rather than EXT_shader_image_load_store).

Graphic3d_RenderingParams::AdaptiveScreenSamplingAtomic option has been added
to activate 1-pass Adaptive Screen Sampling mode when supported by hardware.

vfps command has been extended with -duration argument allowing to limit command execution time.
vactivate command has been extended with -noUpdate argument.
Affected Issues
0030476
mod - src/Graphic3d/Graphic3d_RenderingParams.hxx Diff File
mod - src/Graphic3d/Graphic3d_TypeOfLimit.hxx Diff File
mod - src/OpenGl/OpenGl_Context.cxx Diff File
mod - src/OpenGl/OpenGl_Context.hxx Diff File
mod - src/OpenGl/OpenGl_FrameStats.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cxx Diff File
mod - src/OpenGl/OpenGl_TileSampler.cxx Diff File
mod - src/OpenGl/OpenGl_TileSampler.hxx Diff File
mod - src/OpenGl/OpenGl_View.hxx Diff File
mod - src/OpenGl/OpenGl_View_Raytrace.cxx Diff File
mod - src/Shaders/Display.fs Diff File
mod - src/Shaders/RaytraceBase.fs Diff File
mod - src/Shaders/RaytraceRender.fs Diff File
mod - src/Shaders/Shaders_Display_fs.pxx Diff File
mod - src/Shaders/Shaders_RaytraceBase_fs.pxx Diff File
mod - src/Shaders/Shaders_RaytraceRender_fs.pxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands_1.mm Diff File

Issue History

Date Modified Username Field Change
2019-02-05 11:18 kgv New Issue
2019-02-05 11:18 kgv Assigned To => kgv
2019-02-05 11:20 git Note Added: 0082032
2019-02-05 12:39 kgv Relationship added child of 0027607
2019-02-05 12:39 kgv Product Version 7.3.0 => 7.1.0
2019-02-05 23:17 git Note Added: 0082042
2019-02-06 19:26 git Note Added: 0082054
2019-02-06 19:27 kgv Steps to Reproduce Updated
2019-02-06 20:55 git Note Added: 0082058
2019-02-06 23:16 git Note Added: 0082059
2019-02-07 11:55 git Note Added: 0082061
2019-02-07 12:00 kgv Relationship added related to 0030483
2019-02-07 16:03 git Note Added: 0082066
2019-02-07 16:06 git Note Added: 0082068
2019-02-07 17:33 git Note Added: 0082074
2019-02-08 10:54 git Note Added: 0082080
2019-02-08 10:56 git Note Added: 0082081
2019-02-08 14:49 git Note Added: 0082084
2019-02-08 15:55 git Note Added: 0082086
2019-02-08 16:02 git Note Added: 0082087
2019-02-08 19:48 git Note Added: 0082100
2019-02-08 19:53 git Note Added: 0082101
2019-02-08 20:01 kgv Note Added: 0082102
2019-02-08 20:03 kgv Steps to Reproduce Updated
2019-02-08 20:08 kgv Note Added: 0082104
2019-02-08 20:08 kgv Assigned To kgv => san
2019-02-08 20:08 kgv Status new => resolved
2019-02-08 20:08 kgv Description Updated
2019-02-08 22:28 kgv Note Edited: 0082102
2019-02-08 23:25 kgv Note Edited: 0082102
2019-02-08 23:27 kgv Note Edited: 0082102
2019-02-11 12:21 git Note Added: 0082118
2019-02-11 12:42 git Note Added: 0082119
2019-02-11 12:44 git Note Added: 0082121
2019-02-11 17:38 git Note Added: 0082132
2019-02-11 18:05 git Note Added: 0082134
2019-02-11 18:14 git Note Added: 0082135
2019-02-11 18:17 git Note Added: 0082136
2019-02-12 09:32 git Note Added: 0082143
2019-02-15 17:33 kgv Assigned To san => osa
2019-02-15 17:35 osa Note Added: 0082201
2019-02-15 17:35 osa Assigned To osa => bugmaster
2019-02-15 17:35 osa Status resolved => reviewed
2019-02-16 11:47 apn Test case number => Not needed
2019-02-16 11:48 apn Changeset attached => occt master e084dbbc
2019-02-16 11:48 apn Assigned To bugmaster => apn
2019-02-16 11:48 apn Status reviewed => verified
2019-02-16 11:48 apn Resolution open => fixed
2019-03-03 00:29 kgv Relationship added has duplicate 0029450
2019-03-05 13:46 git Note Added: 0082631
2019-03-05 13:46 git Note Added: 0082632
2019-03-05 13:46 git Note Added: 0082633
2019-03-05 13:46 git Note Added: 0082634
2019-03-05 13:46 git Note Added: 0082635