Trying something a bit more radical for timing

This commit is contained in:
samcake 2016-04-12 15:29:31 -07:00
parent 70ac8ac8a5
commit ab9f41f5eb
8 changed files with 26 additions and 41 deletions

View file

@ -189,28 +189,29 @@ Item {
height: parent.evalEvenHeight()
object: parent.drawOpaqueConfig
valueUnit: "ms"
valueScale: 1000
plots: [
{
object: Render.getConfig("RenderDeferred"),
prop: "cpuTiming",
prop: "cpuRunTime",
label: "Lighting",
color: "#E2334D"
},
{
object: Render.getConfig("DrawOpaqueDeferred"),
prop: "cpuTiming",
prop: "cpuRunTime",
label: "Opaques",
color: "#1AC567"
},
{
object: Render.getConfig("DrawTransparentDeferred"),
prop: "cpuTiming",
prop: "cpuRunTime",
label: "Translucents",
color: "#00B4EF"
},
{
object: Render.getConfig("RenderDeferred"),
prop: "cpuTiming",
prop: "cpuRunTime",
label: "Lighting",
color: "#E2334D"
}

View file

@ -118,12 +118,14 @@ void Framebuffer::resize(uint16 width, uint16 height, uint16 numSamples) {
if (_renderBuffers[i]) {
_renderBuffers[i]._texture->resize2D(width, height, numSamples);
_numSamples = _renderBuffers[i]._texture->getNumSamples();
++_colorStamps[i];
}
}
if (_depthStencilBuffer) {
_depthStencilBuffer._texture->resize2D(width, height, numSamples);
_numSamples = _depthStencilBuffer._texture->getNumSamples();
++_depthStamp;
}
_width = width;

View file

@ -127,7 +127,6 @@ void Antialiasing::run(const render::SceneContextPointer& sceneContext, const re
// FXAA step
getAntialiasingPipeline();
batch.setResourceTexture(0, framebufferCache->getLightingTexture());
// _antialiasingBuffer->setRenderBuffer(0, _antialiasingTexture);
batch.setFramebuffer(_antialiasingBuffer);
batch.setPipeline(getAntialiasingPipeline());

View file

@ -45,12 +45,7 @@ void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderC
}
void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
quint64 msecsElapsed = _cpuTimer.restart();
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
DependencyManager::get<DeferredLightingEffect>()->render(renderContext);
config->setCPUTiming(_cpuTimer.elapsed());
}
RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
@ -181,8 +176,6 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
assert(renderContext->args);
assert(renderContext->args->_viewFrustum);
quint64 msecsElapsed = _cpuTimer.restart();
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
RenderArgs* args = renderContext->args;
@ -204,9 +197,7 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
args->_batch = nullptr;
});
msecsElapsed = _cpuTimer.elapsed();
config->setNumDrawn((int)inItems.size());
config->setCPUTiming(msecsElapsed);
}
DrawOverlay3D::DrawOverlay3D(bool opaque) :
@ -221,7 +212,6 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
config->setNumDrawn((int)inItems.size());
emit config->numDrawnChanged();

View file

@ -31,45 +31,23 @@ public:
using JobModel = render::Job::Model<PrepareDeferred>;
};
class RenderDeferredConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(quint64 cpuTiming READ getCPUTiming NOTIFY dirty)
public:
quint64 getCPUTiming() { return _cpuTiming; }
void setCPUTiming(quint64 timing) { _cpuTiming = timing; emit dirty(); }
signals:
void dirty();
protected:
int _cpuTiming{ 0 };
};
class RenderDeferred {
public:
using Config = RenderDeferredConfig;
using JobModel = render::Job::Model<RenderDeferred, RenderDeferredConfig>;
void configure(const Config& config) {}
using JobModel = render::Job::Model<RenderDeferred>;
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
QElapsedTimer _cpuTimer;
};
class DrawConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged)
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
Q_PROPERTY(quint64 cpuTiming READ getCPUTiming NOTIFY numDrawnChanged)
public:
int getNumDrawn() { return _numDrawn; }
void setNumDrawn(int num) { _numDrawn = num; emit numDrawnChanged(); }
quint64 getCPUTiming() { return _cpuTiming; }
void setCPUTiming(quint64 timing) { _cpuTiming = timing; emit numDrawnChanged(); }
int maxDrawn{ -1 };
@ -79,7 +57,6 @@ signals:
protected:
int _numDrawn{ 0 };
int _cpuTiming{ 0 };
};
class DrawDeferred {
@ -95,7 +72,6 @@ public:
protected:
render::ShapePlumberPointer _shapePlumber;
int _maxDrawn; // initialized by Config
QElapsedTimer _cpuTimer;
};
class DrawStencilDeferred {

View file

@ -127,6 +127,10 @@ 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 dirty())
quint64 _CPURunTime{ 0 };
public:
using Persistent = PersistentConfig<JobConfig>;
@ -151,11 +155,16 @@ public:
Q_INVOKABLE QString toJSON() { return QJsonDocument(toJsonValue(*this).toObject()).toJson(QJsonDocument::Compact); }
Q_INVOKABLE void load(const QVariantMap& map) { qObjectFromJsonValue(QJsonObject::fromVariantMap(map), *this); emit loaded(); }
// Running Time measurement
void setCPURunTime(quint64 ustime) { _CPURunTime = ustime; }
quint64 getCPUTRunTime() const { return _CPURunTime; }
public slots:
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
signals:
void loaded();
void dirty();
};
class TaskConfig : public JobConfig {
@ -223,7 +232,10 @@ public:
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
protected:
void setCPURunTime(quint64 ustime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(ustime); }
QConfigPointer _config;
friend class Job;
};
using ConceptPointer = std::shared_ptr<Concept>;
@ -254,6 +266,7 @@ public:
renderContext->jobConfig = std::static_pointer_cast<Config>(_config);
if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
jobRun(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>());
}
renderContext->jobConfig.reset();
}
@ -278,8 +291,11 @@ public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
PerformanceTimer perfTimer(_name.c_str());
PROFILE_RANGE(_name.c_str());
auto start = usecTimestampNow();
_concept->run(sceneContext, renderContext);
_concept->setCPURunTime(usecTimestampNow() - start);
}
protected:

View file

@ -147,3 +147,4 @@ void PerformanceTimer::dumpAllTimerRecords() {
<< "usecs over" << i.value().getCount() << "calls";
}
}

View file

@ -78,7 +78,7 @@ public:
PerformanceTimer(const QString& name);
~PerformanceTimer();
static bool isActive();
static void setActive(bool active);