mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Expose ASW activation status, provide normalized present rate information
This commit is contained in:
parent
c892d8a81a
commit
ce9d637b3f
6 changed files with 36 additions and 5 deletions
|
@ -654,6 +654,11 @@ float OpenGLDisplayPlugin::presentRate() const {
|
|||
return _presentRate.rate();
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::resetPresentRate() {
|
||||
// FIXME
|
||||
// _presentRate = RateCounter<100>();
|
||||
}
|
||||
|
||||
float OpenGLDisplayPlugin::renderRate() const {
|
||||
return _renderRate.rate();
|
||||
}
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
|
||||
float presentRate() const override;
|
||||
|
||||
void resetPresentRate() override;
|
||||
|
||||
float newFramePresentRate() const override;
|
||||
|
||||
float droppedFrameRate() const override;
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
/// By default, all HMDs are stereo
|
||||
virtual bool isStereo() const { return isHmd(); }
|
||||
virtual bool isThrottled() const { return false; }
|
||||
virtual float getTargetFrameRate() const { return 0.0f; }
|
||||
virtual float getTargetFrameRate() const { return 1.0f; }
|
||||
virtual bool hasAsyncReprojection() const { return false; }
|
||||
|
||||
/// Returns a boolean value indicating whether the display is currently visible
|
||||
|
@ -189,6 +189,11 @@ public:
|
|||
virtual float renderRate() const { return -1.0f; }
|
||||
// Rate at which we present to the display device
|
||||
virtual float presentRate() const { return -1.0f; }
|
||||
// Reset the present rate tracking (useful for if the target frame rate changes as in ASW for Oculus)
|
||||
virtual void resetPresentRate() {}
|
||||
// Return the present rate as fraction of the target present rate (hopefully 0.0 and 1.0)
|
||||
virtual float normalizedPresentRate() const { return presentRate() / getTargetFrameRate(); }
|
||||
|
||||
// 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
|
||||
|
|
|
@ -28,6 +28,12 @@ OculusDisplayPlugin::OculusDisplayPlugin() {
|
|||
_compositorDroppedFrames.store(0);
|
||||
}
|
||||
|
||||
float OculusDisplayPlugin::getTargetFrameRate() const {
|
||||
if (_aswActive) {
|
||||
return _hmdDesc.DisplayRefreshRate / 2.0f;
|
||||
}
|
||||
return _hmdDesc.DisplayRefreshRate;
|
||||
}
|
||||
|
||||
bool OculusDisplayPlugin::internalActivate() {
|
||||
bool result = Parent::internalActivate();
|
||||
|
@ -185,8 +191,6 @@ void OculusDisplayPlugin::hmdPresent() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!OVR_SUCCESS(result)) {
|
||||
logWarning("Failed to present");
|
||||
}
|
||||
|
@ -195,12 +199,20 @@ void OculusDisplayPlugin::hmdPresent() {
|
|||
static int appDroppedFrames = 0;
|
||||
ovrPerfStats perfStats;
|
||||
ovr_GetPerfStats(_session, &perfStats);
|
||||
bool shouldResetPresentRate = false;
|
||||
for (int i = 0; i < perfStats.FrameStatsCount; ++i) {
|
||||
const auto& frameStats = perfStats.FrameStats[i];
|
||||
int delta = frameStats.CompositorDroppedFrameCount - compositorDroppedFrames;
|
||||
_stutterRate.increment(delta);
|
||||
compositorDroppedFrames = frameStats.CompositorDroppedFrameCount;
|
||||
appDroppedFrames = frameStats.AppDroppedFrameCount;
|
||||
bool newAswState = ovrTrue == frameStats.AswIsActive;
|
||||
if (_aswActive.exchange(newAswState) != newAswState) {
|
||||
shouldResetPresentRate = true;
|
||||
}
|
||||
}
|
||||
if (shouldResetPresentRate) {
|
||||
resetPresentRate();
|
||||
}
|
||||
_appDroppedFrames.store(appDroppedFrames);
|
||||
_compositorDroppedFrames.store(compositorDroppedFrames);
|
||||
|
@ -212,6 +224,7 @@ void OculusDisplayPlugin::hmdPresent() {
|
|||
|
||||
QJsonObject OculusDisplayPlugin::getHardwareStats() const {
|
||||
QJsonObject hardwareStats;
|
||||
hardwareStats["asw_active"] = _aswActive.load();
|
||||
hardwareStats["app_dropped_frame_count"] = _appDroppedFrames.load();
|
||||
hardwareStats["compositor_dropped_frame_count"] = _compositorDroppedFrames.load();
|
||||
hardwareStats["long_render_count"] = _longRenders.load();
|
||||
|
|
|
@ -20,7 +20,8 @@ public:
|
|||
|
||||
QString getPreferredAudioInDevice() const override;
|
||||
QString getPreferredAudioOutDevice() const override;
|
||||
|
||||
float getTargetFrameRate() const override;
|
||||
|
||||
virtual QJsonObject getHardwareStats() const;
|
||||
|
||||
protected:
|
||||
|
@ -39,6 +40,7 @@ private:
|
|||
gpu::FramebufferPointer _outputFramebuffer;
|
||||
bool _customized { false };
|
||||
|
||||
std::atomic_bool _aswActive;
|
||||
std::atomic_int _compositorDroppedFrames;
|
||||
std::atomic_int _appDroppedFrames;
|
||||
std::atomic_int _longSubmits;
|
||||
|
|
|
@ -88,7 +88,11 @@ ovrSession acquireOculusSession() {
|
|||
}
|
||||
|
||||
if (!session) {
|
||||
if (!OVR_SUCCESS(ovr_Initialize(nullptr))) {
|
||||
ovrInitParams initParams {
|
||||
ovrInit_RequestVersion | ovrInit_MixedRendering, OVR_MINOR_VERSION, nullptr, 0, 0
|
||||
};
|
||||
|
||||
if (!OVR_SUCCESS(ovr_Initialize(&initParams))) {
|
||||
logWarning("Failed to initialize Oculus SDK");
|
||||
return session;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue