LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::Backends::DirectX12Backend Class Reference

Implements the DirectX 12 RenderBackend. More...

#include <dx12.hpp>

Inherits LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >, and LiteFX::Resource< THandle >.

Classes

class  DirectX12BackendImpl
 

Public Member Functions

 DirectX12Backend (const App &app, const bool &advancedSoftwareRasterizer=false)
 
 DirectX12Backend (const DirectX12Backend &) noexcept=delete
 
 DirectX12Backend (DirectX12Backend &&) noexcept=delete
 
virtual ~DirectX12Backend ()
 
virtual BackendType type () const noexcept override
 Gets the type of the backend. More...
 
virtual String name () const noexcept override
 Gets the name of the backend. More...
 
virtual Array< const DirectX12GraphicsAdapter * > listAdapters () const override
 
virtual const DirectX12GraphicsAdapterfindAdapter (const Optional< UInt64 > &adapterId=std::nullopt) const override
 Finds an adapter using its unique ID. More...
 
virtual void registerDevice (String name, UniquePtr< DirectX12Device > &&device) override
 
virtual void releaseDevice (const String &name) override
 Destroys and removes a device from the backend. More...
 
virtual DirectX12Devicedevice (const String &name) noexcept override
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual const DirectX12Devicedevice (const String &name) const noexcept override
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
UniquePtr< DirectX12SurfacecreateSurface (const HWND &hwnd) const
 Creates a surface on a window handle. More...
 
virtual void enableAdvancedSoftwareRasterizer (const bool &enable=false)
 Enables Windows Advanced Software Rasterization (WARP). More...
 
- Public Member Functions inherited from LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >
virtual ~RenderBackend () noexcept=default
 
virtual Array< const adapter_type * > listAdapters () const=0
 
virtual const adapter_typefindAdapter (const Optional< UInt64 > &adapterId=std::nullopt) const=0
 Finds an adapter using its unique ID. More...
 
virtual void registerDevice (String name, UniquePtr< device_type > &&device)=0
 
device_typecreateDevice (String name, const adapter_type &adapter, UniquePtr< surface_type > &&surface, TArgs &&... _args)
 Creates a new graphics device. More...
 
virtual void releaseDevice (const String &name)=0
 Destroys and removes a device from the backend. More...
 
virtual device_typedevice (const String &name) noexcept=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual const device_typedevice (const String &name) const noexcept=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual const device_typeoperator[] (const String &name) const noexcept
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual device_typeoperator[] (const String &name) noexcept
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IRenderBackend
virtual ~IRenderBackend () noexcept=default
 
Array< const IGraphicsAdapter * > listAdapters () const
 Lists all available graphics adapters. More...
 
virtual const IGraphicsAdapterfindAdapter (const Optional< UInt64 > &adapterId=std::nullopt) const =0
 Finds an adapter using its unique ID. More...
 
virtual IGraphicsDevicedevice (const String &name) noexcept=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual const IGraphicsDevicedevice (const String &name) const noexcept=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual const IGraphicsDeviceoperator[] (const String &name) const noexcept
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
virtual IGraphicsDeviceoperator[] (const String &name) noexcept
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found. More...
 
- Public Member Functions inherited from LiteFX::IBackend
virtual ~IBackend () noexcept=default
 
virtual BackendType type () const noexcept=0
 Gets the type of the backend. More...
 
const BackendState & state () const noexcept
 Returns the state of the backend. More...
 
virtual String name () const noexcept=0
 Gets the name of the backend. More...
 
- Public Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
virtual ~Resource () noexcept=default
 
const THandle & handle () const noexcept override
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::IResource< THandle >
virtual ~IResource () noexcept=default
 
virtual const THandle & handle () const noexcept=0
 Returns the resource managed by the class. More...
 

Protected Member Functions

virtual void activate () override
 Called by the parent App, if the backend is started. More...
 
virtual void deactivate () override
 Called by the parent App, if the backend is stopped. More...
 
- Protected Member Functions inherited from LiteFX::IBackend
BackendState & state () noexcept
 Returns the state of the backend. More...
 
virtual void activate ()=0
 Called by the parent App, if the backend is started. More...
 
virtual void deactivate ()=0
 Called by the parent App, if the backend is stopped. More...
 
- Protected Member Functions inherited from LiteFX::Resource< THandle >
 Resource (const THandle handle) noexcept
 Initializes the managed resource. More...
 
THandle & handle () noexcept override
 Returns the resource managed by the class. More...
 
virtual THandle & handle () noexcept=0
 Returns the resource managed by the class. More...
 

