mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 21:23:18 +02:00
Add render Jobs for Shape sorting
This commit is contained in:
parent
4bbf206f64
commit
331d32ef78
3 changed files with 52 additions and 3 deletions
|
@ -182,8 +182,6 @@ void FetchItems::run(const SceneContextPointer& sceneContext, const RenderContex
|
|||
}
|
||||
|
||||
void DepthSortItems::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ItemIDsBounds& outItems) {
|
||||
outItems.clear();
|
||||
outItems.reserve(inItems.size());
|
||||
depthSortItems(sceneContext, renderContext, _frontToBack, inItems, outItems);
|
||||
}
|
||||
|
||||
|
@ -215,3 +213,35 @@ void DrawLight::run(const SceneContextPointer& sceneContext, const RenderContext
|
|||
args->_batch = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
void PipelineSortShapes::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ShapesIDsBounds& outShapes) {
|
||||
auto& scene = sceneContext->_scene;
|
||||
outShapes.clear();
|
||||
|
||||
for (const auto& item : inItems) {
|
||||
auto key = scene->getItem(item.id).getShapeKey();
|
||||
auto outItems = outShapes.find(key);
|
||||
if (outItems == outShapes.end()) {
|
||||
outItems = outShapes.insert(std::make_pair(key, ItemIDsBounds{})).first;
|
||||
outItems->second.reserve(inItems.size());
|
||||
}
|
||||
|
||||
outItems->second.push_back(item);
|
||||
}
|
||||
|
||||
for (auto& items : outShapes) {
|
||||
items.second.shrink_to_fit();
|
||||
}
|
||||
}
|
||||
|
||||
void DepthSortShapes::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapesIDsBounds& inShapes, ShapesIDsBounds& outShapes) {
|
||||
for (auto& pipeline : inShapes) {
|
||||
auto& inItems = pipeline.second;
|
||||
auto outItems = outShapes.find(pipeline.first);
|
||||
if (outItems == outShapes.end()) {
|
||||
outItems = outShapes.insert(std::make_pair(pipeline.first, ItemIDsBounds{})).first;
|
||||
}
|
||||
|
||||
depthSortItems(sceneContext, renderContext, _frontToBack, inItems, outItems->second);
|
||||
}
|
||||
}
|
|
@ -66,6 +66,21 @@ public:
|
|||
using JobModel = Task::Job::Model<DrawLight>;
|
||||
};
|
||||
|
||||
class PipelineSortShapes {
|
||||
public:
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ItemIDsBounds& inItems, ShapesIDsBounds& outShapes);
|
||||
using JobModel = Task::Job::ModelIO<PipelineSortShapes, ItemIDsBounds, ShapesIDsBounds>;
|
||||
};
|
||||
|
||||
class DepthSortShapes {
|
||||
public:
|
||||
bool _frontToBack;
|
||||
DepthSortShapes(bool frontToBack = true) : _frontToBack(frontToBack) {}
|
||||
|
||||
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const ShapesIDsBounds& inShapes, ShapesIDsBounds& outShapes);
|
||||
using JobModel = Task::Job::ModelIO<DepthSortShapes, ShapesIDsBounds, ShapesIDsBounds>;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // hifi_render_DrawTask_h
|
||||
|
|
|
@ -432,7 +432,11 @@ public:
|
|||
AABox bounds;
|
||||
};
|
||||
|
||||
typedef std::vector< ItemIDAndBounds > ItemIDsBounds;
|
||||
// A list of items to be passed between rendering jobs
|
||||
using ItemIDsBounds = std::vector<ItemIDAndBounds>;
|
||||
|
||||
// A map of items by ShapeKey to optimize rendering pipeline assignments
|
||||
using ShapesIDsBounds = std::unordered_map<ShapeKey, ItemIDsBounds, ShapeKey::Hash, ShapeKey::KeyEqual>;
|
||||
|
||||
|
||||
// A map of ItemIDSets allowing to create bucket lists of items which are filtering correctly
|
||||
|
|
Loading…
Reference in a new issue