Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 1 file). Show all
Unified · Split
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "gpu/StandardShaderLib.h" |
| 33 | 33 | |
| 34 | 34 | #include "graphics/TextureMap.h" |
| 35 | +#include "graphics/BufferViewHelpers.h" | |
| 35 | 36 | #include "render/Args.h" |
| 36 | 37 | |
| 37 | 38 | #include "standardTransformPNTC_vert.h" |
| @@ -2409,26 +2410,15 @@ graphics::MeshPointer GeometryCache::meshFromShape(Shape geometryShape, glm::vec · 2371 unmodified lines | ||
| 2409 | 2410 | |
| 2410 | 2411 | qDebug() << "GeometryCache::getMeshProxyListFromShape" << shapeData << stringFromShape(geometryShape); |
| 2411 | 2412 | |
| 2412 | − auto cloneBufferView = [](const gpu::BufferView& in) -> gpu::BufferView { | |
| 2413 | − auto buffer = std::make_shared<gpu::Buffer>(*in._buffer); // copy | |
| 2414 | − // FIXME: gpu::BufferView seems to have a bug where constructing a new instance from an existing one | |
| 2415 | − // results in over-multiplied buffer/view sizes -- hence constructing manually here from each input prop | |
| 2416 | − auto out = gpu::BufferView(buffer, in._offset, in._size, in._stride, in._element); | |
| 2417 | − Q_ASSERT(out.getNumElements() == in.getNumElements()); | |
| 2418 | − Q_ASSERT(out._size == in._size); | |
| 2419 | − Q_ASSERT(out._buffer->getSize() == in._buffer->getSize()); | |
| 2420 | − return out; | |
| 2421 | − }; | |
| 2422 | − | |
| 2423 | − auto positionsBufferView = cloneBufferView(shapeData->_positionView); | |
| 2424 | − auto normalsBufferView = cloneBufferView(shapeData->_normalView); | |
| 2425 | − auto indexBufferView = cloneBufferView(shapeData->_indicesView); | |
| 2413 | + auto positionsBufferView = buffer_helpers::clone(shapeData->_positionView); | |
| 2414 | + auto normalsBufferView = buffer_helpers::clone(shapeData->_normalView); | |
| 2415 | + auto indexBufferView = buffer_helpers::clone(shapeData->_indicesView); | |
| 2426 | 2416 | |
| 2427 | 2417 | gpu::BufferView::Size numVertices = positionsBufferView.getNumElements(); |
| 2428 | 2418 | Q_ASSERT(numVertices == normalsBufferView.getNumElements()); |
| 2429 | 2419 | |
| 2430 | 2420 | // apply input color across all vertices |
| 2431 | − auto colorsBufferView = cloneBufferView(shapeData->_normalView); | |
| 2421 | + auto colorsBufferView = buffer_helpers::clone(shapeData->_normalView); | |
| 2432 | 2422 | for (gpu::BufferView::Size i = 0; i < numVertices; i++) { |
| 2433 | 2423 | colorsBufferView.edit<glm::vec3>((gpu::BufferView::Index)i) = color; |
| 2434 | 2424 | } |