measure average time of 'present'

This commit is contained in:
Andrew Meadows 2017-12-19 13:03:36 -08:00
parent 7a9d566e02
commit 5c84c5f845
2 changed files with 7 additions and 0 deletions

View file

@ -679,6 +679,7 @@ void OpenGLDisplayPlugin::internalPresent() {
void OpenGLDisplayPlugin::present() {
auto frameId = (uint64_t)presentCount();
PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId)
uint64_t startPresent = usecTimestampNow();
{
PROFILE_RANGE_EX(render, "updateFrameData", 0xff00ff00, frameId)
updateFrameData();
@ -713,6 +714,7 @@ void OpenGLDisplayPlugin::present() {
gpu::Backend::freeGPUMemSize.set(gpu::gl::getFreeDedicatedMemory());
}
_movingAveragePresent.addSample((float)(usecTimestampNow() - startPresent));
}
float OpenGLDisplayPlugin::newFramePresentRate() const {

View file

@ -21,8 +21,10 @@
#include <QtCore/QWaitCondition>
#include <GLMHelpers.h>
#include <NumericalConstants.h>
#include <RegisteredMetaTypes.h>
#include <shared/Bilateral.h>
#include <SimpleMovingAverage.h>
#include <gpu/Forward.h>
#include "Plugin.h"
@ -203,6 +205,7 @@ public:
virtual void cycleDebugOutput() {}
void waitForPresent();
float getAveragePresentTime() { return _movingAveragePresent.average / (float)USECS_PER_MSEC; } // in msec
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator();
@ -220,6 +223,8 @@ protected:
std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> _hudOperator { std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)>() };
MovingAverage<float, 10> _movingAveragePresent;
private:
QMutex _presentMutex;
QWaitCondition _presentCondition;