Monthly Archives: November 2012

Moving from DirectX 9 to DirectX 11

Hello everyone, I am currently implementing a DirectX 11 engine and I thought it would be nice to write an article about some of the most important changes I have come across with respect to DirectX 9.

This article is aimed at people who have got at least a medium level of D3D9 and want to begin programming using D3D11. Some of the topics I am going to talk about were already introduced in D3D10.


If you have done some D3D9 programming before it is most likely that you used D3DXVECTOR as your vector type. The problem now is that D3DX11, in contrast to D3DX9 and D3DX10, does not include a vector type (In addition D3DX11 is deprecated for Windows 8).

Instead, Microsoft wants you to use XNAMATH.  There’s a good reason for using XNAMATH; XNA provides a vector type called XMVECTOR which take advantage of SIMD (Single instruction, multiple data); this means that we can increase our application performance by using this new type.

Likewise, we should use XMMATRIX (XNAMATH matrix type) for matrix calculations so that we can take advantage of SIMD as well for computations involving matrices.

However there are some considerations when using these types; for instance, XMVECTOR and XMMATRIX must be 16-byte aligned, this is done automatically for local and global variables but not for class members or struct members, in these two cases it is recommended to use XMFLOAT types (XMFLOAT3, XMFLOAT4X4, …) when storing the data into a class and then transform these types into XMVECTOR and XMMATRIX before doing the calculations.  There are some other restrictions (like when passing these types as parameters to a function); you can find more information here.

Good bye onLostDevice and OnResetDevice

In D3D9 if we didn’t want our application to crash when resizing the screen, minimizing, maximizing, etc, we had to create onResetDevice and onLostDevices methods for our resources (Information here ). This issue was usually translated into a lot of extra lines of code for assets management.

Continue reading