DX10 vertex & index double buffering

5225bc0c3bf66f4c275c332de6388d1f
0
SyntaxError 101 Nov 22, 2010 at 03:06

I have almost finished porting my game engine from DX9 to DX10 but I have one final problem I haven’t been able to solve yet. I’m using double buffering of my terrain so that one set of vertex index buffers is being updated by the CPU while a second set is being used by the GPU. When the new version is ready I swap buffer sets. This used to work fine in DX9 However in DX10 there is a noticeable hiccup when swapping. I think this may be because I can no long specify the pool where my vertex and index buffers are created. The only options I can use are D3D10_USAGE_DYNAMIC & D3D10_CPU_ACCESS_WRITE. So what I think is happening is that DX10 doesn’t actually copy the data to the card when you Unmap the your buffers. It may weight until you actualy try to use it in case you aren’t done yet and are going to map and write to a different section before you are ready. I’m not %100 sure about this it’s just a guess. In any case if this is what’s happening then that explains the hicup beucase it has to copy the data to the card before using it. I noticed that ID3DX10Mesh has a CommitToDevice member that’s supposed to copy data to the card. It has this in addtion to the Map and Unmap functions for it’s buffers. However I don’t see anything like this for just rgular vertex and index buffers. Anyone know how to force a commit?

3 Replies

Please log in or register to post a reply.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 22, 2010 at 14:19

What parameters do you pass to the Map() function? Probably not D3D10_MAP_WRITE_DISCARD, or are you?

http://msdn.microsoft.com/en-us/library/bb205318(v=VS.85).aspx

5225bc0c3bf66f4c275c332de6388d1f
0
SyntaxError 101 Nov 22, 2010 at 15:21

@.oisyn

What parameters do you pass to the Map() function? Probably not D3D10_MAP_WRITE_DISCARD, or are you? http://msdn.microsoft.com/en-us/library/bb205318(v=VS.85).aspx

Yes I am actually since I don’t need to save the previous contents of the buffer.

5225bc0c3bf66f4c275c332de6388d1f
0
SyntaxError 101 Nov 24, 2010 at 02:53

Well I kind of figured it out. Evidently DX9 is better at streaming large buffers to the GPU than DX10, or at least on my hardware. What I’m doing now is breaking terrain up into smaller sized buffers (before I had terrain chunks but they were all in one large buffer) where each small buffer is actually a buffer pair: one D3D10_USAGE_STAGING buffer (CPU side only) and one D3D10_USAGE_DEFAULT buffer (GPU side only). After I build things in the staging buffer I do a CopyResource to copy to the default buffer. I think this may actually be how ID3DX10Mesh works. It explains what CommitToDevice does and why there is no CommitToDevice in the regular vertex and index buffer interface. The MS documentation on CommitToDevice pretty much says this in not so many words. If ID3DX10Mesh works this way it makes me wonder if I should ever be using D3D10_USAGE_DYNAMIC buffers.