Since the release of DirectX Tool Kit four years ago, it has proven to be a very useful library for samples, indie and hobbyist projects, people moving from XNA Game Studio to C++, learning Direct3D 11, and for developers looking for supported replacements for the legacy D3DX library and the retiring of the legacy DirectX SDK.
Today I’m announcing the DirectX Tool Kit for DirectX 12, which is hosted as it’s own GitHub site. After much discussion and debate, we realized that both tool kits are really independent projects. While they share a lot of code (all the non-graphics stuff is 100% identical), the Direct3D 12 API is significantly different than Direct3D 11 so the graphics components ‘feel’ the same but in practice are used very differently.
DirectXTK for DirectX 12 includes the following components:
- CommonStates – Factory for common combinations of rendering states (C++ versions modelled after the 'public fields' of BlendState, DepthStencilState, RasterizerState, and SampleState classes used for XNA Game Studio)
- DDSTextureLoader - light-weight DDS file texture loader
- DirectXHelpers - misc C++ helpers for D3D programming
- Effects – a collection of ready-to-use common shaders (C++ versions of the BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, and SkinnedEffect used for XNA Game Studio)
- GeometricPrimitives – geometry helpers for common shapes (Cube, Sphere, GeoSphere, Cylinder, Torus, Teapot, Tetrahedron, Octahedron, Dodecahedron, and Isosahedron)
- GraphicsMemory - helper for managing graphics memory allocation
- Model – draws simple meshes loaded from
- PostProcess - set of built-in shaders for common post-processing operations
- PrimitiveBatch – simple and efficient way to draw user primitives which replicates the simplicity of the Direct3D 9 era DrawUP APIs
- ScreenGrab - light-weight screen shot saver
- SpriteBatch – a 2D sprite rendering class (a C++ version of the SpriteBatch used for XNA Game Studio)
- SpriteFont – a bitmap based text rendering (a C++ version of the SpriteFont used for XNA Game Studio)
- VertexTypes – collection of commonly used vertex buffer data structures with a input layout descriptions (C++ versions of VertexPositionColor, VertexPositionTexture, VertexPositionColorTexture, and VertexPositionNormalTexture structures used for XNA Game Studio)
- WICTextureLoader - WIC-based image file texture loader
DirectX Tool Kit for DirectX 12 also includes DirectX Tool Kit for Audio, GamePad, Keyboard, Mouse, and SimpleMath. The MakeSpriteFont and XWBTool tools are identical so they are hosted on the DirectX Tool Kit for DirectX 11 GitHub.
There are a few key differences compared to the DirectX 11 version:
- No support for
loadingDGSL effect shaders (i.e. DGSLEffect)
- VertexTypes does not include
- DirectX Tool Kit for DirectX 11 supports Feature Level 9.3, while DirectX 12 requires Direct3D Feature Level 11.0. There are no expected DirectX 12 drivers for any lower feature level devices.
- The library assumes it is building for Windows 10 (aka
_WIN32_WINNT=0x0A00) so it makes use of XAudio 2.9 and WIC2 as well as DirectX 12.
A word of caution: DirectX 12 is an API designed for graphics experts. If you are not already an expert in using Direct3D 11, I’d recommend sticking with the Direct3D 11 API until you find yourself in need of the additional control. Direct3D 12 provides a great deal of control over memory allocation, synchronization, state management which can result in reduced CPU overhead for rendering compared to older versions of Direct3D, but that control means the API is quite unforgiving. If you are new to Direct3D entirely, definitely start with Direct3D 11 first.
DirectX Tool Kit for DirectX 12 is documented on the GitHub wiki and there are basic tutorials on it’s usage. It’s also host on NuGet for Windows Universal Platform (UWP) apps and Win32 desktop apps on Windows 10.
Both version so the DirectX Tool Kit now include support for NormalMapEffect and per-pixel lighting support for EnvironmentMapEffect.
vcpkg: The vcpkg C++ Package Manager has a directxtk12 port available.
CMO:: Originally DirectX Tool Kit for DX12 did not support loading Visual Studio Content Pipeline (CMO) models. This is now supported with the September 2021 release. DGSL shaders are still not supported.