-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Improve fps counter #1886
Improve fps counter #1886
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1886 +/- ##
==========================================
+ Coverage 95.69% 95.71% +0.01%
==========================================
Files 125 125
Lines 9926 9970 +44
==========================================
+ Hits 9499 9543 +44
Misses 427 427 ☔ View full report in Codecov by Sentry. |
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.
This is looking good, wdyt @Meakk ?
…liding average of time between frames
I don't think the last commit works but I don't know why? |
…ost recent seconds worth of frames to calculate fps average
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.
Great! Thank you for your contribution!
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.
please convert all tabs to space
Why is clang-format not detecting that? |
no idea, to improve definitely |
I pushed the style changes |
Co-authored-by: Mathieu Westphal <[email protected]>
glEndQuery(GL_TIME_ELAPSED); | ||
GLint elapsed; | ||
glGetQueryObjectiv(this->Timer, GL_QUERY_RESULT, &elapsed); |
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.
glEndQuery(GL_TIME_ELAPSED); | |
GLint elapsed; | |
glGetQueryObjectiv(this->Timer, GL_QUERY_RESULT, &elapsed); | |
glEndQuery(GL_TIME_ELAPSED); | |
GLint elapsed; | |
glGetQueryObjectiv(this->Timer, GL_QUERY_RESULT, &elapsed); |
// Get CPU frame time | ||
double elapsedTime = std::chrono::duration_cast<std::chrono::microseconds>(cpuElapsed).count() * 1e-6; |
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.
// Get CPU frame time | |
double elapsedTime = std::chrono::duration_cast<std::chrono::microseconds>(cpuElapsed).count() * 1e-6; | |
// Get CPU frame time | |
double elapsedTime = std::chrono::duration_cast<std::chrono::microseconds>(cpuElapsed).count() * 1e-6; |
// Get min between CPU frame time and GPU frame time | ||
elapsedTime = std::min(elapsedTime, elapsed * 1e-9); |
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.
// Get min between CPU frame time and GPU frame time | |
elapsedTime = std::min(elapsedTime, elapsed * 1e-9); | |
// Get min between CPU frame time and GPU frame time | |
elapsedTime = std::min(elapsedTime, elapsed * 1e-9); |
#endif | ||
|
||
this->UIActor->SetFpsValue(fps); | ||
this->UIActor->UpdateFpsValue(elapsedTime); |
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.
this->UIActor->UpdateFpsValue(elapsedTime); | |
this->UIActor->UpdateFpsValue(elapsedTime); |
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.
still incorrect indenting, sorrt about that
Let's merge it. Formatting will be handle in #1912 |
Thanks @GabrielNakamoto! |
SetFpsValue()
toUpdateFpsValue()
which will automatically accumulate fps values before setting the display value to the average. The number of frames it waits to average is decided by the static member variablevtkF3DUIActor::FramesToAverage
vtkF3DRenderer::Render()
function I updated it to check if its information hasvtkF3DRenderPass::RENDER_UI_ONLY()
set to 1 If it does it calculates the fps value and calls the UI Actor'sUpdateFpsValue()
Let me know what you think the number of frames to average should be (currently set to 5).
From building it and using some of the example models it seems that the render UI only is working however I may be wrong.
Seeing this is my first time contributing I'm starting a pull request to get some advice.