void D3D11HardwareBuffer::copyData(HardwareBuffer& srcBuffer, UINT32 srcOffset, UINT32 dstOffset, UINT32 length, bool discardWholeBuffer) { // If we're copying same-size buffers in their entirety if (srcOffset == 0 && dstOffset == 0 && length == mSizeInBytes && mSizeInBytes == srcBuffer.getSizeInBytes()) { mDevice.getImmediateContext()->CopyResource(mD3DBuffer, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer()); if (mDevice.hasError()) { String errorDescription = mDevice.getErrorDescription(); BS_EXCEPT(RenderingAPIException, "Cannot copy D3D11 resource\nError Description:" + errorDescription); } } else { // Copy subregion D3D11_BOX srcBox; srcBox.left = (UINT)srcOffset; srcBox.right = (UINT)srcOffset + length; srcBox.top = 0; srcBox.bottom = 1; srcBox.front = 0; srcBox.back = 1; mDevice.getImmediateContext()->CopySubresourceRegion(mD3DBuffer, 0, (UINT)dstOffset, 0, 0, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer(), 0, &srcBox); if (mDevice.hasError()) { String errorDescription = mDevice.getErrorDescription(); BS_EXCEPT(RenderingAPIException, "Cannot copy D3D11 subresource region\nError Description:" + errorDescription); } } }
//--------------------------------------------------------------------- void D3D11HardwareBuffer::copyData(HardwareBuffer& srcBuffer, size_t srcOffset, size_t dstOffset, size_t length, bool discardWholeBuffer) { // If we're copying same-size buffers in their entirety... if (srcOffset == 0 && dstOffset == 0 && length == mSizeInBytes && mSizeInBytes == srcBuffer.getSizeInBytes()) { // schedule hardware buffer copy mDevice.GetImmediateContext()->CopyResource(mlpD3DBuffer, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer()); if (mDevice.isError()) { String errorDescription = mDevice.getErrorDescription(); OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Cannot copy D3D11 resource\nError Description:" + errorDescription, "D3D11HardwareBuffer::copyData"); } } else { // copy subregion D3D11_BOX srcBox; srcBox.left = (UINT)srcOffset; srcBox.right = (UINT)srcOffset + length; srcBox.top = 0; srcBox.bottom = 1; srcBox.front = 0; srcBox.back = 1; mDevice.GetImmediateContext()->CopySubresourceRegion(mlpD3DBuffer, 0, (UINT)dstOffset, 0, 0, static_cast<D3D11HardwareBuffer&>(srcBuffer).getD3DBuffer(), 0, &srcBox); if (mDevice.isError()) { String errorDescription = mDevice.getErrorDescription(); OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Cannot copy D3D11 subresource region\nError Description:" + errorDescription, "D3D11HardwareBuffer::copyData"); } } }
void HardwareBuffer::copyData(HardwareBuffer& srcBuffer) { size_t sz = std::min(getSizeInBytes(), srcBuffer.getSizeInBytes()); copyData(srcBuffer, 0, 0, sz, TRUE); }