void GLES2HardwareIndexBuffer::copyData(HardwareBuffer& srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, bool discardWholeBuffer) { // If the buffer is not in system memory we can use ARB_copy_buffers to do an optimised copy. if (srcBuffer.isSystemMemory()) { HardwareBuffer::copyData(srcBuffer, srcOffset, dstOffset, length, discardWholeBuffer); } else { // Unbind the current buffer OGRE_CHECK_GL_ERROR(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); // Zero out this(destination) buffer OGRE_CHECK_GL_ERROR(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBufferId)); OGRE_CHECK_GL_ERROR(glBufferData(GL_ELEMENT_ARRAY_BUFFER, length, 0, GLES2HardwareBufferManager::getGLUsage(mUsage))); OGRE_CHECK_GL_ERROR(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); // Do it the fast way. OGRE_CHECK_GL_ERROR(glBindBuffer(GL_COPY_READ_BUFFER, static_cast<GLES2HardwareIndexBuffer &>(srcBuffer).getGLBufferId())); OGRE_CHECK_GL_ERROR(glBindBuffer(GL_COPY_WRITE_BUFFER, mBufferId)); OGRE_CHECK_GL_ERROR(glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, srcOffset, dstOffset, length)); OGRE_CHECK_GL_ERROR(glBindBuffer(GL_COPY_READ_BUFFER, 0)); OGRE_CHECK_GL_ERROR(glBindBuffer(GL_COPY_WRITE_BUFFER, 0)); } }
//--------------------------------------------------------------------- void D3D11HardwareUniformBuffer::copyData(HardwareBuffer& srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, bool discardWholeBuffer) { // check if the other buffer is also a D3D11HardwareVertexBuffer if (srcBuffer.isSystemMemory()) { // src is not a D3D11HardwareVertexBuffer - use default copy HardwareBuffer::copyData(srcBuffer, srcOffset, dstOffset, length, discardWholeBuffer); } else { // src is a D3D11HardwareUniformBuffer use d3d11 optimized copy D3D11HardwareUniformBuffer& d3dBuf = static_cast<D3D11HardwareUniformBuffer&>(srcBuffer); mBufferImpl->copyData(*(d3dBuf.mBufferImpl), srcOffset, dstOffset, length, discardWholeBuffer); } }
void GL3PlusHardwareIndexBuffer::copyData(HardwareBuffer& srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, bool discardWholeBuffer) { // If the buffer is not in system memory we can use ARB_copy_buffers to do an optimised copy. if (srcBuffer.isSystemMemory()) { HardwareBuffer::copyData(srcBuffer, srcOffset, dstOffset, length, discardWholeBuffer); } else { if(mUseShadowBuffer) { mShadowBuffer->copyData(srcBuffer, srcOffset, dstOffset, length, discardWholeBuffer); } mBuffer.copyData(static_cast<GL3PlusHardwareIndexBuffer&>(srcBuffer).getGLBufferId(), srcOffset, dstOffset, length, discardWholeBuffer); } }