mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Exposing the gpu RangeTimer counter for the AO effect
This commit is contained in:
parent
10de1ac9b5
commit
93c7c182b3
9 changed files with 42 additions and 13 deletions
|
@ -104,12 +104,12 @@ panel.newSlider("Tone Mapping Exposure", -10, 10,
|
|||
panel.newSlider("Ambient Occlusion Radius", 0.0, 2.0,
|
||||
function (value) { Render.ambientOcclusion.radius = value; },
|
||||
function() { return Render.ambientOcclusion.radius; },
|
||||
function (value) { return (value); });
|
||||
function (value) { return (value.toFixed(2)); });
|
||||
|
||||
panel.newSlider("Ambient Occlusion Level", 0.0, 1.0,
|
||||
function (value) { Render.ambientOcclusion.level = value; },
|
||||
function() { return Render.ambientOcclusion.level; },
|
||||
function (value) { return (value); });
|
||||
function (value) { return (value.toFixed(2)); });
|
||||
|
||||
panel.newSlider("Ambient Occlusion Num Samples", 1, 32,
|
||||
function (value) { Render.ambientOcclusion.numSamples = value; },
|
||||
|
@ -119,7 +119,7 @@ panel.newSlider("Ambient Occlusion Num Samples", 1, 32,
|
|||
panel.newSlider("Ambient Occlusion Num Spiral Turns", 0.0, 30.0,
|
||||
function (value) { Render.ambientOcclusion.numSpiralTurns = value; },
|
||||
function() { return Render.ambientOcclusion.numSpiralTurns; },
|
||||
function (value) { return (value); });
|
||||
function (value) { return (value.toFixed(2)); });
|
||||
|
||||
panel.newCheckbox("Ambient Occlusion Dithering",
|
||||
function (value) { Render.ambientOcclusion.ditheringEnabled = value; },
|
||||
|
@ -129,7 +129,7 @@ panel.newCheckbox("Ambient Occlusion Dithering",
|
|||
panel.newSlider("Ambient Occlusion Edge Sharpness", 0.0, 1.0,
|
||||
function (value) { Render.ambientOcclusion.edgeSharpness = value; },
|
||||
function() { return Render.ambientOcclusion.edgeSharpness; },
|
||||
function (value) { return (value); });
|
||||
function (value) { return (value.toFixed(2)); });
|
||||
|
||||
panel.newSlider("Ambient Occlusion Blur Radius", 0.0, 6.0,
|
||||
function (value) { Render.ambientOcclusion.blurRadius = value; },
|
||||
|
@ -139,7 +139,14 @@ panel.newSlider("Ambient Occlusion Blur Radius", 0.0, 6.0,
|
|||
panel.newSlider("Ambient Occlusion Blur Deviation", 0.0, 3.0,
|
||||
function (value) { Render.ambientOcclusion.blurDeviation = value; },
|
||||
function() { return Render.ambientOcclusion.blurDeviation; },
|
||||
function (value) { return (value); });
|
||||
function (value) { return (value.toFixed(2)); });
|
||||
|
||||
|
||||
panel.newSlider("Ambient Occlusion GPU time", 0.0, 10.0,
|
||||
function (value) {},
|
||||
function() { return Render.ambientOcclusion.gpuTime; },
|
||||
function (value) { return (value.toFixed(2) + " ms"); });
|
||||
|
||||
|
||||
var tickTackPeriod = 500;
|
||||
|
||||
|
@ -147,6 +154,7 @@ function updateCounters() {
|
|||
opaquesCounter.update();
|
||||
transparentsCounter.update();
|
||||
overlaysCounter.update();
|
||||
panel.update("Ambient Occlusion GPU time");
|
||||
}
|
||||
Script.setInterval(updateCounters, tickTackPeriod);
|
||||
|
||||
|
|
|
@ -3853,6 +3853,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
|||
|
||||
auto engineContext = _renderEngine->getRenderContext();
|
||||
renderInterface->setItemCounts(engineContext->getItemsConfig());
|
||||
renderInterface->setJobGPUTimes(engineContext->getAmbientOcclusion().gpuTime);
|
||||
|
||||
}
|
||||
|
||||
activeRenderingThread = nullptr;
|
||||
|
|
|
@ -36,7 +36,7 @@ void Query::triggerReturnHandler(uint64_t queryResult) {
|
|||
}
|
||||
|
||||
|
||||
Timer::Timer() {
|
||||
RangeTimer::RangeTimer() {
|
||||
for (int i = 0; i < QUERY_QUEUE_SIZE; i++) {
|
||||
_timerQueries.push_back(std::make_shared<gpu::Query>([&, i] (const Query& query) {
|
||||
_tailIndex ++;
|
||||
|
@ -46,11 +46,11 @@ Timer::Timer() {
|
|||
}
|
||||
}
|
||||
|
||||
void Timer::begin(gpu::Batch& batch) {
|
||||
void RangeTimer::begin(gpu::Batch& batch) {
|
||||
_headIndex++;
|
||||
batch.beginQuery(_timerQueries[rangeIndex(_headIndex)]);
|
||||
}
|
||||
void Timer::end(gpu::Batch& batch) {
|
||||
void RangeTimer::end(gpu::Batch& batch) {
|
||||
if (_headIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -65,3 +65,7 @@ void Timer::end(gpu::Batch& batch) {
|
|||
batch.getQuery(_timerQueries[rangeIndex(_tailIndex)]);
|
||||
}
|
||||
}
|
||||
|
||||
double RangeTimer::getAverage() const {
|
||||
return _movingAverage.average;
|
||||
}
|
|
@ -44,12 +44,12 @@ namespace gpu {
|
|||
typedef std::vector< QueryPointer > Queries;
|
||||
|
||||
|
||||
// gpu timer is just returning an estimate of the time taken by a chunck of work delimited by the
|
||||
// gpu RangeTimer is just returning an estimate of the time taken by a chunck of work delimited by the
|
||||
// begin and end calls repeated for several times.
|
||||
// The result is always a late average of the time spent for that same task a few cycles ago.
|
||||
class Timer {
|
||||
class RangeTimer {
|
||||
public:
|
||||
Timer();
|
||||
RangeTimer();
|
||||
void begin(gpu::Batch& batch);
|
||||
void end(gpu::Batch& batch);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
float getBlurDeviation() const { return _parametersBuffer.get<Parameters>()._blurInfo.z; }
|
||||
|
||||
|
||||
double getTimerAverage() const { return _gpuTimer.getAverage(); }
|
||||
double getGPUTime() const { return _gpuTimer.getAverage(); }
|
||||
|
||||
using JobModel = render::Task::Job::Model<AmbientOcclusionEffect>;
|
||||
|
||||
|
@ -113,7 +113,7 @@ private:
|
|||
gpu::PipelinePointer _hBlurPipeline;
|
||||
gpu::PipelinePointer _vBlurPipeline;
|
||||
|
||||
gpu::Timer _gpuTimer;
|
||||
gpu::RangeTimer _gpuTimer;
|
||||
};
|
||||
|
||||
#endif // hifi_AmbientOcclusionEffect_h
|
||||
|
|
|
@ -202,6 +202,11 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
|
|||
job.run(sceneContext, renderContext);
|
||||
}
|
||||
|
||||
if (_occlusionJobIndex >= 0 && renderContext->getOcclusionStatus()) {
|
||||
renderContext->getAmbientOcclusion().gpuTime = _jobs[_occlusionJobIndex].edit<AmbientOcclusionEffect>().getGPUTime();
|
||||
} else {
|
||||
renderContext->getAmbientOcclusion().gpuTime = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
void DrawOpaqueDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems) {
|
||||
|
|
|
@ -49,4 +49,8 @@ void RenderScriptingInterface::setItemCounts(const render::RenderContext::ItemsC
|
|||
_opaque->setCounts(items.opaque);
|
||||
_transparent->setCounts(items.transparent);
|
||||
_overlay3D->setCounts(items.overlay3D);
|
||||
}
|
||||
|
||||
void RenderScriptingInterface::setJobGPUTimes(double aoTime) {
|
||||
_ambientOcclusion->gpuTime = aoTime;
|
||||
}
|
|
@ -78,6 +78,7 @@ namespace RenderScripting {
|
|||
Q_PROPERTY(float edgeSharpness MEMBER edgeSharpness)
|
||||
Q_PROPERTY(int blurRadius MEMBER blurRadius)
|
||||
Q_PROPERTY(float blurDeviation MEMBER blurDeviation)
|
||||
Q_PROPERTY(double gpuTime MEMBER gpuTime)
|
||||
};
|
||||
using AmbientOcclusionPointer = std::unique_ptr<AmbientOcclusion>;
|
||||
};
|
||||
|
@ -103,6 +104,9 @@ class RenderScriptingInterface : public QObject, public Dependency {
|
|||
render::RenderContext getRenderContext();
|
||||
void setItemCounts(const render::RenderContext::ItemsConfig& items);
|
||||
|
||||
// FIXME: It is ugly, we need a cleaner solution
|
||||
void setJobGPUTimes(double aoTime);
|
||||
|
||||
protected:
|
||||
RenderScriptingInterface();
|
||||
~RenderScriptingInterface() {};
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
float edgeSharpness = 1.0f;
|
||||
int blurRadius = 3;
|
||||
float blurDeviation = 2.1f;
|
||||
|
||||
double gpuTime = 0.0;
|
||||
};
|
||||
|
||||
RenderContext(ItemsConfig items, Tone tone, AmbientOcclusion ao, int drawStatus, bool drawHitEffect, glm::vec4 deferredDebugSize, int deferredDebugMode);
|
||||
|
|
Loading…
Reference in a new issue