History

templatize graphics engine tasks' run method

Zach Pomerantz committed 9 years ago

Commit 8d630671 parent dbf4f2d9 files · +18 −80Browse files

Unified · Split

9 files
  1. libraries/render-utils/src/RenderDeferredTask.cpp +0 −20
  2. libraries/render-utils/src/RenderDeferredTask.h +0 −1
  3. libraries/render-utils/src/RenderForwardTask.cpp +0 −20
  4. libraries/render-utils/src/RenderForwardTask.h +0 −1
  5. libraries/render-utils/src/RenderShadowTask.cpp +0 −14
  6. libraries/render-utils/src/RenderShadowTask.h +0 −1
  7. libraries/render/src/render/Engine.cpp +0 −8
  8. libraries/render/src/render/Engine.h +2 −2
  9. libraries/render/src/render/Task.h +16 −13
libraries/render-utils/src/RenderDeferredTask.cpp+0−20
@@ -228,26 +228,6 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) { · 227 unmodified lines
228228
229229 }
230230
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−
251231 void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
252232 timer = _gpuTimer;
253233 gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
libraries/render-utils/src/RenderDeferredTask.h+0−1
@@ -200,7 +200,6 @@ public: · 199 unmodified lines
200200 RenderDeferredTask(render::CullFunctor cullFunctor);
201201
202202 void configure(const Config& config) {}
203− void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
204203
205204 using JobModel = Model<RenderDeferredTask, Config>;
206205
libraries/render-utils/src/RenderForwardTask.cpp+0−20
@@ -86,26 +86,6 @@ RenderForwardTask::RenderForwardTask(CullFunctor cullFunctor) { · 85 unmodified lines
8686 addJob<Blit>("Blit", framebuffer);
8787 }
8888
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−
10989 void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
11090 auto framebufferCache = DependencyManager::get<FramebufferCache>();
11191 auto framebufferSize = framebufferCache->getFrameBufferSize();
libraries/render-utils/src/RenderForwardTask.h+0−1
@@ -24,7 +24,6 @@ public: · 23 unmodified lines
2424 RenderForwardTask(render::CullFunctor cullFunctor);
2525
2626 void configure(const Config& config) {}
27− void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
2827
2928 using JobModel = Model<RenderForwardTask, Config>;
3029 };
libraries/render-utils/src/RenderShadowTask.cpp+0−14
@@ -139,20 +139,6 @@ void RenderShadowTask::configure(const Config& configuration) { · 138 unmodified lines
139139 Task::configure(configuration);
140140 }
141141
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−
156142 void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) {
157143 auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
158144 const auto globalShadow = lightStage->getShadow(0);
libraries/render-utils/src/RenderShadowTask.h+0−1
@@ -49,7 +49,6 @@ public: · 48 unmodified lines
4949 RenderShadowTask(render::CullFunctor shouldRender);
5050
5151 void configure(const Config& configuration);
52− void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
5352 };
5453
5554 class RenderShadowSetup {
libraries/render/src/render/Engine.cpp+0−8
@@ -52,11 +52,3 @@ void Engine::load() { · 51 unmodified lines
5252 }
5353 }
5454 }
55−
56−void Engine::run() {
57− for (auto job : _jobs) {
58− job.run(_sceneContext, _renderContext);
59− }
60−
61−}
62−
libraries/render/src/render/Engine.h+2−2
@@ -39,8 +39,8 @@ namespace render { · 38 unmodified lines
3939 RenderContextPointer getRenderContext() const { return _renderContext; }
4040
4141 // Render a frame
42− // A frame must have a scene registered and a context set to render
43− void run();
42+ // Must have a scene registered and a context set
43+ void run() { assert(_sceneContext && _renderContext); Task::run(_sceneContext, _renderContext); }
4444
4545 protected:
4646 SceneContextPointer _sceneContext;
libraries/render/src/render/Task.h+16−13
@@ -593,22 +593,20 @@ public: · 592 unmodified lines
593593 using QConfigPointer = Job::QConfigPointer;
594594 using None = Job::None;
595595
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 {
597597 public:
598598 using Data = T;
599− using Input = I;
599+ using Input = None;
600600 using Output = O;
601601
602602 Data _data;
603− Varying _input;
604603 Varying _output;
605604
606− const Varying getInput() const override { return _input; }
607605 const Varying getOutput() const override { return _output; }
608606
609607 template <class... A>
610608 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()) {
612610 // Recreate the Config to use the templated type
613611 _data.template createConfiguration<C>();
614612 _config = _data.getConfiguration();
@@ -620,16 +618,15 @@ public: · 5 unmodified lines
620618 }
621619
622620 void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) override {
623− renderContext->jobConfig = std::static_pointer_cast<Config>(_config);
624− if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
625− jobRun(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>());
621+ auto config = std::static_pointer_cast<Config>(_config);
622+ if (config->alwaysEnabled || config->enabled) {
623+ for (auto job : _data._jobs) {
624+ job.run(sceneContext, renderContext);
625+ }
626626 }
627− renderContext->jobConfig.reset();
628627 }
629628 };
630− template <class T, class I, class C = Config> using ModelI = Model<T, C, I, None>;
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>;
629+ template <class T, class O, class C = Config> using ModelO = Model<T, C, O>;
633630
634631 using Jobs = std::vector<Job>;
635632
@@ -688,8 +685,14 @@ public: · 52 unmodified lines
688685 }
689686 }
690687
688+ void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
689+ for (auto job : _jobs) {
690+ job.run(sceneContext, renderContext);
691+ }
692+ }
693+
691694 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;
693696
694697 QConfigPointer _config;
695698 Jobs _jobs;