Pass JobConfig to jobs

This commit is contained in:
Zach Pomerantz 2016-01-22 14:31:58 -08:00
parent 5698be5435
commit c903fc4739
2 changed files with 15 additions and 8 deletions

View file

@ -28,6 +28,8 @@ using SceneContextPointer = std::shared_ptr<SceneContext>;
const int showDisplayStatusFlag = 1; const int showDisplayStatusFlag = 1;
const int showNetworkStatusFlag = 2; const int showNetworkStatusFlag = 2;
class JobConfig;
class RenderContext { class RenderContext {
public: public:
class ItemsConfig { class ItemsConfig {
@ -107,6 +109,7 @@ public:
int _deferredDebugMode; int _deferredDebugMode;
glm::vec4 _deferredDebugSize; glm::vec4 _deferredDebugSize;
std::shared_ptr<JobConfig> jobConfig{ nullptr };
protected: protected:
RenderArgs* _args; RenderArgs* _args;

View file

@ -128,10 +128,11 @@ public:
} }
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
std::shared_ptr<Job::Config>& config = std::static_pointer_cast<Job::Config>(_config); renderContext->jobConfig = std::static_pointer_cast<Job::Config>(_config);
if (config->alwaysEnabled || config->enabled) { if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
jobRun(_data, sceneContext, renderContext); jobRun(_data, sceneContext, renderContext);
} }
renderContext->jobConfig.reset();
} }
}; };
@ -154,10 +155,11 @@ public:
} }
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
std::shared_ptr<Job::Config>& config = std::static_pointer_cast<Job::Config>(_config); renderContext->jobConfig = std::static_pointer_cast<Job::Config>(_config);
if (config->alwaysEnabled || config->enabled) { if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
jobRunI(_data, sceneContext, renderContext, _input.get<I>()); jobRunI(_data, sceneContext, renderContext, _input.get<I>());
} }
renderContext->jobConfig.reset();
} }
}; };
@ -180,10 +182,11 @@ public:
} }
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
std::shared_ptr<Job::Config>& config = std::static_pointer_cast<Job::Config>(_config); renderContext->jobConfig = std::static_pointer_cast<Job::Config>(_config);
if (config->alwaysEnabled || config->enabled) { if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
jobRunO(_data, sceneContext, renderContext, _output.edit<O>()); jobRunO(_data, sceneContext, renderContext, _output.edit<O>());
} }
renderContext->jobConfig.reset();
} }
}; };
@ -209,10 +212,11 @@ public:
} }
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
std::shared_ptr<Job::Config>& config = std::static_pointer_cast<Job::Config>(_config); renderContext->jobConfig = std::static_pointer_cast<Job::Config>(_config);
if (config->alwaysEnabled || config->enabled) { if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
jobRunIO(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>()); jobRunIO(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>());
} }
renderContext->jobConfig.reset();
} }
}; };