View Issue Details

IDProjectCategoryView StatusLast Update
0024739Open CASCADEOCCT:Visualizationpublic2014-12-01 09:57
ReporterdbpAssigned Toapn  
PrioritynormalSeverityintegration request 
Status closedResolutionfixed 
Product Version6.7.0 
Target Version6.8.0Fixed in Version6.8.0 
Summary0024739: TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and portability
DescriptionPorting TKOpenGl ray-tracing to OpenGL/GLSL
Additional information
and documentation updates
To improve stability and extend supported GPU devices OCCT ray-tracing core was redesigned and ported to OpenGL/GLSL framework. Currently, the most of OpenGL 3.1 compatible cards can run ray-tracing. This patch also improves performance of the rendering: in "lightweight" modes (only shadows or transparency) ray-tracing performance were increased by 50-100%.
TagsNo tags attached.
Test case numberNot needed

Relationships

related to 0024546 closedabv GCC compiler warnings in OpenGl 
related to 0024795 closedapn TKOpenGl - new compilation warnings 
related to 0024838 closedbugmaster Visualization, TKOpenGl - make general rendering path compatible with OpenGL 3.1+ core profiles 
related to 0025527 closedbugmaster Documentation - remove redundant references to OpenCL 

Activities

dbp

2014-03-26 15:01

developer   ~0028491

Dear kgv,

please review the path in branch CR24739_2.

kgv

2014-03-27 10:16

developer   ~0028503

Last edited: 2014-03-27 10:24

Please take into account the following remarks:

-    IsReflectionsEnabled (1),
+    IsReflectionsEnabled (0),

-//#define RAY_TRACE_PRINT_INFO
+#define RAY_TRACE_PRINT_INFO

Unrelated changes?

-OpenGl_Flipper.cxx
+OpenGl_Flipper.cxx
\ No newline at end of file

Please avoid such changes.

+    if (aTriangleSet->BVH()->Depth() > myBottomLevelTreeDepth)
+    {
+      myBottomLevelTreeDepth = aTriangleSet->BVH()->Depth();
+    }

Max?

+  theCtx->core20->glBindAttribLocation (myProgramID, theIndex, theName);
+
+  return Standard_True;

Here and in other places - please prefer core20fwd.

+  myTraversalStackSize = 24;

Replace 24 with global constant and document why 24 is used by default.

+    //! Loads shader source from specified files.
+    void Load (const TCollection_AsciiString* theFileNames, const Standard_Integer theCount);

Sequence of TCollection_HAsciiString or NULL-terminated list?

   Standard_Boolean Raytrace (const Graphic3d_CView& theCView,
-              const int theSizeX, const int theSizeY, const Tint theToSwap);
+                             const Standard_Integer theSizeX,
+                             const Standard_Integer theSizeY,
+                             const Standard_Integer theToSwap);

theToSwap - Standard_Boolean?

+  Standard_Integer myUniformLocations[2][9];

magic numbers...

+  Handle(OpenGl_FrameBuffer) myRaytraceFBO2;
+
+  Handle(OpenGl_ShaderObject) LoadShader (const ShaderSource& theSource, GLenum theType);

Mixed declarations of functions and fields.

+        myView->TextureEnv()->Bind (myGlContext, GL_TEXTURE12);
+      aProgram->SetSampler (myGlContext, "uEnvironmentMapTexture", 12);

Enumeration instead of 12 and GL_TEXTURE12 (GL_TEXTURE0 + Samplers_EnvTexture)?

+  TCollection_AsciiString aFolder = OSD_Environment ("CSF_ShadersDirectory").Value();

Graphic3d_ShaderProgram::ShadersFolder().

+      const TCollection_ExtendedString aMessage = "Error: Failed to set vertex shader source";
+     
+      myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB,
+        GL_DEBUG_TYPE_ERROR_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aMessage);

Here and in other places - "Error: " prefix looks redundant here since it is created by PushMessage().

+  if (!myRaytraceProgram.IsNull())
+    myRaytraceProgram->Release (myGlContext.operator->());

Consider creation of auxiliary function to improve readability and robustness.
inline void NullifyResource (Handle(OpenGl_Resource)&      theResource,
                             const Handle(OpenGl_Context)& theCtx)
{
  if (!theResource.IsNull())
  {
    theResource->Release (theCtx.operator->());
    theResource.Nullify();
  }
}


+  if (aBVH->NodeInfoBuffer().size() > 0)

!empty()

