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