This is SunshineBooming, a small Driver engineer at GPU company, whose main job is to write DirectX12 Drivers. I will continue to update this DX12 Spec series, which may be unpopular, but it is all based on practical experience and work experience. If you have any GPU related questions, you can interact in the comment section without hesitation:
DirectX12 Spec General Catalog.
1. Basic concepts
The runtime under Windows is basically the same as under Linux, divided into user mode and kernel mode
Directx 12 drivers are also divided into UMD (user mode driver) and KMD (kernel mode driver)
UMD runs in user mode and has its own independent VA (virtual address) space. If UMD crashes, it will only cause the application to exit abnormally, and the system will continue to run as usual
KMD runs in kernel mode, sharing the VA space of the system. If KMD crashes, it usually causes system abnormalities, with a common occurrence being a blue screen restart.
Driver and runtime interaction process
Referring to Microsoft's official website, the above WDDM architecture diagram can be obtained
The WDDM architecture defines an interaction process for application developers and driver developers, checks the correctness of interaction parameters, and throws detailed exception information.
- Application calls APIs to Direct3D runtime, such as OpenAdapter, CreatDevice, CreatResource, Draw, and so on.
- After checking the parameters of the Direct3D runtime, the corresponding parameters are passed to UMD. UMD generates GPU hardware corresponding instructions based on the parameters and passes them to the runtime in Kernel Mode, which is dxgkrnl.
- Dxgkrnl then passes the instructions to KMD, which generally caches the instructions into GPU hardware's ring buffer or similar caches, and then triggers GPU hardware to execute the instructions.
- Note: The above processes are all executed on the CPU side, and instructions can only be truly executed when KMD provides hardware to the GPU side through the PCIE bus.
From the perspective of application developers, of course, they only care about the interaction process between Application and Direct3D runtime. As for how the runtime, driver, and even hardware work, it is the responsibility of the system and underlying developers
From the perspective of driving developers, of course, we only care about the interaction between Direct3D and UMD, dxgkrnl and KMD, and then need to analyze the behavior of the runtime. As for the behavior of the Application, we don't really care or understand it.