mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
Move instanced pipeline setup to lambda from batch
This commit is contained in:
parent
cb06d4a9e4
commit
f0797d8ea0
4 changed files with 10 additions and 14 deletions
|
@ -73,12 +73,10 @@ public:
|
||||||
BufferPointers buffers;
|
BufferPointers buffers;
|
||||||
Function function;
|
Function function;
|
||||||
DrawCallInfoBuffer drawCallInfos;
|
DrawCallInfoBuffer drawCallInfos;
|
||||||
Pipeline::Pointer pipeline;
|
|
||||||
|
|
||||||
size_t count() const { return drawCallInfos.size(); }
|
size_t count() const { return drawCallInfos.size(); }
|
||||||
|
|
||||||
void process(Batch& batch) {
|
void process(Batch& batch) {
|
||||||
batch.setPipeline(pipeline);
|
|
||||||
if (function) {
|
if (function) {
|
||||||
function(batch, *this);
|
function(batch, *this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1925,16 +1925,19 @@ uint32_t toCompactColor(const glm::vec4& color) {
|
||||||
|
|
||||||
static const size_t INSTANCE_COLOR_BUFFER = 0;
|
static const size_t INSTANCE_COLOR_BUFFER = 0;
|
||||||
|
|
||||||
template <typename F>
|
void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color,
|
||||||
void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color, const render::ShapePipelinePointer& pipeline, F f) {
|
const render::ShapePipelinePointer& pipeline, gpu::Batch::NamedBatchData::Function f) {
|
||||||
|
// Add color to named buffer
|
||||||
{
|
{
|
||||||
gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);
|
gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);
|
||||||
auto compactColor = toCompactColor(color);
|
auto compactColor = toCompactColor(color);
|
||||||
instanceColorBuffer->append(compactColor);
|
instanceColorBuffer->append(compactColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add call to named buffer
|
||||||
batch.setupNamedCalls(name, [f, pipeline](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
|
batch.setupNamedCalls(name, [f, pipeline](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
|
||||||
batch.setPipeline(pipeline->get(batch));
|
batch.setPipeline(pipeline->pipeline);
|
||||||
|
pipeline->prepare(batch);
|
||||||
f(batch, data);
|
f(batch, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,6 @@ ShapeKey::Filter::Builder::Builder() {
|
||||||
_mask.set(INVALID);
|
_mask.set(INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer ShapePipeline::get(gpu::Batch& batch) {
|
|
||||||
batchSetter(*this, batch);
|
|
||||||
return this->pipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShapePlumber::addPipelineHelper(const Filter& filter, ShapeKey key, int bit, const PipelinePointer& pipeline) {
|
void ShapePlumber::addPipelineHelper(const Filter& filter, ShapeKey key, int bit, const PipelinePointer& pipeline) {
|
||||||
// Iterate over all keys
|
// Iterate over all keys
|
||||||
if (bit < (int)ShapeKey::FlagBit::NUM_FLAGS) {
|
if (bit < (int)ShapeKey::FlagBit::NUM_FLAGS) {
|
||||||
|
|
|
@ -223,9 +223,9 @@ public:
|
||||||
ShapePipeline(gpu::PipelinePointer pipeline, LocationsPointer locations, BatchSetter batchSetter) :
|
ShapePipeline(gpu::PipelinePointer pipeline, LocationsPointer locations, BatchSetter batchSetter) :
|
||||||
pipeline(pipeline), locations(locations), batchSetter(batchSetter) {}
|
pipeline(pipeline), locations(locations), batchSetter(batchSetter) {}
|
||||||
|
|
||||||
// Normally, a pipeline is accessed thorugh pickPipeline. If it needs to be accessed manually,
|
// Normally, a pipeline is accessed thorugh pickPipeline. If it needs to be set manually,
|
||||||
// this method preps the pipeline with defaults set by its batchSetter and returns only the gpu::Pipeline.
|
// after calling setPipeline this method should be called to prepare the pipeline with default buffers.
|
||||||
gpu::PipelinePointer get(gpu::Batch& batch);
|
void prepare(gpu::Batch& batch) { batchSetter(*this, batch); }
|
||||||
|
|
||||||
gpu::PipelinePointer pipeline;
|
gpu::PipelinePointer pipeline;
|
||||||
std::shared_ptr<Locations> locations;
|
std::shared_ptr<Locations> locations;
|
||||||
|
|
Loading…
Reference in a new issue