mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 02:03:57 +02:00
Merge pull request #6541 from howard-stearns/correct-target-frame-rate
Don't limit avatar rendering when not vsync'd
This commit is contained in:
commit
589adde41e
9 changed files with 41 additions and 18 deletions
|
@ -3236,6 +3236,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
bool Application::isHMDMode() const {
|
||||
return getActiveDisplayPlugin()->isHmd();
|
||||
}
|
||||
float Application::getTargetFrameRate() { return getActiveDisplayPlugin()->getTargetFrameRate(); }
|
||||
|
||||
QRect Application::getDesirableApplicationGeometry() {
|
||||
QRect applicationGeometry = getWindow()->geometry();
|
||||
|
|
|
@ -160,9 +160,7 @@ public:
|
|||
|
||||
uint32_t getFrameCount() { return _frameCount; }
|
||||
float getFps() const { return _fps; }
|
||||
float const HMD_TARGET_FRAME_RATE = 75.0f;
|
||||
float const DESKTOP_TARGET_FRAME_RATE = 60.0f;
|
||||
float getTargetFrameRate() { return isHMDMode() ? HMD_TARGET_FRAME_RATE : DESKTOP_TARGET_FRAME_RATE; }
|
||||
float getTargetFrameRate(); // frames/second
|
||||
float getLastInstanteousFps() const { return _lastInstantaneousFps; }
|
||||
float getLastUnsynchronizedFps() const { return _lastUnsynchronizedFps; }
|
||||
|
||||
|
|
|
@ -145,13 +145,19 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
|
||||
PerformanceTimer perfTimer("otherAvatars");
|
||||
|
||||
_renderDistanceController.setMeasuredValueSetpoint(qApp->getTargetFrameRate()); // No problem updating in flight.
|
||||
// The PID controller raises the controlled value when the measured value goes up.
|
||||
// The measured value is frame rate. When the controlled value (1 / render cutoff distance)
|
||||
// goes up, the render cutoff distance gets closer, the number of rendered avatars is less, and frame rate
|
||||
// goes up.
|
||||
const float deduced = qApp->getLastUnsynchronizedFps();
|
||||
const float distance = 1.0f / _renderDistanceController.update(deduced, deltaTime);
|
||||
float distance;
|
||||
if (!qApp->isThrottleRendering()) {
|
||||
_renderDistanceController.setMeasuredValueSetpoint(qApp->getTargetFrameRate()); // No problem updating in flight.
|
||||
// The PID controller raises the controlled value when the measured value goes up.
|
||||
// The measured value is frame rate. When the controlled value (1 / render cutoff distance)
|
||||
// goes up, the render cutoff distance gets closer, the number of rendered avatars is less, and frame rate
|
||||
// goes up.
|
||||
const float deduced = qApp->getLastUnsynchronizedFps();
|
||||
distance = 1.0f / _renderDistanceController.update(deduced, deltaTime);
|
||||
} else {
|
||||
// Here we choose to just use the maximum render cutoff distance if throttled.
|
||||
distance = 1.0f / _renderDistanceController.getControlledValueLowLimit();
|
||||
}
|
||||
_renderDistanceAverage.updateAverage(distance);
|
||||
_renderDistance = _renderDistanceAverage.getAverage();
|
||||
int renderableCount = 0;
|
||||
|
|
|
@ -83,16 +83,16 @@ void Basic2DWindowOpenGLDisplayPlugin::internalPresent() {
|
|||
}
|
||||
WindowOpenGLDisplayPlugin::internalPresent();
|
||||
}
|
||||
|
||||
const uint32_t THROTTLED_FRAMERATE = 15;
|
||||
int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval() const {
|
||||
static const int THROTTLED_PAINT_TIMER_DELAY_MS = MSECS_PER_SECOND / 15;
|
||||
static const int ULIMIITED_PAINT_TIMER_DELAY_MS = 1;
|
||||
int result = ULIMIITED_PAINT_TIMER_DELAY_MS;
|
||||
if (_isThrottled) {
|
||||
result = THROTTLED_PAINT_TIMER_DELAY_MS;
|
||||
}
|
||||
if (0 != _framerateTarget) {
|
||||
result = MSECS_PER_SECOND / _framerateTarget;
|
||||
} else if (_isThrottled) {
|
||||
// This test wouldn't be necessary if we could depend on updateFramerate setting _framerateTarget.
|
||||
// Alas, that gets complicated: isThrottled() is const and other stuff depends on it.
|
||||
result = MSECS_PER_SECOND / THROTTLED_FRAMERATE;
|
||||
}
|
||||
|
||||
qDebug() << "New interval " << result;
|
||||
|
@ -112,7 +112,6 @@ bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
|||
return shouldThrottle;
|
||||
}
|
||||
|
||||
|
||||
void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
|
||||
QAction* checkedFramerate{ nullptr };
|
||||
foreach(auto action, _framerateActions) {
|
||||
|
@ -134,11 +133,13 @@ void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
|
|||
} else if (FRAMERATE_30 == actionText) {
|
||||
_framerateTarget = 30;
|
||||
}
|
||||
}
|
||||
} else if (_isThrottled) {
|
||||
_framerateTarget = THROTTLED_FRAMERATE;
|
||||
}
|
||||
|
||||
int newInterval = getDesiredInterval();
|
||||
qDebug() << newInterval;
|
||||
_timer.start(getDesiredInterval());
|
||||
_timer.start(newInterval);
|
||||
}
|
||||
|
||||
// FIXME target the screen the window is currently on
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "WindowOpenGLDisplayPlugin.h"
|
||||
|
||||
const float TARGET_FRAMERATE_Basic2DWindowOpenGL = 60.0f;
|
||||
|
||||
class QScreen;
|
||||
class QAction;
|
||||
|
||||
|
@ -18,6 +20,8 @@ class Basic2DWindowOpenGLDisplayPlugin : public WindowOpenGLDisplayPlugin {
|
|||
public:
|
||||
virtual const QString & getName() const override;
|
||||
|
||||
virtual float getTargetFrameRate() override { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
|
||||
|
||||
virtual void activate() override;
|
||||
|
||||
virtual void submitSceneTexture(uint32_t frameIndex, uint32_t sceneTexture, const glm::uvec2& sceneSize) override;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
/// By default, all HMDs are stereo
|
||||
virtual bool isStereo() const { return isHmd(); }
|
||||
virtual bool isThrottled() const { return false; }
|
||||
virtual float getTargetFrameRate() { return 0.0f; }
|
||||
|
||||
// Rendering support
|
||||
|
||||
|
|
|
@ -12,12 +12,16 @@
|
|||
struct SwapFramebufferWrapper;
|
||||
using SwapFboPtr = QSharedPointer<SwapFramebufferWrapper>;
|
||||
|
||||
const float TARGET_RATE_Oculus = 75.0f;
|
||||
|
||||
class OculusDisplayPlugin : public OculusBaseDisplayPlugin {
|
||||
public:
|
||||
virtual void activate() override;
|
||||
virtual const QString & getName() const override;
|
||||
virtual void setEyeRenderPose(uint32_t frameIndex, Eye eye, const glm::mat4& pose) override final;
|
||||
|
||||
virtual float getTargetFrameRate() override { return TARGET_RATE_Oculus; }
|
||||
|
||||
protected:
|
||||
virtual void internalPresent() override;
|
||||
virtual void customizeContext() override;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#include <OVR_CAPI.h>
|
||||
|
||||
const float TARGET_RATE_OculusLegacy = 75.0f;
|
||||
|
||||
class OculusLegacyDisplayPlugin : public WindowOpenGLDisplayPlugin {
|
||||
public:
|
||||
OculusLegacyDisplayPlugin();
|
||||
|
@ -25,6 +27,8 @@ public:
|
|||
virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
||||
virtual int getHmdScreen() const override;
|
||||
|
||||
virtual float getTargetFrameRate() override { return TARGET_RATE_OculusLegacy; }
|
||||
|
||||
// Stereo specific methods
|
||||
virtual bool isHmd() const override { return true; }
|
||||
virtual glm::mat4 getProjection(Eye eye, const glm::mat4& baseProjection) const override;
|
||||
|
|
|
@ -13,12 +13,16 @@
|
|||
|
||||
#include <display-plugins/WindowOpenGLDisplayPlugin.h>
|
||||
|
||||
const float TARGET_RATE_OpenVr = 90.0f; // FIXME: get from sdk tracked device property? This number is vive-only.
|
||||
|
||||
class OpenVrDisplayPlugin : public WindowOpenGLDisplayPlugin {
|
||||
public:
|
||||
virtual bool isSupported() const override;
|
||||
virtual const QString & getName() const override;
|
||||
virtual bool isHmd() const override { return true; }
|
||||
|
||||
virtual float getTargetFrameRate() override { return TARGET_RATE_OpenVr; }
|
||||
|
||||
virtual void activate() override;
|
||||
virtual void deactivate() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue