Home » Learn » Samples »

HelloD3D12 DirectX® 12 Sample

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.


  • 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:

Hybrid Shadows

Hybrid Shadows Sample

This sample demonstrates how to combine ray traced shadows and rasterized shadow maps together to achieve higher quality and performance.

GLTFSample Cauldron Sample Project

This sample demonstrates how to use most of Cauldron’s features. It is also a useful reference for getting started with developing your own samples and prototypes.

You may also be interested in...

Some light reading to take away with you. Our ISAs, manuals, whitepapers, and many more.

Explore our huge collection of detailed tutorials, sample code, presentations, and documentation to find your answers to your graphics development questions.

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

Browse all our fantastic tutorials, including programming techniques, performance improvements, guest blogs, and how to use our tools.