Unsolved Measuring frame rendering time
-
This post is deleted! -
@artwaw, How does your timer differ from the one I use?
I believe it will also give values with a large difference.
In addition, I am interested in exactly in microseconds. -
@mrjbom said in Measuring frame rendering time:
As per QT Doc
If you need to trigger a repaint from places other than paintGL() (a typical example is when using timers to animate scenes), you should call the widget's update() function to schedule an update.
I feel if you want to measure the frame rendering time
void MainOpenGLWidget::paintGL()
{
QElapsedTimer framerateTime;
framerateTime.start();sceneManager->callInitSceneAndOptionsWidget(this->width(), this->height()); sceneManager->callDrawScene(); lastFrameRenderTimeInNanoseconds = framerateTime.nsecsElapsed();
}
-
I just noticed something. You should not call update() from within paintGL(). It works the other way around: update(), whether called implicitly or explicitly, calls paintGl() to render the scene...paintGL() is a virtual callback, not a slot.
public: render_time; void paintGl() { begin_time=now() // do stuff render_time = now() - begin_time }
-
@Kent-Dorfman, do you suggest not calling update() at all?
If I don't call it from paintGL() or other places, then my frames don't update(sometimes abruptly update themselves). -
@Kent-Dorfman, @nagesh, The documentation says: The signals aboutToCompose() and frameSwapped() will be emitted when the composition is starting and ending.
What happens if I start measuring the time when aboutToCompose() happens and end the change when frameSwapped() happens, so I get the frame rendering time?
-
@mrjbom calling update will schedule the paint event for the processing which means internally it triggers paintGL().
For constant update of frames you can do it with the QTimer slot call update()
or as soon as new frame is available call update()As per QT doc
in frameSwapped()This signal is emitted after the potentially blocking buffer swap has been done. Applications that wish to continuously repaint synchronized to the vertical refresh, should issue an update() upon this signal. This allows for a much smoother experience compared to the traditional usage of timers.
I feel frame rendering is happening in paintGL()
-
@nagesh said in Measuring frame rendering time:
I feel frame rendering is happening in paintGL()
In paintGL, the frame is being prepared. So it is useless to measure time there.
-
@mrjbom read the description for paintGL()
https://doc.qt.io/qt-5/qopenglwidget.html
it says.. paintGL() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated.What does your function
sceneManager->callDrawScene() doing? -
@nagesh It draws the current scene. The usual functions that are usually found in paintGL().
In any case, if I measure the time only within paintGL (), then the time is constantly different from the previous one.
Probably because QElapsedTimer reads the time within the operating system, not my application, so due to the task switching by the operating system, it is different.
How can I measure the time regardless of the task switching by the operating system? -
@mrjbom There is class in qt QOpenGLTimerQuery
https://doc.qt.io/qt-5/qopengltimerquery.htmlWhether it's applicable for your requirement not sure.
-
@mrjbom Dude! We've been over this. You cannot accurately measure the time spent in a call that takes nanoseconds or microseconds to complete. you are not using a realtime OS. Either research the science of RTOS or give up on getting consistent numbers.
-
@nagesh Got it! This is what I need.
To be more precise, QOpenGLTimeMonitor () helped me.
Thank you for your help.