Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 10 files). Show all
Unified · Split
| @@ -43,7 +43,6 @@ static const int VERTICES_PER_TRIANGLE = 3; · 42 unmodified lines | |||
| 43 | static const gpu::Element POSITION_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ }; | 43 | static const gpu::Element POSITION_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ }; |
| 44 | static const gpu::Element NORMAL_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ }; | 44 | static const gpu::Element NORMAL_ELEMENT{ gpu::VEC3, gpu::FLOAT, gpu::XYZ }; |
| 45 | static const gpu::Element COLOR_ELEMENT{ gpu::VEC4, gpu::NUINT8, gpu::RGBA }; | 45 | static const gpu::Element COLOR_ELEMENT{ gpu::VEC4, gpu::NUINT8, gpu::RGBA }; |
| 46 | static const gpu::Element TRANSFORM_ELEMENT{ gpu::MAT4, gpu::FLOAT, gpu::XYZW }; | ||
| 47 | 46 | ||
| 48 | static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT; | 47 | static gpu::Stream::FormatPointer SOLID_STREAM_FORMAT; |
| 49 | static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT; | 48 | static gpu::Stream::FormatPointer INSTANCED_SOLID_STREAM_FORMAT; |
| @@ -491,7 +490,6 @@ gpu::Stream::FormatPointer& getInstancedSolidStreamFormat() { · 441 unmodified lines | |||
| 491 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, POSITION_ELEMENT); | 490 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::POSITION, gpu::Stream::POSITION, POSITION_ELEMENT); |
| 492 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::NORMAL, gpu::Stream::NORMAL, NORMAL_ELEMENT); | 491 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::NORMAL, gpu::Stream::NORMAL, NORMAL_ELEMENT); |
| 493 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::COLOR, gpu::Stream::COLOR, COLOR_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | 492 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::COLOR, gpu::Stream::COLOR, COLOR_ELEMENT, 0, gpu::Stream::PER_INSTANCE); |
| 494 | INSTANCED_SOLID_STREAM_FORMAT->setAttribute(gpu::Stream::INSTANCE_XFM, gpu::Stream::INSTANCE_XFM, TRANSFORM_ELEMENT, 0, gpu::Stream::PER_INSTANCE); | ||
| 495 | } | 493 | } |
| 496 | return INSTANCED_SOLID_STREAM_FORMAT; | 494 | return INSTANCED_SOLID_STREAM_FORMAT; |
| 497 | } | 495 | } |
| @@ -511,11 +509,9 @@ GeometryCache::~GeometryCache() { · 13 unmodified lines | |||
| 511 | #endif //def WANT_DEBUG | 509 | #endif //def WANT_DEBUG |
| 512 | } | 510 | } |
| 513 | 511 | ||
| 514 | void setupBatchInstance(gpu::Batch& batch, gpu::BufferPointer transformBuffer, gpu::BufferPointer colorBuffer) { | 512 | void setupBatchInstance(gpu::Batch& batch, gpu::BufferPointer colorBuffer) { |
| 515 | gpu::BufferView colorView(colorBuffer, COLOR_ELEMENT); | 513 | gpu::BufferView colorView(colorBuffer, COLOR_ELEMENT); |
| 516 | batch.setInputBuffer(gpu::Stream::COLOR, colorView); | 514 | batch.setInputBuffer(gpu::Stream::COLOR, colorView); |
| 517 | gpu::BufferView instanceXfmView(transformBuffer, 0, transformBuffer->getSize(), TRANSFORM_ELEMENT); | ||
| 518 | batch.setInputBuffer(gpu::Stream::INSTANCE_XFM, instanceXfmView); | ||
| 519 | } | 515 | } |
| 520 | 516 | ||
| 521 | void GeometryCache::renderShape(gpu::Batch& batch, Shape shape) { | 517 | void GeometryCache::renderShape(gpu::Batch& batch, Shape shape) { |
| @@ -530,13 +526,13 @@ void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape) { · 8 unmodified lines | |||
| 530 | 526 | ||
| 531 | void GeometryCache::renderShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& transformBuffer, gpu::BufferPointer& colorBuffer) { | 527 | void GeometryCache::renderShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& transformBuffer, gpu::BufferPointer& colorBuffer) { |
| 532 | batch.setInputFormat(getInstancedSolidStreamFormat()); | 528 | batch.setInputFormat(getInstancedSolidStreamFormat()); |
| 533 | setupBatchInstance(batch, transformBuffer, colorBuffer); | 529 | setupBatchInstance(batch, colorBuffer); |
| 534 | _shapes[shape].drawInstances(batch, count); | 530 | _shapes[shape].drawInstances(batch, count); |
| 535 | } | 531 | } |
| 536 | 532 | ||
| 537 | void GeometryCache::renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& transformBuffer, gpu::BufferPointer& colorBuffer) { | 533 | void GeometryCache::renderWireShapeInstances(gpu::Batch& batch, Shape shape, size_t count, gpu::BufferPointer& transformBuffer, gpu::BufferPointer& colorBuffer) { |
| 538 | batch.setInputFormat(getInstancedSolidStreamFormat()); | 534 | batch.setInputFormat(getInstancedSolidStreamFormat()); |
| 539 | setupBatchInstance(batch, transformBuffer, colorBuffer); | 535 | setupBatchInstance(batch, colorBuffer); |
| 540 | _shapes[shape].drawWireInstances(batch, count); | 536 | _shapes[shape].drawWireInstances(batch, count); |
| 541 | } | 537 | } |
| 542 | 538 | ||
| @@ -1871,11 +1867,7 @@ void renderInstances(const std::string& name, gpu::Batch& batch, const Transform · 1328 unmodified lines | |||
| 1871 | 1867 | ||
| 1872 | batch.setupNamedCalls(name, [f](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | 1868 | batch.setupNamedCalls(name, [f](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { |
| 1873 | auto pipeline = DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch); | 1869 | auto pipeline = DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch); |
| 1874 | auto location = pipeline->getProgram()->getUniforms().findLocation("Instanced"); | ||
| 1875 | |||
| 1876 | batch._glUniform1i(location, 1); | ||
| 1877 | f(batch, data); | 1870 | f(batch, data); |
| 1878 | batch._glUniform1i(location, 0); | ||
| 1879 | }); | 1871 | }); |
| 1880 | } | 1872 | } |
| 1881 | 1873 | ||