XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Direct3d10 Buffers Help

Last post 09-08-2008 4:32 PM by Ralf Kornmann. 1 replies.
  • 09-03-2008 8:35 AM

    Direct3d10 Buffers Help

    Hi, i am trying to play with d3d10 over the last few days (actually porting my engine from ogl 2.1 to d3d10). I have to say, i am a bit confused with how i should make use of the buffers. I am going to lay down a few questions I have.

    So far, I was creating two large buffers, one for static objects and one for dynamic which i was filling with data. I was copying during init the data from all my meshes chunk by chunk to the static buffer and i was keeping my dynamic buffer empty which i was filling before rendering. During rendering i was binding the appropriate buffer and was moving the pointer to render the data i need.
    Is this the approach i should use for d3d10 too? Create two large buffers, one for static (D3D10_USAGE_DEFAULT and D3D10_USAGE_DYNAMIC) plus a few more for constant buffer data? Most of the samples i have seen on dx10 sdk create a buffer for each individual mesh and d3d10 allows 16 buffers to run simultaneously. Is it better to have two big buffers or many smaller ones? What is the best approach?

    As for the static buffer(or buffers) is it better to gather all the data onto a buffer array and then initialize the d3d10buffer with it, or create an empty buffer and then copy the data chunk by chunk? The latter seems more convienient in terms of the extra storage i would need to have on my app.

    In case i do the latter,  do i use the Map or SubResource method? I assume the SubResource functions are mostly for texture data.

    I am a bit lost :).

    Thank you.

  • 09-08-2008 4:32 PM In reply to

    Re: Direct3d10 Buffers Help

    The number of buffers depends on your needs. In general fewer buffers are better but more complex to handle. Another problem with a single large buffer can occur if you have only limited memory on your graphics adapter and cannot fit anything in. With smaller buffers the video memory manager can swap smaller parts between system and video memory.

    The 16 buffers limit doesn’t mean that you can have only 16 buffers. It means that you can read from up to 16 buffers at the same time. It’s not uncommon to read positions from one buffer and the indices and weights for the skinning from another one. Most time you will see such techniques when same geometry is rendered multiple times with different shaders that require different inputs.

    Collection all data before actual creating the buffer allows you to create an immutable buffer. Such buffers can give you better performances. The usage of Map/Unmap vs UpdateSubresource depends on the type of buffer you create. An dynamic buffer supports Map/Unmap while a default buffer requires UpdateSubresource. Another way ist to create a staging resource (which support map/unmap) and use CopyResiource/CopySubresource to transfer the data to the default resource.

Page 1 of 1 (2 items) Previous Next