-
Notifications
You must be signed in to change notification settings - Fork 530
Add comments to clarify per-frame profiler #1039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| * | ||
| * GpuDuration: (Units::Nanoseconds) GPU time spent rendering data submitted | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| /** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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< | ||
|
|
@@ -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(); | ||
|
|
@@ -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); | ||
|
|
||
|
|
@@ -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(); | ||
|
|
||
There was a problem hiding this comment.
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.