LiteFX 0.4.1.2025
Computer Graphics Engine
Loading...
Searching...
No Matches
LiteFX::Rendering::RenderBackend< TGraphicsDevice > Class Template Referenceabstract

Defines a back-end, that provides a device instance for a certain surface and graphics adapter. More...

#include <rendering.hpp>

Inherits LiteFX::Rendering::IRenderBackend.

Public Types

using device_type = TGraphicsDevice
 
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 ray_tracing_pipeline_type = device_type::ray_tracing_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
 

Public Member Functions

 ~RenderBackend () noexcept override=default
 
virtual const Array< SharedPtr< const adapter_type > > & adapters () const =0
 
const adapter_typefindAdapter (const Optional< UInt64 > &adapterId=std::nullopt) const noexcept override=0
 Finds an adapter using its unique ID.Note that the adapter ID is optional, which allows the back-end to return a default adapter instance. Which adapter is used as default adapter, depends on the actual back-end implementation. The interface does not make any constraints on the default adapter to choose. A naive implementation might simply return the first available adapter.
 
virtual void registerDevice (const String &name, SharedPtr< device_type > &&device)=0
 
template<typename TSelf , typename ... TArgs>
device_typecreateDevice (this TSelf &self, const String &name, const adapter_type &adapter, UniquePtr< surface_type > &&surface, TArgs &&... _args)
 Creates a new graphics device.
 
virtual void releaseDevice (const String &name)=0
 Destroys and removes a device from the backend.
 
