This post is just a quick collection of references for porting math code between DX9/DX10 to DX11.
First, the maths library from dx9/10 is no longer in use in 11. It can still be compiled into a project but the d3dx vectors and matrices are not in the 11 library files or headers. Instead it has been replaced with DirectXMath (or if you are still using the most recent windows 7 sdk it is called XNAMath). Both client sides are the same between the two names, but the new(est) DirectXMath header has more functionality according to msdn. This is a bit confusing for inclusion of a d3d project for two reasons. First, these math libraries are not included with the dx sdk download, but rather the Microsoft windows 7.x (or 8) sdk. So a separate download is required. Second, msdn's getting started page states: "Replace the "xnamath.h" header with "DirectXMath.h" and add "DirectXPackedVector.h" for the "GPU packed"
types." This will only work if metro apps, or another windows 8 preview is installed, for anyone without a preview install still needs to use the xnamath.h (instead of the d3dxMath.h). The details can be found here:
The main difference is using the XMVECTOR when using a function call and storing the result for a class or other container that may want element access as a XMFLOAT4. The conversion between the two types can be perform with XMStore and XMLoad functions.
For shader authoring a small but important change between 10 and 11 is the transition of default row major matrices to column matrices. This port conversion is simple but worth stating. Either transpose row matrices prior to sending to the shader, or in the declaration of the matrix type in hlsl prefix it with row_major. Otherwise WVP matrices might be giving odd results.
Have you found the official lib download link?
ReplyDeleteAm building from Win7 and D3D11 target, besided redirecting the DXSDK_DIR, drop the dxerr.lib support, now am confronting the DirectXMath, v110_xp or vc110 toolset don't provide it. Comming from OpenGL and aware of the problem, it has been annoying to set up on Win7
ReplyDeleteThis is the best link i have found so far
ReplyDeletehttp://blogs.msdn.com/b/chuckw/archive/2011/02/23/xna-math-version-2-04.aspx
Hmm it seems DirectXMath.h is the way, but for some reason compiler is not accepting the header, though i can compile d3d11.h which is at same folder. Thanks anyways
ReplyDelete