Merging with Blue

This commit is contained in:
samcake 2016-08-30 17:06:29 -07:00
commit 47aaed491d
16 changed files with 137 additions and 137 deletions

View file

@ -25,7 +25,7 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
auto query = batch._queries.get(batch._params[paramOffset]._uint);
GLQuery* glquery = syncGPUObject(*query);
if (glquery) {
glGetInteger64v(GL_TIMESTAMP, (GLint64*) &glquery->_batchTimeRange);
glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime);
if (timeElapsed) {
glBeginQuery(GL_TIME_ELAPSED, glquery->_endqo);
} else {
@ -46,7 +46,7 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) {
}
GLint64 now;
glGetInteger64v(GL_TIMESTAMP, &now);
glquery->_batchTimeRange = now - glquery->_batchTimeRange;
glquery->_batchElapsedTime = now - glquery->_batchElapsedTime;
(void)CHECK_GL_ERROR();
}
@ -66,7 +66,7 @@ void GLBackend::do_getQuery(const Batch& batch, size_t paramOffset) {
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end);
glquery->_result = end - start;
}
query->triggerReturnHandler(glquery->_result, ((double) glquery->_batchTimeRange) / 1000000.0);
query->triggerReturnHandler(glquery->_result, glquery->_batchElapsedTime);
}
(void)CHECK_GL_ERROR();
}

View file

@ -48,7 +48,7 @@ public:
const GLuint& _endqo = { _id };
const GLuint _beginqo = { 0 };
GLuint64 _result { (GLuint64)-1 };
GLuint64 _batchTimeRange;
GLuint64 _batchElapsedTime { (GLuint64) 0 };
protected:
GLQuery(const std::weak_ptr<GLBackend>& backend, const Query& query, GLuint endId, GLuint beginId) : Parent(backend, query, endId), _beginqo(beginId) {}

View file

