View Issue Details

IDProjectCategoryView StatusLast Update
0025303Open CASCADEOCCT:Visualizationpublic2014-11-11 13:01
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Target Version6.8.0Fixed in Version6.8.0 
Summary0025303: Visualization, TKOpenGl - dynamically disable unused light sources in generated GLSL program
DescriptionIt is desired to generate optimized GLSL programs depending on active lights sources configuration (e.g. number and light sources types).

This is essential for compatibility with old and slow graphic cards like NVIDIA Tegra 3 - the program might be executed slower within not-well optimized OpenGL drivers or even not compiled at all due to hardware limits (overall instructions number). Tegra 3:
(0): error C6002: Instruction limit of 256 exceeded; 393 instructions needed to compile program
316 lines, 1 errors.


Mali-400:
0:1:F0003: Shader is too long. This shader is 2019 instruction words long, but Mali-400 GP only supports up to 512 instruction words

TagsNo tags attached.
Test case numberNot needed

Attached Files

  • mali400.png (56,409 bytes)
  • tegra3.png (129,944 bytes)

Relationships

child of 0025282 closedbugmaster Visualization, OpenGl_PrimitiveArray - provide built-in GLSL programs as alternative to FFP 
child of 0025146 closedbugmaster Porting to Android 

Activities

git

2014-10-08 12:29

administrator   ~0032805

Branch CR25303 has been created by kgv.

SHA-1: b5be8765f851287e91c05e18e34e3e23b749920f


Detailed log of new commits:

Author: kgv
Date: Wed Oct 8 12:29:47 2014 +0400

    0025303: Visualization, TKOpenGl - dynamically disable unused light sources in generated GLSL program

kgv

2014-10-09 09:12

developer  

mali400.png (56,409 bytes)

kgv

2014-10-09 11:12

developer  

tegra3.png (129,944 bytes)

kgv

2014-10-09 11:15

developer   ~0032870

Please review patch in branch CR25303.

dbp

2014-10-09 12:36

developer   ~0032875

Dear kgv,

In essence, I have no comments. But in the future you can try additional optimizations to further improve the performance on the devices.

1) Use precision qualifiers.

2) In TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting():

EOL" vec3 aPoint = thePoint.xyz / thePoint.w;"
Do we need this line& If so, use thePoint.xyz * (1.0 / thePoint.w)

EOL" vec4 aMaterialAmbient = theIsFront ? occFrontMaterial_Ambient() : occBackMaterial_Ambient();"
EOL" vec4 aMaterialDiffuse = theIsFront ? occFrontMaterial_Diffuse() : occBackMaterial_Diffuse();"
EOL" vec4 aMaterialSpecular = theIsFront ? occFrontMaterial_Specular() : occBackMaterial_Specular();"
EOL" vec4 aMaterialEmission = theIsFront ? occFrontMaterial_Emission() : occBackMaterial_Emission();"
Use mix() fucntion instead of "?" operator. At least on desktop GPU it compilied into IF/ELSE instructions.

3) In const char THE_FUNC_directionalLight[]:

EOL" vec3 aLight = normalize (occLight_Position (theId).xyz);"
This vector should be normalized on the CPU side.

EOL" if (aNdotL > 0.0)"
EOL" {"
EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());"
EOL" }"
It is possible that eliminating condition will increase performance.

4) const char THE_FUNC_pointLight[]:

EOL" float aDist = length (aLight);"
EOL" aLight = aLight * (1.0 / aDist);" --> aLight *= 1.0 / aDist

EOL" float aSpecl = 0.0;"
EOL" if (aNdotL > 0.0)"
EOL" {"
EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());"
EOL" }"

Check elimination of "if".

dbp

2014-10-09 12:37

developer   ~0032876

Dear bugmaster,

please test the patch in branch CR25303.

apv

2014-10-10 16:32

tester   ~0032981

Dear BugMaster,

Branch CR25303 (and products from GIT master) was compiled on Linux, Windows and MacOS platforms and tested.
SHA-1: b5be8765f851287e91c05e18e34e3e23b749920f

Number of compiler warnings:
occt component:
   Linux: 15 (15 on master)
   Windows: 0 (0 on master)
products component:
   Linux: 11 (11 on master)
   Windows: 1 (1 on master)

Regressions/Differences:
Not detected

Testing case:
Not needed

Testing on Linux:
Total MEMORY difference: 396758492 / 397912148
Total CPU difference: 47500.070000000065 / 47179.37000000023

Testing on Windows:
Total MEMORY difference: 279120000 / 278272188
Total CPU difference: 43579.75 / 32988.6875

git

2014-10-21 16:42

administrator   ~0033428

Branch CR25303 has been deleted by inv.

SHA-1: b5be8765f851287e91c05e18e34e3e23b749920f

Related Changesets

occt: master 256f9ac0

2014-10-08 08:29:47

kgv


Committer: bugmaster Details Diff
0025303: Visualization, TKOpenGl - dynamically disable unused light sources in generated GLSL program Affected Issues
0025303
mod - src/OpenGl/FILES Diff File
add - src/OpenGl/OpenGl_SetOfShaderPrograms.hxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.hxx Diff File
mod - src/OpenGl/OpenGl_View_2.cxx Diff File

Issue History

Date Modified Username Field Change
2014-10-01 11:36 kgv New Issue
2014-10-01 11:36 kgv Assigned To => kgv
2014-10-01 11:44 kgv Relationship added child of 0025282
2014-10-01 11:45 kgv Relationship added child of 0025146
2014-10-08 12:29 git Note Added: 0032805
2014-10-09 09:12 kgv File Added: mali400.png
2014-10-09 11:12 kgv File Added: tegra3.png
2014-10-09 11:15 kgv Note Added: 0032870
2014-10-09 11:15 kgv Assigned To kgv => dbp
2014-10-09 11:15 kgv Status new => resolved
2014-10-09 11:31 kgv Description Updated
2014-10-09 12:36 dbp Note Added: 0032875
2014-10-09 12:37 dbp Note Added: 0032876
2014-10-09 12:37 dbp Assigned To dbp => bugmaster
2014-10-09 12:37 dbp Status resolved => reviewed
2014-10-09 14:40 apv Assigned To bugmaster => apv
2014-10-10 16:30 apv Test case number => Not needed
2014-10-10 16:32 apv Note Added: 0032981
2014-10-10 16:32 apv Assigned To apv => bugmaster
2014-10-10 16:32 apv Status reviewed => tested
2014-10-20 10:24 bugmaster Changeset attached => occt master 256f9ac0
2014-10-20 10:24 bugmaster Status tested => verified
2014-10-20 10:24 bugmaster Resolution open => fixed
2014-10-21 16:42 git Note Added: 0033428
2014-11-11 12:43 aiv Fixed in Version => 6.8.0
2014-11-11 13:01 aiv Status verified => closed