DirectX 11 porting FAQ
[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]
Answers to frequently-asked questions about porting games to the Windows Store.
Where can I read about all of the Windows Store certification requirements for Windows Store apps using DirectX?
See Publishing Direct3D Windows Store apps to the Windows Store.
Is porting my game going to be a set of search-and-replace operations on API methods, or do I need to plan for a more thoughtful porting process?
Direct3D 11 is a significant upgrade from Direct3D 9. There are several paradigm shifts, including separate APIs for the virtualized graphics adapter and its context as well as a new layer of polymorphism for device resources. Your game can still use graphics hardware in essentially the same way, but you'll need to learn about the new Direct3D 11 API architecture and update each part of your graphics code to use the correct API components. See Porting concepts and considerations.
What is the new device context for? Am I supposed to replace my Direct3D 9 device with the Direct3D 11 device, the device context, or both?
The Direct3D device is now used to create resources in video memory, while the device context is used to set pipeline state and generate rendering commands. For more info see: What are the most important changes since Direct3D 9?
Do I have to update my game timer for Windows 8?
QueryPerformanceCounter, along with QueryPerformanceFrequency, is still the best way to implement a game timer for Windows Store games. It works on Windows RT PCs and Windows Phone 8.
You should be aware of a nuance with timers and the Windows Store app lifecycle. Suspend/resume is different from a player re-launching a desktop game because your game will resume a snapshot in time from when the game was last played. If a large amount of time has passed - for example, a few weeks - some game timer implementations might not behave gracefully. You can use app lifecycle events to reset your timer when the game resumes; see Launching and resuming apps.
Games that still use the RDTSC instruction need to upgrade. See Game Timing and Multicore Processors.
My game code is based on D3DX and DXUT. Is there anything available that can help me migrate my code?
The DirectX Tool Kit (DirectXTK) community project offers helper classes for use with Direct3D 11.
How do I maintain code paths for the desktop and the Windows Store?
Chuck Walbourn's article series titled Dual-use Coding Techniques for Games offers guidance on sharing code between the desktop and the Windows Store code paths.
How do I load image resources in my DirectX Windows Store game?
There are two API paths for loading images:
- The content pipeline converts images into DDS files used as Direct3D texture resources. See Using 3-D Assets in Your Game or App.
- The Windows Imaging Component can be used to load images from a variety of formats, and can be used for Direct2D bitmaps as well as Direct3D texture resources.
You can also use the DDSTextureLoader, and the WICTextureLoader, from the DirectXTK or DirectXTex.
Can I still use the Sleep function to delay threads in my Windows Store game?
The Sleep function is not supported for Windows Store apps. Use timers to delay execution of code, for example the Thread Pool API (or the Windows RT thread pool) can be used to create a timer that runs in a separate thread.
Note that your rendering loop will always block until the next vsync. This is a requirement for certification and it saves power on mobile devices. See IDXGISwapChain1::Present1.
Where is the DirectX SDK?
Starting with Windows 8, the DirectX SDK is included as part of the Windows SDK. The most recent DirectX SDK that was separate from the Windows SDK was in June 2010. Direct3D samples are in the Code Gallery along with the rest of the Windows app samples.
What about DirectX redistributables?
The vast majority of components in the Windows 8.0 SDK are already included in supported versions of the OS, or have no DLL component (such as DirectXMath). All Direct3D API components that Windows Store apps can use will already available to your game; you don't need to be redistribute them.
Win32 desktop applications still use DirectSetup, so if you are also upgrading the desktop version of your game see Direct3D 11 Deployment for Game Developers.
Is there any way I can update my desktop code to DirectX 11 before moving away from Effects?
See the Effects for Direct3D 11 Update. Effects 11 helps remove dependencies on legacy DirectX SDK headers; it's intended for use as a porting aid and can only be used with desktop apps.
How do I port my DirectX 9 shadow volumes to DirectX 11?
Use the Walkthrough: Implement shadow volumes using depth buffers in Direct3D 11 to learn more about implementing shadow volumes in Direct3D 11.
Is there a path for porting my DirectX 8 game to the Windows Store?
Yes:
- Read Converting to Direct3D 9.
- Make sure your game has no remnants of the fixed pipeline - see Deprecated Features.
- Then take the DirectX 9 porting path: Port from D3D 9 to Windows Store.
Can I port my DirectX 10 or 11 game to the Windows Store?
DirectX 10.x and 11 desktop games are easy to port to the Windows Store. See Migrating to Direct3D 11.
How do I choose the right display device in a multi-monitor system?
The user selects which monitor your app is displayed on. Let Windows provide the correct adapter by calling D3D11CreateDevice with the first parameter set to nullptr. Then get the device's IDXGIDevice interface, call GetAdapter and use the DXGI adapter to create the swap chain.
How do I turn on antialiasing?
Antialiasing (multisampling) is enabled when you create the Direct3D device. Enumerate multisampling support by calling CheckMultisampleQualityLevels, then set multisample options in the DXGI_SAMPLE_DESC structure when you call CreateSurface.
How do I ask questions?
You can post your questions in Building Windows Store games with DirectX on the MSDN forums. Provide feedback on MSDN articles by rating the topic or add community feedback.
My game renders using multithreading and/or deferred rendering. What do I need to know for Direct3D 11?
Visit Introduction to Multithreading in Direct3D 11 to get started. For a list of key differences, see Threading Differences between Direct3D Versions. Note that deferred rendering uses a device deferred context instead of an immediate context.
Where can I read more about the programmable pipeline since Direct3D 9?
Visit the following topics:
What should I use instead of the .x file format for my models?
While we don’t have an official replacement for the .x file format, many of the samples utilize the SDKMesh format. Visual Studio also has a content pipeline that compiles several popular formats into CMO files that can be loaded with code from the Visual Studio 3D starter kit, or loaded using the DirectXTK.
How do I debug my shaders?
Microsoft Visual Studio Professional 2012 and Microsoft Visual Studio Ultimate 2012 include diagnostic tools for DirectX graphics. See Debugging DirectX Graphics.
What is the Direct3D 11 equivalent for x function?
See the function mapping provided in Map DirectX 9 features to DirectX 11 APIs.
What is the DXGI_FORMAT equivalent of y surface format?
See the surface format mapping provided in Map DirectX 9 features to DirectX 11 APIs.