Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/utils/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,44 @@ Viewer::Viewer(const Arguments& arguments)
objectPickingHelper_ = std::make_unique<ObjectPickingHelper>(viewportSize);
timeline_.start();

// Set up per frame profiler
/**
* Set up per frame profiler to be aware of bottlenecking in processing data
* Interpretation: CpuDuration should be less than GpuDuration to avoid GPU
* idling, and CpuDuration and GpuDuration should be roughly equal for faster
* rendering times
*
* FrameTime: (Units::Nanoseconds) Time to render per frame, 1/FPS, 2 frame
* delay
*
* CpuDuration: (Units::Nanoseconds) CPU time spent processing events,
* physics, traversing SceneGraph, and submitting data to GPU/drivers per
* frame
* Measured using std::chrono::high_resolution_clock, 1 frame delay
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove details such as L560.

*
* GpuDuration: (Units::Nanoseconds) GPU time spent rendering data submitted
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

measured how much time it takes for the GPU to process all work submitted by the CPU.

* by CPU per frame
* Uses asynchronous querying to measure the amount of time
* to fully complete a set of GL commands without stalling rendering, 3 frame
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 3 frame delay.

* delay
* Asynchronous querying extensions: ARB_timer_query (OpenGL 3.3),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will recommend removing such details (L567 - L570)

* EXT_disjoint_timer_query (OpenGL ES, WebGL), EXT_disjoint_timer_query
* (WebGL2)
* Requires an active OpenGL context
*/
Mn::DebugTools::GLFrameProfiler::Values profilerValues =
Mn::DebugTools::GLFrameProfiler::Value::FrameTime |
Mn::DebugTools::GLFrameProfiler::Value::CpuDuration |
Mn::DebugTools::GLFrameProfiler::Value::GpuDuration;

// VertexFetchRatio and PrimitiveClipRatio only supported for GL 4.6
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need this. Undo the change.

* VertexFetchRatio and PrimitiveClipRatio only supported for GL 4.6
*
* VertexFetchRatio: (Units::RatioThousandths) Ratio of vertex shader
* invocations to count of vertices submitted
*
* PrimitiveClipRatio: (Units::PercentageThousandths) Ratio of primitives
* discarded by the clipping stage to count of primitives submitted
*/
#ifndef MAGNUM_TARGET_GLES
if (Mn::GL::Context::current()
.isExtensionSupported<
Expand All @@ -562,6 +593,7 @@ Viewer::Viewer(const Arguments& arguments)
}
#endif

// Per frame profiler will average measurements taken over previous 50 frames
profiler_.setup(profilerValues, 50);

printHelpText();
Expand Down Expand Up @@ -825,7 +857,10 @@ void Viewer::wiggleLastObject() {

float timeSinceLastSimulation = 0.0;
void Viewer::drawEvent() {
// Wrap profiler measurements around all methods to render images from
// RenderCamera
profiler_.beginFrame();

Mn::GL::defaultFramebuffer.clear(Mn::GL::FramebufferClear::Color |
Mn::GL::FramebufferClear::Depth);

Expand Down Expand Up @@ -911,7 +946,9 @@ void Viewer::drawEvent() {
Mn::GL::defaultFramebuffer.bind();
}

// Do not include ImGui content drawing in per frame profiler measurements
profiler_.endFrame();

// Immediately bind the main buffer back so that the "imgui" below can work
// properly
Mn::GL::defaultFramebuffer.bind();
Expand Down