Notes on porting to DirectX 11.1 from earlier versions

Skull model from Frank Luna's book, 'Introduction to 3D Game Programming with DirectX 11', ported to DirectX 11.1.

Yours truly has moved to a new team in the Windows Developer Content org, so now I focus on DirectX and game development. Long-time readers know of my interest in computational methods for mathematical physics, so this is a great opportunity for porting some code to the GPU for high-performance number crunching.

But first, I need to learn DirectX 11.1. So I started by reading Frank Luna’s Introduction to 3D Game Programming with DirectX 11 . I’m about halfway through and ready to play with code, so I took his examples (d3dcoder.net) and tried to build them with Visual Studio 2012 and DX11.1. This turns out not to be a slam dunk; even though it’s only a point upgrade, DX11.1 differs significantly from DX11.  Here are a few notes from along the porting path.

  • The docs are very helpful. Be sure to check out Getting Started with Direct3D. In particular, the docs are good about telling us which functions are deprecated and what we should use instead. For example, here’s the note from the obsolete D3DX11CompileFromFile function:

Note  The D3DX (D3DX 9, D3DX 10, and D3DX 11) utility library is deprecated for Windows 8 and is not supported for Windows Store apps. Instead of using this function, we recommend that you compile offline by using the Fxc.exe command-line compiler or use one of the HLSL compile APIs, like the D3DCompileFromFile API.

  • The DirectX SDK is now legacy; all of the DirectX header files and binaries ship with Visual Studio by default and live at %Program Files%\Windows Kits\8.0\Include\um and %Program Files%\Windows Kits\8.0\Lib\win8\um – you don’t need to add these to your project’s include and lib directories. So don’t be confused when you read somewhere that you need to “download and install the DirectX SDK”. You don’t need to do that now.

  • The D3DX utility library (d3dx11.lib) is no more, so functions that start with “D3DX” aren’t available. Consult the docs for DirectX 11.1 equivalents.

  • XNA is no more. The xnamath library has been moved to the DirectXMath library. Most of the type names are the same, so that’s good.

  • DxErr.lib and dxerr.h have gone away.

  • Set the _XM_NO_INTRINSICS_ compiler flag.

  • A lot of the previous DX11 types and functions have moved into namespaces, so you’ll need using directives to access them, like these:

     using namespace DirectX; 
     using namespace PackedVector;
    

For shader effects, you’ll need a separate shared-source library named Effects11, which is Chuck Walbourn’s baby now. Here's a table that shows the original utility functions and the equivalent Effects11 functions:

D3DX utility function Effects11 equivalent
D3DXCreateEffect D3DXCreateEffectEx D3DXCreateEffectFromResource D3DXCreateEffectFromResourceEx D3D10CompileEffectFromMemory

D3DX11CompileEffectFromMemory

D3DXCreateEffectFromFile D3DXCreateEffectFromFileEx

D3DX11CompileEffectFromFile

D3D10CreateEffectFromMemory

D3DX11CreateEffectFromMemory

D3DXCreateEffectPool D3D10CreateEffectPoolFromMemory

Effects 11 does not support 'effect pools' or D3DCOMPILE_EFFECT_CHILD_EFFECT. Effect groups provide a more efficient solution for common scenarios previously addressed with 'effect pools'

D3DXDisassembleEffect D3D10DisassembleEffect

D3DDisassemble D3DDisassemble10Effect in D3DCompile

The version of Effect11.lib that ships with Frank Luna’s book won’t link when you’re building with DX11.1, so you’ll need to recompile. Fortunately, Chuck gives us solutions files for VS2010, VS2012, and VS2013, so it’s a snap. Drop the new Effects11.lib and d3dx11effect.h header into Frank’s Common folder, and you’re ready to build.

Technorati Tags: Windows,Windows SDK,DirectX

Comments

  • Anonymous
    August 10, 2013
    Hello, i'm also converting the code to work with dx11.1, but i have a problem with D3D10CreateEffectFromMemory as it takes a dx10 device and not 11

  • Anonymous
    August 10, 2013
    Actually i think i got it reversed, but in that case i'm getting unresolved external symbol error