mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0027899: Visualization, Ray Tracing - Provide ability to rebuild GLSL shaders on the fly
For debugging and performance analysis it is reasonable to provide the ability to rebuild ray tracing shaders on the fly. In this way, it will be possible to analyze the impact of different shaders modifications without re-launching and re-configuring the scene. This functionality can be used in the following way: > vrenderparams -rebuild
This commit is contained in:
parent
ede89abcb9
commit
d877e61038
@ -63,6 +63,7 @@ public:
|
||||
CoherentPathTracingMode (Standard_False),
|
||||
AdaptiveScreenSampling (Standard_False),
|
||||
ShowSamplingTiles (Standard_False),
|
||||
RebuildRayTracingShaders (Standard_False),
|
||||
// stereoscopic parameters
|
||||
StereoMode (Graphic3d_StereoMode_QuadBuffer),
|
||||
AnaglyphFilter (Anaglyph_RedCyan_Optimized),
|
||||
@ -103,6 +104,7 @@ public:
|
||||
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
|
||||
|
@ -869,7 +869,8 @@ protected: //! @name methods related to ray-tracing
|
||||
Standard_Boolean initRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
|
||||
|
||||
//! Releases OpenGL/GLSL shader programs.
|
||||
void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext);
|
||||
void releaseRaytraceResources (const Handle(OpenGl_Context)& theGlContext,
|
||||
const Standard_Boolean theToRebuild = Standard_False);
|
||||
|
||||
//! Updates auxiliary OpenGL frame buffers.
|
||||
Standard_Boolean updateRaytraceBuffers (const Standard_Integer theSizeX,
|
||||
|
@ -1271,10 +1271,19 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
||||
|
||||
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();
|
||||
@ -1385,6 +1394,8 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
|
||||
|
||||
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);
|
||||
@ -1681,19 +1692,9 @@ inline void nullifyResource (const Handle(OpenGl_Context)& theGlContext, Handle(
|
||||
// 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);
|
||||
|
||||
@ -1701,24 +1702,38 @@ void OpenGl_View::releaseRaytraceResources (const Handle(OpenGl_Context)& theGlC
|
||||
nullifyResource (theGlContext, myPostFSAAProgram);
|
||||
nullifyResource (theGlContext, myOutImageProgram);
|
||||
|
||||
nullifyResource (theGlContext, mySceneNodeInfoTexture);
|
||||
nullifyResource (theGlContext, mySceneMinPointTexture);
|
||||
nullifyResource (theGlContext, mySceneMaxPointTexture);
|
||||
|
||||
nullifyResource (theGlContext, myGeometryVertexTexture);
|
||||
nullifyResource (theGlContext, myGeometryNormalTexture);
|
||||
nullifyResource (theGlContext, myGeometryTexCrdTexture);
|
||||
nullifyResource (theGlContext, myGeometryTriangTexture);
|
||||
nullifyResource (theGlContext, mySceneTransformTexture);
|
||||
|
||||
nullifyResource (theGlContext, myRaytraceLightSrcTexture);
|
||||
nullifyResource (theGlContext, myRaytraceMaterialTexture);
|
||||
|
||||
myRaytraceGeometry.ReleaseResources (theGlContext);
|
||||
|
||||
if (myRaytraceScreenQuad.IsValid())
|
||||
if (!theToRebuild) // complete release
|
||||
{
|
||||
myRaytraceScreenQuad.Release (theGlContext.operator->());
|
||||
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);
|
||||
|
||||
nullifyResource (theGlContext, mySceneNodeInfoTexture);
|
||||
nullifyResource (theGlContext, mySceneMinPointTexture);
|
||||
nullifyResource (theGlContext, mySceneMaxPointTexture);
|
||||
|
||||
nullifyResource (theGlContext, myGeometryVertexTexture);
|
||||
nullifyResource (theGlContext, myGeometryNormalTexture);
|
||||
nullifyResource (theGlContext, myGeometryTexCrdTexture);
|
||||
nullifyResource (theGlContext, myGeometryTriangTexture);
|
||||
nullifyResource (theGlContext, mySceneTransformTexture);
|
||||
|
||||
nullifyResource (theGlContext, myRaytraceLightSrcTexture);
|
||||
nullifyResource (theGlContext, myRaytraceMaterialTexture);
|
||||
|
||||
myRaytraceGeometry.ReleaseResources (theGlContext);
|
||||
|
||||
if (myRaytraceScreenQuad.IsValid ())
|
||||
{
|
||||
myRaytraceScreenQuad.Release (theGlContext.operator->());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8522,6 +8522,23 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
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";
|
||||
@ -9663,6 +9680,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"\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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user