How to Configure Binary to Load DirectX Agility SDK
This article explains how to configure a Windows application binary to load the DirectX 12 Agility SDK runtime rather than the default operating system version. By exporting two specific configuration variables from your main executable, you instruct the system's loader to redirect DirectX 12 calls to a decoupled local runtime folder, enabling the deployment of the latest DirectX features across different Windows versions without requiring OS updates.
The Agility SDK Loading Mechanism
The DirectX Agility SDK works by using the system's default
d3d12.dll in System32 as a forwarder. When the
application initializes DirectX 12 via functions such as
D3D12CreateDevice, the system loader examines the export
table of the calling executable (.exe). If the application
exports specific Agility SDK configuration symbols, the loader
dynamically binds to the local D3D12Core.dll provided with
the application instead of using the OS default version.
Required Binary Exports
To enable the Agility SDK, your application's executable must export two variables:
D3D12SDKVersion: AUINTdefining the version number of the Agility SDK being targeted.D3D12SDKPath: Aconst char*(LPCSTR) string specifying the relative directory path where the Agility SDK binaries are located, relative to the executable.
Implementation in C++
Add the following code to a source file compiled into the primary
.exe binary:
#include <windows.h>
// Export the Agility SDK configuration variables
extern "C" {
__declspec(dllexport) extern const UINT D3D12SDKVersion = 614; // Replace with your target Agility SDK version
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
}If you are using the official Microsoft DirectX 12 Agility SDK NuGet package, headers provide macros to streamline this setup:
#include <d3d12.h>
extern "C" {
__declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION;
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
}Runtime Deployment Structure
The folder containing your application binary must be organized so
the loader can locate the SDK files at runtime. For the relative path
.\\D3D12\\, place the platform-specific files in that
directory alongside your executable:
GameOrApp/
├── Application.exe
└── D3D12/
├── D3D12Core.dll
└── d3d12SDKLayers.dll (optional, for debug layers)
Important Considerations
- Primary Executable Only: The configuration symbols
must be exported by the process's main
.exefile. Exporting these variables from a dynamic link library (.dll) loaded by the application will be ignored by the OS loader. - Relative Paths: The
D3D12SDKPathmust be a relative path pointing to a subdirectory adjacent to the executable. Absolute paths are not permitted for security reasons. - Fallback Behavior: If the exported version cannot
be found or fails to load, the system loader gracefully falls back to
the system's default
D3D12Core.dlllocated inSystem32. Ensure appropriate error handling when checking for feature support viaCheckFeatureSupport.