device_typedevice (const String &name) noexcept override=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found.
Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

 
const device_typedevice (const String &name) const noexcept override=0
 Looks up a device and returns a pointer to it, or nullptr, if no device with the provided name could be found.
Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

 
const device_typeoperator[] (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.
Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

 
device_typeoperator[] (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.
Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

 
- Public Member Functions inherited from LiteFX::Rendering::IRenderBackend
 ~IRenderBackend () noexcept override=default
 
Enumerable< SharedPtr< const IGraphicsAdapter > > listAdapters () const
 Lists all available graphics adapters.
 
- Public Member Functions inherited from LiteFX::IBackend
virtual ~IBackend () noexcept=default
 
virtual BackendType type () const noexcept=0
 Gets the type of the backend.
 
const BackendStatestate () const noexcept
 Returns the state of the backend.
 
virtual StringView name () const noexcept=0
 Gets the name of the backend.
 

Protected Member Functions

 RenderBackend () noexcept=default
 
 RenderBackend (RenderBackend &&) noexcept=default
 
 RenderBackend (const RenderBackend &)=default
 
RenderBackendoperator= (RenderBackend &&) noexcept=default
 
RenderBackendoperator= (const RenderBackend &)=default
 
- Protected Member Functions inherited from LiteFX::Rendering::IRenderBackend
 IRenderBackend () noexcept=default
 
 IRenderBackend (IRenderBackend &&) noexcept=default
 
 IRenderBackend (const IRenderBackend &)=default
 
IRenderBackendoperator= (const IRenderBackend &)=default
 
IRenderBackendoperator= (IRenderBackend &&) noexcept=default
 
- Protected Member Functions inherited from LiteFX::IBackend
 IBackend () noexcept=default
 
 IBackend (const IBackend &)=default
 
 IBackend (IBackend &&) noexcept=default
 
IBackendoperator= (const IBackend &)=default
 
IBackendoperator= (IBackend &&) noexcept=default
 
BackendStatestate () noexcept
 Returns the state of the backend.
 
virtual void activate ()=0
 Called by the parent App, if the backend is started.
 
virtual void deactivate ()=0
 Called by the parent App, if the backend is stopped.
 

Detailed Description

template<typename TGraphicsDevice>
requires meta::implements<TGraphicsDevice, GraphicsDevice<typename TGraphicsDevice::factory_type, typename TGraphicsDevice::surface_type, typename TGraphicsDevice::adapter_type, typename TGraphicsDevice::swap_chain_type, typename TGraphicsDevice::command_queue_type, typename TGraphicsDevice::render_pass_type, typename TGraphicsDevice::render_pipeline_type, typename TGraphicsDevice::compute_pipeline_type, typename TGraphicsDevice::ray_tracing_pipeline_type, typename TGraphicsDevice::barrier_type>>
class LiteFX::Rendering::RenderBackend< TGraphicsDevice >

Defines a back-end, that provides a device instance for a certain surface and graphics adapter.

Template Parameters
TGraphicsDeviceThe type of the graphics device. Must implement GraphicsDevice.

Member Typedef Documentation

◆ adapter_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::adapter_type = device_type::adapter_type

◆ barrier_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::barrier_type = device_type::barrier_type

◆ buffer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::buffer_type = factory_type::buffer_type

◆ command_buffer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::command_buffer_type = device_type::command_buffer_type

◆ command_queue_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::command_queue_type = device_type::command_queue_type

◆ compute_pipeline_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::compute_pipeline_type = device_type::compute_pipeline_type

◆ descriptor_layout_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::descriptor_layout_type = factory_type::descriptor_layout_type

◆ device_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::device_type = TGraphicsDevice

◆ factory_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::factory_type = device_type::factory_type

◆ frame_buffer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::frame_buffer_type = device_type::frame_buffer_type

◆ image_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::image_type = factory_type::image_type

◆ index_buffer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::index_buffer_type = factory_type::index_buffer_type

◆ input_assembler_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::input_assembler_type = device_type::input_assembler_type

◆ pipeline_layout_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::pipeline_layout_type = device_type::pipeline_layout_type

◆ rasterizer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::rasterizer_type = device_type::rasterizer_type

◆ ray_tracing_pipeline_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::ray_tracing_pipeline_type = device_type::ray_tracing_pipeline_type

◆ render_pass_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::render_pass_type = device_type::render_pass_type

◆ render_pipeline_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::render_pipeline_type = device_type::render_pipeline_type

◆ sampler_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::sampler_type = factory_type::sampler_type

◆ shader_program_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::shader_program_type = device_type::shader_program_type

◆ surface_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::surface_type = device_type::surface_type

◆ swap_chain_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::swap_chain_type = device_type::swap_chain_type

◆ vertex_buffer_type

template<typename TGraphicsDevice >
using LiteFX::Rendering::RenderBackend< TGraphicsDevice >::vertex_buffer_type = factory_type::vertex_buffer_type

Constructor & Destructor Documentation

◆ RenderBackend() [1/3]

template<typename TGraphicsDevice >
LiteFX::Rendering::RenderBackend< TGraphicsDevice >::RenderBackend ( )
protecteddefaultnoexcept

◆ RenderBackend() [2/3]

template<typename TGraphicsDevice >
LiteFX::Rendering::RenderBackend< TGraphicsDevice >::RenderBackend ( RenderBackend< TGraphicsDevice > && )
protecteddefaultnoexcept

◆ RenderBackend() [3/3]

template<typename TGraphicsDevice >
LiteFX::Rendering::RenderBackend< TGraphicsDevice >::RenderBackend ( const RenderBackend< TGraphicsDevice > & )
protecteddefault

◆ ~RenderBackend()

template<typename TGraphicsDevice >
LiteFX::Rendering::RenderBackend< TGraphicsDevice >::~RenderBackend ( )
overridedefaultnoexcept

Member Function Documentation

◆ adapters()

template<typename TGraphicsDevice >
virtual const Array< SharedPtr< const adapter_type > > & LiteFX::Rendering::RenderBackend< TGraphicsDevice >::adapters ( ) const
pure virtual

◆ createDevice()

template<typename TGraphicsDevice >
template<typename TSelf , typename ... TArgs>
device_type & LiteFX::Rendering::RenderBackend< TGraphicsDevice >::createDevice ( this TSelf & self,
const String & name,
const adapter_type & adapter,
UniquePtr< surface_type > && surface,
TArgs &&... _args )
inline

Creates a new graphics device.

Parameters
_argsThe arguments that are passed to the graphics device constructor.
Returns
A pointer of the created graphics device instance.

◆ device() [1/2]

template<typename TGraphicsDevice >
const device_type * LiteFX::Rendering::RenderBackend< TGraphicsDevice >::device ( const String & name) const
overridepure virtualnoexcept

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

Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

Implements LiteFX::Rendering::IRenderBackend.

Implemented in LiteFX::Rendering::Backends::DirectX12Backend, and LiteFX::Rendering::Backends::VulkanBackend.

◆ device() [2/2]

template<typename TGraphicsDevice >
device_type * LiteFX::Rendering::RenderBackend< TGraphicsDevice >::device ( const String & name)
overridepure virtualnoexcept

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

Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

Implements LiteFX::Rendering::IRenderBackend.

Implemented in LiteFX::Rendering::Backends::DirectX12Backend, and LiteFX::Rendering::Backends::VulkanBackend.

◆ findAdapter()

template<typename TGraphicsDevice >
const adapter_type * LiteFX::Rendering::RenderBackend< TGraphicsDevice >::findAdapter ( const Optional< UInt64 > & adapterId = std::nullopt) const
overridepure virtualnoexcept

Finds an adapter using its unique ID.Note that the adapter ID is optional, which allows the back-end to return a default adapter instance. Which adapter is used as default adapter, depends on the actual back-end implementation. The interface does not make any constraints on the default adapter to choose. A naive implementation might simply return the first available adapter.

Implements LiteFX::Rendering::IRenderBackend.

Implemented in LiteFX::Rendering::Backends::DirectX12Backend, and LiteFX::Rendering::Backends::VulkanBackend.

◆ operator=() [1/2]

template<typename TGraphicsDevice >
RenderBackend & LiteFX::Rendering::RenderBackend< TGraphicsDevice >::operator= ( const RenderBackend< TGraphicsDevice > & )
protecteddefault

◆ operator=() [2/2]

template<typename TGraphicsDevice >
RenderBackend & LiteFX::Rendering::RenderBackend< TGraphicsDevice >::operator= ( RenderBackend< TGraphicsDevice > && )
protecteddefaultnoexcept

◆ operator[]() [1/2]

template<typename TGraphicsDevice >
const device_type * LiteFX::Rendering::RenderBackend< TGraphicsDevice >::operator[] ( const String & name) const
inlineoverridevirtualnoexcept

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

Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

Reimplemented from LiteFX::Rendering::IRenderBackend.

◆ operator[]() [2/2]

template<typename TGraphicsDevice >
device_type * LiteFX::Rendering::RenderBackend< TGraphicsDevice >::operator[] ( const String & name)
inlineoverridevirtualnoexcept

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

Parameters
nameThe name of the device.
Returns
A pointer to the device or nullptr, if no device could be found.

Reimplemented from LiteFX::Rendering::IRenderBackend.

◆ registerDevice()

template<typename TGraphicsDevice >
virtual void LiteFX::Rendering::RenderBackend< TGraphicsDevice >::registerDevice ( const String & name,
SharedPtr< device_type > && device )
pure virtual

◆ releaseDevice()

template<typename TGraphicsDevice >
virtual void LiteFX::Rendering::RenderBackend< TGraphicsDevice >::releaseDevice ( const String & name)
pure virtual

Destroys and removes a device from the backend.

Parameters
nameThe name of the device.

Implemented in LiteFX::Rendering::Backends::DirectX12Backend, and LiteFX::Rendering::Backends::VulkanBackend.