Lecture #13. Resources in DX12

Computer graphics in Game development

Ivan Belyavtsev

21.10.2022

Resource

Resource is any data in memory

  • Vertex buffer
  • Index buffer
  • Constant buffer
  • Texture
  • Depth/Stencil buffer [1]

Type of resources

  • Committed
  • Placed
  • Reserved [1]

Resource heap types

  • Default - no CPU access
  • Upload - CPU can write
  • Readback - CPU can read [1]

Lab: 3.03 load_assets: vertex, index and constant buffers

  1. Allocate memory for vertex and index buffers
  2. Implement resource creation on upload heap
  3. Create committed resources for vertex, index and constant buffers on upload heap
  4. Implement map, unmap, and copying data to the resource
  5. Copy resource data to suitable resources

Resource descriptors

Resource descriptor is a properties of the particular resource.

  • CreateConstantBufferView
  • CreateDepthStencilView
  • CreateRenderTargetView
  • CreateShaderResourceView
  • CreateUnorderedAccessView [1]

Descriptor heaps

Descriptors heaps hold resource descriptors.

Types of descriptor heaps:

  • CBV, SRV, and UAV
  • SAMPLER
  • RTV
  • DSV [1]

Lab: 3.04 load_pipeline: descriptor heaps

  1. Implement create_heap, get_cpu_descriptor_handle, get_gpu_descriptor_handle, and get methods of cg::renderer::descriptor_heap
  2. Create a descriptor heap for render targets
  3. Create render target views
  4. Create a descriptor heap for a constant buffer
  5. Create a constant buffer view
  6. Create vertex buffer views
  7. Create index buffer views

Resource barriers

In DX12 the application is managing all resource states:

  • D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
  • D3D12_RESOURCE_STATE_RENDER_TARGET
  • D3D12_RESOURCE_STATE_DEPTH_WRITE
  • D3D12_RESOURCE_STATE_DEPTH_READ
  • D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
  • D3D12_RESOURCE_STATE_COPY_DEST
  • D3D12_RESOURCE_STATE_COPY_SOURCE
  • D3D12_RESOURCE_STATE_PRESENT and others [1]

References

1.
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.