MantisBT - Open CASCADE
View Issue Details
0030476Open CASCADE[OCCT] OCCT:Visualizationpublic2019-02-05 11:182019-03-05 13:46
kgv 
apn 
normalminor 
verifiedfixed 
[OCCT] 7.1.0 
[OCCT] 7.4.0* 
Not needed
0030476: Visualization, Path Tracing - Adaptive Screen Sampling leads to unstable results
Activation 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.
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
No tags attached.
has duplicate 0029450closed bugmaster Constantly repeated difference in images of tests "v3d raytrace" 
related to 0030483verified apn Visualization, Path Tracing - make Tile Size configurable 
child of 0027607closed kgv Visualization - Implement adaptive screen space sampling in path tracing 
Issue History
2019-02-05 11:18kgvNew Issue
2019-02-05 11:18kgvAssigned To => kgv
2019-02-05 11:20gitNote Added: 0082032
2019-02-05 12:39kgvRelationship addedchild of 0027607
2019-02-05 12:39kgvProduct Version7.3.0 => 7.1.0
2019-02-05 23:17gitNote Added: 0082042
2019-02-06 19:26gitNote Added: 0082054
2019-02-06 19:27kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20633#r20633
2019-02-06 20:55gitNote Added: 0082058
2019-02-06 23:16gitNote Added: 0082059
2019-02-07 11:55gitNote Added: 0082061
2019-02-07 12:00kgvRelationship addedrelated to 0030483
2019-02-07 16:03gitNote Added: 0082066
2019-02-07 16:06gitNote Added: 0082068
2019-02-07 17:33gitNote Added: 0082074
2019-02-08 10:54gitNote Added: 0082080
2019-02-08 10:56gitNote Added: 0082081
2019-02-08 14:49gitNote Added: 0082084
2019-02-08 15:55gitNote Added: 0082086
2019-02-08 16:02gitNote Added: 0082087
2019-02-08 19:48gitNote Added: 0082100
2019-02-08 19:53gitNote Added: 0082101
2019-02-08 20:01kgvNote Added: 0082102
2019-02-08 20:03kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=20649#r20649
2019-02-08 20:08kgvNote Added: 0082104
2019-02-08 20:08kgvAssigned Tokgv => san
2019-02-08 20:08kgvStatusnew => resolved
2019-02-08 20:08kgvDescription Updatedbug_revision_view_page.php?rev_id=20651#r20651
2019-02-08 22:28kgvNote Edited: 0082102bug_revision_view_page.php?bugnote_id=82102#r20653
2019-02-08 23:25kgvNote Edited: 0082102bug_revision_view_page.php?bugnote_id=82102#r20654
2019-02-08 23:27kgvNote Edited: 0082102bug_revision_view_page.php?bugnote_id=82102#r20655
2019-02-11 12:21gitNote Added: 0082118
2019-02-11 12:42gitNote Added: 0082119
2019-02-11 12:44gitNote Added: 0082121
2019-02-11 17:38gitNote Added: 0082132
2019-02-11 18:05gitNote Added: 0082134
2019-02-11 18:14gitNote Added: 0082135
2019-02-11 18:17gitNote Added: 0082136
2019-02-12 09:32gitNote Added: 0082143
2019-02-15 17:33kgvAssigned Tosan => osa
2019-02-15 17:35osaNote Added: 0082201
2019-02-15 17:35osaAssigned Toosa => bugmaster
2019-02-15 17:35osaStatusresolved => reviewed
2019-02-16 11:47apnTest case number => Not needed
2019-02-16 11:48apnChangeset attached => occt master e084dbbc
2019-02-16 11:48apnAssigned Tobugmaster => apn
2019-02-16 11:48apnStatusreviewed => verified
2019-02-16 11:48apnResolutionopen => fixed
2019-03-03 00:29kgvRelationship addedhas duplicate 0029450
2019-03-05 13:46gitNote Added: 0082631
2019-03-05 13:46gitNote Added: 0082632
2019-03-05 13:46gitNote Added: 0082633
2019-03-05 13:46gitNote Added: 0082634
2019-03-05 13:46gitNote Added: 0082635

