Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 13 files). Show all
Unified · Split
| @@ -524,24 +524,24 @@ void GeometryCache::renderWireShape(gpu::Batch& batch, Shape shape) { · 523 unmodified lines | ||
| 524 | 524 | _shapes[shape].drawWire(batch); |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | −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& colorBuffer) { | |
| 528 | 528 | batch.setInputFormat(getInstancedSolidStreamFormat()); |
| 529 | 529 | setupBatchInstance(batch, colorBuffer); |
| 530 | 530 | _shapes[shape].drawInstances(batch, count); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | −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& colorBuffer) { | |
| 534 | 534 | batch.setInputFormat(getInstancedSolidStreamFormat()); |
| 535 | 535 | setupBatchInstance(batch, colorBuffer); |
| 536 | 536 | _shapes[shape].drawWireInstances(batch, count); |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | −void GeometryCache::renderCubeInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer transformBuffer, gpu::BufferPointer colorBuffer) { | |
| 540 | − renderShapeInstances(batch, Cube, count, transformBuffer, colorBuffer); | |
| 539 | +void GeometryCache::renderCubeInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer colorBuffer) { | |
| 540 | + renderShapeInstances(batch, Cube, count, colorBuffer); | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | −void GeometryCache::renderWireCubeInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer transformBuffer, gpu::BufferPointer colorBuffer) { | |
| 544 | − renderWireShapeInstances(batch, Cube, count, transformBuffer, colorBuffer); | |
| 543 | +void GeometryCache::renderWireCubeInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer colorBuffer) { | |
| 544 | + renderWireShapeInstances(batch, Cube, count, colorBuffer); | |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | void GeometryCache::renderCube(gpu::Batch& batch) { |
| @@ -552,8 +552,8 @@ void GeometryCache::renderWireCube(gpu::Batch& batch) { · 4 unmodified lines | ||
| 552 | 552 | renderWireShape(batch, Cube); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | −void GeometryCache::renderSphereInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer transformBuffer, gpu::BufferPointer colorBuffer) { | |
| 556 | − renderShapeInstances(batch, Sphere, count, transformBuffer, colorBuffer); | |
| 555 | +void GeometryCache::renderSphereInstances(gpu::Batch& batch, size_t count, gpu::BufferPointer colorBuffer) { | |
| 556 | + renderShapeInstances(batch, Sphere, count, colorBuffer); | |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | void GeometryCache::renderSphere(gpu::Batch& batch) { |
| @@ -1854,37 +1854,31 @@ static const size_t INSTANCE_TRANSFORM_BUFFER = 0; · 1294 unmodified lines | ||
| 1854 | 1854 | static const size_t INSTANCE_COLOR_BUFFER = 1; |
| 1855 | 1855 | |
| 1856 | 1856 | template <typename F> |
| 1857 | −void renderInstances(const std::string& name, gpu::Batch& batch, const Transform& transform, const glm::vec4& color, F f) { | |
| 1857 | +void renderInstances(const std::string& name, gpu::Batch& batch, const glm::vec4& color, F f) { | |
| 1858 | 1858 | { |
| 1859 | − gpu::BufferPointer instanceTransformBuffer = batch.getNamedBuffer(name, INSTANCE_TRANSFORM_BUFFER); | |
| 1860 | − glm::mat4 glmTransform; | |
| 1861 | − instanceTransformBuffer->append(transform.getMatrix(glmTransform)); | |
| 1862 | − | |
| 1863 | 1859 | gpu::BufferPointer instanceColorBuffer = batch.getNamedBuffer(name, INSTANCE_COLOR_BUFFER); |
| 1864 | 1860 | auto compactColor = toCompactColor(color); |
| 1865 | 1861 | instanceColorBuffer->append(compactColor); |
| 1866 | 1862 | } |
| 1867 | 1863 | |
| 1868 | 1864 | batch.setupNamedCalls(name, [f](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { |
| 1869 | − auto pipeline = DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch); | |
| 1865 | + DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch); | |
| 1870 | 1866 | f(batch, data); |
| 1871 | 1867 | }); |
| 1872 | 1868 | } |
| 1873 | 1869 | |
| 1874 | −void GeometryCache::renderSolidSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { | |
| 1870 | +void GeometryCache::renderSolidSphereInstance(gpu::Batch& batch, const glm::vec4& color) { | |
| 1875 | 1871 | static const std::string INSTANCE_NAME = __FUNCTION__; |
| 1876 | − renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1877 | − DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data.count, | |
| 1878 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1872 | + renderInstances(INSTANCE_NAME, batch, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1873 | + DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, GeometryCache::Sphere, data.count(), | |
| 1879 | 1874 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1880 | 1875 | }); |
| 1881 | 1876 | } |
| 1882 | 1877 | |
| 1883 | −void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { | |
| 1878 | +void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const glm::vec4& color) { | |
| 1884 | 1879 | static const std::string INSTANCE_NAME = __FUNCTION__; |
| 1885 | − renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1886 | − DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data.count, | |
| 1887 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1880 | + renderInstances(INSTANCE_NAME, batch, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1881 | + DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, GeometryCache::Sphere, data.count(), | |
| 1888 | 1882 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1889 | 1883 | }); |
| 1890 | 1884 | } |
| @@ -1893,12 +1887,12 @@ void GeometryCache::renderWireSphereInstance(gpu::Batch& batch, const Transform& · 2 unmodified lines | ||
| 1893 | 1887 | // available shape types, both solid and wireframes |
| 1894 | 1888 | //#define DEBUG_SHAPES |
| 1895 | 1889 | |
| 1896 | −void GeometryCache::renderSolidCubeInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { | |
| 1890 | +void GeometryCache::renderSolidCubeInstance(gpu::Batch& batch, const glm::vec4& color) { | |
| 1897 | 1891 | static const std::string INSTANCE_NAME = __FUNCTION__; |
| 1898 | 1892 | |
| 1899 | 1893 | #ifdef DEBUG_SHAPES |
| 1900 | 1894 | static auto startTime = usecTimestampNow(); |
| 1901 | − renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1895 | + renderInstances(INSTANCE_NAME, batch, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1902 | 1896 | |
| 1903 | 1897 | auto usecs = usecTimestampNow(); |
| 1904 | 1898 | usecs -= startTime; |
| @@ -1923,29 +1917,25 @@ void GeometryCache::renderSolidCubeInstance(gpu::Batch& batch, const Transform& · 18 unmodified lines | ||
| 1923 | 1917 | |
| 1924 | 1918 | // For the first half second for a given shape, show the wireframe, for the second half, show the solid. |
| 1925 | 1919 | if (fractionalSeconds > 0.5f) { |
| 1926 | − DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count, | |
| 1927 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1920 | + DependencyManager::get<GeometryCache>()->renderShapeInstances(batch, shape, data.count(), | |
| 1928 | 1921 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1929 | 1922 | } else { |
| 1930 | − DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count, | |
| 1931 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1923 | + DependencyManager::get<GeometryCache>()->renderWireShapeInstances(batch, shape, data.count(), | |
| 1932 | 1924 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1933 | 1925 | } |
| 1934 | 1926 | }); |
| 1935 | 1927 | #else |
| 1936 | − renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1937 | − DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data.count, | |
| 1938 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1928 | + renderInstances(INSTANCE_NAME, batch, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1929 | + DependencyManager::get<GeometryCache>()->renderCubeInstances(batch, data.count(), | |
| 1939 | 1930 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1940 | 1931 | }); |
| 1941 | 1932 | #endif |
| 1942 | 1933 | } |
| 1943 | 1934 | |
| 1944 | −void GeometryCache::renderWireCubeInstance(gpu::Batch& batch, const Transform& transform, const glm::vec4& color) { | |
| 1935 | +void GeometryCache::renderWireCubeInstance(gpu::Batch& batch, const glm::vec4& color) { | |
| 1945 | 1936 | static const std::string INSTANCE_NAME = __FUNCTION__; |
| 1946 | − renderInstances(INSTANCE_NAME, batch, transform, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1947 | − DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data.count, | |
| 1948 | − data.buffers[INSTANCE_TRANSFORM_BUFFER], | |
| 1937 | + renderInstances(INSTANCE_NAME, batch, color, [](gpu::Batch& batch, gpu::Batch::NamedBatchData& data) { | |
| 1938 | + DependencyManager::get<GeometryCache>()->renderWireCubeInstances(batch, data.count(), | |
| 1949 | 1939 | data.buffers[INSTANCE_COLOR_BUFFER]); |
| 1950 | 1940 | }); |
| 1951 | 1941 | } |