directxtk12-usage
Skill1.8k starsChanged 4 months agoMITView on GitHub
Guide for integrating DirectX Tool Kit for DirectX 12 into new projects and understanding the library's API surface. Use this skill when asked about how to use DirectXTK12, set up a new project, or get an overview of available classes and functionality.
Trending
Quiet since May.thin dataabout the whole repository
Who's talking about microsoft/DirectXTK12
- mastercomfig/tf2-patches-old“DX12 support”GitHub · Sep 15, 2020 · 4 reactions
- mustikka10/headscale“[WIP] Fix runtime bug in application”GitHub · May 2, 2026
- microsoft/vcpkg“[directxtk, directxtk12, directxtex, directxmesh] March 2026 release”GitHub · Apr 1, 2026
- microsoft/Xbox-GDK-Samples“DirectX Tool Kit for DX12 patch for GameInput 1.2”GitHub · May 7, 2025
- microsoft/vcpkg“[directxtk(12), directxmesh, directxtex, uvatlas] Update ports for Sept 2024”GitHub · Sep 6, 2024
The biggest 5 of 10 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 10
Talked about on GitHub (10 times).
On GitHub · 10
- Sep 15, 2020DX12 support — mastercomfig/tf2-patches-old4 reactions · 4 comments
- May 2, 2026[WIP] Fix runtime bug in application — mustikka10/headscale0 reactions
- Apr 1, 2026[directxtk, directxtk12, directxtex, directxmesh] March 2026 release — microsoft/vcpkg0 reactions · 1 comment
- May 7, 2025DirectX Tool Kit for DX12 patch for GameInput 1.2 — microsoft/Xbox-GDK-Samples0 reactions · 1 comment
- Sep 6, 2024[directxtk(12), directxmesh, directxtex, uvatlas] Update ports for Sept 2024 — microsoft/vcpkg0 reactions · 2 comments
5 more on GitHub
- Dec 11, 2023Move Xbox GDK rendering code to public repo — libsdl-org/SDL0 reactions · 2 comments
- Sep 6, 2023test — eunbi-kim/junit_doc0 reactions
- Apr 30, 2023[directxmesh, directxtex, directxtk(12), uvatlas] April 2023 updates — microsoft/vcpkg0 reactions · 7 comments
- Apr 5, 2023[directxmesh, directxtex, directxtk(12), uvatlas] update ports for March 2023 releases — microsoft/vcpkg0 reactions · 1 comment
- Oct 14, 2021Support compressed SDKMESH/DDS — walbourn/directxtk12modelviewer0 reactions
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- releaseSkill
- directxtk12-tutorialSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 3 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
If using GameInput for the game input functionality, add the following:
- Distinctive: line 60
If using DirectX Tool Kit for Audio and GameInput, add the following:
- Distinctive: line 97
Use the d3d12game_vcpkg template as a starting point.
- Very specific: line 101
Use directxtk12_desktop_win10 for Win32 desktop applications or directxtk12_uwp for UWP apps.
- Very specific: line 105
Add the appropriate .vcxproj from the DirectXTK12/ folder to your solution and add a project reference.
- Very specific: line 120
Create a GraphicsMemory instance (one per device).
- Very specific: line 121
Create a DescriptorHeap for SRV/CBV/UAV descriptors.
- Very specific: line 122
Use ResourceUploadBatch to upload textures and static buffers to the GPU.
- Very specific: line 123
Create rendering helpers (e.g., SpriteBatch, Effects, Model) with the appropriate pipeline state.
- Very specific: line 151
Descriptor Heaps: Use DescriptorHeap to manage shader-visible descriptor heaps.
- Very specific: line 157
All classes and functions reside in the DirectX namespace.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DirectX Tool Kit for DirectX 12 — Usage Guide
Overview
The DirectX Tool Kit for DirectX 12 (DirectXTK12) is a collection of helper classes for writing Direct3D 12 C++ code for Win32 desktop applications (Windows 10+), Xbox Series X|S, Xbox One, and Universal Windows Platform (UWP) apps.
- Repository: https://github.com/microsoft/DirectXTK12
- Documentation: https://github.com/microsoft/DirectXTK12/wiki
- NuGet Packages:
directxtk12_desktop_win10,directxtk12_uwp - vcpkg Port:
directxtk12
Integration Methods
vcpkg manifest-mode (Recommended)
In your vcpkg.json file, add the following:
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"directx-headers",
"directxmath",
"directxtk12"
]
}If using GameInput for the game input functionality, add the following:
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"directx-headers",
"directxmath",
{
"name": "directxtk12",
"default-features": false,
"features": [
"gameinput"
]
}
]
}If using DirectX Tool Kit for Audio and GameInput, add the following:
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"directx-headers",
"directxmath",
{
"name": "directxtk12",
"default-features": false,
"features": [
"gameinput",
"xaudio2-9"
]
}
]
}vcpkg (classic)
vcpkg install directxtk12Features: xaudio2-9 (DirectX Tool Kit for Audio using XAudio 2.9), gameinput (Using GameInput for gamepad, keyboard, and mouse), tools (command-line tools). Triplets: x64-windows, arm64-windows, etc.
For DLL usage (x64-windows default triplet), define DIRECTX_TOOLKIT_IMPORT in your consuming project. For static library usage, use -static-md triplet variants.
CMakeLists.txt:
find_package(directxtk12 CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE Microsoft::DirectXTK12)Use the d3d12game_vcpkg template as a starting point.
NuGet
Use directxtk12_desktop_win10 for Win32 desktop applications or directxtk12_uwp for UWP apps.
Project Reference
Add the appropriate .vcxproj from the DirectXTK12/ folder to your solution and add a project reference. Add the DirectXTK12\Inc directory to your Additional Include Directories.
Minimum Requirements
- Windows 10 May 2020 Update SDK (19041) or later
- Visual Studio 2022, Visual Studio 2026, clang for Windows v12+, or MinGW 12.2
- Direct3D Feature Level 11.0 or higher
Getting Started
For a full step-by-step walkthrough, see the Getting Started tutorial on the wiki.
A minimal initialization sequence:
- Create a
ID3D12Device. - Create a
GraphicsMemoryinstance (one per device). - Create a
DescriptorHeapfor SRV/CBV/UAV descriptors. - Use
ResourceUploadBatchto upload textures and static buffers to the GPU. - Create rendering helpers (e.g.,
SpriteBatch,Effects,Model) with the appropriate pipeline state. - Each frame, call
GraphicsMemory::Commitafter executing command lists.
API Reference
The public API is defined in the header files in the Inc/ directory. See the reference overview for a categorized summary of all classes and helpers.
Full documentation for each class is available on the GitHub wiki.
API signatures are defined in the public headers under the Inc/ directory. Always consult those headers for the authoritative function signatures, parameters, and SAL annotations.
Key Concepts
Resource Ownership
DirectXTK12 classes follow RAII principles. Most objects are created with std::make_unique and destroyed automatically. COM resources are managed with Microsoft::WRL::ComPtr.
Device-Dependent vs Device-Independent
Most DirectXTK12 objects are device-dependent — they are created with a ID3D12Device* and must be recreated if the device is lost. Plan your resource management accordingly.
Thread Safety
DirectXTK12 rendering classes (SpriteBatch, Effects, PrimitiveBatch, etc.) are not thread-safe. Use one instance per thread, or synchronize access externally. Resource creation (texture loading, model loading) can be done from any thread.
Key Concepts for DirectX 12 Users
- Pipeline State Objects (PSOs): Unlike the DX11 version, DX12 requires explicit PSO management. Use
EffectPipelineStateDescriptionandRenderTargetStateto configure PSOs for effects and rendering helpers. - Descriptor Heaps: Use
DescriptorHeapto manage shader-visible descriptor heaps. Most rendering classes require descriptor heap indices at draw time. - Resource Upload: GPU resources must be uploaded explicitly.
ResourceUploadBatchbatches uploads into a single command list for efficiency. - Graphics Memory:
GraphicsMemorymanages per-frame dynamic allocations (constant buffers, dynamic vertex/index buffers). CallCommitonce per frame.
Namespace
All classes and functions reside in the DirectX namespace. Headers that contain Direct3D 12-specific types use inline namespace DX12 to avoid conflicts when both DX11 and DX12 toolkits are linked together.
#include "SpriteBatch.h"
// Usage:
auto spriteBatch = std::make_unique<DirectX::SpriteBatch>(device, ...);Common Patterns
Creating an Effect
#include "Effects.h"
#include "EffectPipelineStateDescription.h"
#include "RenderTargetState.h"
RenderTargetState rtState(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_D32_FLOAT);
EffectPipelineStateDescription pd(
&VertexPositionNormalTexture::InputLayout,
CommonStates::Opaque,
CommonStates::DepthDefault,
CommonStates::CullCounterClockwise,
rtState);
auto effect = std::make_unique<BasicEffect>(device, EffectFlags::Lighting | EffectFlags::Texture, pd);Loading and Drawing a Model
#include "Model.h"
auto model = Model::CreateFromSDKMESH(device, L"mymodel.sdkmesh");
// Upload resources
ResourceUploadBatch upload(device);
upload.Begin();
model->LoadStaticBuffers(device, upload);
upload.End(commandQueue).wait();
// Draw (simplified — see wiki for full parameter details)
model->Draw(commandList, ...);Texture Loading
#include "DDSTextureLoader.h"
#include "ResourceUploadBatch.h"
#include "DescriptorHeap.h"
ResourceUploadBatch upload(device);
upload.Begin();
Microsoft::WRL::ComPtr<ID3D12Resource> texture;
CreateDDSTextureFromFile(device, upload, L"texture.dds", texture.ReleaseAndGetAddressOf());
upload.End(commandQueue).wait();Input Handling
#include "Keyboard.h"
#include "Mouse.h"
#include "GamePad.h"
auto keyboard = std::make_unique<DirectX::Keyboard>();
auto mouse = std::make_unique<DirectX::Mouse>();
auto gamePad = std::make_unique<DirectX::GamePad>();
// In update loop
auto kb = keyboard->GetState();
if (kb.Escape)
PostQuitMessage(0);
auto pad = gamePad->GetState(0);
if (pad.IsConnected())
{
if (pad.IsAPressed())
/* jump */;
}Audio
#include "Audio.h"
// Create audio engine
auto audioEngine = std::make_unique<DirectX::AudioEngine>();
// Load and play a sound
auto soundEffect = std::make_unique<DirectX::SoundEffect>(audioEngine.get(), L"explosion.wav");
soundEffect->Play();
// Per-frame update
audioEngine->Update();Note: Code examples above are simplified for clarity. Consult the wiki tutorials and public headers in
Inc/for complete working code with all required parameters.
Further Reading
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