@ -24,17 +24,16 @@ Query::~Query()
{
}
double Query::getElapsedTime() const {
double Query::getGPUElapsedTime() const {
return ((double)_queryResult) / 1000000.0;
}
double Query::getBatchPerformTime() const {
return _batchPerformTime;
double Query::getBatchElapsedTime() const {
return ((double)_usecBatchElapsedTime) / 1000000.0;
}
void Query::triggerReturnHandler(uint64_t queryResult, double cpuTime) {
void Query::triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime) {
_queryResult = queryResult;
_batchPerformTime = cpuTime;
_usecBatchElapsedTime = batchElapsedTime;
if (_returnHandler) {
_returnHandler(*this);
@ -46,11 +45,9 @@ RangeTimer::RangeTimer() {
for (int i = 0; i < QUERY_QUEUE_SIZE; i++) {
_timerQueries.push_back(std::make_shared<gpu::Query>([&, i] (const Query& query) {
_tailIndex ++;
auto elapsedTime = query.getElapsedTime();
_movingAverageGPU.addSample(elapsedTime);
auto elapsedTimeCPU = query.getBatchPerformTime();
_movingAverageCPU.addSample(elapsedTimeCPU);
_movingAverageGPU.addSample(query.getGPUElapsedTime());
_movingAverageBatch.addSample(query.getBatchElapsedTime());
}));
}
}
@ -75,10 +72,10 @@ void RangeTimer::end(gpu::Batch& batch) {
}
}
double RangeTimer::getAverageGPU() const {
double RangeTimer::getGPUAverage() const {
return _movingAverageGPU.average;
}
double RangeTimer::getAverageCPU() const {
return _movingAverageCPU.average;
double RangeTimer::getBatchAverage() const {
return _movingAverageBatch.average;
}

View file

@ -30,17 +30,17 @@ namespace gpu {
Query(const Handler& returnHandler);
~Query();
double getElapsedTime() const;
double getBatchPerformTime() const;
double getGPUElapsedTime() const;
double getBatchElapsedTime() const;
// Only for gpu::Context
const GPUObjectPointer gpuObject {};
void triggerReturnHandler(uint64_t queryResult, double cpuTime);
void triggerReturnHandler(uint64_t queryResult, uint64_t batchElapsedTime);
protected:
Handler _returnHandler;
uint64_t _queryResult = 0;
double _batchPerformTime { 0.0 };
uint64_t _queryResult { 0 };
uint64_t _usecBatchElapsedTime { 0 };
};
typedef std::shared_ptr<Query> QueryPointer;
@ -56,8 +56,8 @@ namespace gpu {
void begin(gpu::Batch& batch);
void end(gpu::Batch& batch);
double getAverageGPU() const;
double getAverageCPU() const;
double getGPUAverage() const;
double getBatchAverage() const;
protected:
@ -66,9 +66,10 @@ namespace gpu {
gpu::Queries _timerQueries;
int _headIndex = -1;
int _tailIndex = -1;
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageCPU;
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageGPU;
MovingAverage<double, QUERY_QUEUE_SIZE * 2> _movingAverageBatch;
int rangeIndex(int index) const { return (index % QUERY_QUEUE_SIZE); }
};

View file

@ -433,8 +433,7 @@ void AmbientOcclusionEffect::run(const render::SceneContextPointer& sceneContext
// Update the timer
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->gpuTime = _gpuTimer.getAverageGPU();
config->gpuBatchTime = _gpuTimer.getAverageCPU();
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
}

View file

@ -53,7 +53,7 @@ protected:
using AmbientOcclusionFramebufferPointer = std::shared_ptr<AmbientOcclusionFramebuffer>;
class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
class AmbientOcclusionEffectConfig : public render::GPUJobConfig::Persistent {
Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty)
@ -68,10 +68,9 @@ class AmbientOcclusionEffectConfig : public render::Job::Config::Persistent {
Q_PROPERTY(int numSamples MEMBER numSamples WRITE setNumSamples)
Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel)
Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius)
Q_PROPERTY(double gpuTime READ getGpuTime)
Q_PROPERTY(double gpuBatchTime READ getGpuBatchTime)
public:
AmbientOcclusionEffectConfig() : render::Job::Config::Persistent("Ambient Occlusion", false) {}
AmbientOcclusionEffectConfig() : render::GPUJobConfig::Persistent("Ambient Occlusion", false) {}
const int MAX_RESOLUTION_LEVEL = 4;
const int MAX_BLUR_RADIUS = 6;
@ -85,8 +84,6 @@ public:
void setNumSamples(int samples) { numSamples = std::max(1.0f, (float)samples); emit dirty(); }
void setResolutionLevel(int level) { resolutionLevel = std::max(0, std::min(level, MAX_RESOLUTION_LEVEL)); emit dirty(); }
void setBlurRadius(int radius) { blurRadius = std::max(0, std::min(MAX_BLUR_RADIUS, radius)); emit dirty(); }
double getGpuTime() { return gpuTime; }
double getGpuBatchTime() { return gpuBatchTime; }
float radius{ 0.5f };
float perspectiveScale{ 1.0f };
@ -101,8 +98,6 @@ public:
bool ditheringEnabled{ true }; // randomize the distribution of taps per pixel, should always be true
bool borderingEnabled{ true }; // avoid evaluating information from non existing pixels out of the frame, should always be true
bool fetchMipsEnabled{ true }; // fetch taps in sub mips to otpimize cache, should always be true
double gpuTime { 0.0 };
double gpuBatchTime { 0.0 };
signals:
void dirty();

View file

@ -735,6 +735,5 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
});
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->gpuTime = _gpuTimer.getAverageGPU();
config->gpuBatchTime = _gpuTimer.getAverageCPU();
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
}

View file

@ -164,24 +164,7 @@ public:
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
};
class RenderDeferredConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(double gpuTime READ getGpuTime)
Q_PROPERTY(double gpuBatchTime READ getGpuBatchTime)
public:
RenderDeferredConfig() : render::Job::Config(true) {}
double getGpuTime() { return gpuTime; }
double getGpuBatchTime() { return gpuBatchTime; }
double gpuTime { 0.0 };
double gpuBatchTime { 0.0 };
signals:
void dirty();
};
using RenderDeferredConfig = render::GPUJobConfig;
class RenderDeferred {
public:

View file

@ -245,7 +245,7 @@ void EndGPURangeTimer::run(const render::SceneContextPointer& sceneContext, cons
});
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->setTime(timer->getAverageGPU(), timer->getAverageCPU());
config->setGPUBatchRunTime(timer->getGPUAverage(), timer->getBatchAverage());
}

View file

