Merge pull request #9047 from jherico/stutter

Add stutter tracking
This commit is contained in:
Chris Collins 2016-11-11 11:39:00 -08:00 committed by GitHub
commit b9b90cc646
9 changed files with 37 additions and 3 deletions

View file

@ -69,6 +69,10 @@ Item {
StatText { StatText {
text: "Present Drop Rate: " + root.presentdroprate.toFixed(2); text: "Present Drop Rate: " + root.presentdroprate.toFixed(2);
} }
StatText {
text: "Stutter Rate: " + root.stutterrate.toFixed(3);
visible: root.stutterrate != -1;
}
StatText { StatText {
text: "Simrate: " + root.simrate text: "Simrate: " + root.simrate
} }

View file

@ -1197,6 +1197,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
properties["present_rate"] = displayPlugin->presentRate(); properties["present_rate"] = displayPlugin->presentRate();
properties["new_frame_present_rate"] = displayPlugin->newFramePresentRate(); properties["new_frame_present_rate"] = displayPlugin->newFramePresentRate();
properties["dropped_frame_rate"] = displayPlugin->droppedFrameRate(); properties["dropped_frame_rate"] = displayPlugin->droppedFrameRate();
properties["stutter_rate"] = displayPlugin->stutterRate();
properties["sim_rate"] = getAverageSimsPerSecond(); properties["sim_rate"] = getAverageSimsPerSecond();
properties["avatar_sim_rate"] = getAvatarSimrate(); properties["avatar_sim_rate"] = getAvatarSimrate();
properties["has_async_reprojection"] = displayPlugin->hasAsyncReprojection(); properties["has_async_reprojection"] = displayPlugin->hasAsyncReprojection();

View file

@ -128,7 +128,8 @@ void Stats::updateStats(bool force) {
STAT_UPDATE(renderrate, displayPlugin->renderRate()); STAT_UPDATE(renderrate, displayPlugin->renderRate());
STAT_UPDATE(presentrate, displayPlugin->presentRate()); STAT_UPDATE(presentrate, displayPlugin->presentRate());
STAT_UPDATE(presentnewrate, displayPlugin->newFramePresentRate()); STAT_UPDATE(presentnewrate, displayPlugin->newFramePresentRate());
STAT_UPDATE(presentdroprate, qApp->getActiveDisplayPlugin()->droppedFrameRate()); STAT_UPDATE(presentdroprate, displayPlugin->droppedFrameRate());
STAT_UPDATE(stutterrate, displayPlugin->stutterRate());
} else { } else {
STAT_UPDATE(presentrate, -1); STAT_UPDATE(presentrate, -1);
STAT_UPDATE(presentnewrate, -1); STAT_UPDATE(presentnewrate, -1);

View file

@ -36,7 +36,9 @@ class Stats : public QQuickItem {
STATS_PROPERTY(float, renderrate, 0) STATS_PROPERTY(float, renderrate, 0)
// How often the display plugin is presenting to the device // How often the display plugin is presenting to the device
STATS_PROPERTY(float, presentrate, 0) STATS_PROPERTY(float, presentrate, 0)
// How often the display device reprojecting old frames
STATS_PROPERTY(float, stutterrate, 0)
STATS_PROPERTY(float, presentnewrate, 0) STATS_PROPERTY(float, presentnewrate, 0)
STATS_PROPERTY(float, presentdroprate, 0) STATS_PROPERTY(float, presentdroprate, 0)
STATS_PROPERTY(int, simrate, 0) STATS_PROPERTY(int, simrate, 0)
@ -140,6 +142,7 @@ signals:
void presentrateChanged(); void presentrateChanged();
void presentnewrateChanged(); void presentnewrateChanged();
void presentdroprateChanged(); void presentdroprateChanged();
void stutterrateChanged();
void simrateChanged(); void simrateChanged();
void avatarSimrateChanged(); void avatarSimrateChanged();
void avatarCountChanged(); void avatarCountChanged();

View file

@ -710,3 +710,7 @@ void HmdDisplayPlugin::compositeExtra() {
HmdDisplayPlugin::~HmdDisplayPlugin() { HmdDisplayPlugin::~HmdDisplayPlugin() {
qDebug() << "Destroying HmdDisplayPlugin"; qDebug() << "Destroying HmdDisplayPlugin";
} }
float HmdDisplayPlugin::stutterRate() const {
return _stutterRate.rate();
}

View file

@ -44,6 +44,8 @@ public:
return false; return false;
} }
float stutterRate() const override;
protected: protected:
virtual void hmdPresent() = 0; virtual void hmdPresent() = 0;
virtual bool isHmdMounted() const = 0; virtual bool isHmdMounted() const = 0;
@ -108,8 +110,9 @@ protected:
QMap<uint32_t, FrameInfo> _frameInfos; QMap<uint32_t, FrameInfo> _frameInfos;
FrameInfo _currentPresentFrameInfo; FrameInfo _currentPresentFrameInfo;
FrameInfo _currentRenderFrameInfo; FrameInfo _currentRenderFrameInfo;
RateCounter<> _stutterRate;
bool _disablePreview{ true }; bool _disablePreview { true };
private: private:
ivec4 getViewportForSourceSize(const uvec2& size) const; ivec4 getViewportForSourceSize(const uvec2& size) const;
float getLeftCenterPixel() const; float getLeftCenterPixel() const;

View file

@ -188,6 +188,8 @@ public:
virtual float renderRate() const { return -1.0f; } virtual float renderRate() const { return -1.0f; }
// Rate at which we present to the display device // Rate at which we present to the display device
virtual float presentRate() const { return -1.0f; } virtual float presentRate() const { return -1.0f; }
// Rate at which old frames are presented to the device display
virtual float stutterRate() const { return -1.0f; }
// Rate at which new frames are being presented to the display device // Rate at which new frames are being presented to the display device
virtual float newFramePresentRate() const { return -1.0f; } virtual float newFramePresentRate() const { return -1.0f; }
// Rate at which rendered frames are being skipped // Rate at which rendered frames are being skipped

View file

@ -146,6 +146,16 @@ void OculusDisplayPlugin::hmdPresent() {
if (!OVR_SUCCESS(result)) { if (!OVR_SUCCESS(result)) {
logWarning("Failed to present"); logWarning("Failed to present");
} }
static int droppedFrames = 0;
ovrPerfStats perfStats;
ovr_GetPerfStats(_session, &perfStats);
for (int i = 0; i < perfStats.FrameStatsCount; ++i) {
const auto& frameStats = perfStats.FrameStats[i];
int delta = frameStats.CompositorDroppedFrameCount - droppedFrames;
_stutterRate.increment(delta);
droppedFrames = frameStats.CompositorDroppedFrameCount;
}
} }
_presentRate.increment(); _presentRate.increment();
} }

View file

@ -641,6 +641,12 @@ void OpenVrDisplayPlugin::hmdPresent() {
vr::VRCompositor()->PostPresentHandoff(); vr::VRCompositor()->PostPresentHandoff();
_presentRate.increment(); _presentRate.increment();
} }
vr::Compositor_FrameTiming frameTiming;
memset(&frameTiming, 0, sizeof(vr::Compositor_FrameTiming));
frameTiming.m_nSize = sizeof(vr::Compositor_FrameTiming);
vr::VRCompositor()->GetFrameTiming(&frameTiming);
_stutterRate.increment(frameTiming.m_nNumDroppedFrames);
} }
void OpenVrDisplayPlugin::postPreview() { void OpenVrDisplayPlugin::postPreview() {