]> OCCT Git - occt.git/commitdiff
0028115: Visualization, Ray tracing - Fix crash on NVIDIA GPUs with driver version...
authordbp <dbp@opencascade.org>
Wed, 16 Nov 2016 14:47:07 +0000 (17:47 +0300)
committerapn <apn@opencascade.com>
Thu, 17 Nov 2016 15:49:34 +0000 (18:49 +0300)
src/OpenGl/OpenGl_View_Raytrace.cxx

index 1b36a4be40d34f633481ab1131b4ad0f1efce79d..0b7a463087b33511b0fb10ef08bfcf8682e1d02c 100644 (file)
@@ -1838,7 +1838,7 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
                                                      const Standard_Integer        theSizeY,
                                                      const Handle(OpenGl_Context)& theGlContext)
 {
-  // Auxiliary buffers are not used.
+  // Auxiliary buffers are not used
   if (!myRaytraceParameters.GlobalIllumination && !myRenderParams.IsAntialiasingEnabled)
   {
     myRaytraceFBO1[0]->Release (theGlContext.operator->());
@@ -1849,6 +1849,12 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
     return Standard_True;
   }
 
+  if (myRaytraceFBO1[0]->GetSizeX() != theSizeX
+   || myRaytraceFBO1[0]->GetSizeY() != theSizeY)
+  {
+    myAccumFrames = 0;
+  }
+
   myRaytraceFBO1[0]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
   myRaytraceFBO2[0]->InitLazy (theGlContext, theSizeX, theSizeY, GL_RGBA32F, myFboDepthFormat);
 
@@ -1890,6 +1896,10 @@ Standard_Boolean OpenGl_View::updateRaytraceBuffers (const Standard_Integer
     myRaytraceOutputTexture[0]->InitRectangle (theGlContext,
       theSizeX * 3, theSizeY * 2, OpenGl_TextureFormat::Create<GLfloat, 1>());
 
+    // workaround for some NVIDIA drivers
+    myRaytraceVisualErrorTexture->Release (theGlContext.operator->());
+    myRaytraceTileOffsetsTexture->Release (theGlContext.operator->());
+
     myRaytraceVisualErrorTexture->Init (theGlContext,
       GL_R32I, GL_RED_INTEGER, GL_INT, myTileSampler.NbTilesX(), myTileSampler.NbTilesY(), Graphic3d_TOT_2D);