Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualHodgman

Posted 07 April 2013 - 03:45 PM

That wiki doesn't describe a "D3D comparability mode", it just has some tips on how to do some operations that are easy in D3D but confusing in GL.

When it comes to less buffers & large strides, vs more buffers with small strides, no, there is not a preferred way for each API. They both cope with either way just as well as each other.

In D3D, the 'stream' param of the declaration is the index of the vertex buffer that will be read from. Before drawing, you must bind a vertex buffer to this slot with SetStreamSource.

As for the optimal data layout, it depends in multiple different vertex shaders use the same data (e.g. A shadow mapping shader only needs position, not normals, etc), and on the actual GPUs memory fetching hardware. This will operate like any CPU cache, where it will overfetch whole 'cache lines' from RAM - usually you'd want your vertex stride to match this size, which means putting multiple attributes together - back in this era of GPUs, 32 byte stride was the recommedation, but this depends on the GPU... However, as above, if you pack pos/normal together, then the shadow mapping shader will be loading normals into the cache for no reason, so maybe it would be preferable to have one buffer with just positions, and another with all other attributes...
Really though, don't worry too much about it. It doesn't matter if your GPU usage isn't 100% optimal.

#1Hodgman

Posted 07 April 2013 - 03:41 PM

That wiki doesn't describe a "D3D comparability mode", it just has some tips on how to do some operations that are easy in D3D but confusing in GL.

When it comes to less buffers & large strides, vs more buffers with small strides, no, there is not a preferred way for each API. They both cope with either way just as well as each other.

In D3D, the 'stream' param of the declaration is the index of the vertex buffer that will be read from. Before drawing, you must bind a vertex buffer to this slot with SetStreamSource.

As for the optimal data layout, it depends in multiple different vertex shaders use the same data (e.g. A shadow mapping shader only needs position, not normals, etc), and on the actual GPUs memory fetching hardware. This will operate like any CPU cache, where it will overfetch whole 'cache lines' from RAM - usually you'd want your vertex stride to match this size, which means putting multiple attributes together. However, as above, if you pack pos/normal together, then the shadow mapping shader will be loading normals into the cache for no reason...
Really though, don't worry too much about it. It doesn't matter if your GPU usage isn't 100% optimal.

PARTNERS