Additional Inherited Members

- Public Types inherited from LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >
using device_type = DirectX12Device
 
using surface_type = device_type::surface_type
 
using adapter_type = device_type::adapter_type
 
using swap_chain_type = device_type::swap_chain_type
 
using command_queue_type = device_type::command_queue_type
 
using command_buffer_type = device_type::command_buffer_type
 
using factory_type = device_type::factory_type
 
using barrier_type = device_type::barrier_type
 
using descriptor_layout_type = factory_type::descriptor_layout_type
 
using vertex_buffer_type = factory_type::vertex_buffer_type
 
using index_buffer_type = factory_type::index_buffer_type
 
using buffer_type = factory_type::buffer_type
 
using image_type = factory_type::image_type
 
using sampler_type = factory_type::sampler_type
 
using frame_buffer_type = device_type::frame_buffer_type
 
using render_pass_type = device_type::render_pass_type
 
using pipeline_layout_type = device_type::pipeline_layout_type
 
using render_pipeline_type = device_type::render_pipeline_type
 
using compute_pipeline_type = device_type::compute_pipeline_type
 
using shader_program_type = device_type::shader_program_type
 
using input_assembler_type = device_type::input_assembler_type
 
using rasterizer_type = device_type::rasterizer_type
 

Detailed Description

Implements the DirectX 12 RenderBackend.

Constructor & Destructor Documentation

◆ DirectX12Backend() [1/3]

DirectX12Backend::DirectX12Backend ( const App app,
const bool &  advancedSoftwareRasterizer = false 
)
explicit

◆ DirectX12Backend() [2/3]

LiteFX::Rendering::Backends::DirectX12Backend::DirectX12Backend ( const DirectX12Backend )
deletenoexcept

◆ DirectX12Backend() [3/3]

LiteFX::Rendering::Backends::DirectX12Backend::DirectX12Backend ( DirectX12Backend &&  )
deletenoexcept

◆ ~DirectX12Backend()

DirectX12Backend::~DirectX12Backend ( )
virtualdefaultnoexcept

Member Function Documentation

◆ activate()

void DirectX12Backend::activate ( )
overrideprotectedvirtual

Called by the parent App, if the backend is started.

Implements LiteFX::IBackend.

◆ createSurface()

UniquePtr< DirectX12Surface > DirectX12Backend::createSurface ( const HWND &  hwnd) const

Creates a surface on a window handle.

Parameters
hwndThe window handle on which the surface should be created.
Returns
The instance of the created surface.

◆ deactivate()

void DirectX12Backend::deactivate ( )
overrideprotectedvirtual

Called by the parent App, if the backend is stopped.

Implements LiteFX::IBackend.

◆ device() [1/2]

const DirectX12Device * DirectX12Backend::device ( const String name) const
overridevirtualnoexcept

Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found.

Implements LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >.

◆ device() [2/2]

DirectX12Device * DirectX12Backend::device ( const String name)
overridevirtualnoexcept

Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found.

Implements LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >.

◆ enableAdvancedSoftwareRasterizer()

void DirectX12Backend::enableAdvancedSoftwareRasterizer ( const bool &  enable = false)
virtual

Enables Windows Advanced Software Rasterization (WARP).

Enabling software rasterization disables hardware rasterization. Requesting adapters using findAdapter or listAdapters will only return WARP-compatible adapters.

Parameters
enabletrue, if advanced software rasterization should be used.

◆ findAdapter()

const DirectX12GraphicsAdapter * DirectX12Backend::findAdapter ( const Optional< UInt64 > &  adapterId = std::nullopt) const
overridevirtual

Finds an adapter using its unique ID.

Implements LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >.

◆ listAdapters()

Array< const DirectX12GraphicsAdapter * > DirectX12Backend::listAdapters ( ) const
overridevirtual

◆ name()

String DirectX12Backend::name ( ) const
overridevirtualnoexcept

Gets the name of the backend.

Implements LiteFX::IBackend.

◆ registerDevice()

void DirectX12Backend::registerDevice ( String  name,
UniquePtr< DirectX12Device > &&  device 
)
overridevirtual

◆ releaseDevice()

void DirectX12Backend::releaseDevice ( const String name)
overridevirtual

Destroys and removes a device from the backend.

Implements LiteFX::Rendering::RenderBackend< DirectX12Backend, DirectX12Device >.

◆ type()

BackendType DirectX12Backend::type ( ) const
overridevirtualnoexcept

Gets the type of the backend.

Implements LiteFX::IBackend.