D3D11

This page gives an overview of the main classes constituting D3D11-based implementation of Diligent Engine.

The following articles provide detailed description of the key system components:

Buffers and Buffer Views

  • BufferD3D11Impl – implementation of a buffer object ( IBuffer interface)
    • BufferD3D11Impl class is a wrapper over ID3D11Buffer interface
    • Buffers are created by the render device ( RenderDeviceD3D11Impl::CreateBuffer() method)
    • Constructor of  BufferD3D11Impl initializes internal D3D11 buffer by calling ID3D11Device::CreateBuffer() method
    • Buffers can be bound to the pipeline as constant (uniform) buffer, as shader resource (SRV) or an unordered access view (UAV), or can be used as vertex or index buffers for draw commands
    • m_State member is used to indicate the current state of the buffer (vertex buffer, index buffer, SRV, UAV or constant buffer) that is used by the device context for state management
  • BufferViewD3D11Impl – implementation of a buffer resource view ( IBufferView interface)
    • BufferViewD3D11Impl class is a wrapper over ID3D11View interface
    • Buffer views are created by the BufferD3D11Impl::CreateViewInternal() method, which in turn calls BufferD3D11Impl::CreateSRV() or BufferD3D11Impl::CreateUAV() depending on the view type being created

Textures and Texture Views

  • TextureBaseD3D11Impl – base implementation of a texture object ( ITexture interface)
    • Textures are created by the render device ( RenderDeviceD3D11Impl::CreateTexture() method)
    • Textures can be bound to the graphics pipeline as shader resource (SRV), render target (RTV), depth-stencil (DSV) or unordered access view (UAV)
    • m_State member is used to indicate the current state of the texture (SRV, RTV, DSV or UAV) that is used by the device context for state management
    • The class defines pure virtual methods CreateSRV(), CreateRTV(), CreateDSV(), and CreateUAV() that are called by TextureBaseD3D11::CreateViewInternal() and implemented in derived classes for specific D3D11 texture types.
  • Texture1D_D3D11Impl – implementation of a 1D texture
    • The class is a wrapper over  ID3D11Texture1D interface
    • Class constructor calls D3D11Device::CreateTexture1D() to initialize internal Direct3D11 1D texture object
    • The class provides specific implementations of CreateSRV(), CreateRTV(), CreateDSV(), and CreateUAV() methods for 1D texture
  • Texture2D_D3D11Impl – implementation of a 2D texture
    • The class is a wrapper over  ID3D11Texture2D interface
    • Class constructor calls D3D11Device::CreateTexture2D() to initialize internal Direct3D11 2D texture object
    • The class provides specific implementations of CreateSRV(), CreateRTV(), CreateDSV(), and CreateUAV() methods for 2D texture
  • Texture3D_D3D11Impl – implementation of a 3D texture object
    • The class is a wrapper over  ID3D11Texture3D interface
    • Class constructor calls D3D11Device::CreateTexture3D() to initialize internal Direct3D11 3D texture object
    • The class provides specific implementations of CreateSRV(), CreateRTV(), CreateDSV(), and CreateUAV() methods for 3D texture (3D textures do not support DSVs, so CreateDSV() method only logs an error)
  • TextureViewD3D11Impl – implementation of a texture view ( ITextureView interface)
    • TextureViewD3D11Impl class is a wrapper over ID3D11View interface
    • Texture views are created by TextureBaseD3D11Impl::CreateViewInternal() method that calls  CreateSRV(), CreateRTV(), CreateDSV(), and CreateUAV() virtual method depending on the type of the view being created. The methods are implemented in derived classes and perform actions specific to the texture dimension (1D, 2D, or 3D)

Samplers

  • SamplerD3D11Impl – implementation of a sampler object ( ISampler interface)
    • SamplerD3D11Impl is a wrapper over ID3D11SamplerState interface
    • Samplers are created by the render device ( RenderDeviceD3D11Impl::CreateSampler() method)
    • Class constructor calls ID3D11Device::CreateSamplerState() to initialize internal D3D11 sampler state object
    • Samplers can be set in a texture view if the view type is SRV

Shaders

  • ShaderD3D11Impl – implementation of a shader object ( IShader interface)
    • Shaders are created by the render device ( RenderDeviceD3D11Impl::CreateShader() method)
    • Shaders are part of the Pipeline State
    • Constructor of ShaderD3D11Impl compiles the shader, loads shader resources from the byte code and initializes an instance of ShaderResourcesD3D11 class. It also initializes static resource layout that only references static shader resources and static shader resource cache that keeps references to objects bound as static resources.

Shader Resource Management System

Shader resource management system in D3D11-based implementation comprises two main components: shader resource layout ( ShaderResourceLayoutD3D11 class) and shader resource cache ( ShaderResourceCacheD3D11 class). Shader resource layout defines how resources are mapped to shader registers. Shader resource cache provides space to keep references to objects bound as shader resources. The are two ways shader resource layouts and caches used in the system:

  1. Every shader object ( ShaderD3D11Impl) comprises an instance of shader resource layout to facilitate management of static shader resources
    • The layout object is bound to the shader resource cache that provides storage for object references
  2. Every shader resource binding object ( ShaderResourceBindingD3D11Impl) contains shader resource cache and shader resource layout of every active shader stage
    • Every resource layout object is connected to corresponding shader resource cache that provides storage for object references

Main articles:

Pipeline State

  • PipelineStateD3D11Impl – implementation of a pipeline state object ( IPipelineState interface)
    • PSOs are created by the render device ( RenderDeviceD3D11Impl::CreatePipelineState() method)
    • PipelineStateD3D11Impl class encapsulates the following D3D11 states (initialized by the class constructor):
      • Blend state ( ID3D11BlendState)
      • Rasterizer state ( ID3D11RasterizerState)
      • Depth-stencil state ( ID3D11DepthStencilState)
      • Input layout ( ID3D11InputLayout)
      • Shader stages
    • Pipeline state object also comprises memory allocator to facilitate allocation of internal structures for shader resource layouts and caches

Render Device

  • RenderDeviceD3D11Impl – implementation of a render deivce ( IRenderDevice interface)
    • The class is a wrapper over ID3D11Device interface
    • Render device is responsible for creating most of the engine objects: buffers ( RenderDeviceD3D11Impl::CreateBuffer()), textures ( RenderDeviceD3D11Impl::CreateTexture()), samplers ( RenderDeviceD3D11Impl::CreateSampler()), shaders ( RenderDeviceD3D11Impl::CreateShader()), pipeline states ( RenderDeviceD3D11Impl::CreatePipelineState())
      • RenderDeviceD3D11Impl::CreateTexture() depending on the dimension of the texture creates an instance of  Texture1D_D3D11ImplTexture2D_D3D11Impl, or  Texture3D_D3D11Impl class

Device Context

  • DeviceContextD3D11Impl – implementation of a device context ( IDeviceContext interface)
    • The class provides methods to configure different parts of the pipeline (set pipeline state, vertex and index buffers, blend factors, etc.)
    • The class implements draw and dispatch compute command
    • The class tracks currently bound states to avoid redundant state changes
    • The class transitions resources to the correct states and commits them to the GPU pipeline
  • CommandListD3D11Impl – implementation of a command list ( ICommandList interface)
    • Command list object is created when  FinishCommandList() method is called on a deferred context. Finished command list can be submitted for execution by the ExecuteCommandList() method.

Related articles: