Hello,
I have 4 little questions about buffers in DX10:
1. Can I use a buffer created with usage = D3D10_USAGE_DEFAULT as destination in method CopyResource(ID3D10Resource *pDstResource, ID3D10Resource *pSrcResource)?
2. Which of these lock methods will perform better/faster:
Method A:
Vec3* verts;
vbuffer->Map( D3D10_MAP_WRITE, 0, (void**)&verts);
for(int i=0; i < 100; i++) {
//... Around 30 vector subtractions and about 10 cross products
verts = resultVector;
}
vbuffer->Unmap();
Method B:
Vec3* result = new Vec3[100];
for(int i=0; i < 100; i++) {
// Around 30 vector subtractions and about 10 cross products and then
result = resultVector;
}
Vec3* result
vbuffer->Map( D3D10_MAP_WRITE, 0, (void**)&verts);
for(int i=0; i < 100; i++)
verts = result; // Just copy the result to the buffer
vbuffer->Unmap();
So method A calculates everything while the buffer is locked and B calculates everything before the lock and just copies the data to the buffer. Will one of the methods generally be faster?
3. Is it ok to update only some vertices of a vertexbuffer or should I always refill the whole vector? So is this ok:
Vec3* verts;
vbuffer->Map( D3D10_MAP_WRITE, 0, (void**)&verts);
verts[20] = ...
verts[82] = ...
vbuffer->Unmap()
4. Last one: I have a vertexbuffer with terrain vertices that change from time to time (somtimes every frame and then sometimes only every 5 minutes). Should I create a dynamic vertex buffer and copy the new data directly the buffer per Map() or should I create 2 vertexbuffer's: one vertexbuffer with usage=D3D10_USAGE_DEFAULT and one with usage=D3D10_USAGE_STAGING and then copy the new data to the staging buffer and then copy the staging buffer to the default buffer with Copyresource? (I am asking because the docu says dynamic resources are a good choice for a resources that will be updated by the CPU at least once (!) per frame - which is not the case in my application)