Unified · Split
| @@ -228,26 +228,6 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { · 227 unmodified lines | |||
| 228 | 228 | ||
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { | ||
| 232 | // sanity checks | ||
| 233 | assert(sceneContext); | ||
| 234 | if (!sceneContext->_scene) { | ||
| 235 | return; | ||
| 236 | } | ||
| 237 | |||
| 238 | |||
| 239 | // Is it possible that we render without a viewFrustum ? | ||
| 240 | if (!(renderContext->args && renderContext->args->hasViewFrustum())) { | ||
| 241 | return; | ||
| 242 | } | ||
| 243 | |||
| 244 | auto config = std::static_pointer_cast<Config>(renderContext->jobConfig); | ||
| 245 | |||
| 246 | for (auto job : _jobs) { | ||
| 247 | job.run(sceneContext, renderContext); | ||
| 248 | } | ||
| 249 | } | ||
| 250 | |||
| 251 | void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) { | 231 | void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) { |
| 252 | timer = _gpuTimer; | 232 | timer = _gpuTimer; |
| 253 | gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { | 233 | gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) { |
| @@ -200,7 +200,6 @@ public: · 199 unmodified lines | |||
| 200 | RenderDeferredTask(render::CullFunctor cullFunctor); | 200 | RenderDeferredTask(render::CullFunctor cullFunctor); |
| 201 | 201 | ||
| 202 | void configure(const Config& config) {} | 202 | void configure(const Config& config) {} |
| 203 | void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); | ||
| 204 | 203 | ||
| 205 | using JobModel = Model<RenderDeferredTask, Config>; | 204 | using JobModel = Model<RenderDeferredTask, Config>; |
| 206 | 205 | ||
| @@ -86,26 +86,6 @@ RenderForwardTask::RenderForwardTask(CullFunctor cullFunctor) { · 85 unmodified lines | |||
| 86 | addJob<Blit>("Blit", framebuffer); | 86 | addJob<Blit>("Blit", framebuffer); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | void RenderForwardTask::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { | ||
| 90 | // sanity checks | ||
| 91 | assert(sceneContext); | ||
| 92 | if (!sceneContext->_scene) { | ||
| 93 | return; | ||
| 94 | } | ||
| 95 | |||
| 96 | |||
| 97 | // Is it possible that we render without a viewFrustum ? | ||
| 98 | if (!(renderContext->args && renderContext->args->hasViewFrustum())) { | ||
| 99 | return; | ||
| 100 | } | ||
| 101 | |||
| 102 | auto config = std::static_pointer_cast<Config>(renderContext->jobConfig); | ||
| 103 | |||
| 104 | for (auto job : _jobs) { | ||
| 105 | job.run(sceneContext, renderContext); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) { | 89 | void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) { |
| 110 | auto framebufferCache = DependencyManager::get<FramebufferCache>(); | 90 | auto framebufferCache = DependencyManager::get<FramebufferCache>(); |
| 111 | auto framebufferSize = framebufferCache->getFrameBufferSize(); | 91 | auto framebufferSize = framebufferCache->getFrameBufferSize(); |
| @@ -24,7 +24,6 @@ public: · 23 unmodified lines | |||
| 24 | RenderForwardTask(render::CullFunctor cullFunctor); | 24 | RenderForwardTask(render::CullFunctor cullFunctor); |
| 25 | 25 | ||
| 26 | void configure(const Config& config) {} | 26 | void configure(const Config& config) {} |
| 27 | void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); | ||
| 28 | 27 | ||
| 29 | using JobModel = Model<RenderForwardTask, Config>; | 28 | using JobModel = Model<RenderForwardTask, Config>; |
| 30 | }; | 29 | }; |
| @@ -139,20 +139,6 @@ void RenderShadowTask::configure(const Config& configuration) { · 138 unmodified lines | |||
| 139 | Task::configure(configuration); | 139 | Task::configure(configuration); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) { | ||
| 143 | assert(sceneContext); | ||
| 144 | RenderArgs* args = renderContext->args; | ||
| 145 | |||
| 146 | // sanity checks | ||
| 147 | if (!sceneContext->_scene || !args) { | ||
| 148 | return; | ||
| 149 | } | ||
| 150 | |||
| 151 | for (auto job : _jobs) { | ||
| 152 | job.run(sceneContext, renderContext); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) { | 142 | void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) { |
| 157 | auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage(); | 143 | auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage(); |
| 158 | const auto globalShadow = lightStage->getShadow(0); | 144 | const auto globalShadow = lightStage->getShadow(0); |
| @@ -49,7 +49,6 @@ public: · 48 unmodified lines | |||
| 49 | RenderShadowTask(render::CullFunctor shouldRender); | 49 | RenderShadowTask(render::CullFunctor shouldRender); |
| 50 | 50 | ||
| 51 | void configure(const Config& configuration); | 51 | void configure(const Config& configuration); |
| 52 | void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); | ||
| 53 | }; | 52 | }; |
| 54 | 53 | ||
| 55 | class RenderShadowSetup { | 54 | class RenderShadowSetup { |
| @@ -52,11 +52,3 @@ void Engine::load() { · 51 unmodified lines | |||
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | |||
| 56 | void Engine::run() { | ||
| 57 | for (auto job : _jobs) { | ||
| 58 | job.run(_sceneContext, _renderContext); | ||
| 59 | } | ||
| 60 | |||
| 61 | } | ||
| 62 | |||
| @@ -39,8 +39,8 @@ namespace render { · 38 unmodified lines | |||
| 39 | RenderContextPointer getRenderContext() const { return _renderContext; } | 39 | RenderContextPointer getRenderContext() const { return _renderContext; } |
| 40 | 40 | ||
| 41 | // Render a frame | 41 | // Render a frame |
| 42 | // A frame must have a scene registered and a context set to render | 42 | // Must have a scene registered and a context set |
| 43 | void run(); | 43 | void run() { assert(_sceneContext && _renderContext); Task::run(_sceneContext, _renderContext); } |
| 44 | 44 | ||
| 45 | protected: | 45 | protected: |
| 46 | SceneContextPointer _sceneContext; | 46 | SceneContextPointer _sceneContext; |
| @@ -593,22 +593,20 @@ public: · 592 unmodified lines | |||
| 593 | using QConfigPointer = Job::QConfigPointer; | 593 | using QConfigPointer = Job::QConfigPointer; |
| 594 | using None = Job::None; | 594 | using None = Job::None; |
| 595 | 595 | ||
| 596 | template <class T, class C = Config, class I = None, class O = None> class Model : public Job::Concept { | 596 | template <class T, class C = Config, class O = None> class Model : public Job::Concept { |
| 597 | public: | 597 | public: |
| 598 | using Data = T; | 598 | using Data = T; |
| 599 | using Input = I; | 599 | using Input = None; |
| 600 | using Output = O; | 600 | using Output = O; |
| 601 | 601 | ||
| 602 | Data _data; | 602 | Data _data; |
| 603 | Varying _input; | ||
| 604 | Varying _output; | 603 | Varying _output; |
| 605 | 604 | ||
| 606 | const Varying getInput() const override { return _input; } | ||
| 607 | const Varying getOutput() const override { return _output; } | 605 | const Varying getOutput() const override { return _output; } |
| 608 | 606 | ||
| 609 | template <class... A> | 607 | template <class... A> |
| 610 | Model(const Varying& input, A&&... args) : | 608 | Model(const Varying& input, A&&... args) : |
| 611 | Concept(nullptr), _data(Data(std::forward<A>(args)...)), _input(input), _output(Output()) { | 609 | Concept(nullptr), _data(Data(std::forward<A>(args)...)), _output(Output()) { |
| 612 | // Recreate the Config to use the templated type | 610 | // Recreate the Config to use the templated type |
| 613 | _data.template createConfiguration<C>(); | 611 | _data.template createConfiguration<C>(); |
| 614 | _config = _data.getConfiguration(); | 612 | _config = _data.getConfiguration(); |
| @@ -620,16 +618,15 @@ public: · 5 unmodified lines | |||
| 620 | } | 618 | } |
| 621 | 619 | ||
| 622 | void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) override { | 620 | void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) override { |
| 623 | renderContext->jobConfig = std::static_pointer_cast<Config>(_config); | 621 | auto config = std::static_pointer_cast<Config>(_config); |
| 624 | if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) { | 622 | if (config->alwaysEnabled || config->enabled) { |
| 625 | jobRun(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>()); | 623 | for (auto job : _data._jobs) { |
| 624 | job.run(sceneContext, renderContext); | ||
| 625 | } | ||
| 626 | } | 626 | } |
| 627 | renderContext->jobConfig.reset(); | ||
| 628 | } | 627 | } |
| 629 | }; | 628 | }; |
| 630 | template <class T, class I, class C = Config> using ModelI = Model<T, C, I, None>; | 629 | template <class T, class O, class C = Config> using ModelO = Model<T, C, O>; |
| 631 | template <class T, class O, class C = Config> using ModelO = Model<T, C, None, O>; | ||
| 632 | template <class T, class I, class O, class C = Config> using ModelIO = Model<T, C, I, O>; | ||
| 633 | 630 | ||
| 634 | using Jobs = std::vector<Job>; | 631 | using Jobs = std::vector<Job>; |
| 635 | 632 | ||
| @@ -688,8 +685,14 @@ public: · 52 unmodified lines | |||
| 688 | } | 685 | } |
| 689 | } | 686 | } |
| 690 | 687 | ||
| 688 | void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { | ||
| 689 | for (auto job : _jobs) { | ||
| 690 | job.run(sceneContext, renderContext); | ||
| 691 | } | ||
| 692 | } | ||
| 693 | |||
| 691 | protected: | 694 | protected: |
| 692 | template <class T, class C, class I, class O> friend class Model; | 695 | template <class T, class C, class O> friend class Model; |
| 693 | 696 | ||
| 694 | QConfigPointer _config; | 697 | QConfigPointer _config; |
| 695 | Jobs _jobs; | 698 | Jobs _jobs; |