mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 07:43:57 +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);
|
||||
|
||||
// CPU: Fetch the renderOpaques
|
||||
auto fetchedOpaques = addJob<FetchItems>("FetchOpaque", FetchItems([](const RenderContextPointer& context, int count) {
|
||||
context->getItemsConfig().opaque.numFeed = count;
|
||||
}));
|
||||
auto fetchedOpaques = addJob<FetchItems>("FetchOpaque");
|
||||
auto culledOpaques = addJob<CullItems<RenderDetails::OPAQUE_ITEM>>("CullOpaque", fetchedOpaques, cullFunctor);
|
||||
auto opaques = addJob<DepthSortItems>("DepthSortOpaque", culledOpaques);
|
||||
|
||||
// CPU only, create the list of renderedTransparents items
|
||||
auto fetchedTransparents = addJob<FetchItems>("FetchTransparent", FetchItems(
|
||||
ItemFilter::Builder::transparentShape().withoutLayered(),
|
||||
[](const RenderContextPointer& context, int count) {
|
||||
context->getItemsConfig().transparent.numFeed = count;
|
||||
}
|
||||
));
|
||||
ItemFilter::Builder::transparentShape().withoutLayered()));
|
||||
auto culledTransparents = addJob<CullItems<RenderDetails::TRANSLUCENT_ITEM>>("CullTransparent", fetchedTransparents, cullFunctor);
|
||||
auto transparents = addJob<DepthSortItems>("DepthSortTransparent", culledTransparents, DepthSortItems(false));
|
||||
|
||||
|
|
|
@ -177,9 +177,7 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
|
|||
}
|
||||
}
|
||||
|
||||
if (_probeNumItems) {
|
||||
_probeNumItems(renderContext, (int)outItems.size());
|
||||
}
|
||||
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
|
||||
}
|
||||
|
||||
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 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:
|
||||
typedef std::function<void (const RenderContextPointer& context, int count)> ProbeNumItems;
|
||||
FetchItems() {}
|
||||
FetchItems(const ProbeNumItems& probe): _probeNumItems(probe) {}
|
||||
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>;
|
||||
Q_PROPERTY(int numItems READ getNumItems)
|
||||
int getNumItems() { return numItems; }
|
||||
int numItems{ 0 };
|
||||
};
|
||||
|
||||
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 {
|
||||
public:
|
||||
CullItems(CullFunctor cullFunctor) : _cullFunctor{ cullFunctor } {}
|
||||
|
|
Loading…
Reference in a new issue