mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
Add Job::Config to FetchItems
This commit is contained in:
parent
c903fc4739
commit
adc9d2ea07
3 changed files with 23 additions and 23 deletions
|
@ -89,19 +89,13 @@ RenderDeferredTask::RenderDeferredTask(CullFunctor cullFunctor) {
|
||||||
initDeferredPipelines(*shapePlumber);
|
initDeferredPipelines(*shapePlumber);
|
||||||
|
|
||||||
// CPU: Fetch the renderOpaques
|
// CPU: Fetch the renderOpaques
|
||||||
auto fetchedOpaques = addJob<FetchItems>("FetchOpaque", FetchItems([](const RenderContextPointer& context, int count) {
|
auto fetchedOpaques = addJob<FetchItems>("FetchOpaque");
|
||||||
context->getItemsConfig().opaque.numFeed = count;
|
|
||||||
}));
|
|
||||||
auto culledOpaques = addJob<CullItems<RenderDetails::OPAQUE_ITEM>>("CullOpaque", fetchedOpaques, cullFunctor);
|
auto culledOpaques = addJob<CullItems<RenderDetails::OPAQUE_ITEM>>("CullOpaque", fetchedOpaques, cullFunctor);
|
||||||
auto opaques = addJob<DepthSortItems>("DepthSortOpaque", culledOpaques);
|
auto opaques = addJob<DepthSortItems>("DepthSortOpaque", culledOpaques);
|
||||||
|
|
||||||
// CPU only, create the list of renderedTransparents items
|
// CPU only, create the list of renderedTransparents items
|
||||||
auto fetchedTransparents = addJob<FetchItems>("FetchTransparent", FetchItems(
|
auto fetchedTransparents = addJob<FetchItems>("FetchTransparent", FetchItems(
|
||||||
ItemFilter::Builder::transparentShape().withoutLayered(),
|
ItemFilter::Builder::transparentShape().withoutLayered()));
|
||||||
[](const RenderContextPointer& context, int count) {
|
|
||||||
context->getItemsConfig().transparent.numFeed = count;
|
|
||||||
}
|
|
||||||
));
|
|
||||||
auto culledTransparents = addJob<CullItems<RenderDetails::TRANSLUCENT_ITEM>>("CullTransparent", fetchedTransparents, cullFunctor);
|
auto culledTransparents = addJob<CullItems<RenderDetails::TRANSLUCENT_ITEM>>("CullTransparent", fetchedTransparents, cullFunctor);
|
||||||
auto transparents = addJob<DepthSortItems>("DepthSortTransparent", culledTransparents, DepthSortItems(false));
|
auto transparents = addJob<DepthSortItems>("DepthSortTransparent", culledTransparents, DepthSortItems(false));
|
||||||
|
|
||||||
|
|
|
@ -177,9 +177,7 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_probeNumItems) {
|
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
|
||||||
_probeNumItems(renderContext, (int)outItems.size());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthSortItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
void DepthSortItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||||
|
|
|
@ -27,21 +27,29 @@ void depthSortItems(const SceneContextPointer& sceneContext, const RenderContext
|
||||||
void renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
|
void renderItems(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems);
|
||||||
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems = -1);
|
void renderShapes(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapePlumberPointer& shapeContext, const ItemIDsBounds& inItems, int maxDrawnItems = -1);
|
||||||
|
|
||||||
class FetchItems {
|
class FetchItemsConfig : public Job::Config {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef std::function<void (const RenderContextPointer& context, int count)> ProbeNumItems;
|
Q_PROPERTY(int numItems READ getNumItems)
|
||||||
FetchItems() {}
|
int getNumItems() { return numItems; }
|
||||||
FetchItems(const ProbeNumItems& probe): _probeNumItems(probe) {}
|
int numItems{ 0 };
|
||||||
FetchItems(const ItemFilter& filter, const ProbeNumItems& probe): _filter(filter), _probeNumItems(probe) {}
|
|
||||||
|
|
||||||
ItemFilter _filter = ItemFilter::Builder::opaqueShape().withoutLayered();
|
|
||||||
ProbeNumItems _probeNumItems;
|
|
||||||
|
|
||||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemIDsBounds& outItems);
|
|
||||||
using JobModel = Job::ModelO<FetchItems, ItemIDsBounds>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<RenderDetails::Type T = RenderDetails::Type::OTHER_ITEM>
|
class FetchItems {
|
||||||
|
public:
|
||||||
|
using Config = FetchItemsConfig;
|
||||||
|
using JobModel = Job::ModelO<FetchItems, ItemIDsBounds, Config>;
|
||||||
|
|
||||||
|
FetchItems() {}
|
||||||
|
FetchItems(const ItemFilter& filter) : _filter(filter) {}
|
||||||
|
|
||||||
|
ItemFilter _filter{ ItemFilter::Builder::opaqueShape().withoutLayered() };
|
||||||
|
|
||||||
|
void configure(const Config&) {}
|
||||||
|
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, ItemIDsBounds& outItems);
|
||||||
|
};
|
||||||
|
|
||||||
|
template<RenderDetails::Type T>
|
||||||
class CullItems {
|
class CullItems {
|
||||||
public:
|
public:
|
||||||
CullItems(CullFunctor cullFunctor) : _cullFunctor{ cullFunctor } {}
|
CullItems(CullFunctor cullFunctor) : _cullFunctor{ cullFunctor } {}
|
||||||
|
|
Loading…
Reference in a new issue