How to Export D3D12SDKVersion for Agility SDK

The Microsoft DirectX 12 Agility SDK allows developers to adopt modern graphics features without requiring end users to update their Windows operating system. Central to this architecture is D3D12SDKVersion, an exported symbol that communicates the required SDK release number to the Windows DirectX runtime. This article explains what D3D12SDKVersion is, how the DirectX runtime detects it, and how to properly declare and export it alongside D3D12SDKPath in C/C++ game code.

Understanding D3D12SDKVersion

Historically, new DirectX 12 features were tied directly to specific Windows OS updates through the system-provided d3d12.dll. The Agility SDK decouples the D3D12 runtime from the OS by distributing updated runtimes (D3D12Core.dll) directly alongside the game executable.

D3D12SDKVersion is an unsigned integer variable exported by the game's primary executable (.exe). When the game calls D3D12CreateDevice, the OS-level loader inspects the executable's export table. If D3D12SDKVersion is present, the runtime compares this value against the inbox system runtime. If the requested version is newer than the inbox version and supported by the platform, the operating system redirects D3D12 API calls to the local Agility SDK runtime binaries distributed with the application.

Exporting D3D12SDKVersion in Game Code

To enable the Agility SDK, you must export two variables from your main executable: D3D12SDKVersion and D3D12SDKPath.

Both variables must be exported with C-linkage to prevent C++ name mangling, ensuring the loader can locate them by their exact symbol names.

#include <windows.h>
#include <d3d12.h>

// Export the Agility SDK version and relative path to the runtime binaries
extern "C" {
    __declspec(dllexport) extern const UINT D3D12SDKVersion = 614; // Example SDK version
    __declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
}

Best Practices for Implementation

  • Use Header Constants: Rather than hardcoding the version integer, use the D3D12_SDK_VERSION macro defined in the d3d12.h header provided by your installed Agility SDK NuGet package:

    extern "C" {
        __declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION;
        __declspec(dllexport) extern const char* D3D12SDKPath = ".\\D3D12\\";
    }
  • Executable Scope: These symbols must be exported from the main executable process (.exe), not from dynamic libraries (.dll). If your rendering engine is packaged as a DLL, the hosting .exe must still define and export these variables.

  • Path Resolution: The D3D12SDKPath specifies the folder relative to the executable containing the architecture-specific D3D12Core.dll and other SDK components. Ensure your build pipeline copies the correct binaries (e.g., x64 or ARM64) to this designated directory.