Direct3D 12 - Obtaining Graphics Driver Version
By Vilem Otte
directx, direct3d, d3d12, graphics, drivers, dxgi, nvidia, amd, intel
The Problem
Obtaining graphics driver version seems quite easy from the outside, as there is a method provided by DXGI - namely IDXGIAdapter::CheckInterfaceSupport method. Which has a signature of:
HRESULT CheckInterfaceSupport(
[in] REFGUID InterfaceName,
[out] LARGE_INTEGER *pUMDVersion
);
This method should be called with InterfaceName being __uuidof(IDXGIDevice) and it will return version of Direct3D user mode driver. For details, you can see the specifications of the method at - https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiadapter-checkinterfacesupport - yet here comes the problem - the returned value doesn't match driver version of the vendors (or rather does not match the number vendors advertise - you can still get to the user mode driver version, it just gets complicated...
Vendor Specifics
Intel
Intel way of driver versioning is straightforward, they use the same numbering as DXGI user mode driver version.
AMD
AMD is a bit more tricky in this - while you can see the DXGI user mode driver version through Device Manager and in the Driver tab of the specific graphics adapter properties, like:
Driver version can be seen through device manager
In general they use their own numbering in installers, on website or in their own software application. The number looks like: 24.8.1 ... so can we obtain this number? Yes, through AMD GPU Services - or AGS in short. The library is available from here - https://gpuopen.com/amd-gpu-services-ags-library/
The code to obtain driver version then looks like this:
// Obtain driver with AGS (AMD)
AGSContext* agsContext = nullptr;
AGSGPUInfo agsGpuInfo = {};
if (agsInitialize(AGS_CURRENT_VERSION, nullptr, &agsContext, &agsGpuInfo) == AGS_SUCCESS)
{
// At this point there are 2 strings - agsGpuInfo.radeonSoftwareVersion and agsGpuInfo.driverVersion
//
// agsGpuInfo.radeonSoftwareVersion - "24.8.1"
// agsGpuInfo.driverVersion - "24.10.37.04-240823a-407010C-AMD-Software-Adrenalin-Edition"
//
// Where the first one contains the string we need to use
}
agsDeInitialize(agsContext);
NVidia
NVidia also uses their own way to number driver version - and they also provide their own library to do so - NVAPI. The library is available from here - https://developer.nvidia.com/rtx/path-tracing/nvapi/get-started
The code to obtain driver version looks like this:
NvU32 nvDriverVersion = 0;
NvAPI_ShortString buildBranchString;
if (NvAPI_SYS_GetDriverAndBranchVersion(&nvDriverVersion, buildBranchString) == NVAPI_OK)
{
// At this point there are again 2 values - number and string - nvDriverVersion and buildBranchString
//
// nvDriverVersion - 55123
// buildBranchString - "r551_06"
//
// The first one being decimal representing `version number * 100` - i.e. in this case it is `551.23`
}
Conclusion
The above code and information should be used whenever any reporting is needed from the software as it provides correct driver information. In our engine, driver versions are printed in output logs (and console in case you're running with console) for both - DXGI version and vendor-specific version.