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
1925 1925
1926static const size_t INSTANCE_COLOR_BUFFER = 0;1926static const size_t INSTANCE_COLOR_BUFFER = 0;
1927 1927
1928template <typename F>1928void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color,
1929void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color, const render::ShapePipelinePointer& pipeline, F f) {1929 const render::ShapePipelinePointer& pipeline, gpu::Batch::NamedBatchData::Function f) {
1930 // Add color to named buffer
1930 {1931 {
1931 gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);1932 gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER);
1932 auto compactColor = toCompactColor(color);1933 auto compactColor = toCompactColor(color);
1933 instanceColorBuffer->append(compactColor);1934 instanceColorBuffer->append(compactColor);
1934 }1935 }
1935 1936
1937 // Add call to named buffer
1936 batch.setupNamedCalls(name, [f, pipeline](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) {1938 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);
1938 f(batch, data);1941 f(batch, data);
1939 });1942 });
1940}1943}