[This documentation is preliminary and is subject to change.]
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.1 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.1 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.1.
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.1 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.1?
See Implementing shadow buffers for Direct3D feature level 9.
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.0 applications 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.1?
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.1 equivalent for x function?
Use the following table to help convert code from Direct3D 9 to Direct3D 11.1.
| Direct3D9 | Direct3D 11.1 Equivalent |
|---|---|
|
The graphics pipeline stages are described in Graphics Pipeline. | |
|
Call IDXGISwapChain1::Present1 with the DXGI_PRESENT_TEST flag set. | |
|
ID3D11DeviceContext::DrawIndexed ID3D11DeviceContext::DrawIndexedInstanced ID3D11DeviceContext::DrawInstanced | |
|
No direct equivalent | |
|
Use standard cursor APIs. | |
|
LOST device and POOL_MANAGED no longer exist. IDXGISwapChain1::Present1 can fail with a DXGI_ERROR_DEVICE_REMOVED return value. | |
|
IDirect3DDevice9:DrawRectPatch IDirect3DDevice9:MultiplyTransform |
The fixed-function pipeline has been deprecated. |
|
IDirect3DDevice9:CheckDepthStencilMatch IDirect3DDevice9:CheckDeviceFormat |
Capability bits are replaced with feature levels. Only a few format and feature usage cases are optional for any given feature level. These can be checked with ID3D11Device1::CheckFeatureSupport and ID3D11Device1::CheckFormatSupport. |
What is the DXGI_FORMAT equivalent of y surface format?
Use the following table to convert Direct3D 9 formats into DXGI formats.
| Direct3D 9 Format | Direct3D 11.1 Format |
|---|---|
|
D3DFMT_UNKNOWN |
DXGI_FORMAT_UNKNOWN |
|
D3DFMT_R8G8B8 |
Not available |
|
D3DFMT_A8R8G8B8 |
DXGI_FORMAT_B8G8R8A8_UNORM DXGI_FORMAT_B8G8R8A8_UNORM_SRGB |
|
D3DFMT_X8R8G8B8 |
DXGI_FORMAT_B8G8R8X8_UNORM DXGI_FORMAT_B8G8R8X8_UNORM_SRGB |
|
D3DFMT_R5G6B5 |
DXGI_FORMAT_B5G6R5_UNORM |
|
D3DFMT_X1R5G5B5 |
Not available |
|
D3DFMT_A1R5G5B5 |
DXGI_FORMAT_B5G5R5A1_UNORM |
|
D3DFMT_A4R4G4B4 |
DXGI_FORMAT_B4G4R4A4_UNORM |
|
D3DFMT_R3G3B2 |
Not available |
|
D3DFMT_A8 |
DXGI_FORMAT_A8_UNORM |
|
D3DFMT_A8R3G3B2 |
Not available |
|
D3DFMT_X4R4G4B4 |
Not available |
|
D3DFMT_A2B10G10R10 |
DXGI_FORMAT_R10G10B10A2 |
|
D3DFMT_A8B8G8R8 |
DXGI_FORMAT_R8G8B8A8_UNORM DXGI_FORMAT_R8G8B8A8_UNORM_SRGB |
|
D3DFMT_X8B8G8R8 |
Not available |
|
D3DFMT_G16R16 |
DXGI_FORMAT_R16G16_UNORM |
|
D3DFMT_A2R10G10B10 |
Not available |
|
D3DFMT_A16B16G16R16 |
DXGI_FORMAT_R16G16B16A16_UNORM |
|
D3DFMT_A8P8 |
Not available |
|
D3DFMT_P8 |
Not available |
|
D3DFMT_L8 |
DXGI_FORMAT_R8_UNORM Note Use .r swizzle in shader to duplicate red to other components to get Direct3D 9 behavior. |
|
D3DFMT_A8L8 |
DXGI_FORMAT_R8G8_UNORM Note Use swizzle .rrrg in shader to duplicate red and move green to the alpha components to get Direct3D 9 behavior. |
|
D3DFMT_A4L4 |
Not available |
|
D3DFMT_V8U8 |
DXGI_FORMAT_R8G8_SNORM |
|
D3DFMT_L6V5U5 |
Not available |
|
D3DFMT_X8L8V8U8 |
Not available |
|
D3DFMT_Q8W8V8U8 |
DXGI_FORMAT_R8G8B8A8_SNORM |
|
D3DFMT_V16U16 |
DXGI_FORMAT_R16G16_SNORM |
|
D3DFMT_W11V11U10 |
Not available |
|
D3DFMT_A2W10V10U10 |
Not available |
|
D3DFMT_UYVY |
Not available |
|
D3DFMT_R8G8_B8G8 |
DXGI_FORMAT_G8R8_G8B8_UNORM Note In Direct3D 9 the data was scaled up by 255.0f, but this can be handled in the shader. |
|
D3DFMT_YUY2 |
Not available |
|
D3DFMT_G8R8_G8B8 |
DXGI_FORMAT_R8G8_B8G8_UNORM Note In Direct3D 9 the data was scaled up by 255.0f, but this can be handled in the shader. |
|
D3DFMT_DXT1 |
DXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGB |
|
D3DFMT_DXT2 |
DXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGB Note DXT1 and DXT2 are the same from an API/hardware perspective. The only difference is whether premultiplied alpha is used, which can be tracked by an application and doesn't need a separate format. |
|
D3DFMT_DXT3 |
DXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGB |
|
D3DFMT_DXT4 |
DXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGB Note DXT3 and DXT4 are the same from an API/hardware perspective. The only difference is whether premultiplied alpha is used, which can be tracked by an application and doesn't need a separate format. |
|
D3DFMT_DXT5 |
DXGI_FORMAT_BC3_UNORM & DXGI_FORMAT_BC3_UNORM_SRGB |
|
D3DFMT_D16 & D3DFMT_D16_LOCKABLE |
DXGI_FORMAT_D16_UNORM |
|
D3DFMT_D32 |
Not available |
|
D3DFMT_D15S1 |
Not available |
|
D3DFMT_D24S8 |
Not available |
|
D3DFMT_D24X8 |
Not available |
|
D3DFMT_D24X4S4 |
Not available |
|
D3DFMT_D16 |
DXGI_FORMAT_D16_UNORM |
|
D3DFMT_D32F_LOCKABLE |
DXGI_FORMAT_D32_FLOAT |
|
D3DFMT_D24FS8 |
Not available |
|
D3DFMT_S1D15 |
Not available |
|
D3DFMT_S8D24 |
DXGI_FORMAT_D24_UNORM_S8_UINT |
|
D3DFMT_X8D24 |
Not available |
|
D3DFMT_X4S4D24 |
Not available |
|
D3DFMT_L16 |
DXGI_FORMAT_R16_UNORM Note Use .r swizzle in shader to duplicate red to other components to get D3D9 behavior. |
|
D3DFMT_INDEX16 |
DXGI_FORMAT_R16_UINT |
|
D3DFMT_INDEX32 |
DXGI_FORMAT_R32_UINT |
|
D3DFMT_Q16W16V16U16 |
DXGI_FORMAT_R16G16B16A16_SNORM |
|
D3DFMT_MULTI2_ARGB8 |
Not available |
|
D3DFMT_R16F |
DXGI_FORMAT_R16_FLOAT |
|
D3DFMT_G16R16F |
DXGI_FORMAT_R16G16_FLOAT |
|
D3DFMT_A16B16G16R16F |
DXGI_FORMAT_R16G16B16A16_FLOAT |
|
D3DFMT_R32F |
DXGI_FORMAT_R32_FLOAT |
|
D3DFMT_G32R32F |
DXGI_FORMAT_R32G32_FLOAT |
|
D3DFMT_A32B32G32R32F |
DXGI_FORMAT_R32G32B32A32_FLOAT |
|
D3DFMT_CxV8U8 |
Not available |
|
D3DDECLTYPE_FLOAT1 |
DXGI_FORMAT_R32_FLOAT |
|
D3DDECLTYPE_FLOAT2 |
DXGI_FORMAT_R32G32_FLOAT |
|
D3DDECLTYPE_FLOAT3 |
DXGI_FORMAT_R32G32B32_FLOAT |
|
D3DDECLTYPE_FLOAT4 |
DXGI_FORMAT_R32G32B32A32_FLOAT |
|
D3DDECLTYPED3DCOLOR |
Not available |
|
D3DDECLTYPE_UBYTE4 |
DXGI_FORMAT_R8G8B8A8_UINT Note The shader gets UINT values, but if Direct3D 9 style integral floats are needed (0.0f, 1.0f... 255.f), UINT can just be converted to float32 in the shader. |
|
D3DDECLTYPE_SHORT2 |
DXGI_FORMAT_R16G16_SINT Note The shader gets SINT values, but if Direct3D 9 style integral floats are needed, SINT can just be converted to float32 in the shader. |
|
D3DDECLTYPE_SHORT4 |
DXGI_FORMAT_R16G16B16A16_SINT Note The shader gets SINT values, but if Direct3D 9 style integral floats are needed, SINT can just be converted to float32 in the shader. |
|
D3DDECLTYPE_UBYTE4N |
DXGI_FORMAT_R8G8B8A8_UNORM |
|
D3DDECLTYPE_SHORT2N |
DXGI_FORMAT_R16G16_SNORM |
|
D3DDECLTYPE_SHORT4N |
DXGI_FORMAT_R16G16B16A16_SNORM |
|
D3DDECLTYPE_USHORT2N |
DXGI_FORMAT_R16G16_UNORM |
|
D3DDECLTYPE_USHORT4N |
DXGI_FORMAT_R16G16B16A16_UNORM |
|
D3DDECLTYPE_UDEC3 |
Not available |
|
D3DDECLTYPE_DEC3N |
Not available |
|
D3DDECLTYPE_FLOAT16_2 |
DXGI_FORMAT_R16G16_FLOAT |
|
D3DDECLTYPE_FLOAT16_4 |
DXGI_FORMAT_R16G16B16A16_FLOAT |
|
FourCC 'ATI1' |
DXGI_FORMAT_BC4_UNORM Note Requires Feature Level 10.0 or later |
|
FourCC 'ATI2' |
DXGI_FORMAT_BC5_UNORM Note Requires Feature Level 10.0 or later |
Build date: 3/22/2013