SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::vk::VulkanBackend Class Referencefinal

Vulkan implementation of IRenderBackend. More...

#include <VulkanBackend.h>

Inheritance diagram for spark::render::vk::VulkanBackend:
spark::render::RenderBackend< VulkanDevice > spark::render::Resource< VkInstance > spark::render::IRenderBackend spark::render::IResource< VkInstance > spark::render::IBackend

Classes

struct  Impl
 

Public Member Functions

 VulkanBackend (std::span< std::string > extensions={}, std::span< std::string > validation_layers={})
 Initializes a VulkanBackend.
 
 VulkanBackend (const VulkanBackend &other)=delete
 
 VulkanBackend (VulkanBackend &&other) noexcept=delete
 
VulkanBackendoperator= (const VulkanBackend &other)=delete
 
VulkanBackendoperator= (VulkanBackend &&other) noexcept=delete
 
std::unique_ptr< VulkanSurfacecreateSurface (const std::function< VkSurfaceKHR(const VkInstance &)> &predicate) const
 Creates a surface using the predicate callback.
 
std::span< std::string > enabledValidationLayers () const noexcept
 Gets the list of enabled validation layers.
 
std::vector< const VulkanGraphicsAdapter * > adapters () const noexcept override
 Lists all available graphics adapters.
 
const VulkanGraphicsAdapterfindAdapter (const std::optional< lib::Uuid > &id) const override
 Finds a graphics adapter by unique id.
 
VulkanDevicedevice (const std::string &name) noexcept override
 Searches for a graphics device by name.
 
const VulkanDevicedevice (const std::string &name) const noexcept override
 Searches for a graphics device by name.
 
void registerDevice (std::string name, std::unique_ptr< VulkanDevice > &&device) override
 Registers a new graphics device.
 
void releaseDevice (const std::string &name) override
 Unregisters a graphics device.
 
- Public Member Functions inherited from spark::render::RenderBackend< VulkanDevice >
virtual void registerDevice (std::string name, std::unique_ptr< device_type > &&device)=0
 Registers a new graphics device.
 
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.
 
- Public Member Functions inherited from spark::render::Resource< VkInstance >
 Resource (VkInstance handle) noexcept
 Initializes the managed resource with the given handle.
 
 Resource (const Resource &other)=delete
 
 Resource (Resource &&other) noexcept=delete
 
Resourceoperator= (const Resource &other)=delete
 
Resourceoperator= (Resource &&other) noexcept=delete
 
const VkInstance & handle () const final
 Gets the managed resource handle.
 

Static Public Member Functions

static bool ValidateInstanceLayers (std::span< std::string > validation_layers) noexcept
 Checks if all elements of validation_layers are contained by the a list of available validation layers.
 
static std::vector< std::string > InstanceValidationLayers () noexcept
 Gets all available validation layers.
 
static bool ValidateInstanceExtensions (std::span< std::string > extensions) noexcept
 Checks if all elements of extensions are contained by the a list of available extensions.
 
static std::vector< std::string > AvailableInstanceExtensions () noexcept
 Gets all available instance extensions.
 

Additional Inherited Members

- Public Types inherited from spark::render::RenderBackend< VulkanDevice >
using device_type
 
using surface_type
 
using adapter_type
 
using swap_chain_type
 
using command_queue_type
 
using command_buffer_type
 
using frame_buffer_type
 
using render_pass_type
 
using pipeline_layout_type
 
using render_pipeline_type
 
using shader_program_type
 
using input_assembler_type
 
using rasterizer_type
 
- Public Types inherited from spark::render::IResource< VkInstance >
using handle_type
 
- Protected Member Functions inherited from spark::render::Resource< VkInstance >
VkInstance & handle () final
 Gets the managed resource handle.
 

Detailed Description

Vulkan implementation of IRenderBackend.

Constructor & Destructor Documentation

◆ VulkanBackend()

spark::render::vk::VulkanBackend::VulkanBackend ( std::span< std::string > extensions = {},
std::span< std::string > validation_layers = {} )
explicit

Initializes a VulkanBackend.

Parameters
extensionsThe instance extensions to enable on the backend.
validation_layersThe validation layers to enable on the backend.

Member Function Documentation

◆ adapters()

std::vector< const VulkanGraphicsAdapter * > spark::render::vk::VulkanBackend::adapters ( ) const
nodiscardoverridevirtualnoexcept

Lists all available graphics adapters.

Returns
A std::vector containing all available graphics adapters.

Implements spark::render::RenderBackend< VulkanDevice >.

◆ AvailableInstanceExtensions()

std::vector< std::string > spark::render::vk::VulkanBackend::AvailableInstanceExtensions ( )
staticnoexcept

Gets all available instance extensions.

Returns
A list of available extensions.

◆ createSurface()

std::unique_ptr< VulkanSurface > spark::render::vk::VulkanBackend::createSurface ( const std::function< VkSurfaceKHR(const VkInstance &)> & predicate) const
nodiscard

Creates a surface using the predicate callback.

Parameters
predicateA callback that gets called with the backend instance handle and creates the surface instance.
Returns
The instance of the created surface.

◆ device() [1/2]

const VulkanDevice * spark::render::vk::VulkanBackend::device ( const std::string & name) const
nodiscardoverridevirtualnoexcept

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::RenderBackend< VulkanDevice >.

◆ device() [2/2]

VulkanDevice * spark::render::vk::VulkanBackend::device ( const std::string & name)
nodiscardoverridevirtualnoexcept

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::RenderBackend< VulkanDevice >.

◆ enabledValidationLayers()

std::span< std::string > spark::render::vk::VulkanBackend::enabledValidationLayers ( ) const
noexcept

Gets the list of enabled validation layers.

Returns
A std::span of enabled validation layers.

◆ findAdapter()

const VulkanGraphicsAdapter * spark::render::vk::VulkanBackend::findAdapter ( const std::optional< lib::Uuid > & id) const
nodiscardoverridevirtual

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::RenderBackend< VulkanDevice >.

◆ InstanceValidationLayers()

std::vector< std::string > spark::render::vk::VulkanBackend::InstanceValidationLayers ( )
staticnoexcept

Gets all available validation layers.

Returns
A list of available validation layers.

◆ registerDevice()

void spark::render::vk::VulkanBackend::registerDevice ( std::string name,
std::unique_ptr< VulkanDevice > && device )
override

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()

void spark::render::vk::VulkanBackend::releaseDevice ( const std::string & name)
overridevirtual

Unregisters a graphics device.

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

Implements spark::render::RenderBackend< VulkanDevice >.

◆ ValidateInstanceExtensions()

bool spark::render::vk::VulkanBackend::ValidateInstanceExtensions ( std::span< std::string > extensions)
staticnoexcept

Checks if all elements of extensions are contained by the a list of available extensions.

Parameters
extensionsThe extensions to check.
Returns
true, if all elements of extensions are contained by the a list of available extensions.

◆ ValidateInstanceLayers()

bool spark::render::vk::VulkanBackend::ValidateInstanceLayers ( std::span< std::string > validation_layers)
staticnoexcept

Checks if all elements of validation_layers are contained by the a list of available validation layers.

Parameters
validation_layersThe validation layers to check.
Returns
true, if all elements of validation_layers are contained by the a list of available validation layers.