Notes
(0082032)
git   
2019-02-05 11:20   
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
(0082042)
git   
2019-02-05 23:17   
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

(0082054)
git   
2019-02-06 19:26   
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.
(0082058)
git   
2019-02-06 20:55   
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

(0082059)
git   
2019-02-06 23:16   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 35c63e65d545335d2085b1b86a14b21c00be23af
(0082061)
git   
2019-02-07 11:55   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 2d4e3889d779bda9fb573f6e7f71d39396fbd7f2
(0082066)
git   
2019-02-07 16:03   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 473d17bb1014cd67428cce53a6e657f6dc335158
(0082068)
git   
2019-02-07 16:06   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 46ea82372095e9f783cfa247db223c9d5b236adf
(0082074)
git   
2019-02-07 17:33   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: f53025b37a84e0327010fb55e8da5928f833db56
(0082080)
git   
2019-02-08 10:54   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 79f60ffe8da05ede0f18b3846ddfa13bac470253
(0082081)
git   
2019-02-08 10:56   
Branch CR30476_1 has been updated forcibly by kgv.

SHA-1: 92326a8b0d637f48c6a5656f71e07360775df17c
(0082084)
git   
2019-02-08 14:49   
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
(0082086)
git   
2019-02-08 15:55   
Branch CR30476_2 has been updated forcibly by kgv.

SHA-1: e6dbfff9b140ea242c975392b8eaa4f2e39e56eb
(0082087)
git   
2019-02-08 16:02   
Branch CR30476_2 has been updated forcibly by kgv.

SHA-1: c7643957b571877cbfd34095234c01668c09c421
(0082100)
git   
2019-02-08 19:48   
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.
(0082101)
git   
2019-02-08 19:53   
Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: e68ed8b82559dae92f06ff14f4355a3f924fb12c
(0082102)
kgv   
2019-02-08 20:01   
(edited on: 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).

(0082104)
kgv   
2019-02-08 20:08   
Patch is ready for review.
(0082118)
git   
2019-02-11 12:21   
Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: ea9a867861d686f24abefba9d7c508163b13ac38
(0082119)
git   
2019-02-11 12:42   
Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: 2c7b0c24895f344297734cf3d2bd7f94d8c20f24
(0082121)
git   
2019-02-11 12:44   
Branch CR30476_3 has been updated forcibly by kgv.

SHA-1: 56b13e3c92a2fbabc97d6cd1cbd30f2ec238a0e4
(0082132)
git   
2019-02-11 17:38   
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
(0082134)
git   
2019-02-11 18:05   
Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 5268d8cb0873ff24a146696f8e15b21f7f82c84d
(0082135)
git   
2019-02-11 18:14   
Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: d23a036567db55c09923eae1acec45e6dc53bb14
(0082136)
git   
2019-02-11 18:17   
Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 8ca4105d42701540b7298a93dcd0090fa84c0ca0
(0082143)
git   
2019-02-12 09:32   
Branch CR30476_4 has been updated forcibly by kgv.

SHA-1: 51a71b9d2ded8b2990aae45ea74a5f046f3c44d9
(0082201)
osa   
2019-02-15 17:35   
Reviewed without remarks
(0082631)
git   
2019-03-05 13:46   
Branch CR30476 has been deleted by kgv.

SHA-1: 2027cfb985868f5d9dd35a1a21166c6b1b049e68
(0082632)
git   
2019-03-05 13:46   
Branch CR30476_1 has been deleted by kgv.

SHA-1: 92326a8b0d637f48c6a5656f71e07360775df17c
(0082633)
git   
2019-03-05 13:46   
Branch CR30476_2 has been deleted by kgv.

SHA-1: c7643957b571877cbfd34095234c01668c09c421
(0082634)
git   
2019-03-05 13:46   
Branch CR30476_3 has been deleted by kgv.

SHA-1: 56b13e3c92a2fbabc97d6cd1cbd30f2ec238a0e4
(0082635)
git   
2019-03-05 13:46   
Branch CR30476_4 has been deleted by kgv.

SHA-1: 51a71b9d2ded8b2990aae45ea74a5f046f3c44d9