CoherentPathTracingMode (Standard_False),
AdaptiveScreenSampling (Standard_False),
ShowSamplingTiles (Standard_False),
+ RebuildRayTracingShaders (Standard_False),
// stereoscopic parameters
StereoMode (Graphic3d_StereoMode_QuadBuffer),
AnaglyphFilter (Anaglyph_RedCyan_Optimized),
Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
Standard_Boolean AdaptiveScreenSampling; //!< enables/disables adaptive screen sampling mode for path tracing, FALSE by default
Standard_Boolean ShowSamplingTiles; //!< enables/disables debug mode for adaptive screen sampling, FALSE by default
+ Standard_Boolean RebuildRayTracingShaders; //!< forces rebuilding ray tracing shaders at the next frame
Graphic3d_StereoMode StereoMode; //!< stereoscopic output mode, Graphic3d_StereoMode_QuadBuffer by default
Anaglyph AnaglyphFilter; //!< filter for anaglyph output, Anaglyph_RedCyan_Optimized by default
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->());
+ }
}
}
return 1;
}
}
+ else if (aFlag == "-rebuildglsl"
+ || aFlag == "-rebuild")
+ {
+ if (toPrint)
+ {
+ theDI << (aParams.RebuildRayTracingShaders ? "on" : "off") << " ";
+ continue;
+ }
+
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams.RebuildRayTracingShaders = toEnable;
+ }
else
{
std::cout << "Error: wrong syntax, unknown flag '" << anArg << "'\n";
"\n '-env on|off' Enables/disables environment map background"
"\n '-iss on|off' Enables/disables adaptive screen sampling (PT mode)"
"\n '-issd on|off' Shows screen sampling distribution in ISS mode"
+ "\n '-rebuildGlsl on|off' Rebuild Ray-Tracing GLSL programs (for debugging)"
"\n '-shadingModel model' Controls shading model from enumeration"
"\n color, flat, gouraud, phong"
"\n '-resolution value' Sets a new pixels density (PPI), defines scaling factor for parameters like text size"