It's not quite clear what you're asking, because you cannot update buffer with ID3D10Device::CopySubresourceRegion()
. I'm trying to clarify resource copying and resource updating in my answer.
Updating resource
By "updating" resource we usually mean transferring data from system memory to GPU memory1, with overwriting.
For updating resource you use either ID3D10Buffer::Map()
/ID3D10Buffer::Unmap()
pair or ID3D10Device::UpdateSubresource()
method. Which is better to use depends on resource properties and update frequency (read Nvidia's "canonical" paper).
Usage is really straightforward. Here is a case for simple 1D buffer, such as vertex buffer.
// Source array/vector (srcData): [xxxxDATADATADATADATADATAxxxxxxxxxxx]
// ^ ^
// srcBegin (srcBegin+bytesToCopy)
//
// Destination buffer (pBuffer): [xxDATADATADATADATADATAxxxxxxxxxxxxx]
// ^ ^
// destinationBegin (destinationBegin+bytesToCopy)
D3D11_BOX box{};
box.left = destinationBegin;
box.right = destinationBegin + bytesToCopy;
box.top = 0;
box.bottom = 1;
box.front = 0;
box.back = 1;
Device->UpdateSubresource(pBuffer, 0, &box, (uint8_t*)srcData+srcBegin, 0, 0);
Copying resource
As name states, ID3D10Device::CopySubresourceRegion()
method is suited for copying data between two resources (such as buffers or textures). Simplifying, you can think of it as of copying chunks of data inside videocard's memory (but that's not always true). You cannot "update" GPU memory with that method, as data being copied already there.
Here is a simple example:
D3D11_BOX srcBox{};
srcBox.left = srcBegin;
srcBox.right = srcBegin + size;
srcBox.top = 0;
srcBox.bottom = 1;
srcBox.front = 0;
srcBox.back = 1;
Device->CopySubresourceRegion(pDst, 0, dstBegin, 0, 0, pSrc, 0, &srcBox);
Hope it helps.
BTW, there is no any reason to learn DirectX 10 in 2013. You can start with DirectX 11, its API is almost the same, but more features.
1 This explanation is overly simplified. We can never be sure where given resource resides (GPU, system memory, whatever storage), as it is up to driver implementer to decide where when and which kinds of resources to store.