mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-08 07:02:25 +02:00
Picking pid values
This commit is contained in:
parent
0da22db837
commit
37b4cf6223
5 changed files with 42 additions and 10 deletions
|
@ -5028,8 +5028,9 @@ void Application::updateLOD(float deltaTime) const {
|
|||
float presentTime = getActiveDisplayPlugin()->getAveragePresentTime();
|
||||
float engineRunTime = (float)(_renderEngine->getConfiguration().get()->getCPURunTime());
|
||||
float gpuTime = getGPUContext()->getFrameTimerGPUAverage();
|
||||
float batchTime = getGPUContext()->getFrameTimerBatchAverage();
|
||||
auto lodManager = DependencyManager::get<LODManager>();
|
||||
lodManager->setRenderTimes(presentTime, engineRunTime, gpuTime);
|
||||
lodManager->setRenderTimes(presentTime, engineRunTime, batchTime, gpuTime);
|
||||
lodManager->autoAdjustLOD(deltaTime);
|
||||
} else {
|
||||
DependencyManager::get<LODManager>()->resetLODAdjust();
|
||||
|
|
|
@ -58,18 +58,21 @@ const uint64_t LOD_AUTO_ADJUST_PERIOD = 4 * (uint64_t)(LOD_ADJUST_RUNNING_AVG_TI
|
|||
const float LOD_AUTO_ADJUST_DECREMENT_FACTOR = 0.8f;
|
||||
const float LOD_AUTO_ADJUST_INCREMENT_FACTOR = 1.2f;
|
||||
|
||||
void LODManager::setRenderTimes(float presentTime, float engineRunTime, float gpuTime) {
|
||||
void LODManager::setRenderTimes(float presentTime, float engineRunTime, float batchTime, float gpuTime) {
|
||||
_presentTime = presentTime;
|
||||
_engineRunTime = engineRunTime;
|
||||
_batchTime = batchTime;
|
||||
_gpuTime = gpuTime;
|
||||
}
|
||||
|
||||
void LODManager::autoAdjustLOD(float realTimeDelta) {
|
||||
// float maxRenderTime = glm::max(glm::max(_presentTime, _engineRunTime), _gpuTime);
|
||||
float maxRenderTime = glm::max(glm::max(_presentTime, _engineRunTime), _gpuTime);
|
||||
// compute time-weighted running average maxRenderTime
|
||||
// Note: we MUST clamp the blend to 1.0 for stability
|
||||
float blend = (realTimeDelta < LOD_ADJUST_RUNNING_AVG_TIMESCALE) ? realTimeDelta / LOD_ADJUST_RUNNING_AVG_TIMESCALE : 1.0f;
|
||||
_avgRenderTime = (1.0f - blend) * _avgRenderTime + blend * maxRenderTime; // msec
|
||||
// _avgRenderTime = maxRenderTime;
|
||||
if (!_automaticLODAdjust || _avgRenderTime == 0.0f) {
|
||||
// early exit
|
||||
return;
|
||||
|
@ -78,7 +81,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
|
|||
float oldOctreeSizeScale = _octreeSizeScale;
|
||||
float oldSolidAngle = getLODAngleDeg();
|
||||
|
||||
float targetFPS = getLODDecreaseFPS();
|
||||
float targetFPS = 0.5 * (getLODDecreaseFPS() + getLODIncreaseFPS());
|
||||
float targetPeriod = 1.0f / targetFPS;
|
||||
|
||||
float currentFPS = (float)MSECS_PER_SECOND / _avgRenderTime;
|
||||
|
@ -87,13 +90,12 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
|
|||
auto dt = (float) ((now - lastTime) / double(USECS_PER_MSEC));
|
||||
if (dt < targetPeriod * _pidCoefs.w) return;
|
||||
|
||||
float deltaFPS = currentFPS - getLODDecreaseFPS();
|
||||
|
||||
lastTime = now;
|
||||
auto previous_error = _pidHistory.x;
|
||||
auto previous_integral = _pidHistory.y;
|
||||
|
||||
auto error = getLODDecreaseFPS() - currentFPS;
|
||||
auto error = (targetFPS - currentFPS) / targetFPS;
|
||||
error = glm::clamp(error, -1.0f, 1.0f);
|
||||
auto integral = previous_integral + error * dt;
|
||||
auto derivative = (error - previous_error) / dt;
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ class LODManager : public QObject, public Dependency {
|
|||
|
||||
Q_PROPERTY(float presentTime READ getPresentTime)
|
||||
Q_PROPERTY(float engineRunTime READ getEngineRunTime)
|
||||
Q_PROPERTY(float batchTime READ getBatchTime)
|
||||
Q_PROPERTY(float gpuTime READ getGPUTime)
|
||||
Q_PROPERTY(float avgRenderTime READ getAverageRenderTime)
|
||||
Q_PROPERTY(float fps READ getMaxTheoreticalFPS)
|
||||
|
@ -178,10 +179,11 @@ public:
|
|||
|
||||
float getPresentTime() const { return _presentTime; }
|
||||
float getEngineRunTime() const { return _engineRunTime; }
|
||||
float getBatchTime() const { return _batchTime; }
|
||||
float getGPUTime() const { return _gpuTime; }
|
||||
|
||||
static bool shouldRender(const RenderArgs* args, const AABox& bounds);
|
||||
void setRenderTimes(float presentTime, float engineRunTime, float gpuTime);
|
||||
void setRenderTimes(float presentTime, float engineRunTime, float batchTime, float gpuTime);
|
||||
void autoAdjustLOD(float realTimeDelta);
|
||||
|
||||
void loadSettings();
|
||||
|
@ -240,7 +242,9 @@ private:
|
|||
bool _automaticLODAdjust = true;
|
||||
float _presentTime { 0.0f }; // msec
|
||||
float _engineRunTime { 0.0f }; // msec
|
||||
float _batchTime{ 0.0f }; // msec
|
||||
float _gpuTime { 0.0f }; // msec
|
||||
|
||||
float _avgRenderTime { 0.0f }; // msec
|
||||
float _desktopMaxRenderTime { DEFAULT_DESKTOP_MAX_RENDER_TIME };
|
||||
float _hmdMaxRenderTime { DEFAULT_HMD_MAX_RENDER_TIME };
|
||||
|
@ -248,7 +252,7 @@ private:
|
|||
float _octreeSizeScale = DEFAULT_OCTREE_SIZE_SCALE;
|
||||
int _boundaryLevelAdjust = 0;
|
||||
|
||||
glm::vec4 _pidCoefs{ 0.1526f, 0.00000015f, 15.f, 4.0f };
|
||||
glm::vec4 _pidCoefs{ 4.0f, 0.0000000f, 0.f, 4.0f };
|
||||
glm::vec4 _pidHistory{ 0.0f };
|
||||
glm::vec4 _pidOutputs{ 0.0f };
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ Item {
|
|||
|
||||
|
||||
property var valueMax : 1
|
||||
property var valueMin : 0
|
||||
|
||||
property var _values
|
||||
property var tick : 0
|
||||
|
@ -90,6 +91,11 @@ Item {
|
|||
_values[i].valueMax *= 0.25 // Fast reduce the max value as we click
|
||||
}
|
||||
}
|
||||
function resetMin() {
|
||||
for (var i = 0; i < _values.length; i++) {
|
||||
_values[i].valueMin *= 0.25 // Fast reduce the min value as we click
|
||||
}
|
||||
}
|
||||
|
||||
function pullFreshValues() {
|
||||
// Wait until values are created to begin pulling
|
||||
|
@ -99,6 +105,7 @@ Item {
|
|||
tick++;
|
||||
|
||||
var currentValueMax = 0
|
||||
var currentValueMin = 0
|
||||
for (var i = 0; i < _values.length; i++) {
|
||||
|
||||
var currentVal = (+_values[i].object[_values[i].value]) * _values[i].scale;
|
||||
|
@ -112,26 +119,44 @@ Item {
|
|||
_values[i].valueMax *= 0.99
|
||||
_values[i].numSamplesConstantMax = 0
|
||||
}
|
||||
if (lostValue <= _values[i].valueMin) {
|
||||
_values[i].valueMin *= 0.99
|
||||
_values[i].numSamplesConstantMin = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (_values[i].valueMax < currentVal) {
|
||||
_values[i].valueMax = currentVal;
|
||||
_values[i].numSamplesConstantMax = 0
|
||||
}
|
||||
if (_values[i].valueMin < currentVal) {
|
||||
_values[i].valueMin = currentVal;
|
||||
_values[i].numSamplesConstantMin = 0
|
||||
}
|
||||
|
||||
if (_values[i].numSamplesConstantMax > VALUE_HISTORY_SIZE) {
|
||||
_values[i].numSamplesConstantMax = 0
|
||||
_values[i].valueMax *= 0.95 // lower slowly the current max if no new above max since a while
|
||||
}
|
||||
|
||||
if (_values[i].numSamplesConstantMin > VALUE_HISTORY_SIZE) {
|
||||
_values[i].numSamplesConstantMin = 0
|
||||
_values[i].valueMin *= 0.95 // lower slowly the current min if no new above min since a while
|
||||
}
|
||||
|
||||
if (currentValueMax < _values[i].valueMax) {
|
||||
currentValueMax = _values[i].valueMax
|
||||
}
|
||||
if (currentValueMin < _values[i].valueMin) {
|
||||
currentValueMin = _values[i].valueMin
|
||||
}
|
||||
}
|
||||
|
||||
if ((valueMax < currentValueMax) || (tick % VALUE_HISTORY_SIZE == 0)) {
|
||||
valueMax = currentValueMax;
|
||||
}
|
||||
if ((valueMin < currentValueMin) || (tick % VALUE_HISTORY_SIZE == 0)) {
|
||||
valueMin = currentValueMin;
|
||||
}
|
||||
mycanvas.requestPaint()
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ Item {
|
|||
label: "LOD PID Kp"
|
||||
valueVar: LODManager["pidKp"]
|
||||
valueVarSetter: (function (v) { LODManager["pidKp"] = v })
|
||||
max: 0.2
|
||||
max: 2.0
|
||||
min: 0.0
|
||||
integral: false
|
||||
numDigits: 3
|
||||
|
|
Loading…
Reference in a new issue