Standard_Boolean aToRebuildShaders = Standard_False;
+ if (myRenderParams.RebuildRayTracingShaders) // requires complete re-initialization
+ {
+ myRaytraceInitStatus = OpenGl_RT_NONE;
+ releaseRaytraceResources (theGlContext, Standard_True);
+ myRenderParams.RebuildRayTracingShaders = Standard_False; // clear rebuilding flag
+ }
+
if (myRaytraceInitStatus == OpenGl_RT_INIT)
{
if (!myIsRaytraceDataValid)
+ {
return Standard_True;
+ }
const Standard_Integer aRequiredStackSize =
myRaytraceGeometry.TopLevelTreeDepth() + myRaytraceGeometry.BotLevelTreeDepth();
if (myRaytraceInitStatus == OpenGl_RT_NONE)
{
+ myAccumFrames = 0; // reject accumulated frames
+
if (!theGlContext->IsGlGreaterEqual (3, 1))
{
return safeFailBack ("Ray-tracing requires OpenGL 3.1 and higher", theGlContext);
// function : releaseRaytraceResources
// purpose : Releases OpenGL/GLSL shader programs
// =======================================================================
-void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext)
+void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext, const Standard_Boolean theToRebuild)
{
- myRaytraceFBO1[0]->Release (theGlContext.operator->());
- myRaytraceFBO1[1]->Release (theGlContext.operator->());
- myRaytraceFBO2[0]->Release (theGlContext.operator->());
- myRaytraceFBO2[1]->Release (theGlContext.operator->());
-
- nullifyResource (theGlContext, myRaytraceOutputTexture[0]);
- nullifyResource (theGlContext, myRaytraceOutputTexture[1]);
-
- nullifyResource (theGlContext, myRaytraceTileOffsetsTexture);
- nullifyResource (theGlContext, myRaytraceVisualErrorTexture);
-
+ // release shader resources
nullifyResource (theGlContext, myRaytraceShader);
nullifyResource (theGlContext, myPostFSAAShader);
nullifyResource (theGlContext, myPostFSAAProgram);
nullifyResource (theGlContext, myOutImageProgram);
- nullifyResource (theGlContext, mySceneNodeInfoTexture);
- nullifyResource (theGlContext, mySceneMinPointTexture);
- nullifyResource (theGlContext, mySceneMaxPointTexture);
+ if (!theToRebuild) // complete release
+ {
+ myRaytraceFBO1[0]->Release (theGlContext.operator->());
+ myRaytraceFBO1[1]->Release (theGlContext.operator->());
+ myRaytraceFBO2[0]->Release (theGlContext.operator->());
+ myRaytraceFBO2[1]->Release (theGlContext.operator->());
+
+ nullifyResource (theGlContext, myRaytraceOutputTexture[0]);
+ nullifyResource (theGlContext, myRaytraceOutputTexture[1]);
- nullifyResource (theGlContext, myGeometryVertexTexture);
- nullifyResource (theGlContext, myGeometryNormalTexture);
- nullifyResource (theGlContext, myGeometryTexCrdTexture);
- nullifyResource (theGlContext, myGeometryTriangTexture);
- nullifyResource (theGlContext, mySceneTransformTexture);
+ nullifyResource (theGlContext, myRaytraceTileOffsetsTexture);
+ nullifyResource (theGlContext, myRaytraceVisualErrorTexture);
- nullifyResource (theGlContext, myRaytraceLightSrcTexture);
- nullifyResource (theGlContext, myRaytraceMaterialTexture);
+ nullifyResource (theGlContext, mySceneNodeInfoTexture);
+ nullifyResource (theGlContext, mySceneMinPointTexture);
+ nullifyResource (theGlContext, mySceneMaxPointTexture);
- myRaytraceGeometry.ReleaseResources (theGlContext);
+ nullifyResource (theGlContext, myGeometryVertexTexture);
+ nullifyResource (theGlContext, myGeometryNormalTexture);
+ nullifyResource (theGlContext, myGeometryTexCrdTexture);
+ nullifyResource (theGlContext, myGeometryTriangTexture);
+ nullifyResource (theGlContext, mySceneTransformTexture);
- if (myRaytraceScreenQuad.IsValid())
- {
- myRaytraceScreenQuad.Release (theGlContext.operator->());
+ nullifyResource (theGlContext, myRaytraceLightSrcTexture);
+ nullifyResource (theGlContext, myRaytraceMaterialTexture);
+
+ myRaytraceGeometry.ReleaseResources (theGlContext);
+
+ if (myRaytraceScreenQuad.IsValid ())
+ {
+ myRaytraceScreenQuad.Release (theGlContext.operator->());
+ }
}
}