diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index aed360823d..c92ebbeec0 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -115,6 +115,8 @@ RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) { skinProgram, state); } + const auto cachedMode = addJob("Setup"); + // CPU jobs: // Fetch and cull the items from the scene auto shadowFilter = ItemFilter::Builder::visibleWorldItems().withTypeShape().withOpaque().withoutLayered(); @@ -127,6 +129,8 @@ RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) { // GPU jobs: Render to shadow map addJob("RenderShadowMap", sortedShapes, shapePlumber); + + addJob("Teardown", cachedMode); } void RenderShadowTask::configure(const Config& configuration) { @@ -144,16 +148,18 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render return; } + for (auto job : _jobs) { + job.run(sceneContext, renderContext); + } +} + +void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) { auto lightStage = DependencyManager::get()->getLightStage(); const auto globalShadow = lightStage->getShadow(0); - // If the global light is not set, bail - if (!globalShadow) { - return; - } - // Cache old render args - RenderArgs::RenderMode mode = args->_renderMode; + RenderArgs* args = renderContext->args; + output = args->_renderMode; auto nearClip = args->getViewFrustum().getNearClip(); float nearDepth = -args->_boomOffset.z; @@ -163,14 +169,12 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render // Set the keylight render args args->pushViewFrustum(*(globalShadow->getFrustum())); args->_renderMode = RenderArgs::SHADOW_RENDER_MODE; +} - // TODO: Allow runtime manipulation of culling ShouldRenderFunctor - - for (auto job : _jobs) { - job.run(sceneContext, renderContext); - } +void RenderShadowTeardown::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Input& input) { + RenderArgs* args = renderContext->args; // Reset the render args args->popViewFrustum(); - args->_renderMode = mode; + args->_renderMode = input; }; diff --git a/libraries/render-utils/src/RenderShadowTask.h b/libraries/render-utils/src/RenderShadowTask.h index 4a6ff1b0e9..8405f10c2a 100644 --- a/libraries/render-utils/src/RenderShadowTask.h +++ b/libraries/render-utils/src/RenderShadowTask.h @@ -52,4 +52,18 @@ public: void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); }; +class RenderShadowSetup { +public: + using Output = RenderArgs::RenderMode; + using JobModel = render::Job::ModelO; + void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output); +}; + +class RenderShadowTeardown { +public: + using Input = RenderArgs::RenderMode; + using JobModel = render::Job::ModelI; + void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, const Input& input); +}; + #endif // hifi_RenderShadowTask_h