Cleanup new render settings

This commit is contained in:
Zach Pomerantz 2016-01-26 13:57:30 -08:00
parent 2d0d542765
commit 5009e8702e
18 changed files with 93 additions and 104 deletions

View file

@ -584,7 +584,6 @@ Menu::Menu() {
// Developer > Physics >>> // Developer > Physics >>>
MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics"); MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics");
addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowOwned);
addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowHulls);
// Developer > Display Crash Options // Developer > Display Crash Options

View file

@ -244,7 +244,6 @@ namespace MenuOption {
const QString OutputMenu = "Display"; const QString OutputMenu = "Display";
const QString PackageModel = "Package Model..."; const QString PackageModel = "Package Model...";
const QString Pair = "Pair"; const QString Pair = "Pair";
const QString PhysicsShowOwned = "Highlight Simulation Ownership";
const QString PhysicsShowHulls = "Draw Collision Hulls"; const QString PhysicsShowHulls = "Draw Collision Hulls";
const QString PipelineWarnings = "Log Render Pipeline Warnings"; const QString PipelineWarnings = "Log Render Pipeline Warnings";
const QString Preferences = "General..."; const QString Preferences = "General...";

View file

@ -101,13 +101,13 @@ AmbientOcclusionEffect::AmbientOcclusionEffect() {
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters)); _parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters));
} }
void AmbientOcclusionEffect::configure(const Config& configuration) { void AmbientOcclusionEffect::configure(const Config& config) {
DependencyManager::get<DeferredLightingEffect>()->setAmbientOcclusionEnabled(configuration.enabled); DependencyManager::get<DeferredLightingEffect>()->setAmbientOcclusionEnabled(config.enabled);
bool shouldUpdateGaussion = false; bool shouldUpdateGaussion = false;
const double RADIUS_POWER = 6.0; const double RADIUS_POWER = 6.0;
const auto& radius = configuration.radius; const auto& radius = config.radius;
if (radius != getRadius()) { if (radius != getRadius()) {
auto& current = _parametersBuffer.edit<Parameters>().radiusInfo; auto& current = _parametersBuffer.edit<Parameters>().radiusInfo;
current.x = radius; current.x = radius;
@ -115,39 +115,39 @@ void AmbientOcclusionEffect::configure(const Config& configuration) {
current.z = (float)(1.0 / pow((double)radius, RADIUS_POWER)); current.z = (float)(1.0 / pow((double)radius, RADIUS_POWER));
} }
if (configuration.obscuranceLevel != getObscuranceLevel()) { if (config.obscuranceLevel != getObscuranceLevel()) {
auto& current = _parametersBuffer.edit<Parameters>().radiusInfo; auto& current = _parametersBuffer.edit<Parameters>().radiusInfo;
current.w = configuration.obscuranceLevel; current.w = config.obscuranceLevel;
} }
if (configuration.falloffBias != getFalloffBias()) { if (config.falloffBias != getFalloffBias()) {
auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo; auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo;
current.z = configuration.falloffBias; current.z = config.falloffBias;
} }
if (configuration.edgeSharpness != getEdgeSharpness()) { if (config.edgeSharpness != getEdgeSharpness()) {
auto& current = _parametersBuffer.edit<Parameters>().blurInfo; auto& current = _parametersBuffer.edit<Parameters>().blurInfo;
current.x = configuration.edgeSharpness; current.x = config.edgeSharpness;
} }
if (configuration.blurDeviation != getBlurDeviation()) { if (config.blurDeviation != getBlurDeviation()) {
auto& current = _parametersBuffer.edit<Parameters>().blurInfo; auto& current = _parametersBuffer.edit<Parameters>().blurInfo;
current.z = configuration.blurDeviation; current.z = config.blurDeviation;
shouldUpdateGaussion = true; shouldUpdateGaussion = true;
} }
if (configuration.numSpiralTurns != getNumSpiralTurns()) { if (config.numSpiralTurns != getNumSpiralTurns()) {
auto& current = _parametersBuffer.edit<Parameters>().sampleInfo; auto& current = _parametersBuffer.edit<Parameters>().sampleInfo;
current.z = configuration.numSpiralTurns; current.z = config.numSpiralTurns;
} }
if (configuration.numSamples != getNumSamples()) { if (config.numSamples != getNumSamples()) {
auto& current = _parametersBuffer.edit<Parameters>().sampleInfo; auto& current = _parametersBuffer.edit<Parameters>().sampleInfo;
current.x = configuration.numSamples; current.x = config.numSamples;
current.y = 1.0f / configuration.numSamples; current.y = 1.0f / config.numSamples;
} }
const auto& resolutionLevel = configuration.resolutionLevel; const auto& resolutionLevel = config.resolutionLevel;
if (resolutionLevel != getResolutionLevel()) { if (resolutionLevel != getResolutionLevel()) {
auto& current = _parametersBuffer.edit<Parameters>().resolutionInfo; auto& current = _parametersBuffer.edit<Parameters>().resolutionInfo;
current.x = (float)resolutionLevel; current.x = (float)resolutionLevel;
@ -156,20 +156,20 @@ void AmbientOcclusionEffect::configure(const Config& configuration) {
DependencyManager::get<FramebufferCache>()->setAmbientOcclusionResolutionLevel(resolutionLevel); DependencyManager::get<FramebufferCache>()->setAmbientOcclusionResolutionLevel(resolutionLevel);
} }
if (configuration.blurRadius != getBlurRadius()) { if (config.blurRadius != getBlurRadius()) {
auto& current = _parametersBuffer.edit<Parameters>().blurInfo; auto& current = _parametersBuffer.edit<Parameters>().blurInfo;
current.y = (float)configuration.blurRadius; current.y = (float)config.blurRadius;
shouldUpdateGaussion = true; shouldUpdateGaussion = true;
} }
if (configuration.ditheringEnabled != isDitheringEnabled()) { if (config.ditheringEnabled != isDitheringEnabled()) {
auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo; auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo;
current.x = (float)configuration.ditheringEnabled; current.x = (float)config.ditheringEnabled;
} }
if (configuration.borderingEnabled != isBorderingEnabled()) { if (config.borderingEnabled != isBorderingEnabled()) {
auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo; auto& current = _parametersBuffer.edit<Parameters>().ditheringInfo;
current.w = (float)configuration.borderingEnabled; current.w = (float)config.borderingEnabled;
} }
if (shouldUpdateGaussion) { if (shouldUpdateGaussion) {

View file

@ -18,9 +18,6 @@
class AmbientOcclusionEffectConfig : public render::Job::Config { class AmbientOcclusionEffectConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
public:
AmbientOcclusionEffectConfig() : render::Job::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty) Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty) Q_PROPERTY(bool ditheringEnabled MEMBER ditheringEnabled NOTIFY dirty)
Q_PROPERTY(bool borderingEnabled MEMBER borderingEnabled NOTIFY dirty) Q_PROPERTY(bool borderingEnabled MEMBER borderingEnabled NOTIFY dirty)
@ -34,6 +31,8 @@ public:
Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel) Q_PROPERTY(int resolutionLevel MEMBER resolutionLevel WRITE setResolutionLevel)
Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius) Q_PROPERTY(int blurRadius MEMBER blurRadius WRITE setBlurRadius)
Q_PROPERTY(double gpuTime READ getGpuTime) Q_PROPERTY(double gpuTime READ getGpuTime)
public:
AmbientOcclusionEffectConfig() : render::Job::Config(false) {}
const int MAX_RESOLUTION_LEVEL = 4; const int MAX_RESOLUTION_LEVEL = 4;
const int MAX_BLUR_RADIUS = 6; const int MAX_BLUR_RADIUS = 6;
@ -73,7 +72,7 @@ public:
AmbientOcclusionEffect(); AmbientOcclusionEffect();
void configure(const Config& configuration); void configure(const Config& config);
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
float getRadius() const { return _parametersBuffer.get<Parameters>().radiusInfo.x; } float getRadius() const { return _parametersBuffer.get<Parameters>().radiusInfo.x; }

View file

@ -18,10 +18,9 @@
class AntiAliasingConfig : public render::Job::Config { class AntiAliasingConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled)
public: public:
AntiAliasingConfig() : render::Job::Config(false) {} AntiAliasingConfig() : render::Job::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled)
}; };
class Antialiasing { class Antialiasing {
@ -30,7 +29,7 @@ public:
using JobModel = render::Job::Model<Antialiasing, Config>; using JobModel = render::Job::Model<Antialiasing, Config>;
Antialiasing(); Antialiasing();
void configure(const Config& configuration) {} void configure(const Config& config) {}
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
const gpu::PipelinePointer& getAntialiasingPipeline(); const gpu::PipelinePointer& getAntialiasingPipeline();

View file

@ -232,6 +232,10 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
} }
} }
void DebugDeferredBuffer::configure(const Config& config) {
_mode = (Mode)config.mode;
_size = config.size;
}
void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
assert(renderContext->args); assert(renderContext->args);

