Threading Model of User-Mode Display Driver

The user-mode display driver is not loaded into multiple processes simultaneously--the user-mode display driver DLL is loaded into the address space of each process separately. Still, multiple threads can run in the user-mode display driver at the same time. However, each thread that is running in the user-mode display driver must access a different display device, which is created by a call to the user-mode display driver's CreateDevice function. For example:

  • An application that creates two Microsoft Direct3D devices can have two threads that access these devices independently.

  • An application can use, on two different threads, a Direct3D device that the Microsoft DirectX 9.0 Direct3D runtime created along with a Microsoft DirectDraw device that the DirectX 5.0 runtime created.

Note   Two or more threads that are using the same display device can never run in the user-mode display driver simultaneously.

Like the display miniport driver, the user-mode display driver is not required to use any global data structures, because Direct3D devices are independent and state and resources from each device do not affect the other devices. If the user-mode display driver must maintain global cross-device data structures (such as, for a custom system memory heap manager), it must arbitrate access by using its own mechanisms. Such global data structures that the driver manages are strongly discouraged. Because the Direct3D runtime opens an independent "view" of the shared resource in each user-mode display device that must access the resource, cross-process or cross-device resources should not be handled differently from resources that a single process or device use. Lifetime and other management are handled by the DirectX graphics kernel subsystem (Dxgkrnl.sys).

On multiple-processor computers, the Direct3D runtime might call a user-mode display driver from a worker thread instead of from the main application thread. This multiple-processor optimization is transparent to the user-mode display driver. When the runtime uses multiple-processor optimization, it still ensures that only one thread that references a particular device runs in the driver at any given time.