mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 14:29:50 +02:00
templatize graphics engine tasks' run method
This commit is contained in:
parent
dbf4f2d23b
commit
8d63067fa5
9 changed files with 18 additions and 80 deletions
|
@ -228,26 +228,6 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderDeferredTask::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
|
||||||
// sanity checks
|
|
||||||
assert(sceneContext);
|
|
||||||
if (!sceneContext->_scene) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Is it possible that we render without a viewFrustum ?
|
|
||||||
if (!(renderContext->args && renderContext->args->hasViewFrustum())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
|
||||||
|
|
||||||
for (auto job : _jobs) {
|
|
||||||
job.run(sceneContext, renderContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
|
void BeginGPURangeTimer::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, gpu::RangeTimerPointer& timer) {
|
||||||
timer = _gpuTimer;
|
timer = _gpuTimer;
|
||||||
gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(renderContext->args->_context, [&](gpu::Batch& batch) {
|
||||||
|
|
|
@ -200,7 +200,6 @@ public:
|
||||||
RenderDeferredTask(render::CullFunctor cullFunctor);
|
RenderDeferredTask(render::CullFunctor cullFunctor);
|
||||||
|
|
||||||
void configure(const Config& config) {}
|
void configure(const Config& config) {}
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
|
||||||
|
|
||||||
using JobModel = Model<RenderDeferredTask, Config>;
|
using JobModel = Model<RenderDeferredTask, Config>;
|
||||||
|
|
||||||
|
|
|
@ -86,26 +86,6 @@ RenderForwardTask::RenderForwardTask(CullFunctor cullFunctor) {
|
||||||
addJob<Blit>("Blit", framebuffer);
|
addJob<Blit>("Blit", framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderForwardTask::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
|
||||||
// sanity checks
|
|
||||||
assert(sceneContext);
|
|
||||||
if (!sceneContext->_scene) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Is it possible that we render without a viewFrustum ?
|
|
||||||
if (!(renderContext->args && renderContext->args->hasViewFrustum())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
|
||||||
|
|
||||||
for (auto job : _jobs) {
|
|
||||||
job.run(sceneContext, renderContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
void PrepareFramebuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, gpu::FramebufferPointer& framebuffer) {
|
||||||
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
auto framebufferCache = DependencyManager::get<FramebufferCache>();
|
||||||
auto framebufferSize = framebufferCache->getFrameBufferSize();
|
auto framebufferSize = framebufferCache->getFrameBufferSize();
|
||||||
|
|
|
@ -24,7 +24,6 @@ public:
|
||||||
RenderForwardTask(render::CullFunctor cullFunctor);
|
RenderForwardTask(render::CullFunctor cullFunctor);
|
||||||
|
|
||||||
void configure(const Config& config) {}
|
void configure(const Config& config) {}
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
|
||||||
|
|
||||||
using JobModel = Model<RenderForwardTask, Config>;
|
using JobModel = Model<RenderForwardTask, Config>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,20 +139,6 @@ void RenderShadowTask::configure(const Config& configuration) {
|
||||||
Task::configure(configuration);
|
Task::configure(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderShadowTask::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext) {
|
|
||||||
assert(sceneContext);
|
|
||||||
RenderArgs* args = renderContext->args;
|
|
||||||
|
|
||||||
// sanity checks
|
|
||||||
if (!sceneContext->_scene || !args) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto job : _jobs) {
|
|
||||||
job.run(sceneContext, renderContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) {
|
void RenderShadowSetup::run(const SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, Output& output) {
|
||||||
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
auto lightStage = DependencyManager::get<DeferredLightingEffect>()->getLightStage();
|
||||||
const auto globalShadow = lightStage->getShadow(0);
|
const auto globalShadow = lightStage->getShadow(0);
|
||||||
|
|
|
@ -49,7 +49,6 @@ public:
|
||||||
RenderShadowTask(render::CullFunctor shouldRender);
|
RenderShadowTask(render::CullFunctor shouldRender);
|
||||||
|
|
||||||
void configure(const Config& configuration);
|
void configure(const Config& configuration);
|
||||||
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderShadowSetup {
|
class RenderShadowSetup {
|
||||||
|
|
|
@ -52,11 +52,3 @@ void Engine::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::run() {
|
|
||||||
for (auto job : _jobs) {
|
|
||||||
job.run(_sceneContext, _renderContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ namespace render {
|
||||||
RenderContextPointer getRenderContext() const { return _renderContext; }
|
RenderContextPointer getRenderContext() const { return _renderContext; }
|
||||||
|
|
||||||
// Render a frame
|
// Render a frame
|
||||||
// A frame must have a scene registered and a context set to render
|
// Must have a scene registered and a context set
|
||||||
void run();
|
void run() { assert(_sceneContext && _renderContext); Task::run(_sceneContext, _renderContext); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SceneContextPointer _sceneContext;
|
SceneContextPointer _sceneContext;
|
||||||
|
|
|
@ -593,22 +593,20 @@ public:
|
||||||
using QConfigPointer = Job::QConfigPointer;
|
using QConfigPointer = Job::QConfigPointer;
|
||||||
using None = Job::None;
|
using None = Job::None;
|
||||||
|
|
||||||
template <class T, class C = Config, class I = None, class O = None> class Model : public Job::Concept {
|
template <class T, class C = Config, class O = None> class Model : public Job::Concept {
|
||||||
public:
|
public:
|
||||||
using Data = T;
|
using Data = T;
|
||||||
using Input = I;
|
using Input = None;
|
||||||
using Output = O;
|
using Output = O;
|
||||||
|
|
||||||
Data _data;
|
Data _data;
|
||||||
Varying _input;
|
|
||||||
Varying _output;
|
Varying _output;
|
||||||
|
|
||||||
const Varying getInput() const override { return _input; }
|
|
||||||
const Varying getOutput() const override { return _output; }
|
const Varying getOutput() const override { return _output; }
|
||||||
|
|
||||||
template <class... A>
|
template <class... A>
|
||||||
Model(const Varying& input, A&&... args) :
|
Model(const Varying& input, A&&... args) :
|
||||||
Concept(nullptr), _data(Data(std::forward<A>(args)...)), _input(input), _output(Output()) {
|
Concept(nullptr), _data(Data(std::forward<A>(args)...)), _output(Output()) {
|
||||||
// Recreate the Config to use the templated type
|
// Recreate the Config to use the templated type
|
||||||
_data.template createConfiguration<C>();
|
_data.template createConfiguration<C>();
|
||||||
_config = _data.getConfiguration();
|
_config = _data.getConfiguration();
|
||||||
|
@ -620,16 +618,15 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) override {
|
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) override {
|
||||||
renderContext->jobConfig = std::static_pointer_cast<Config>(_config);
|
auto config = std::static_pointer_cast<Config>(_config);
|
||||||
if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->enabled) {
|
if (config->alwaysEnabled || config->enabled) {
|
||||||
jobRun(_data, sceneContext, renderContext, _input.get<I>(), _output.edit<O>());
|
for (auto job : _data._jobs) {
|
||||||
|
job.run(sceneContext, renderContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
renderContext->jobConfig.reset();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <class T, class I, class C = Config> using ModelI = Model<T, C, I, None>;
|
template <class T, class O, class C = Config> using ModelO = Model<T, C, O>;
|
||||||
template <class T, class O, class C = Config> using ModelO = Model<T, C, None, O>;
|
|
||||||
template <class T, class I, class O, class C = Config> using ModelIO = Model<T, C, I, O>;
|
|
||||||
|
|
||||||
using Jobs = std::vector<Job>;
|
using Jobs = std::vector<Job>;
|
||||||
|
|
||||||
|
@ -688,8 +685,14 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
|
||||||
|
for (auto job : _jobs) {
|
||||||
|
job.run(sceneContext, renderContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <class T, class C, class I, class O> friend class Model;
|
template <class T, class C, class O> friend class Model;
|
||||||
|
|
||||||
QConfigPointer _config;
|
QConfigPointer _config;
|
||||||
Jobs _jobs;
|
Jobs _jobs;
|
||||||
|
|
Loading…
Reference in a new issue