Exposing the timing of the jobs by default

This commit is contained in:
samcake 2016-04-18 14:53:06 -07:00
parent 3887dfdf34
commit ca720efce6
5 changed files with 61 additions and 61 deletions

View file

@ -200,6 +200,41 @@ Item {
} }
] ]
} }
PlotPerf {
title: "Timing"
height: parent.evalEvenHeight()
object: parent.drawOpaqueConfig
valueUnit: "ms"
valueScale: 1000
valueNumDigits: "1"
plots: [
{
object: Render.getConfig("DrawOpaqueDeferred"),
prop: "cpuRunTime",
label: "Opaques",
color: "#1AC567"
},
{
object: Render.getConfig("DrawTransparentDeferred"),
prop: "cpuRunTime",
label: "Translucents",
color: "#00B4EF"
},
{
object: Render.getConfig("RenderDeferred"),
prop: "cpuRunTime",
label: "Lighting",
color: "#FED959"
},
{
object: Render.getConfig("RenderDeferredTask"),
prop: "cpuRunTime",
label: "RenderFrame",
color: "#E2334D"
}
]
}
} }
} }

View file

@ -30,8 +30,7 @@ vec4 evalSkyboxLight(vec3 direction, float lod) {
// Transform directions to worldspace // Transform directions to worldspace
vec3 fragNormal = vec3(invViewMat * vec4(normal, 0.0)); vec3 fragNormal = vec3(invViewMat * vec4(normal, 0.0));
// vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0)); vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0));
vec3 fragEyeVector = vec3(invViewMat * vec4(-normalize(position), 0.0));
vec3 fragEyeDir = normalize(fragEyeVector); vec3 fragEyeDir = normalize(fragEyeVector);
// Get light // Get light
@ -90,32 +89,15 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
color += (1 - metallic) * albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light); color += (1 - metallic) * albedo * evalSphericalLight(getLightAmbientSphere(light), fragNormal).xyz * obscurance * getLightAmbientIntensity(light);
// Specular highlight from ambient // Specular highlight from ambient
//vec3 direction = -reflect(fragEyeDir, fragNormal); vec3 direction = -reflect(fragEyeDir, fragNormal);
// -normalize(position)
vec3 direction = -reflect(-normalize(position), normal);
// vec3 direction = normal;
// if (gl_FragCoord.x > 1000) {
float angleY = fract(asin(direction.y)/ 0.314);
float angleX = fract(acos(normalize(direction.xz).x)/ 0.314);
float stripeY = step(0.05,abs(angleY));
float stripeX = step(0.05,abs(angleX));
float grid = max(stripeY, stripeX);
return mix( 0.5 * direction + vec3(0.5), mix(vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0), stripeY), grid);
// }
float levels = getLightAmbientMapNumMips(light); float levels = getLightAmbientMapNumMips(light);
float lod = min(floor((roughness) * levels), levels); float lod = min(floor((roughness) * levels), levels);
// vec4 skyboxLight = evalSkyboxLight(direction, lod); vec4 skyboxLight = evalSkyboxLight(direction, lod);
vec4 skyboxLight = evalSkyboxLight(direction, levels * 0.5); vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness);
color += ambientFresnel * skyboxLight.rgb * obscurance * getLightAmbientIntensity(light);
return skyboxLight.xyz; return color;
//vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness);
//color += ambientFresnel * skyboxLight.rgb * obscurance * getLightAmbientIntensity(light);
//return color;
} }
<@endfunc@> <@endfunc@>

View file

@ -12,8 +12,6 @@
#include "RenderDeferredTask.h" #include "RenderDeferredTask.h"
#include <QElapsedTimer>
#include <PerfStat.h> #include <PerfStat.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <RenderArgs.h> #include <RenderArgs.h>
@ -47,13 +45,7 @@ void PrepareDeferred::run(const SceneContextPointer& sceneContext, const RenderC
} }
void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
QElapsedTimer cpuTimer;
cpuTimer.start();
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
DependencyManager::get<DeferredLightingEffect>()->render(renderContext); DependencyManager::get<DeferredLightingEffect>()->render(renderContext);
config->setStats(cpuTimer.elapsed());
} }
RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
@ -183,8 +175,6 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) { void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemBounds& inItems) {
assert(renderContext->args); assert(renderContext->args);
assert(renderContext->args->_viewFrustum); assert(renderContext->args->_viewFrustum);
QElapsedTimer cpuTimer;
cpuTimer.start();
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig); auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
@ -207,7 +197,7 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
args->_batch = nullptr; args->_batch = nullptr;
}); });
config->setStats((int)inItems.size(), cpuTimer.elapsed()); config->setNumDrawn((int)inItems.size());
} }
DrawOverlay3D::DrawOverlay3D(bool opaque) : DrawOverlay3D::DrawOverlay3D(bool opaque) :

