mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Clean up task construction
This commit is contained in:
parent
ed5c53f23c
commit
82f7ea515d
3 changed files with 36 additions and 60 deletions
|
@ -77,30 +77,28 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
|
ShapePlumberPointer shapePlumber = std::make_shared<ShapePlumber>();
|
||||||
initDeferredPipelines(*shapePlumber);
|
initDeferredPipelines(*shapePlumber);
|
||||||
|
|
||||||
// CPU only, create the list of renderedOpaques items
|
// CPU: Fetch the renderOpaques
|
||||||
addJob<FetchItems>("FetchOpaque", FetchItems([](const RenderContextPointer& context, int count) {
|
const auto fetchedOpaques = addJob<FetchItems>("FetchOpaque", FetchItems([](const RenderContextPointer& context, int count) {
|
||||||
context->getItemsConfig().opaque.numFeed = count;
|
context->getItemsConfig().opaque.numFeed = count;
|
||||||
}));
|
}));
|
||||||
addJob<CullItems<RenderDetails::OPAQUE_ITEM>>("CullOpaque", _jobs.back().getOutput());
|
const auto culledOpaques = addJob<CullItems<RenderDetails::OPAQUE_ITEM>>("CullOpaque", fetchedOpaques);
|
||||||
addJob<DepthSortItems>("DepthSortOpaque", _jobs.back().getOutput());
|
const auto opaques = addJob<DepthSortItems>("DepthSortOpaque", culledOpaques);
|
||||||
auto& renderedOpaques = _jobs.back().getOutput();
|
|
||||||
|
|
||||||
// CPU only, create the list of renderedTransparents items
|
// CPU only, create the list of renderedTransparents items
|
||||||
addJob<FetchItems>("FetchTransparent", FetchItems(
|
const auto fetchedTransparents = addJob<FetchItems>("FetchTransparent", FetchItems(
|
||||||
ItemFilter::Builder::transparentShape().withoutLayered(),
|
ItemFilter::Builder::transparentShape().withoutLayered(),
|
||||||
[](const RenderContextPointer& context, int count) {
|
[](const RenderContextPointer& context, int count) {
|
||||||
context->getItemsConfig().transparent.numFeed = count;
|
context->getItemsConfig().transparent.numFeed = count;
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addJob<CullItems<RenderDetails::TRANSLUCENT_ITEM>>("CullTransparent", _jobs.back().getOutput());
|
const auto culledTransparents = addJob<CullItems<RenderDetails::TRANSLUCENT_ITEM>>("CullTransparent", fetchedTransparents);
|
||||||
addJob<DepthSortItems>("DepthSortTransparent", _jobs.back().getOutput(), DepthSortItems(false));
|
const auto transparents = addJob<DepthSortItems>("DepthSortTransparent", culledTransparents, DepthSortItems(false));
|
||||||
auto& renderedTransparents = _jobs.back().getOutput();
|
|
||||||
|
|
||||||
// GPU Jobs: Start preparing the deferred and lighting buffer
|
// GPU Jobs: Start preparing the deferred and lighting buffer
|
||||||
addJob<PrepareDeferred>("PrepareDeferred");
|
addJob<PrepareDeferred>("PrepareDeferred");
|
||||||
|
|
||||||
// Render opaque objects in DeferredBuffer
|
// Render opaque objects in DeferredBuffer
|
||||||
addJob<DrawOpaqueDeferred>("DrawOpaqueDeferred", renderedOpaques, shapePlumber);
|
addJob<DrawOpaqueDeferred>("DrawOpaqueDeferred", opaques, shapePlumber);
|
||||||
|
|
||||||
// Once opaque is all rendered create stencil background
|
// Once opaque is all rendered create stencil background
|
||||||
addJob<DrawStencilDeferred>("DrawOpaqueStencil");
|
addJob<DrawStencilDeferred>("DrawOpaqueStencil");
|
||||||
|
@ -116,16 +114,16 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
|
|
||||||
// AO job, to be revisited
|
// AO job, to be revisited
|
||||||
addJob<AmbientOcclusion>("AmbientOcclusion");
|
addJob<AmbientOcclusion>("AmbientOcclusion");
|
||||||
_jobs.back().setEnabled(false);
|
|
||||||
_occlusionJobIndex = (int)_jobs.size() - 1;
|
_occlusionJobIndex = (int)_jobs.size() - 1;
|
||||||
|
enableJob(_occlusionJobIndex, false);
|
||||||
|
|
||||||
// AA job to be revisited
|
// AA job to be revisited
|
||||||
addJob<Antialiasing>("Antialiasing");
|
addJob<Antialiasing>("Antialiasing");
|
||||||
_jobs.back().setEnabled(false);
|
|
||||||
_antialiasingJobIndex = (int)_jobs.size() - 1;
|
_antialiasingJobIndex = (int)_jobs.size() - 1;
|
||||||
|
enableJob(_antialiasingJobIndex, false);
|
||||||
|
|
||||||
// Render transparent objects forward in LigthingBuffer
|
// Render transparent objects forward in LigthingBuffer
|
||||||
addJob<DrawTransparentDeferred>("DrawTransparentDeferred", renderedTransparents, shapePlumber);
|
addJob<DrawTransparentDeferred>("DrawTransparentDeferred", transparents, shapePlumber);
|
||||||
|
|
||||||
// Lighting Buffer ready for tone mapping
|
// Lighting Buffer ready for tone mapping
|
||||||
addJob<ToneMappingDeferred>("ToneMapping");
|
addJob<ToneMappingDeferred>("ToneMapping");
|
||||||
|
@ -133,24 +131,24 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
|
|
||||||
// Debugging Deferred buffer job
|
// Debugging Deferred buffer job
|
||||||
addJob<DebugDeferredBuffer>("DebugDeferredBuffer");
|
addJob<DebugDeferredBuffer>("DebugDeferredBuffer");
|
||||||
_jobs.back().setEnabled(false);
|
|
||||||
_drawDebugDeferredBufferIndex = (int)_jobs.size() - 1;
|
_drawDebugDeferredBufferIndex = (int)_jobs.size() - 1;
|
||||||
|
enableJob(_drawDebugDeferredBufferIndex, false);
|
||||||
|
|
||||||
// Status icon rendering job
|
// Status icon rendering job
|
||||||
{
|
{
|
||||||
// Grab a texture map representing the different status icons and assign that to the drawStatsuJob
|
// Grab a texture map representing the different status icons and assign that to the drawStatsuJob
|
||||||
auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
|
auto iconMapPath = PathUtils::resourcesPath() + "icons/statusIconAtlas.svg";
|
||||||
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
||||||
addJob<DrawStatus>("DrawStatus", renderedOpaques, DrawStatus(statusIconMap));
|
addJob<DrawStatus>("DrawStatus", opaques, DrawStatus(statusIconMap));
|
||||||
_jobs.back().setEnabled(false);
|
|
||||||
_drawStatusJobIndex = (int)_jobs.size() - 1;
|
_drawStatusJobIndex = (int)_jobs.size() - 1;
|
||||||
|
enableJob(_drawStatusJobIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
addJob<DrawOverlay3D>("DrawOverlay3D", shapePlumber);
|
addJob<DrawOverlay3D>("DrawOverlay3D", shapePlumber);
|
||||||
|
|
||||||
addJob<HitEffect>("HitEffect");
|
addJob<HitEffect>("HitEffect");
|
||||||
_jobs.back().setEnabled(false);
|
|
||||||
_drawHitEffectJobIndex = (int)_jobs.size() -1;
|
_drawHitEffectJobIndex = (int)_jobs.size() -1;
|
||||||
|
enableJob(_drawHitEffectJobIndex, false);
|
||||||
|
|
||||||
addJob<Blit>("Blit");
|
addJob<Blit>("Blit");
|
||||||
}
|
}
|
||||||
|
@ -168,21 +166,12 @@ void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const Rend
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we turn the deferred buffer debug on/off
|
|
||||||
setDrawDebugDeferredBuffer(renderContext->_deferredDebugMode);
|
setDrawDebugDeferredBuffer(renderContext->_deferredDebugMode);
|
||||||
|
|
||||||
// Make sure we turn the displayItemStatus on/off
|
|
||||||
setDrawItemStatus(renderContext->getDrawStatus());
|
setDrawItemStatus(renderContext->getDrawStatus());
|
||||||
|
|
||||||
// Make sure we display hit effect on screen, as desired from a script
|
|
||||||
setDrawHitEffect(renderContext->getDrawHitEffect());
|
setDrawHitEffect(renderContext->getDrawHitEffect());
|
||||||
|
|
||||||
|
|
||||||
// TODO: turn on/off AO through menu item
|
// TODO: turn on/off AO through menu item
|
||||||
setOcclusionStatus(renderContext->getOcclusionStatus());
|
setOcclusionStatus(renderContext->getOcclusionStatus());
|
||||||
|
|
||||||
setAntialiasingStatus(renderContext->getFxaaStatus());
|
setAntialiasingStatus(renderContext->getFxaaStatus());
|
||||||
|
|
||||||
setToneMappingExposure(renderContext->getTone().exposure);
|
setToneMappingExposure(renderContext->getTone().exposure);
|
||||||
setToneMappingToneCurve(renderContext->getTone().toneCurve);
|
setToneMappingToneCurve(renderContext->getTone().toneCurve);
|
||||||
|
|
||||||
|
|
|
@ -113,41 +113,32 @@ public:
|
||||||
|
|
||||||
class RenderDeferredTask : public render::Task {
|
class RenderDeferredTask : public render::Task {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderDeferredTask();
|
RenderDeferredTask();
|
||||||
|
|
||||||
int _drawDebugDeferredBufferIndex = -1;
|
int _drawDebugDeferredBufferIndex;
|
||||||
int _drawStatusJobIndex = -1;
|
int _drawStatusJobIndex;
|
||||||
int _drawHitEffectJobIndex = -1;
|
int _drawHitEffectJobIndex;
|
||||||
|
int _occlusionJobIndex;
|
||||||
|
int _antialiasingJobIndex;
|
||||||
|
int _toneMappingJobIndex;
|
||||||
|
|
||||||
void setDrawDebugDeferredBuffer(int draw) {
|
void setDrawDebugDeferredBuffer(int draw) { enableJob(_drawDebugDeferredBufferIndex, draw >= 0); }
|
||||||
if (_drawDebugDeferredBufferIndex >= 0) {
|
bool doDrawDebugDeferredBuffer() const { return getEnableJob(_drawDebugDeferredBufferIndex); }
|
||||||
_jobs[_drawDebugDeferredBufferIndex].setEnabled(draw >= 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool doDrawDebugDeferredBuffer() const { if (_drawDebugDeferredBufferIndex >= 0) { return _jobs[_drawDebugDeferredBufferIndex].isEnabled(); } else { return false; } }
|
|
||||||
|
|
||||||
void setDrawItemStatus(int draw) {
|
void setDrawItemStatus(int draw) { enableJob(_drawStatusJobIndex, draw > 0); }
|
||||||
if (_drawStatusJobIndex >= 0) {
|
bool doDrawItemStatus() const { return getEnableJob(_drawStatusJobIndex); }
|
||||||
_jobs[_drawStatusJobIndex].setEnabled(draw > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool doDrawItemStatus() const { if (_drawStatusJobIndex >= 0) { return _jobs[_drawStatusJobIndex].isEnabled(); } else { return false; } }
|
|
||||||
|
|
||||||
void setDrawHitEffect(bool draw) { if (_drawHitEffectJobIndex >= 0) { _jobs[_drawHitEffectJobIndex].setEnabled(draw); } }
|
void setDrawHitEffect(bool draw) { enableJob(_drawHitEffectJobIndex, draw); }
|
||||||
bool doDrawHitEffect() const { if (_drawHitEffectJobIndex >=0) { return _jobs[_drawHitEffectJobIndex].isEnabled(); } else { return false; } }
|
bool doDrawHitEffect() const { return getEnableJob(_drawHitEffectJobIndex); }
|
||||||
|
|
||||||
int _occlusionJobIndex = -1;
|
|
||||||
|
|
||||||
void setOcclusionStatus(bool draw) { if (_occlusionJobIndex >= 0) { _jobs[_occlusionJobIndex].setEnabled(draw); } }
|
void setOcclusionStatus(bool draw) { enableJob(_occlusionJobIndex, draw); }
|
||||||
bool doOcclusionStatus() const { if (_occlusionJobIndex >= 0) { return _jobs[_occlusionJobIndex].isEnabled(); } else { return false; } }
|
bool doOcclusionStatus() const { return getEnableJob(_occlusionJobIndex); }
|
||||||
|
|
||||||
int _antialiasingJobIndex = -1;
|
|
||||||
|
|
||||||
void setAntialiasingStatus(bool draw) { if (_antialiasingJobIndex >= 0) { _jobs[_antialiasingJobIndex].setEnabled(draw); } }
|
void setAntialiasingStatus(bool draw) { enableJob(_antialiasingJobIndex, draw); }
|
||||||
bool doAntialiasingStatus() const { if (_antialiasingJobIndex >= 0) { return _jobs[_antialiasingJobIndex].isEnabled(); } else { return false; } }
|
bool doAntialiasingStatus() const { return getEnableJob(_antialiasingJobIndex); }
|
||||||
|
|
||||||
int _toneMappingJobIndex = -1;
|
|
||||||
|
|
||||||
void setToneMappingExposure(float exposure);
|
void setToneMappingExposure(float exposure);
|
||||||
float getToneMappingExposure() const;
|
float getToneMappingExposure() const;
|
||||||
|
@ -156,11 +147,6 @@ public:
|
||||||
int getToneMappingToneCurve() const;
|
int getToneMappingToneCurve() const;
|
||||||
|
|
||||||
virtual void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
virtual void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
|
|
||||||
gpu::Queries _timerQueries;
|
|
||||||
int _currentTimerQueryIndex = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // hifi_RenderDeferredTask_h
|
#endif // hifi_RenderDeferredTask_h
|
||||||
|
|
|
@ -207,12 +207,13 @@ public:
|
||||||
virtual ~Task() = default;
|
virtual ~Task() = default;
|
||||||
|
|
||||||
// Queue a new job to the task; returns the job's index
|
// Queue a new job to the task; returns the job's index
|
||||||
template <class T, class... A> size_t addJob(std::string name, A&&... args) {
|
template <class T, class... A> const Varying addJob(std::string name, A&&... args) {
|
||||||
_jobs.emplace_back(name, std::make_shared<typename T::JobModel>(std::forward<A>(args)...));
|
_jobs.emplace_back(name, std::make_shared<typename T::JobModel>(std::forward<A>(args)...));
|
||||||
return _jobs.size() - 1;
|
return _jobs.back().getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Job& getJob(size_t i) const { return _jobs.at(i); }
|
void enableJob(size_t jobIndex, bool enable = true) { _jobs.at(jobIndex).setEnabled(enable); }
|
||||||
|
bool getEnableJob(size_t jobIndex) const { return _jobs.at(jobIndex).isEnabled(); }
|
||||||
|
|
||||||
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {}
|
virtual void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue