HelloD3D12 is a small, introductory Direct3D® 12 sample, which shows how to set up a window and render a textured quad complete with proper uploading handling, multiple frames queued and constant buffers.

There are three samples with increasing complexity. 

Common functionality, like window creation, present handling is part of hellod3d12\src\D3D12Sample.cpp

The rest is scaffolding of very minor interest; ImageIO has some helper classes to load an image from disk using WIC, Window contains a class to create a Win32 window.

The samples are:

  • D3D12Quad: Renders a quad. This is the most basic sample.
  • D3D12AnimatedQuad: Animates the quad by using a constant buffer.
  • D3D12TexturedQuad: Adds a texture to the animated quad sample.

Points of interest

  • The application queues multiple frames. To protect the per-frame command lists and other resources, fences are created. After the command list for a frame is submitted, the fence is signaled and the next command list is used.
  • The texture and mesh data is uploaded using an upload heap. This happens during the initialization and shows how to transfer data to the GPU. Ideally, this should be running on the copy queue but for the sake of simplicity it is run on the general graphics queue.
  • Constant buffers are placed in an upload heap. Placing them in the upload heap is best if the buffers are read once.
  • Barriers are as specific as possible and grouped. Transitioning many resources in one barrier is faster than using multiple barriers as the GPU have to flush caches, and if multiple barriers are grouped, the caches are only flushed once.
  • The application uses a root signature slot for the most frequently changing constant buffer.
  • The DEBUG configuration will automatically enable the debug layers to validate the API usage. Check the source code for details, as this requires the graphics tools to be installed.

Requirements

  • A graphics card with Direct3D® 12 support.
    • For instance, any GCN-based AMD GPU.
  • Windows® 10 (64-bit recommended).
  • Visual Studio® 2015 with Visual C++ and the Windows® 10 SDK installed.

You may also like: