mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:36:26 +02:00
handle throttle render case and clean up code logic to be more obvious
This commit is contained in:
parent
0c2a630a59
commit
68e730af45
2 changed files with 27 additions and 21 deletions
|
@ -50,6 +50,7 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
currentFPS = ASSUMED_FPS;
|
currentFPS = ASSUMED_FPS;
|
||||||
_lastUpShift = _lastDownShift = usecTimestampNow();
|
_lastUpShift = _lastDownShift = usecTimestampNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
_fpsAverageStartWindow.updateAverage(currentFPS);
|
_fpsAverageStartWindow.updateAverage(currentFPS);
|
||||||
_fpsAverageDownWindow.updateAverage(currentFPS);
|
_fpsAverageDownWindow.updateAverage(currentFPS);
|
||||||
_fpsAverageUpWindow.updateAverage(currentFPS);
|
_fpsAverageUpWindow.updateAverage(currentFPS);
|
||||||
|
@ -64,12 +65,17 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
if (_automaticLODAdjust) {
|
if (_automaticLODAdjust) {
|
||||||
|
|
||||||
// LOD Downward adjustment
|
// LOD Downward adjustment
|
||||||
// If our last adjust was an upshift, then we don't want to consider any downshifts until we've delayed at least
|
// If we've been downshifting, we watch a shorter downshift window so that we will quickly move toward our
|
||||||
// our START_DELAY_WINDOW_IN_SECS
|
// target frame rate. But if we haven't just done a downshift (either because our last shift was an upshift,
|
||||||
bool doDownShift = _lastAdjustWasUpShift
|
// or because we've just started out) then we look at a much longer window to consider whether or not to start
|
||||||
? (elapsedSinceUpShift > START_SHIFT_ELPASED && _fpsAverageStartWindow.getAverage() < getLODDecreaseFPS())
|
// downshifting.
|
||||||
: (elapsedSinceDownShift > DOWN_SHIFT_ELPASED && _fpsAverageDownWindow.getAverage() < getLODDecreaseFPS());
|
bool doDownShift = false;
|
||||||
|
|
||||||
|
if (_isDownshifting) {
|
||||||
|
doDownShift = (elapsedSinceDownShift > DOWN_SHIFT_ELPASED && _fpsAverageDownWindow.getAverage() < getLODDecreaseFPS());
|
||||||
|
} else {
|
||||||
|
doDownShift = (elapsedSinceUpShift > START_SHIFT_ELPASED && _fpsAverageStartWindow.getAverage() < getLODDecreaseFPS());
|
||||||
|
}
|
||||||
|
|
||||||
if (doDownShift) {
|
if (doDownShift) {
|
||||||
|
|
||||||
|
@ -83,24 +89,26 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
if (_lastAdjustWasUpShift) {
|
if (_isDownshifting) {
|
||||||
qDebug() << "adjusting LOD DOWN after initial delay..."
|
// subsequent downshift
|
||||||
<< "average fps for last "<< START_DELAY_WINDOW_IN_SECS <<"seconds was "
|
|
||||||
<< _fpsAverageStartWindow.getAverage()
|
|
||||||
<< "minimum is:" << getLODDecreaseFPS()
|
|
||||||
<< "elapsedSinceUpShift:" << elapsedSinceUpShift
|
|
||||||
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
|
||||||
} else {
|
|
||||||
qDebug() << "adjusting LOD DOWN..."
|
qDebug() << "adjusting LOD DOWN..."
|
||||||
<< "average fps for last "<< DOWN_SHIFT_WINDOW_IN_SECS <<"seconds was "
|
<< "average fps for last "<< DOWN_SHIFT_WINDOW_IN_SECS <<"seconds was "
|
||||||
<< _fpsAverageDownWindow.getAverage()
|
<< _fpsAverageDownWindow.getAverage()
|
||||||
<< "minimum is:" << getLODDecreaseFPS()
|
<< "minimum is:" << getLODDecreaseFPS()
|
||||||
<< "elapsedSinceDownShift:" << elapsedSinceDownShift
|
<< "elapsedSinceDownShift:" << elapsedSinceDownShift
|
||||||
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
||||||
|
} else {
|
||||||
|
// first downshift
|
||||||
|
qDebug() << "adjusting LOD DOWN after initial delay..."
|
||||||
|
<< "average fps for last "<< START_DELAY_WINDOW_IN_SECS <<"seconds was "
|
||||||
|
<< _fpsAverageStartWindow.getAverage()
|
||||||
|
<< "minimum is:" << getLODDecreaseFPS()
|
||||||
|
<< "elapsedSinceUpShift:" << elapsedSinceUpShift
|
||||||
|
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastDownShift = now;
|
_lastDownShift = now;
|
||||||
_lastAdjustWasUpShift = false;
|
_isDownshifting = true;
|
||||||
|
|
||||||
emit LODDecreased();
|
emit LODDecreased();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +138,7 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
<< " NEW _octreeSizeScale=" << _octreeSizeScale;
|
||||||
|
|
||||||
_lastUpShift = now;
|
_lastUpShift = now;
|
||||||
_lastAdjustWasUpShift = true;
|
_isDownshifting = false;
|
||||||
|
|
||||||
emit LODIncreased();
|
emit LODIncreased();
|
||||||
}
|
}
|
||||||
|
@ -149,13 +157,11 @@ void LODManager::autoAdjustLOD(float currentFPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LODManager::resetLODAdjust() {
|
void LODManager::resetLODAdjust() {
|
||||||
|
_fpsAverageStartWindow.reset();
|
||||||
// TODO: Do we need this???
|
|
||||||
/*
|
|
||||||
_fpsAverageDownWindow.reset();
|
_fpsAverageDownWindow.reset();
|
||||||
_fpsAverageUpWindow.reset();
|
_fpsAverageUpWindow.reset();
|
||||||
_lastAdjust = usecTimestampNow();
|
_lastUpShift = _lastDownShift = usecTimestampNow();
|
||||||
*/
|
_isDownshifting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LODManager::getLODFeedbackText() {
|
QString LODManager::getLODFeedbackText() {
|
||||||
|
|
|
@ -107,7 +107,7 @@ private:
|
||||||
|
|
||||||
quint64 _lastDownShift = 0;
|
quint64 _lastDownShift = 0;
|
||||||
quint64 _lastUpShift = 0;
|
quint64 _lastUpShift = 0;
|
||||||
bool _lastAdjustWasUpShift = true; // start out as if we've just upshifted
|
bool _isDownshifting = false; // start out as if we're not downshifting
|
||||||
|
|
||||||
SimpleMovingAverage _fpsAverageStartWindow = START_DELAY_SAMPLES_OF_FRAMES;
|
SimpleMovingAverage _fpsAverageStartWindow = START_DELAY_SAMPLES_OF_FRAMES;
|
||||||
SimpleMovingAverage _fpsAverageDownWindow = DOWN_SHIFT_SAMPLES_OF_FRAMES;
|
SimpleMovingAverage _fpsAverageDownWindow = DOWN_SHIFT_SAMPLES_OF_FRAMES;
|
||||||
|
|
Loading…
Reference in a new issue