View file

@ -18,16 +18,16 @@
class DebugDeferredBufferConfig : public render::Job::Config { class DebugDeferredBufferConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
public:
DebugDeferredBufferConfig() : render::Job::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled) Q_PROPERTY(bool enabled MEMBER enabled)
Q_PROPERTY(int mode MEMBER mode WRITE setMode) Q_PROPERTY(int mode MEMBER mode WRITE setMode)
Q_PROPERTY(glm::vec4 size MEMBER size NOTIFY dirty) Q_PROPERTY(glm::vec4 size MEMBER size NOTIFY dirty)
public:
DebugDeferredBufferConfig() : render::Job::Config(false) {}
void setMode(int newMode); void setMode(int newMode);
int mode{ 0 }; int mode{ 0 };
glm::vec4 size{ 0, 0, 0, 0 }; glm::vec4 size{ 0.0f, 0.0f, 0.0f, 0.0f };
signals: signals:
void dirty(); void dirty();
}; };
@ -39,10 +39,7 @@ public:
DebugDeferredBuffer(); DebugDeferredBuffer();
void configure(const Config& config) { void configure(const Config& config);
_mode = (Mode)config.mode;
_size = config.size;
}
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
protected: protected:

View file

@ -13,10 +13,9 @@
class HitEffectConfig : public render::Job::Config { class HitEffectConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled)
public: public:
HitEffectConfig() : render::Job::Config(false) {} HitEffectConfig() : render::Job::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled)
}; };
class HitEffect { class HitEffect {
@ -25,7 +24,7 @@ public:
using JobModel = render::Job::Model<HitEffect, Config>; using JobModel = render::Job::Model<HitEffect, Config>;
HitEffect(); HitEffect();
void configure(const Config&) {} void configure(const Config& config) {}
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
const gpu::PipelinePointer& getHitEffectPipeline(); const gpu::PipelinePointer& getHitEffectPipeline();

View file

@ -67,13 +67,13 @@ void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderCo
DependencyManager::get<DeferredLightingEffect>()->render(renderContext); DependencyManager::get<DeferredLightingEffect>()->render(renderContext);
} }
void ToneMappingDeferred::configure(const Config& configuration) { void ToneMappingDeferred::configure(const Config& config) {
if (configuration.exposure >= 0) { if (config.exposure >= 0.0f) {
_toneMappingEffect.setExposure(configuration.exposure); _toneMappingEffect.setExposure(config.exposure);
} }
if (configuration.curve >= 0) {
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)configuration.curve);
if (config.curve >= 0) {
_toneMappingEffect.setToneCurve((ToneMappingEffect::ToneCurve)config.curve);
} }
} }
@ -169,7 +169,7 @@ void DrawDeferred::run(const SceneContextPointer& sceneContext, const RenderCont
assert(renderContext->args); assert(renderContext->args);
assert(renderContext->args->_viewFrustum); assert(renderContext->args->_viewFrustum);
auto& config = std::static_pointer_cast<Config>(renderContext->jobConfig); auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) { gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
@ -218,7 +218,7 @@ void DrawOverlay3D::run(const SceneContextPointer& sceneContext, const RenderCon
auto& scene = sceneContext->_scene; auto& scene = sceneContext->_scene;
auto& items = scene->getMasterBucket().at(ItemFilter::Builder::opaqueShape().withLayered()); auto& items = scene->getMasterBucket().at(ItemFilter::Builder::opaqueShape().withLayered());
auto& config = std::static_pointer_cast<Config>(renderContext->jobConfig); auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
ItemIDsBounds inItems; ItemIDsBounds inItems;
inItems.reserve(items.size()); inItems.reserve(items.size());

View file

@ -43,13 +43,13 @@ public:
class ToneMappingConfig : public render::Job::Config { class ToneMappingConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
public:
ToneMappingConfig() : render::Job::Config(true) {}
Q_PROPERTY(bool enabled MEMBER enabled) Q_PROPERTY(bool enabled MEMBER enabled)
Q_PROPERTY(float exposure MEMBER exposure NOTIFY dirty); Q_PROPERTY(float exposure MEMBER exposure NOTIFY dirty);
Q_PROPERTY(int curve MEMBER curve NOTIFY dirty); Q_PROPERTY(int curve MEMBER curve NOTIFY dirty);
float exposure{ 0.0 }; public:
ToneMappingConfig() : render::Job::Config(true) {}
float exposure{ 0.0f };
int curve{ 3 }; int curve{ 3 };
signals: signals:
void dirty(); void dirty();
@ -60,7 +60,7 @@ public:
using Config = ToneMappingConfig; using Config = ToneMappingConfig;
using JobModel = render::Job::Model<ToneMappingDeferred, Config>; using JobModel = render::Job::Model<ToneMappingDeferred, Config>;
void configure(const Config&); void configure(const Config& config);
void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext); void run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext);
ToneMappingEffect _toneMappingEffect; ToneMappingEffect _toneMappingEffect;
@ -68,9 +68,9 @@ public:
class DrawConfig : public render::Job::Config { class DrawConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
public:
Q_PROPERTY(int numDrawn READ getNumDrawn) Q_PROPERTY(int numDrawn READ getNumDrawn)
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
public:
int getNumDrawn() { return numDrawn; } int getNumDrawn() { return numDrawn; }
int numDrawn{ 0 }; int numDrawn{ 0 };
@ -91,7 +91,7 @@ public:
protected: protected:
render::ShapePlumberPointer _shapePlumber; render::ShapePlumberPointer _shapePlumber;
int _maxDrawn{ -1 }; int _maxDrawn; // initialized by Config
}; };
class DrawStencilDeferred { class DrawStencilDeferred {
@ -115,10 +115,10 @@ public:
class DrawOverlay3DConfig : public render::Job::Config { class DrawOverlay3DConfig : public render::Job::Config {
Q_OBJECT Q_OBJECT
public:
Q_PROPERTY(int numItems READ getNumItems) Q_PROPERTY(int numItems READ getNumItems)
Q_PROPERTY(int numDrawn READ getNumDrawn) Q_PROPERTY(int numDrawn READ getNumDrawn)
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty) Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
public:
int getNumItems() { return numItems; } int getNumItems() { return numItems; }
int getNumDrawn() { return numDrawn; } int getNumDrawn() { return numDrawn; }
@ -144,7 +144,7 @@ public:
protected: protected:
static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable static gpu::PipelinePointer _opaquePipeline; //lazy evaluation hence mutable
render::ShapePlumberPointer _shapePlumber; render::ShapePlumberPointer _shapePlumber;
int _maxDrawn{ -1 }; int _maxDrawn; // initialized by Config
}; };
class Blit { class Blit {

View file

@ -78,6 +78,7 @@ void RenderShadowMap::run(const render::SceneContextPointer& sceneContext, const
}); });
} }
// The shadow task *must* use this base ctor to initialize with its own Config, see Task.h
RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) : Task(std::make_shared<Config>()) { RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) : Task(std::make_shared<Config>()) {
cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; }; cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; };
@ -121,6 +122,7 @@ RenderShadowTask::RenderShadowTask(CullFunctor cullFunctor) : Task(std::make_sha
void RenderShadowTask::configure(const Config& configuration) { void RenderShadowTask::configure(const Config& configuration) {
DependencyManager::get<DeferredLightingEffect>()->setShadowMapEnabled(configuration.enabled); DependencyManager::get<DeferredLightingEffect>()->setShadowMapEnabled(configuration.enabled);
// This is a task, so must still propogate configure() to its Jobs
Task::configure(configuration); Task::configure(configuration);
} }

View file

@ -33,11 +33,10 @@ protected:
class RenderShadowTaskConfig : public render::Task::Config { class RenderShadowTaskConfig : public render::Task::Config {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
public: public:
RenderShadowTaskConfig() : render::Task::Config(false) {} RenderShadowTaskConfig() : render::Task::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled NOTIFY dirty)
signals: signals:
void dirty(); void dirty();
}; };