@ -29,25 +29,8 @@ protected:
gpu::RangeTimerPointer _gpuTimer;
};
using GPURangeTimerConfig = render::GPUJobConfig;
class GPURangeTimerConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(double gpuTime READ getGpuTime)
Q_PROPERTY(double gpuBatchTime READ getGpuBatchTime)
public:
double getGpuTime() { return gpuTime; }
double getGpuBatchTime() { return gpuBatchTime; }
void setTime(double gpu, double batch) {
gpuTime = gpu;
gpuBatchTime = batch;
}
protected:
double gpuTime;
double gpuBatchTime;
};
class EndGPURangeTimer {
public:
using Config = GPURangeTimerConfig;
@ -150,7 +133,7 @@ protected:
gpu::PipelinePointer getOpaquePipeline();
};
using DrawBackgroundDeferredConfig = GPURangeTimerConfig;
using DrawBackgroundDeferredConfig = render::GPUJobConfig;
class DrawBackgroundDeferred {
public:
@ -209,16 +192,7 @@ public:
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& srcFramebuffer);
};
class RenderDeferredTaskConfig : public render::Task::Config {
Q_OBJECT
Q_PROPERTY(double gpuTime READ getGpuTime)
public:
double getGpuTime() { return gpuTime; }
protected:
friend class RenderDeferredTask;
double gpuTime;
};
using RenderDeferredTaskConfig = render::GPUTaskConfig;
class RenderDeferredTask : public render::Task {
public:

View file

@ -201,9 +201,7 @@ void LinearDepthPass::run(const render::SceneContextPointer& sceneContext, const
});
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->gpuTime = _gpuTimer.getAverageGPU();
config->gpuBatchTime = _gpuTimer.getAverageCPU();
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
}
@ -526,8 +524,8 @@ void SurfaceGeometryPass::run(const render::SceneContextPointer& sceneContext, c
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->gpuTime = _gpuTimer.getAverageGPU();
config->gpuBatchTime = _gpuTimer.getAverageCPU(); }
config->setGPUBatchRunTime(_gpuTimer.getGPUAverage(), _gpuTimer.getBatchAverage());
}
const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline() {

View file

@ -62,24 +62,7 @@ protected:
using LinearDepthFramebufferPointer = std::shared_ptr<LinearDepthFramebuffer>;
class LinearDepthPassConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(double gpuTime READ getGpuTime)
Q_PROPERTY(double gpuBatchTime READ getGpuBatchTime)
public:
LinearDepthPassConfig() : render::Job::Config(true) {}
double getGpuTime() { return gpuTime; }
double getGpuBatchTime() { return gpuBatchTime; }
double gpuTime{ 0.0 };
double gpuBatchTime { 0.0 };
signals:
void dirty();
};
using LinearDepthPassConfig = render::GPUJobConfig;
class LinearDepthPass {
public:
@ -152,7 +135,7 @@ protected:
using SurfaceGeometryFramebufferPointer = std::shared_ptr<SurfaceGeometryFramebuffer>;
class SurfaceGeometryPassConfig : public render::Job::Config {
class SurfaceGeometryPassConfig : public render::GPUJobConfig {
Q_OBJECT
Q_PROPERTY(float depthThreshold MEMBER depthThreshold NOTIFY dirty)
Q_PROPERTY(float basisScale MEMBER basisScale NOTIFY dirty)
@ -162,11 +145,8 @@ class SurfaceGeometryPassConfig : public render::Job::Config {
Q_PROPERTY(float diffuseFilterScale MEMBER diffuseFilterScale NOTIFY dirty)
Q_PROPERTY(float diffuseDepthThreshold MEMBER diffuseDepthThreshold NOTIFY dirty)
Q_PROPERTY(double gpuTime READ getGpuTime)
Q_PROPERTY(double gpuBatchTime READ getGpuBatchTime)
public:
SurfaceGeometryPassConfig() : render::Job::Config(true) {}
SurfaceGeometryPassConfig() : render::GPUJobConfig(true) {}
float depthThreshold{ 5.0f }; // centimeters
float basisScale{ 1.0f };
@ -175,12 +155,6 @@ public:
float diffuseFilterScale{ 0.2f };
float diffuseDepthThreshold{ 1.0f };
double getGpuTime() { return gpuTime; }
double getGpuBatchTime() { return gpuBatchTime; }
double gpuTime { 0.0 };
double gpuBatchTime { 0.0 };
signals:
void dirty();
};

View file

@ -334,9 +334,9 @@ protected:
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
class JobConfig : public QObject {
Q_OBJECT
Q_PROPERTY(quint64 cpuRunTime READ getCPUTRunTime NOTIFY newStats())
Q_PROPERTY(double cpuRunTime READ getCPURunTime NOTIFY newStats()) //ms
quint64 _CPURunTime{ 0 };
double _msCPURunTime{ 0.0 };
public:
using Persistent = PersistentConfig<JobConfig>;
@ -364,8 +364,8 @@ public:
// Running Time measurement
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
void setCPURunTime(quint64 ustime) { _CPURunTime = ustime; emit newStats(); }
quint64 getCPUTRunTime() const { return _CPURunTime; }
void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); }
double getCPURunTime() const { return _msCPURunTime; }
public slots:
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
@ -418,6 +418,46 @@ template <class T, class I, class O> void jobRun(T& data, const SceneContextPoin
data.run(sceneContext, renderContext, input, output);
}
class GPUJobConfig : public JobConfig {
Q_OBJECT
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
double _msGPURunTime { 0.0 };
double _msBatchRunTime { 0.0 };
public:
using Persistent = PersistentConfig<GPUJobConfig>;
GPUJobConfig() = default;
GPUJobConfig(bool enabled) : JobConfig(enabled) {}
// Running Time measurement on GPU and for Batch execution
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
double getGPURunTime() const { return _msGPURunTime; }
double getBatchRunTime() const { return _msBatchRunTime; }
};
class GPUTaskConfig : public TaskConfig {
Q_OBJECT
Q_PROPERTY(double gpuRunTime READ getGPURunTime)
Q_PROPERTY(double batchRunTime READ getBatchRunTime)
double _msGPURunTime { 0.0 };
double _msBatchRunTime { 0.0 };
public:
using Persistent = PersistentConfig<GPUTaskConfig>;
GPUTaskConfig() = default;
GPUTaskConfig(bool enabled) : TaskConfig(enabled) {}
// Running Time measurement on GPU and for Batch execution
void setGPUBatchRunTime(double msGpuTime, double msBatchTime) { _msGPURunTime = msGpuTime; _msBatchRunTime = msBatchTime; }
double getGPURunTime() const { return _msGPURunTime; }
double getBatchRunTime() const { return _msBatchRunTime; }
};
class Job {
public:
using Config = JobConfig;
@ -439,7 +479,7 @@ public:
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
protected:
void setCPURunTime(quint64 ustime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(ustime); }
void setCPURunTime(double mstime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(mstime); }
QConfigPointer _config;
@ -502,7 +542,7 @@ public:
_concept->run(sceneContext, renderContext);
_concept->setCPURunTime(usecTimestampNow() - start);
_concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0);
}
protected:

View file

@ -75,10 +75,10 @@ Column {
object: Render.getConfig("AmbientOcclusion")
valueUnit: "ms"
valueScale: 1
valueNumDigits: "4"
valueNumDigits: "3"
plots: [
{
prop: "gpuTime",
prop: "gpuRunTime",
label: "gpu",
color: "#FFFFFF"
}

View file

@ -213,8 +213,8 @@ Item {
height: parent.evalEvenHeight()
object: parent.drawOpaqueConfig
valueUnit: "ms"
valueScale: 1000
valueNumDigits: "1"
valueScale: 1
valueNumDigits: "2"
plots: [
{
object: Render.getConfig("DrawOpaqueDeferred"),

View file

@ -30,7 +30,7 @@ Item {
PlotPerf {
title: "Timing"
title: "GPU Timing"
height: parent.evalEvenHeight()
object: parent.drawOpaqueConfig
valueUnit: "ms"
@ -39,31 +39,71 @@ Item {
plots: [
{
object: Render.getConfig("OpaqueRangeTimer"),
prop: "gpuTime",
prop: "gpuRunTime",
label: "Opaque",
color: "#FFFFFF"
},
{
object: Render.getConfig("LinearDepth"),
prop: "gpuTime",
prop: "gpuRunTime",
label: "LinearDepth",
color: "#00FF00"
},{
object: Render.getConfig("SurfaceGeometry"),
prop: "gpuTime",
prop: "gpuRunTime",
label: "SurfaceGeometry",
color: "#00FFFF"
},
{
object: Render.getConfig("RenderDeferred"),
prop: "gpuTime",
prop: "gpuRunTime",
label: "DeferredLighting",
color: "#FF00FF"
}
,
{
object: Render.getConfig("ToneAndPostRangeTimer"),
prop: "gpuTime",
prop: "gpuRunTime",
label: "tone and post",
color: "#FF0000"
}
]
}
PlotPerf {
title: "Batch Timing"
height: parent.evalEvenHeight()
object: parent.drawOpaqueConfig
valueUnit: "ms"
valueScale: 1
valueNumDigits: "3"
plots: [
{
object: Render.getConfig("OpaqueRangeTimer"),
prop: "batchRunTime",
label: "Opaque",
color: "#FFFFFF"
},
{
object: Render.getConfig("LinearDepth"),
prop: "batchRunTime",
label: "LinearDepth",
color: "#00FF00"
},{
object: Render.getConfig("SurfaceGeometry"),
prop: "batchRunTime",
label: "SurfaceGeometry",
color: "#00FFFF"
},
{
object: Render.getConfig("RenderDeferred"),
prop: "batchRunTime",
label: "DeferredLighting",
color: "#FF00FF"
}
,
{
object: Render.getConfig("ToneAndPostRangeTimer"),
prop: "batchRunTime",
label: "tone and post",
color: "#FF0000"
}