Merge pull request #19428 from tritao/base-tracy-profiler
Base: Add Tracy frame profiling support.
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
# include <Inventor/actions/SoHandleEventAction.h>
|
||||
# include <Inventor/actions/SoRayPickAction.h>
|
||||
# include <Inventor/annex/HardCopy/SoVectorizePSAction.h>
|
||||
# include <Inventor/annex/Profiler/SoProfiler.h>
|
||||
# include <Inventor/annex/Profiler/elements/SoProfilerElement.h>
|
||||
# include <Inventor/details/SoDetail.h>
|
||||
# include <Inventor/elements/SoLightModelElement.h>
|
||||
# include <Inventor/elements/SoOverrideElement.h>
|
||||
@@ -94,6 +96,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Sequencer.h>
|
||||
#include <Base/Profiler.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Base/Tools2D.h>
|
||||
@@ -430,6 +433,11 @@ void View3DInventorViewer::init()
|
||||
// setting up the defaults for the spin rotation
|
||||
initialize();
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
SoProfiler::init();
|
||||
SoProfiler::enable(TRUE);
|
||||
#endif
|
||||
|
||||
// NOLINTBEGIN
|
||||
auto cam = new SoOrthographicCamera;
|
||||
cam->position = SbVec3f(0, 0, 1);
|
||||
@@ -571,9 +579,14 @@ void View3DInventorViewer::init()
|
||||
// the fix and some details what happens behind the scene have a look at this
|
||||
// https://forum.freecad.org/viewtopic.php?f=10&t=7486&p=74777#p74736
|
||||
uint32_t id = this->getSoRenderManager()->getGLRenderAction()->getCacheContext();
|
||||
this->getSoRenderManager()->setGLRenderAction(new SoBoxSelectionRenderAction);
|
||||
auto boxSelectionAction = new SoBoxSelectionRenderAction;
|
||||
this->getSoRenderManager()->setGLRenderAction(boxSelectionAction);
|
||||
this->getSoRenderManager()->getGLRenderAction()->setCacheContext(id);
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
boxSelectionAction->enableElement(SoProfilerElement::getClassTypeId(), SoProfilerElement::getClassStackIndex());
|
||||
#endif
|
||||
|
||||
// set the transparency and antialiasing settings
|
||||
getSoRenderManager()->getGLRenderAction()->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND);
|
||||
|
||||
@@ -2415,6 +2428,8 @@ void View3DInventorViewer::renderGLImage()
|
||||
// upon spin.
|
||||
void View3DInventorViewer::renderScene()
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
// Must set up the OpenGL viewport manually, as upon resize
|
||||
// operations, Coin won't set it up until the SoGLRenderAction is
|
||||
// applied again. And since we need to do glClear() before applying
|
||||
@@ -2434,15 +2449,19 @@ void View3DInventorViewer::renderScene()
|
||||
glDepthRange(0.1,1.0);
|
||||
#endif
|
||||
|
||||
// Render our scenegraph with the image.
|
||||
SoGLRenderAction* glra = this->getSoRenderManager()->getGLRenderAction();
|
||||
SoState* state = glra->getState();
|
||||
SoDevicePixelRatioElement::set(state, devicePixelRatio());
|
||||
SoGLWidgetElement::set(state, qobject_cast<QOpenGLWidget*>(this->getGLWidget()));
|
||||
SoGLRenderActionElement::set(state, glra);
|
||||
SoGLVBOActivatedElement::set(state, this->vboEnabled);
|
||||
drawSingleBackground(col);
|
||||
glra->apply(this->backgroundroot);
|
||||
|
||||
// Render our scenegraph with the image.
|
||||
{
|
||||
ZoneScopedN("Background");
|
||||
SoDevicePixelRatioElement::set(state, devicePixelRatio());
|
||||
SoGLWidgetElement::set(state, qobject_cast<QOpenGLWidget*>(this->getGLWidget()));
|
||||
SoGLRenderActionElement::set(state, glra);
|
||||
SoGLVBOActivatedElement::set(state, this->vboEnabled);
|
||||
drawSingleBackground(col);
|
||||
glra->apply(this->backgroundroot);
|
||||
}
|
||||
|
||||
if (!this->shading) {
|
||||
state->push();
|
||||
@@ -2480,7 +2499,10 @@ void View3DInventorViewer::renderScene()
|
||||
#endif
|
||||
|
||||
// Render overlay front scenegraph.
|
||||
glra->apply(this->foregroundroot);
|
||||
{
|
||||
ZoneScopedN("Foreground");
|
||||
glra->apply(this->foregroundroot);
|
||||
}
|
||||
|
||||
if (this->axiscrossEnabled) {
|
||||
this->drawAxisCross();
|
||||
@@ -2498,8 +2520,11 @@ void View3DInventorViewer::renderScene()
|
||||
|
||||
printDimension();
|
||||
|
||||
for (auto it : this->graphicsItems) {
|
||||
it->paintGL();
|
||||
{
|
||||
ZoneScopedN("Graphics items");
|
||||
for (auto it : this->graphicsItems) {
|
||||
it->paintGL();
|
||||
}
|
||||
}
|
||||
|
||||
//fps rendering
|
||||
@@ -2661,6 +2686,8 @@ void View3DInventorViewer::selectAll()
|
||||
|
||||
bool View3DInventorViewer::processSoEvent(const SoEvent* ev)
|
||||
{
|
||||
ZoneScoped;
|
||||
|
||||
if (naviCubeEnabled && naviCube->processSoEvent(ev)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user