diff --git a/rts/Lua/LuaVBOImpl.cpp b/rts/Lua/LuaVBOImpl.cpp index 75cb5265d1..91b936303c 100644 --- a/rts/Lua/LuaVBOImpl.cpp +++ b/rts/Lua/LuaVBOImpl.cpp @@ -1493,6 +1493,17 @@ bool LuaVBOImpl::CopyTo(const std::shared_ptr& destVBO, int copySize auto result = vbo->CopyTo(*destVBO->vbo, static_cast(copySizeInBytes)); + // VBO::CopyTo only moves GPU->GPU. We need to also copy over the CPU-side bufferData. + if (result && bufferData != nullptr && destVBO->bufferData != nullptr && copySizeInBytes > 0) { + const auto n = std::min({ + static_cast(copySizeInBytes), + bufferSizeInBytes, + destVBO->bufferSizeInBytes + }); + if (n > 0) + memcpy(destVBO->bufferData, bufferData, n); + } + if (!wasBound) vbo->Unbind();