View file

@ -31,7 +31,7 @@ public:
RenderArgs* args; RenderArgs* args;
std::shared_ptr<JobConfig> jobConfig{ nullptr }; std::shared_ptr<JobConfig> jobConfig{ nullptr };
}; };
typedef std::shared_ptr<RenderContext> RenderContextPointer; using RenderContextPointer = std::shared_ptr<RenderContext>;
} }

View file

@ -94,9 +94,9 @@ const gpu::TexturePointer DrawStatus::getStatusIconMap() const {
return _statusIconMap; return _statusIconMap;
} }
void DrawStatus::configure(const Config& configuration) { void DrawStatus::configure(const Config& config) {
_showDisplay = configuration.showDisplay; _showDisplay = config.showDisplay;
_showNetwork = configuration.showNetwork; _showNetwork = config.showNetwork;
} }
void DrawStatus::run(const SceneContextPointer& sceneContext, void DrawStatus::run(const SceneContextPointer& sceneContext,

View file

@ -18,14 +18,15 @@
namespace render { namespace render {
class DrawStatusConfig : public Job::Config { class DrawStatusConfig : public Job::Config {
Q_OBJECT Q_OBJECT
public:
DrawStatusConfig() : Job::Config(false) {}
Q_PROPERTY(bool enabled MEMBER enabled) Q_PROPERTY(bool enabled MEMBER enabled)
Q_PROPERTY(bool showDisplay MEMBER showDisplay NOTIFY dirty) Q_PROPERTY(bool showDisplay MEMBER showDisplay NOTIFY dirty)
Q_PROPERTY(bool showNetwork MEMBER showDisplay NOTIFY dirty) Q_PROPERTY(bool showNetwork MEMBER showDisplay NOTIFY dirty)
public:
DrawStatusConfig() : Job::Config(false) {}
bool showDisplay{ false }; bool showDisplay{ false };
bool showNetwork{ false }; bool showNetwork{ false };
signals: signals:
void dirty(); void dirty();
}; };
@ -38,7 +39,7 @@ namespace render {
DrawStatus() {} DrawStatus() {}
DrawStatus(const gpu::TexturePointer statusIconMap) { setStatusIconMap(statusIconMap); } DrawStatus(const gpu::TexturePointer statusIconMap) { setStatusIconMap(statusIconMap); }
void configure(const Config& configuration); void configure(const Config& config);
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems); void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
const gpu::PipelinePointer getDrawItemBoundsPipeline(); const gpu::PipelinePointer getDrawItemBoundsPipeline();
@ -48,8 +49,8 @@ namespace render {
const gpu::TexturePointer getStatusIconMap() const; const gpu::TexturePointer getStatusIconMap() const;
protected: protected:
bool _showDisplay{ false }; bool _showDisplay; // initialized by Config
bool _showNetwork{ false }; bool _showNetwork; // initialized by Config
int _drawItemBoundPosLoc = -1; int _drawItemBoundPosLoc = -1;
int _drawItemBoundDimLoc = -1; int _drawItemBoundDimLoc = -1;

View file

@ -29,9 +29,10 @@ void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPo
class FetchItemsConfig : public Job::Config { class FetchItemsConfig : public Job::Config {
Q_OBJECT Q_OBJECT
public:
Q_PROPERTY(int numItems READ getNumItems) Q_PROPERTY(int numItems READ getNumItems)
public:
int getNumItems() { return numItems; } int getNumItems() { return numItems; }
int numItems{ 0 }; int numItems{ 0 };
}; };
@ -45,7 +46,7 @@ public:
ItemFilter _filter{ ItemFilter::Builder::opaqueShape().withoutLayered() }; ItemFilter _filter{ ItemFilter::Builder::opaqueShape().withoutLayered() };
void configure(const Config&) {} void configure(const Config& config) {}
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemIDsBounds& outItems); void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemIDsBounds& outItems);
}; };

View file

@ -10,12 +10,6 @@
// //
#include <QtCore/QThread> #include <QtCore/QThread>
#include <qscriptengine.h> // QObject
#include "Context.h"
#include "gpu/Batch.h"
#include <PerfStat.h>
#include "Task.h" #include "Task.h"

View file

@ -19,9 +19,6 @@
#include "gpu/Batch.h" #include "gpu/Batch.h"
#include <PerfStat.h> #include <PerfStat.h>
// Prepare Qt for auto configurations
Q_DECLARE_METATYPE(std::shared_ptr<QObject>)
namespace render { namespace render {
// A varying piece of data, to be used as Job/Task I/O // A varying piece of data, to be used as Job/Task I/O
@ -53,25 +50,26 @@ protected:
std::shared_ptr<Concept> _concept; std::shared_ptr<Concept> _concept;
}; };
class Job;
class Task;
// A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled) // A default Config is always on; to create an enableable Config, use the ctor JobConfig(bool enabled)
class JobConfig : public QObject { class JobConfig : public QObject {
Q_OBJECT Q_OBJECT
public: public:
JobConfig() : alwaysEnabled{ true }, enabled{ true } {} JobConfig() = default;
JobConfig(bool enabled) : alwaysEnabled{ false }, enabled{ enabled } {} JobConfig(bool enabled) : alwaysEnabled{ false }, enabled{ enabled } {}
bool isEnabled() { return alwaysEnabled || enabled; } bool isEnabled() { return alwaysEnabled || enabled; }
bool alwaysEnabled{ true }; bool alwaysEnabled{ true };
bool enabled; bool enabled{ true };
}; };
class Task;
class TaskConfig : public JobConfig { class TaskConfig : public JobConfig {
Q_OBJECT Q_OBJECT
public: public:
TaskConfig() : JobConfig() {} TaskConfig() = default ;
TaskConfig(bool enabled) : JobConfig(enabled) {} TaskConfig(bool enabled) : JobConfig(enabled) {}
void init(Task* task) { _task = task; } void init(Task* task) { _task = task; }
@ -82,6 +80,7 @@ public:
} }
template <class T> void setJobEnabled(bool enable = true, std::string job = "") { template <class T> void setJobEnabled(bool enable = true, std::string job = "") {
assert(getConfig<T>(job)->alwaysEnabled != true);
getConfig<T>(job)->enabled = enable; getConfig<T>(job)->enabled = enable;
refresh(); // trigger a Job->configure refresh(); // trigger a Job->configure
} }
@ -96,24 +95,23 @@ private:
Task* _task; Task* _task;
}; };
template <class T, class C> void jobConfigure(T& model, const C& configuration) { template <class T, class C> void jobConfigure(T& data, const C& configuration) {
model.configure(configuration); data.configure(configuration);
} }
template<class T> void jobConfigure(T&, const JobConfig&) { template<class T> void jobConfigure(T&, const JobConfig&) {
// nop, as the default JobConfig was used, so the data does not need a configure method
} }
template <class T> void jobRun(T& data, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
// FIXME: In c++17, use default classes of nullptr_t to combine these data.run(sceneContext, renderContext);
template <class T> void jobRun(T& model, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
model.run(sceneContext, renderContext);
} }
template <class T, class I> void jobRunI(T& model, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const I& input) { template <class T, class I> void jobRunI(T& data, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const I& input) {
model.run(sceneContext, renderContext, input); data.run(sceneContext, renderContext, input);
} }
template <class T, class O> void jobRunO(T& model, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, O& output) { template <class T, class O> void jobRunO(T& data, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, O& output) {
model.run(sceneContext, renderContext, output); data.run(sceneContext, renderContext, output);
} }
template <class T, class I, class O> void jobRunIO(T& model, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const I& input, O& output) { template <class T, class I, class O> void jobRunIO(T& data, const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const I& input, O& output) {
model.run(sceneContext, renderContext, input, output); data.run(sceneContext, renderContext, input, output);
} }
class Job { class Job {
@ -285,12 +283,10 @@ public:
public: public:
using Data = T; using Data = T;
// TODO: Make Data a shared_ptr, and give Config a weak_ptr
Data _data; Data _data;
// The _config is unused; the model delegates to its data's _config Model(Data data = Data()) : Concept(std::make_shared<C>()), _data(data) {
Model(Data data = Data()) : _data(data), Concept(std::make_shared<C>()) { _config = _data._config; // use the data's config
_config = _data._config;
std::static_pointer_cast<Config>(_config)->init(&_data); std::static_pointer_cast<Config>(_config)->init(&_data);
applyConfiguration(); applyConfiguration();
@ -341,7 +337,7 @@ public:
protected: protected:
template <class T, class C> friend class Model; template <class T, class C> friend class Model;
QConfigPointer _config { nullptr }; QConfigPointer _config;
Jobs _jobs; Jobs _jobs;
}; };