+  if (aTotalBVHNodesNb > 0)
+  {

!= 0

+  glDrawArrays (GL_TRIANGLES, 0, 6);

core15fwd

+  NCollection_Mat4<GLdouble> aOrientationMatrix;
+  NCollection_Mat4<GLdouble> aViewMappingMatrix;
+  NCollection_Mat4<GLdouble> aOrientationInvers;

Nit: aOrientationMatrix, aViewMappingMatrix, aOrientationInvers;

+  static const TCollection_AsciiString aVersion = "#version 130";

Are there particular features used from GLSL130?

+  if (!myGlContext->IsGlGreaterEqual (3, 0))

If GLSL130 is mandatory, than we might consider version OpenGL3.1 as minimum (required for TBO) - otherwise OpenGl2.1 + arbTBO. OpenGL3.0 does not make much sense in real world.

CSF_OPENCL should be removed from OpenGl/EXTERNLIB and TKOpenGl/EXTERNLIB.

dbp

2014-03-27 18:37

developer   ~0028519

Dear kgv,

please review updated patch in branch CR24739_5.

kgv

2014-03-31 12:41

developer   ~0028561

Please test patch in branch CR24739.

mkv

2014-03-31 18:36

tester   ~0028568

Dear kgv,
could you please rebase branch CR24739, there are conflict files.

kgv

2014-04-01 08:55

developer   ~0028575

Please test re-based patch in branch CR24739_7.

mkv

2014-04-01 20:40

tester   ~0028611

Dear BugMaster,

Branch CR24739_7 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
SHA-1: ed6c147d6999c02bde5daa98ae4b6f59d9ad8ede

Number of compiler warnings:

occt component :
Linux: 21 (27 on master)
Windows: 0 (0 on master)

products component :
Linux: 12 (12 on master)
Windows: 2 (2 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 393715464 / 393242136
Total CPU difference: 48697.61999999997 / 57189.309999999896

Testing on Windows:
Total MEMORY difference: 420961968 / 414274688
Total CPU difference: 35780.953125 / 42798.984375

There are no differences in images found by testdiff.

apn

2014-04-04 12:14

administrator   ~0028674

There are compilation errors on MacOS:

In file included from /Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/adm/cmake/TKMath/../../../inc/BVH_BinnedBuilder.hxx:67:
/Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/adm/cmake/TKMath/../../../inc/BVH_BinnedBuilder.lxx:289:5: error: use of undeclared identifier 'UpdateDepth'
UpdateDepth (theBVH, theBVH->Level (aChildIndex));
^
this->
/Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/src/BVH/BVH.cxx:80:16: note: in instantiation of member function 'BVH_BinnedBuilder<double, 2, 32>::BuildNode' requested here
template class BVH_BinnedBuilder<Standard_Real, 2>;
^
/Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/adm/cmake/TKMath/../../../inc/BVH_Builder.hxx:57:8: note: must qualify identifier to find this declaration in dependent base class
void UpdateDepth (BVH_Tree<T, N>* theBVH, const Standard_Integer theLevel)
^
In file included from /Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/src/BVH/BVH.cxx:19:
In file included from /Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/adm/cmake/TKMath/../../../inc/BVH_SweepPlaneBuilder.hxx:43:
/Users/mnt/tools/WOK670/wok_entities/LOC/dev/IR-2014-04-03-IR-2014-04-03-occt/adm/cmake/TKMath/../../../inc/BVH_SweepPlaneBuilder.lxx:188:5: error: use of undeclared identifier 'UpdateDepth'
UpdateDepth (theBVH, theBVH->Level (aChildIndex));

dbp

2014-04-04 12:41

developer   ~0028676

CR24739_7

dbp

2014-04-04 13:56

developer   ~0028679

Dear bugmaster,

Please set patch status to 'tested'.

Related Changesets

occt: master fc73a202

2014-04-04 10:14:02

dbp


Committer: apn Details Diff
0024739: TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and portability

RayTracing - disable reflections by default
Fix possible compilation issue on Mac OS X.
Affected Issues
0024739
mod - samples/tcl/raytrace.tcl Diff File
mod - src/BVH/BVH_BinnedBuilder.lxx Diff File
mod - src/BVH/BVH_Builder.hxx Diff File
mod - src/BVH/BVH_SweepPlaneBuilder.lxx Diff File
mod - src/BVH/BVH_Tree.hxx Diff File
mod - src/BVH/BVH_Tree.lxx Diff File
mod - src/Graphic3d/Graphic3d_CView.hxx Diff File
mod - src/OpenGl/EXTERNLIB Diff File
mod - src/OpenGl/FILES Diff File
rm - src/OpenGl/OpenGl_Cl.hxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.hxx Diff File
mod - src/OpenGl/OpenGl_Group.cxx Diff File
mod - src/OpenGl/OpenGl_LayerList.cxx Diff File
mod - src/OpenGl/OpenGl_LayerList.hxx Diff File
rm - src/OpenGl/OpenGl_RaytraceSource.cxx Diff File
mod - src/OpenGl/OpenGl_SceneGeometry.cxx Diff File
mod - src/OpenGl/OpenGl_SceneGeometry.hxx Diff File
mod - src/OpenGl/OpenGl_ShaderProgram.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderProgram.hxx Diff File
mod - src/OpenGl/OpenGl_Structure.cxx Diff File
mod - src/OpenGl/OpenGl_Structure.hxx Diff File
mod - src/OpenGl/OpenGl_TextureBufferArb.cxx Diff File
mod - src/OpenGl/OpenGl_TextureBufferArb.hxx Diff File
mod - src/OpenGl/OpenGl_View.cxx Diff File
mod - src/OpenGl/OpenGl_View.hxx Diff File
mod - src/OpenGl/OpenGl_View_2.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace.cxx Diff File
mod - src/OpenGl/OpenGl_Workspace.hxx Diff File
mod - src/OpenGl/OpenGl_Workspace_Raytrace.cxx Diff File
add - src/Shaders/RaytraceBase.fs Diff File
add - src/Shaders/RaytraceBase.vs Diff File
add - src/Shaders/RaytraceRender.fs Diff File
add - src/Shaders/RaytraceSmooth.fs Diff File
mod - src/TKOpenGl/EXTERNLIB Diff File
mod - src/ViewerTest/ViewerTest_ViewerCommands.cxx Diff File
mod - tests/v3d/raytrace/bug24130 Diff File
mod - tests/v3d/raytrace/connected Diff File
mod - tests/v3d/raytrace/plastic Diff File

Issue History

Date Modified Username Field Change
2014-03-19 15:23 dbp New Issue
2014-03-19 15:23 dbp Assigned To => dbp
2014-03-25 09:25 kgv Severity feature => integration request
2014-03-25 09:25 kgv Status new => assigned
2014-03-25 09:25 kgv Product Version Unscheduled => 6.7.0
2014-03-25 09:25 kgv Target Version Unscheduled => 6.7.1
2014-03-25 09:25 kgv Summary Porting TKOpenGl ray-tracing to OpenGL/GLSL => TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and portability
2014-03-25 09:49 abv Relationship added related to 0024546
2014-03-26 15:01 dbp Note Added: 0028491
2014-03-26 15:01 dbp Assigned To dbp => kgv
2014-03-26 15:01 dbp Status assigned => feedback
2014-03-27 10:16 kgv Note Added: 0028503
2014-03-27 10:16 kgv Assigned To kgv => dbp
2014-03-27 10:16 kgv Status feedback => assigned
2014-03-27 10:17 kgv Note Edited: 0028503
2014-03-27 10:24 kgv Note Edited: 0028503
2014-03-27 18:37 dbp Note Added: 0028519
2014-03-27 18:37 dbp Assigned To dbp => kgv
2014-03-27 18:37 dbp Status assigned => resolved
2014-03-31 12:41 kgv Note Added: 0028561
2014-03-31 12:41 kgv Assigned To kgv => bugmaster
2014-03-31 12:41 kgv Status resolved => reviewed
2014-03-31 18:36 mkv Note Added: 0028568
2014-03-31 18:47 mkv Assigned To bugmaster => kgv
2014-03-31 18:47 mkv Status reviewed => feedback
2014-03-31 18:57 kgv Assigned To kgv => dbp
2014-04-01 08:55 kgv Note Added: 0028575
2014-04-01 08:55 kgv Assigned To dbp => bugmaster
2014-04-01 08:55 kgv Status feedback => reviewed
2014-04-01 12:56 mkv Assigned To bugmaster => mkv
2014-04-01 20:40 mkv Note Added: 0028611
2014-04-01 20:40 mkv Test case number => Not needed
2014-04-01 20:40 mkv Assigned To mkv => bugmaster
2014-04-01 20:40 mkv Status reviewed => tested
2014-04-03 20:35 kgv Relationship added related to 0024795
2014-04-04 12:14 apn Note Added: 0028674
2014-04-04 12:14 apn Assigned To bugmaster => dbp
2014-04-04 12:14 apn Status tested => assigned
2014-04-04 12:41 dbp Note Added: 0028676
2014-04-04 12:41 dbp Assigned To dbp => kgv
2014-04-04 12:41 dbp Status assigned => resolved
2014-04-04 13:56 dbp Note Added: 0028679
2014-04-04 13:56 dbp Assigned To kgv => bugmaster
2014-04-04 13:56 dbp Status resolved => feedback
2014-04-04 14:03 apn Status feedback => tested
2014-04-04 16:21 abv Target Version 6.7.1 => 6.8.0
2014-04-04 17:03 apn Changeset attached => occt master fc73a202
2014-04-04 17:03 apn Assigned To bugmaster => apn
2014-04-04 17:03 apn Status tested => verified
2014-04-04 17:03 apn Resolution open => fixed
2014-04-16 12:15 kgv Relationship added related to 0024838
2014-10-03 12:21 dbp Additional Information Updated
2014-11-11 12:44 aiv Fixed in Version => 6.8.0
2014-11-11 12:59 aiv Status verified => closed
2014-12-01 09:57 kgv Relationship added related to 0025527