Sampler Feedback Mip-Level Tracking in DirectX 12

Sampler Feedback Streaming in DirectX 12 Ultimate allows graphics engines to record exactly which regions and mip levels of a texture are accessed by the GPU during rendering. By capturing this fine-grained access pattern into a specialized feedback map, the engine eliminates the guesswork from texture streaming, enabling asynchronous loading of only the required mip tiles into video memory rather than entire, heavy texture chains.

The Feedback Map

At the core of the tracking mechanism is a paired resource called a feedback map (typically created via the DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE format). This map acts as a low-resolution representation of the target source texture.

Instead of maintaining a 1:1 pixel mapping, the feedback map represents regions of the source texture grouped into blocks or tiles (such as 8x8, 16x16, or larger texel regions). Each entry in the feedback map stores numerical values that track the minimum (most detailed) mip level requested within that specific region during the draw calls.

Hardware-Level Recording in Shaders

Tracking occurs during shader execution without requiring CPU-side bounding volume projections or manual screen-space distance approximations. The process follows these operational steps:

  1. LOD Calculation: When a pixel or compute shader evaluates texture coordinates, the GPU calculates the level of detail (LOD) using screen-space gradients (\(ddx\) and \(ddy\)), exactly as it does for standard anisotropic or trilinear sampling.
  2. Writing to the Feedback Map: Instead of or alongside a standard Texture2D.Sample instruction, the HLSL shader calls specialized feedback intrinsics, such as WriteSamplerFeedback or WriteSamplerFeedbackBias.
  3. Atomic Min-Mip Resolution: As pixels execute concurrently, the hardware evaluates the requested mip level for each fragment. If a shader invocation requests a higher-resolution mip level than what is currently recorded in the feedback map entry for that tile, the hardware updates that entry using a fast, hardware-accelerated minimum operation. Unaccessed regions remain cleared or set to an invalid mip index (often encoded as a clamp value).

Integration with Reserved Resources

DirectX 12 Ultimate couples sampler feedback directly with Reserved Resources (Tiled Textures). High-resolution textures are broken into standard 64 KB memory tiles across their various mip dimensions.

When the GPU finishes rendering a frame, the feedback map contains an exact footprint of which 64 KB tiles were visible on screen and which specific mip levels were required to avoid visual degradation.

CPU Readback and Streaming Execution

After the render pass completes, the tracking workflow shifts to the asset streaming pipeline:

  1. Resolve and Decode: The feedback map is resolved (if necessary) and read by the CPU or a dedicated GPU streaming compute pass.
  2. Delta Evaluation: The streaming system compares the recorded mip requirements against the current residency map of the tiled texture.
  3. Request Generation: If a shader requested Mip 1 for a specific tile, but only Mip 3 is resident in VRAM, the engine generates an I/O request to load the missing Mip 1 and Mip 2 tiles from storage (often utilizing DirectStorage for high-bandwidth transfer).
  4. Tile Eviction: Feedback maps from multiple consecutive frames are tracked. Tiles that show zero read activity over a set duration are flagged as non-utilized and their physical memory pages are safely unmapped and freed.

By tracking utilization directly at the hardware sampling phase, DirectX 12 Ultimate ensures that memory allocation precisely matches what is visible, virtually eliminating texture over-allocation and mip pop-in.