How DirectStorage Works with NVMe in DirectX Games
DirectStorage modernizes the PC gaming data pipeline by coordinating directly with NVMe hardware to maximize data transfer rates and eliminate CPU bottlenecks. In modern DirectX games, it replaces legacy, single-threaded storage routines with an asynchronous, high-queue-depth architecture that streamlines the operating system's storage stack. By feeding NVMe submission queues efficiently and shifting asset decompression directly to the graphics hardware, DirectStorage enables near-instant asset streaming and significantly reduced load times.
The Limitations of the Legacy Storage Stack
Traditional PC games rely on Win32 storage APIs like
ReadFile, which were designed decades ago for slow,
spinning hard drives. This legacy path processes I/O operations
synchronously or with limited concurrency, generating significant CPU
overhead per request:
- High Context Switching: Each file request transitions between user mode and kernel mode, consuming CPU cycles.
- Sequential Handling: The OS storage stack processes requests in small, unbatched quantities, incapable of saturating modern solid-state hardware.
- CPU-Bound Decompression: Data travels from storage into system RAM, where the CPU decompresses it before uploading it to the GPU via the PCIe bus.
Modern NVMe Controller Architecture
NVMe SSDs rely on massive parallelism, supporting up to 64,000 I/O queues with up to 64,000 commands per queue. The legacy Win32 path typically utilizes only a single queue with shallow depths (often 1 to 4 requests at a time), leaving the vast majority of an NVMe drive's potential bandwidth unused.
DirectStorage bridges this gap by tailoring its architecture to mirror how NVMe hardware functions.
How DirectStorage Coordinates with the OS Stack and NVMe
DirectStorage alters the interaction between the DirectX 12 runtime, the Windows kernel, and the physical NVMe controller through several coordinated steps:
1. Batched, Asynchronous Request Queuing
The game engine submits thousands of simultaneous read requests
through the DirectStorage API (IDStorageQueue). Instead of
executing individual I/O system calls, DirectStorage packages these
requests into high-density batches.
2. Streamlined OS Kernel Traversal
DirectStorage uses an optimized kernel-mode storage driver that bypasses unnecessary layers of the traditional Windows storage filter stack. This specialized path translates DirectStorage batches into native NVMe command structures with minimal CPU involvement and reduced context switches.
3. NVMe Queue Saturation
The optimized OS driver pushes batched commands directly into the NVMe controller's hardware Submission Queues (SQ). Because requests are already ordered and optimized, the NVMe controller can leverage its multiple internal channels and flash dies simultaneously via Direct Memory Access (DMA), moving raw compressed blocks directly into system memory without CPU intervention.
4. GPU-Accelerated Decompression
Once the NVMe controller finishes the DMA transfer, DirectStorage notifies the DirectX runtime. Rather than routing the compressed data through the CPU, the assets are transferred directly to GPU memory (VRAM). The GPU uses specialized compute shaders or dedicated silicon to decompress the assets in parallel, matching the throughput of the NVMe drive and making textures, geometry, and worlds immediately accessible to the DirectX rendering pipeline.