History

Move instanced pipeline setup to lambda from batch

Zach Pomerantz committed 10 years ago

Commit f0797d81 parent cb06d4a4 files · +10 −14Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+7−4
@@ -1925,16 +1925,19 @@ uint32_t toCompactColor(const glm::vec4& color) { · 1924 unmodified lines
19251925
19261926 static const size_t INSTANCE_COLOR_BUFFER = 0;
19271927
1928−template <typename F>
1929−void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color, const render::ShapePipelinePointer& pipeline, F f) {
1928+void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color,
1929+ const render::ShapePipelinePointer& pipeline, gpu::Batch::NamedBatchData::Function f) {
1930+ // Add color to named buffer
19301931 {
19311932 gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);
19321933 auto compactColor = toCompactColor(color);
19331934 instanceColorBuffer->append(compactColor);
19341935 }
1935−
1936+
1937+ // Add call to named buffer
19361938 batch.setupNamedCalls(name, [f, pipeline](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {
1937− batch.setPipeline(pipeline->get(batch));
1939+ batch.setPipeline(pipeline->pipeline);
1940+ pipeline->prepare(batch);
19381941 f(batch, data);
19391942 });
19401943 }