SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::RenderBackend< GraphicsDeviceType > Class Template Referenceabstract

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

#include <Backend.h>

Inheritance diagram for spark::render::RenderBackend< GraphicsDeviceType >:
spark::render::IRenderBackend spark::render::IBackend

Public Types

using device_type = GraphicsDeviceType
 
using surface_type = typename device_type::surface_type
 
using adapter_type = typename device_type::adapter_type
 
using swap_chain_type = typename device_type::swap_chain_type
 
using command_queue_type = typename device_type::command_queue_type
 
using command_buffer_type = typename device_type::command_buffer_type
 
using frame_buffer_type = typename device_type::frame_buffer_type
 
using render_pass_type = typename device_type::render_pass_type
 
using pipeline_layout_type = typename device_type::pipeline_layout_type
 
using render_pipeline_type = typename device_type::render_pipeline_type
 
using shader_program_type = typename device_type::shader_program_type
 
using input_assembler_type = typename device_type::input_assembler_type
 
using rasterizer_type = typename device_type::rasterizer_type
 

Public Member Functions

virtual std::vector< const adapter_type * > adapters () const noexcept=0
 
const adapter_type * findAdapter (const std::optional< lib::Uuid > &id=std::nullopt) const override=0
 Finds a graphics adapter by unique id.
 
device_type * device (const std::string &name) noexcept override=0
 Searches for a graphics device by name.
 
const device_type * device (const std::string &name) const noexcept override=0
 Searches for a graphics device by name.
 
virtual void registerDevice (std::string name, std::unique_ptr< device_type > &&device)=0
 Registers a new graphics device.
 
virtual void releaseDevice (const std::string &name)=0
 Unregisters a graphics device.
 
template<typename Self , typename... Args>
device_type * createDevice (std::string name, const adapter_type &adapter, std::unique_ptr< surface_type > &&surface, Args &&... args)
 Creates a new graphics device.
 
- Public Member Functions inherited from spark::render::IRenderBackend
BackendType type () const noexcept override
 Gets the type of the backend.
 
std::vector< const IGraphicsAdapter * > adapters () const noexcept
 Lists all available graphics adapters.
 

Detailed Description

template<typename GraphicsDeviceType>
class spark::render::RenderBackend< GraphicsDeviceType >

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

Template Parameters
GraphicsDeviceTypeThe type of the graphics device. (inherits from IGraphicsDevice)

Member Function Documentation

◆ adapters()

template<typename GraphicsDeviceType >
virtual std::vector< const adapter_type * > spark::render::RenderBackend< GraphicsDeviceType >::adapters ( ) const
nodiscardpure virtualnoexcept

◆ createDevice()

template<typename GraphicsDeviceType >
template<typename Self , typename... Args>
device_type * spark::render::RenderBackend< GraphicsDeviceType >::createDevice ( std::string name,
const adapter_type & adapter,
std::unique_ptr< surface_type > && surface,
Args &&... args )
inline

Creates a new graphics device.

Template Parameters
SelfThe real type of the backend. (inheriting from RenderBackend)
ArgsThe types of the arguments to pass to the device constructor.
Parameters
nameThe name of the device to create.
adapterThe adapter to use for the device.
surfaceThe surface to use for the device.
argsThe remaining arguments to pass to the device constructor.
Returns
A pointer to the newly created device.

◆ device() [1/2]

template<typename GraphicsDeviceType >
const device_type * spark::render::RenderBackend< GraphicsDeviceType >::device ( const std::string & name) const
nodiscardoverridepure virtualnoexcept

Searches for a graphics device by name.

Parameters
nameThe name of the graphics device to find.
Returns
A pointer to the graphics device if found, nullptr otherwise.

Implements spark::render::IRenderBackend.

Implemented in spark::render::vk::VulkanBackend.

◆ device() [2/2]

template<typename GraphicsDeviceType >
device_type * spark::render::RenderBackend< GraphicsDeviceType >::device ( const std::string & name)
nodiscardoverridepure virtualnoexcept

Searches for a graphics device by name.

Parameters
nameThe name of the graphics device to find.
Returns
A pointer to the graphics device if found, nullptr otherwise.

Implements spark::render::IRenderBackend.

Implemented in spark::render::vk::VulkanBackend.

◆ findAdapter()

template<typename GraphicsDeviceType >
const adapter_type * spark::render::RenderBackend< GraphicsDeviceType >::findAdapter ( const std::optional< lib::Uuid > & id = std::nullopt) const
nodiscardoverridepure virtual

Finds a graphics adapter by unique id.

Parameters
idThe unique id of the graphics adapter to find. If std::nullopt, the returned adapter is implementation-defined.
Returns
A pointer to the graphics adapter if found, nullptr otherwise.

Implements spark::render::IRenderBackend.

Implemented in spark::render::vk::VulkanBackend.

◆ registerDevice()

template<typename GraphicsDeviceType >
virtual void spark::render::RenderBackend< GraphicsDeviceType >::registerDevice ( std::string name,
std::unique_ptr< device_type > && device )
pure virtual

Registers a new graphics device.

Parameters
nameThe name of the device.
deviceA std::unique_ptr to the device to register.
See also
RenderBackend::releaseDevice()

◆ releaseDevice()

template<typename GraphicsDeviceType >
virtual void spark::render::RenderBackend< GraphicsDeviceType >::releaseDevice ( const std::string & name)
pure virtual

Unregisters a graphics device.

Parameters
nameThe name of the device to unregister. This name must match the name used when registering the device.

Implemented in spark::render::vk::VulkanBackend.