The DxgkDdiPreemptCommand function preempts a direct memory access (DMA) buffer that was previously submitted to and currently queued in the hardware command execution unit.



NTSTATUS APIENTRY DxgkDdiPreemptCommand(
  _In_ const HANDLE                 hAdapter,
  _In_ const DXGKARG_PREEMPTCOMMAND *pPreemptCommand
{ ... }


hAdapter [in]

[in] A handle to a context block that is associated with a display adapter. The display miniport driver previously provided this handle to the Microsoft DirectX graphics kernel subsystem in the MiniportDeviceContext output parameter of the DxgkDdiAddDevice function.

pPreemptCommand [in]

[in] A pointer to a DXGKARG_PREEMPTCOMMAND structure that describes the command that is used to preempt a DMA buffer previously submitted to the hardware command execution unit.

Return value

Returns STATUS_SUCCESS upon successful completion. If the driver instead returns an error code, the operating system causes a system bugcheck to occur. For more information, see the following Remarks section.


If the driver determines that the hardware is already finished processing all of the submitted DMA buffers--and that the hardware informed the graphics processing unit (GPU) scheduler about the completions--when its DxgkDdiPreemptCommand function is called to preempt the DMA buffers, the driver should perform the following operations instead of submitting the preempt fence that is identified by the PreemptionFenceId member of DXGKARG_PREEMPTCOMMAND to the hardware:

  • Raise IRQL to interrupt level. For example, the driver can call the DxgkCbSynchronizeExecution function to synchronize with its DxgkDdiInterruptRoutine function.

  • Inform the GPU scheduler about the preemption information. The driver can either call the DxgkCbNotifyInterrupt function directly or call its DxgkDdiInterruptRoutine function (for example, if the driver must perform other updates as well).

    Note that the GPU scheduler handles instances where the hardware has stopped responding because of Timeout Detection and Recovery (TDR) work.

If the driver returns an error code, the Microsoft DirectX graphics kernel subsystem causes a system bugcheck to occur. In a crash dump file, the error is noted by the message BugCheck 0x119, which has the following four parameters.

  1. 0x2
  2. The NTSTATUS error code returned from the failed driver call
  3. A pointer to the DXGKARG_PREEMPTCOMMAND structure
  4. A pointer to an internal scheduler data structure

DxgkDdiPreemptCommand should be made nonpageable because it runs at IRQL = DISPATCH_LEVEL


Target platform


Available in Windows Vista and later versions of the Windows operating systems.


D3dkmddi.h (include D3dkmddi.h)



See also




Send comments about this topic to Microsoft