smoother edges for workload region feedback response

This commit is contained in:
Andrew Meadows 2018-08-30 10:13:35 -07:00
parent a134357489
commit 6c4862910e

View file

@ -135,15 +135,15 @@ glm::vec2 Regulator::run(const Timing_ns& deltaTime, const Timing_ns& measuredTi
float noise = sqrtf(_measuredTimeNoiseSquared);
// check budget
float budgetDelta = _budget.count() - _measuredTimeAverage;
if (abs(budgetDelta) < noise) {
// budget is within the noise
float offsetFromTarget = _budget.count() - _measuredTimeAverage;
if (fabsf(offsetFromTarget) < noise) {
// budget is within the noise --> do nothing
return currentFrontBack;
}
// clamp the step factor
glm::vec2 stepDelta = budgetDelta < 0.0f ? -_relativeStepDown : _relativeStepUp;
// compute response
glm::vec2 stepDelta = offsetFromTarget < 0.0f ? -_relativeStepDown : _relativeStepUp;
stepDelta *= glm::min(1.0f, (fabsf(offsetFromTarget) - noise) / noise); // ease out of "do nothing"
return currentFrontBack * (1.0f + stepDelta);
}