History

use shared buffer_helpers::clone

humbletim committed 8 years ago

Commit 4d43e541 parent b0f444e1 file · +5 −15Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+5−15
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "gpu/StandardShaderLib.h"
3333
3434 #include "graphics/TextureMap.h"
35+#include "graphics/BufferViewHelpers.h"
3536 #include "render/Args.h"
3637
3738 #include "standardTransformPNTC_vert.h"
@@ -2409,26 +2410,15 @@ graphics::MeshPointer GeometryCache::meshFromShape(Shape geometryShape, glm::vec · 2371 unmodified lines
24092410
24102411 qDebug() << "GeometryCache::getMeshProxyListFromShape" << shapeData << stringFromShape(geometryShape);
24112412
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);
24262416
24272417 gpu::BufferView::Size numVertices = positionsBufferView.getNumElements();
24282418 Q_ASSERT(numVertices == normalsBufferView.getNumElements());
24292419
24302420 // apply input color across all vertices
2431− auto colorsBufferView = cloneBufferView(shapeData->_normalView);
2421+ auto colorsBufferView = buffer_helpers::clone(shapeData->_normalView);
24322422 for (gpu::BufferView::Size i = 0; i < numVertices; i++) {
24332423 colorsBufferView.edit<glm::vec3>((gpu::BufferView::Index)i) = color;
24342424 }