Lecture 14: Pipeline setup in DX12

Computer graphics in Game development

Ivan Belyavtsev


Rendering pipeline

From: https://docs.microsoft.com/en-us/windows-hardware/drivers/display/pipelines-for-direct3d-version-11

Pipeline state object

PSO keeps a state of rendering pipeline:

  • Input layout
  • Root signature
  • Shaders bytecode
  • State of rasterizer
  • Blending state
  • Depth/stencil state [1]

PSO doesn’t keep

  • Vertex and index buffers
  • Primitive topology
  • Render target and depth buffer
  • Particular root signature, descriptor heaps and tables [1]


cbuffer ConstantBuffer: register(b0)
    float4x4 mwpMatrix;
struct PSInput
    float4 position : SV_POSITION;
    float4 color : COLOR;
PSInput VSMain(float4 position : POSITION, float4 normal: NORMAL, float4 ambient : COLOR0, float4 diffuse : COLOR1,  float4 emissive : COLOR2)
    PSInput result;
    result.position = mul(mwpMatrix, position);
    result.color = ambient;
    return result;
float4 PSMain(PSInput input) : SV_TARGET
    return input.color;

Descriptor tables and root signature

Root signature links command lists to the resources the shaders require.

Descriptor table hold a range of descriptor heap which is going to be bound to the root signature [1]

Lab: load_assets: pipeline state creation

Command allocator

A region of memory to keep a queue GPU commands.

Has one method Reset, which allows to re-use the memory for the next commands [1]

Command queues

Command queue allows to submit commands via command list and make the fence synchronization

  • ExecuteCommandLists for submitting command lists
  • Signal for setting a special value to the fence [1]

Command lists

Command list a set of GPU command which will executed

  • Reset transfers the command list to the record state
  • Close transfers the command list out of the record state [1]

Lab: Command list creation and population


Fence is an object of GPU-CPU synchronization [1]

command_queue->Signal(fence.Get(), prev_fence_value));

if (fence->GetCompletedValue() < prev_fence_value)
    //fence_event is a system handle for the fence
    ThrowIfFailed(fence->SetEventOnCompletion(prev_fence_value, fence_event));
    WaitForSingleObject(fence_event, INFINITE);

Lab: Synchronization


Satran M. et al. Direct3D 12 programming guide [Electronic resource]. 2019. URL: https://docs.microsoft.com/en-us/windows/win32/direct3d12/directx-12-programming-guide.
// reveal.js plugins