mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #7704 from samcake/lemon
Exposing the CPU TIming of the Render Jobs to the JS API
This commit is contained in:
commit
a572ac31dc
6 changed files with 65 additions and 12 deletions
|
@ -39,6 +39,7 @@ Column {
|
|||
"Shadow",
|
||||
"Pyramid Depth",
|
||||
"Ambient Occlusion",
|
||||
"Ambient Occlusion Blurred",
|
||||
"Custom Shader"
|
||||
]
|
||||
RadioButton {
|
||||
|
|
|
@ -178,9 +178,10 @@ Item {
|
|||
title: "Items"
|
||||
height: parent.evalEvenHeight()
|
||||
object: parent.drawOpaqueConfig
|
||||
|
||||
plots: [
|
||||
{
|
||||
object: Render.getConfig("DrawOpaqueDeferred"),
|
||||
object: parent.drawOpaqueConfig,
|
||||
prop: "numDrawn",
|
||||
label: "Opaques",
|
||||
color: "#1AC567"
|
||||
|
@ -198,7 +199,42 @@ Item {
|
|||
color: "#FED959"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
|
|||
|
||||
// Specular highlight from ambient
|
||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
||||
|
||||
float levels = getLightAmbientMapNumMips(light);
|
||||
float lod = min(floor((roughness) * levels), levels);
|
||||
vec4 skyboxLight = evalSkyboxLight(direction, lod);
|
||||
|
|
|
@ -185,9 +185,6 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
|
|||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
||||
config->setNumDrawn((int)inItems.size());
|
||||
emit config->numDrawnChanged();
|
||||
|
||||
glm::mat4 projMat;
|
||||
Transform viewMat;
|
||||
args->_viewFrustum->evalProjectionMatrix(projMat);
|
||||
|
@ -199,6 +196,8 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
|
|||
renderShapes(sceneContext, renderContext, _shapePlumber, inItems, _maxDrawn);
|
||||
args->_batch = nullptr;
|
||||
});
|
||||
|
||||
config->setNumDrawn((int)inItems.size());
|
||||
}
|
||||
|
||||
DrawOverlay3D::DrawOverlay3D(bool opaque) :
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
using JobModel = render::Job::Model<SetupDeferred>;
|
||||
};
|
||||
|
||||
|
||||
class PrepareDeferred {
|
||||
public:
|
||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||
|
@ -29,32 +30,31 @@ public:
|
|||
using JobModel = render::Job::Model<PrepareDeferred>;
|
||||
};
|
||||
|
||||
|
||||
class RenderDeferred {
|
||||
public:
|
||||
using JobModel = render::Job::Model<RenderDeferred>;
|
||||
|
||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||
|
||||
};
|
||||
|
||||
class DrawConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY numDrawnChanged)
|
||||
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY newStats)
|
||||
|
||||
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
|
||||
public:
|
||||
|
||||
int getNumDrawn() { return numDrawn; }
|
||||
void setNumDrawn(int num) { numDrawn = num; emit numDrawnChanged(); }
|
||||
int getNumDrawn() { return _numDrawn; }
|
||||
void setNumDrawn(int numDrawn) { _numDrawn = numDrawn; emit newStats(); }
|
||||
|
||||
int maxDrawn{ -1 };
|
||||
|
||||
signals:
|
||||
void numDrawnChanged();
|
||||
void newStats();
|
||||
void dirty();
|
||||
|
||||
protected:
|
||||
int numDrawn{ 0 };
|
||||
int _numDrawn{ 0 };
|
||||
};
|
||||
|
||||
class DrawDeferred {
|
||||
|
|
|
@ -127,6 +127,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())
|
||||
|
||||
quint64 _CPURunTime{ 0 };
|
||||
public:
|
||||
using Persistent = PersistentConfig<JobConfig>;
|
||||
|
||||
|
@ -151,11 +154,17 @@ 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
|
||||
// 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:
|
||||
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
|
||||
|
||||
signals:
|
||||
void loaded();
|
||||
void newStats();
|
||||
};
|
||||
|
||||
class TaskConfig : public JobConfig {
|
||||
|
@ -223,7 +232,11 @@ 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>;
|
||||
|
||||
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue