Added render time
This commit is contained in:
parent
c6272846ea
commit
0c8a88cddb
10 changed files with 119 additions and 2 deletions
1
TODO
1
TODO
|
@ -4,6 +4,7 @@ Technlology Preview 2 :
|
||||||
- Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance).
|
- Implement copy-on-write on definitions (to avoid copying whole heightmaps for instance).
|
||||||
- Add clouds to OpenGL with 3d textures.
|
- Add clouds to OpenGL with 3d textures.
|
||||||
- Fix potential holes in land rendering (OpenGL and software).
|
- Fix potential holes in land rendering (OpenGL and software).
|
||||||
|
- Fix polygon culling near the camera in low-res renders (automatic tessellation ?).
|
||||||
|
|
||||||
Technology Preview 3 :
|
Technology Preview 3 :
|
||||||
- Alter aerial perspective using estimation of the amount of light left after cloud layers traversal.
|
- Alter aerial perspective using estimation of the amount of light left after cloud layers traversal.
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include "RenderProcess.h"
|
#include "RenderProcess.h"
|
||||||
|
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
#include <QTime>
|
||||||
#include "MainModelerWindow.h"
|
#include "MainModelerWindow.h"
|
||||||
#include "SoftwareCanvasRenderer.h"
|
#include "SoftwareCanvasRenderer.h"
|
||||||
#include "RenderPreviewProvider.h"
|
#include "RenderPreviewProvider.h"
|
||||||
#include "RenderConfig.h"
|
#include "RenderConfig.h"
|
||||||
|
#include "RenderProgress.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Canvas.h"
|
#include "Canvas.h"
|
||||||
#include "CanvasPreview.h"
|
#include "CanvasPreview.h"
|
||||||
|
@ -171,6 +173,19 @@ void RenderProcess::timerEvent(QTimerEvent *)
|
||||||
|
|
||||||
if (renderer)
|
if (renderer)
|
||||||
{
|
{
|
||||||
|
QTime t = QTime(0, 0, 0).addMSecs(renderer->getProgressHelper()->getDuration());
|
||||||
|
QString info = QString("Elapsed time: ") + t.toString("hh:mm:ss");
|
||||||
|
if (rendering)
|
||||||
|
{
|
||||||
|
unsigned long remaining = renderer->getProgressHelper()->estimateRemainingTime();
|
||||||
|
if (remaining > 10000)
|
||||||
|
{
|
||||||
|
t = QTime(0, 0, 0).addMSecs(remaining);
|
||||||
|
info += " - Remaining: ~" + t.toString("hh:mm:ss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window->setQmlProperty("render_timing", "text", info);
|
||||||
|
|
||||||
window->setQmlProperty("render_progress", "value", renderer->getProgress());
|
window->setQmlProperty("render_progress", "value", renderer->getProgress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,14 @@ BaseRectangle {
|
||||||
anchors.topMargin: 20
|
anchors.topMargin: 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: render_timing
|
||||||
|
objectName: "render_timing"
|
||||||
|
anchors.top: render_progress.bottom
|
||||||
|
anchors.horizontalCenter: render_progress.horizontalCenter
|
||||||
|
anchors.topMargin: 20
|
||||||
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 500
|
interval: 500
|
||||||
running: true
|
running: true
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
#include "RenderProgress.h"
|
#include "RenderProgress.h"
|
||||||
|
|
||||||
#include "Mutex.h"
|
#include "Mutex.h"
|
||||||
|
#include "Time.h"
|
||||||
|
#include "Logs.h"
|
||||||
|
|
||||||
RenderProgress::RenderProgress(int count)
|
RenderProgress::RenderProgress(int count)
|
||||||
{
|
{
|
||||||
lock = new Mutex();
|
lock = new Mutex();
|
||||||
global = 0.0;
|
global = 0.0;
|
||||||
step = 1.0 / (double)count;
|
step = 1.0 / (double)count;
|
||||||
|
start_time = Time::getRelativeTimeMs();
|
||||||
|
end_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
paysages::software::RenderProgress::~RenderProgress()
|
paysages::software::RenderProgress::~RenderProgress()
|
||||||
|
@ -24,6 +28,8 @@ void RenderProgress::reset()
|
||||||
subs.pop();
|
subs.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start_time = Time::getRelativeTimeMs();
|
||||||
|
|
||||||
lock->release();
|
lock->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,3 +71,39 @@ void RenderProgress::exitSub()
|
||||||
|
|
||||||
lock->release();
|
lock->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderProgress::end()
|
||||||
|
{
|
||||||
|
if (subs.size() > 0)
|
||||||
|
{
|
||||||
|
Logs::error() << subs.size() << " progress subs remaining at the end of render" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
end_time = Time::getRelativeTimeMs();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long RenderProgress::getDuration() const
|
||||||
|
{
|
||||||
|
if (end_time)
|
||||||
|
{
|
||||||
|
return end_time - start_time;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Time::getRelativeTimeMs() - start_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long RenderProgress::estimateRemainingTime() const
|
||||||
|
{
|
||||||
|
if (global < 0.00001)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned long done = getDuration();
|
||||||
|
unsigned long total = (unsigned long)((double)done / global);
|
||||||
|
return total - done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,11 +30,26 @@ public:
|
||||||
void add(int value=1);
|
void add(int value=1);
|
||||||
void enterSub(int count);
|
void enterSub(int count);
|
||||||
void exitSub();
|
void exitSub();
|
||||||
|
void end();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the render duration in milliseconds.
|
||||||
|
*/
|
||||||
|
unsigned long getDuration() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the estimated remaining time in milliseconds.
|
||||||
|
*
|
||||||
|
* Returns 0 if unknown.
|
||||||
|
*/
|
||||||
|
unsigned long estimateRemainingTime() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mutex *lock;
|
Mutex *lock;
|
||||||
double global;
|
double global;
|
||||||
double step;
|
double step;
|
||||||
|
unsigned long start_time;
|
||||||
|
unsigned long end_time;
|
||||||
std::stack<RenderSub> subs;
|
std::stack<RenderSub> subs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,7 @@ void SoftwareCanvasRenderer::render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress->exitSub();
|
progress->exitSub();
|
||||||
|
progress->end();
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
src/system/Time.cpp
Normal file
11
src/system/Time.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include "Time.h"
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
static QTime EPOCH = QTime::currentTime();
|
||||||
|
|
||||||
|
unsigned long Time::getRelativeTimeMs()
|
||||||
|
{
|
||||||
|
return EPOCH.msecsTo(QTime::currentTime());
|
||||||
|
}
|
||||||
|
|
21
src/system/Time.h
Normal file
21
src/system/Time.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef TIME_H
|
||||||
|
#define TIME_H
|
||||||
|
|
||||||
|
#include "system_global.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace system {
|
||||||
|
|
||||||
|
class SYSTEMSHARED_EXPORT Time
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Get a timestamp in milliseconds.
|
||||||
|
*/
|
||||||
|
static unsigned long getRelativeTimeMs();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TIME_H
|
|
@ -28,7 +28,8 @@ SOURCES += \
|
||||||
ParallelWorker.cpp \
|
ParallelWorker.cpp \
|
||||||
Semaphore.cpp \
|
Semaphore.cpp \
|
||||||
FileSystem.cpp \
|
FileSystem.cpp \
|
||||||
DataFile.cpp
|
DataFile.cpp \
|
||||||
|
Time.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
system_global.h \
|
system_global.h \
|
||||||
|
@ -46,7 +47,8 @@ HEADERS += \
|
||||||
ParallelWorker.h \
|
ParallelWorker.h \
|
||||||
Semaphore.h \
|
Semaphore.h \
|
||||||
FileSystem.h \
|
FileSystem.h \
|
||||||
DataFile.h
|
DataFile.h \
|
||||||
|
Time.h
|
||||||
|
|
||||||
unix:!symbian {
|
unix:!symbian {
|
||||||
maemo5 {
|
maemo5 {
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace system {
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class Semaphore;
|
class Semaphore;
|
||||||
class PictureWriter;
|
class PictureWriter;
|
||||||
|
class Time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
using namespace paysages::system;
|
using namespace paysages::system;
|
||||||
|
|
Loading…
Reference in a new issue