Improved estimated rendering time

This commit is contained in:
Michaël Lemaire 2015-11-02 23:39:34 +01:00
parent ca7bd84308
commit dc27590496
4 changed files with 32 additions and 10 deletions

2
.gitignore vendored
View file

@ -24,3 +24,5 @@ ui_*.h
/paysages3d-linux.tar.bz2
/config.vim
/callgrind.out.*
*.p3d

View file

@ -211,9 +211,9 @@ void RenderProcess::timerEvent(QTimerEvent *)
if (rendering)
{
unsigned long remaining = renderer->getProgressHelper()->estimateRemainingTime();
if (remaining > 10000)
if (remaining > 0)
{
t = QTime(0, 0, 0).addMSecs(remaining);
t = QTime(0, 0, 0).addMSecs(999 + remaining);
info += " - Remaining: ~" + t.toString("hh:mm:ss");
}
}

View file

@ -9,8 +9,9 @@ RenderProgress::RenderProgress(int count)
lock = new Mutex();
global = 0.0;
step = 1.0 / (double)count;
start_time = Time::getRelativeTimeMs();
start_time = 0;
end_time = 0;
reset();
}
paysages::software::RenderProgress::~RenderProgress()
@ -30,6 +31,10 @@ void RenderProgress::reset()
start_time = Time::getRelativeTimeMs();
prev_est_spent = 0;
prev_est_done = 0.0;
prev_est_speed = 0.0;
lock->release();
}
@ -94,16 +99,24 @@ unsigned long RenderProgress::getDuration() const
}
}
unsigned long RenderProgress::estimateRemainingTime() const
unsigned long RenderProgress::estimateRemainingTime()
{
if (global < 0.00001)
unsigned long spent = getDuration();
double speed = (global - prev_est_done) / (double)(spent - prev_est_spent);
prev_est_speed = prev_est_speed ? (prev_est_speed * 0.8 + speed * 0.2) : speed;
if (spent - prev_est_spent > 5000)
{
return 0;
prev_est_spent = spent;
prev_est_done = global;
}
if (prev_est_speed > 0.0000000001)
{
return (unsigned long)((1.0 - global) / prev_est_speed);
}
else
{
unsigned long done = getDuration();
unsigned long total = (unsigned long)((double)done / global);
return total - done;
return 0;
}
}

View file

@ -42,14 +42,21 @@ public:
*
* Returns 0 if unknown.
*/
unsigned long estimateRemainingTime() const;
unsigned long estimateRemainingTime();
private:
Mutex *lock;
double global;
double step;
unsigned long start_time;
unsigned long end_time;
unsigned long prev_est_spent;
double prev_est_done;
double prev_est_speed;
std::stack<RenderSub> subs;
};