View file

@ -30,44 +30,22 @@ public:
using JobModel = render::Job::Model<PrepareDeferred>; using JobModel = render::Job::Model<PrepareDeferred>;
}; };
class RenderDeferredConfig : public render::Job::Config {
Q_OBJECT
Q_PROPERTY(quint64 cpuTime READ getCPUTime NOTIFY newStats)
public:
quint64 getCPUTime() { return _cpuTime; }
void setStats(quint64 time) { _cpuTime = time; emit newStats(); }
signals:
void newStats();
protected:
quint64 _cpuTime{ 0 };
};
class RenderDeferred { class RenderDeferred {
public: public:
using Config = RenderDeferredConfig; using JobModel = render::Job::Model<RenderDeferred>;
using JobModel = render::Job::Model<RenderDeferred, Config>;
void configure(const Config& config) {}
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
}; };
class DrawConfig : public render::Job::Config { class DrawConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY newStats) Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY newStats)
Q_PROPERTY(quint64 cpuTime READ getCPUTime NOTIFY newStats)
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
public: public:
int getNumDrawn() { return _numDrawn; } int getNumDrawn() { return _numDrawn; }
double getCPUTime() { return _cpuTime; } void setNumDrawn(int numDrawn) { _numDrawn = numDrawn; emit newStats(); }
void setStats(int numDrawn, quint64 time) { _numDrawn = numDrawn; _cpuTime = time; emit newStats(); }
int maxDrawn{ -1 }; int maxDrawn{ -1 };
@ -76,7 +54,6 @@ signals:
void dirty(); void dirty();
protected: protected:
quint64 _cpuTime{ 0 };
int _numDrawn{ 0 }; int _numDrawn{ 0 };
}; };

View file

@ -127,6 +127,9 @@ protected:
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled) // A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
class JobConfig : public QObject { class JobConfig : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(quint64 cpuRunTime READ getCPUTRunTime NOTIFY newStats())
quint64 _CPURunTime{ 0 };
public: public:
using Persistent = PersistentConfig<JobConfig>; using Persistent = PersistentConfig<JobConfig>;
@ -151,11 +154,17 @@ public:
Q_INVOKABLE QString toJSON() { return QJsonDocument(toJsonValue(*this).toObject()).toJson(QJsonDocument::Compact); } 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(); } Q_INVOKABLE void load(const QVariantMap& map) { qObjectFromJsonValue(QJsonObject::fromVariantMap(map), *this); emit loaded(); }
// 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; }
public slots: public slots:
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); } void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
signals: signals:
void loaded(); void loaded();
void newStats();
}; };
class TaskConfig : public JobConfig { class TaskConfig : public JobConfig {
@ -223,7 +232,11 @@ public:
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0; virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) = 0;
protected: protected:
void setCPURunTime(quint64 ustime) { std::static_pointer_cast<Config>(_config)->setCPURunTime(ustime); }
QConfigPointer _config; QConfigPointer _config;
friend class Job;
}; };
using ConceptPointer = std::shared_ptr<Concept>; using ConceptPointer = std::shared_ptr<Concept>;
@ -278,8 +291,11 @@ public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
PerformanceTimer perfTimer(_name.c_str()); PerformanceTimer perfTimer(_name.c_str());
PROFILE_RANGE(_name.c_str()); PROFILE_RANGE(_name.c_str());
auto start = usecTimestampNow();
_concept->run(sceneContext, renderContext); _concept->run(sceneContext, renderContext);
_concept->setCPURunTime(usecTimestampNow() - start);
} }
protected: protected: