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

Vulkan implementation of IGraphicsDevice. More...

#include <VulkanDevice.h>

Inheritance diagram for spark::render::vk::VulkanDevice:
spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass > spark::render::Resource< VkDevice > spark::render::IGraphicsDevice spark::render::IResource< VkDevice >

Classes

struct  Impl
 

Public Member Functions

 VulkanDevice (const VulkanGraphicsAdapter &adapter, std::unique_ptr< VulkanSurface > &&surface, std::span< std::string > extensions={})
 Initializes a new VulkanDevice.
 
 VulkanDevice (const VulkanGraphicsAdapter &adapter, std::unique_ptr< VulkanSurface > &&surface, Format format, const math::Vector2< unsigned > &frame_buffer_size, unsigned frame_buffers, std::span< std::string > extensions={})
 Initializes a new VulkanDevice.
 
 VulkanDevice (const VulkanDevice &other)=delete
 
 VulkanDevice (VulkanDevice &&other) noexcept=delete
 
VulkanDeviceoperator= (const VulkanDevice &other)=delete
 
VulkanDeviceoperator= (VulkanDevice &&other) noexcept=delete
 
std::span< std::string > enabledExtensions () const noexcept
 Gets the extensions used to initialize the device.
 
MultiSamplingLevel maximumMultiSamplingLevel (Format format) const noexcept override
 Gets the maximum number of multi-sampling levels supported for the given format.
 
double ticksPerMillisecond () const noexcept override
 Gets the number of GPU ticks per millisecond.
 
void wait () const override
 Waits until the device is idle.
 
DeviceStatestate () noexcept override
 Gets the device state used to manage the device resources.
 
const VulkanSurfacesurface () const noexcept override
 Gets the surface the device is rendering to.
 
const VulkanGraphicsAdaptergraphicsAdapter () const noexcept override
 Gets the graphics adapter the device uses for drawing.
 
const VulkanFactoryfactory () const noexcept override
 Gets the graphics factory used to create buffers, textures, samplers from the device.
 
const VulkanSwapChainswapChain () const noexcept override
 Gets the graphics adapter that contains the front and back buffers used for presentation.
 
VulkanSwapChainswapChain () noexcept override
 Gets the graphics adapter that contains the front and back buffers used for presentation.
 
const VulkanQueuegraphicsQueue () const noexcept override
 Gets the queue instance used to process draw calls.
 
const VulkanQueuetransferQueue () const noexcept override
 Gets the queue instance used for device-device transfers (e.g. between render-passes).
 
const VulkanQueuebufferQueue () const noexcept override
 Gets the queue instance used for buffer transfers (e.g. between CPU and GPU).
 
const VulkanQueuecomputeQueue () const noexcept override
 Gets the queue instance used for compute operations.
 
- Public Member Functions inherited from spark::render::Resource< VkDevice >
 Resource (VkDevice 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 VkDevice & handle () const final
 Gets the managed resource handle.
 

Additional Inherited Members

- Public Types inherited from spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >
using surface_type
 
using adapter_type
 
using swap_chain_type
 
using command_queue_type
 
using command_buffer_type
 
using factory_type
 
using descriptor_layout_type
 
using vertex_buffer_type
 
using index_buffer_type
 
using buffer_type
 
using image_type
 
using sampler_type
 
using render_pass_type
 
using frame_buffer_type
 
using render_pipeline_type
 
using pipeline_layout_type
 
using shader_program_type
 
using input_assembler_type
 
using rasterizer_type
 
- Public Types inherited from spark::render::IResource< VkDevice >
using handle_type
 
- Protected Member Functions inherited from spark::render::Resource< VkDevice >
VkDevice & handle () final
 Gets the managed resource handle.
 

Detailed Description

Vulkan implementation of IGraphicsDevice.

Constructor & Destructor Documentation

◆ VulkanDevice() [1/2]

spark::render::vk::VulkanDevice::VulkanDevice ( const VulkanGraphicsAdapter & adapter,
std::unique_ptr< VulkanSurface > && surface,
std::span< std::string > extensions = {} )
explicit

Initializes a new VulkanDevice.

Parameters
adapterThe adapter to use for drawing.
surfaceThe surface the device will draw to.
extensionsThe required extensions for the device to be initialized with.

◆ VulkanDevice() [2/2]

spark::render::vk::VulkanDevice::VulkanDevice ( const VulkanGraphicsAdapter & adapter,
std::unique_ptr< VulkanSurface > && surface,
Format format,
const math::Vector2< unsigned > & frame_buffer_size,
unsigned frame_buffers,
std::span< std::string > extensions = {} )
explicit

Initializes a new VulkanDevice.

Parameters
adapterThe adapter to use for drawing.
surfaceThe surface the device will draw to.
formatThe initial format of the swap chain.
frame_buffer_sizeThe initial size of the frame buffers.
frame_buffersThe initial number of frame buffers to use.
extensionsThe required extensions for the device to be initialized with.

Member Function Documentation

◆ bufferQueue()

const VulkanQueue & spark::render::vk::VulkanDevice::bufferQueue ( ) const
nodiscardoverridevirtualnoexcept

Gets the queue instance used for buffer transfers (e.g. between CPU and GPU).

Returns
The ICommandQueue used for buffer transfers.
Note
This can be the same as the graphicsQueue if the device does not support dedicated transfer queues.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ computeQueue()

const VulkanQueue & spark::render::vk::VulkanDevice::computeQueue ( ) const
nodiscardoverridevirtualnoexcept

Gets the queue instance used for compute operations.

Returns
The ICommandQueue used for compute operations.
Note
This can be the same as the graphicsQueue if the device does not support dedicated compute queues.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ enabledExtensions()

std::span< std::string > spark::render::vk::VulkanDevice::enabledExtensions ( ) const
nodiscardnoexcept

Gets the extensions used to initialize the device.

Returns
A std::span containing the extensions used to initialize the device.

◆ factory()

const VulkanFactory & spark::render::vk::VulkanDevice::factory ( ) const
nodiscardoverridevirtualnoexcept

Gets the graphics factory used to create buffers, textures, samplers from the device.

Returns
The IGraphicsFactory instance for the device.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ graphicsAdapter()

const VulkanGraphicsAdapter & spark::render::vk::VulkanDevice::graphicsAdapter ( ) const
nodiscardoverridevirtualnoexcept

Gets the graphics adapter the device uses for drawing.

Returns
The IGraphicsAdapter the device uses for drawing.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ graphicsQueue()

const VulkanQueue & spark::render::vk::VulkanDevice::graphicsQueue ( ) const
nodiscardoverridevirtualnoexcept

Gets the queue instance used to process draw calls.

Returns
The ICommandQueue used to process draw calls.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ maximumMultiSamplingLevel()

MultiSamplingLevel spark::render::vk::VulkanDevice::maximumMultiSamplingLevel ( Format format) const
nodiscardoverridevirtualnoexcept

Gets the maximum number of multi-sampling levels supported for the given format.

Parameters
formatThe Format of the target (i.e. back buffer).
Returns
The maximum MultiSamplingLevel supported for the given format.

Implements spark::render::IGraphicsDevice.

◆ state()

DeviceState & spark::render::vk::VulkanDevice::state ( )
nodiscardoverridevirtualnoexcept

Gets the device state used to manage the device resources.

Returns
A reference to the DeviceState.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ surface()

const VulkanSurface & spark::render::vk::VulkanDevice::surface ( ) const
nodiscardoverridevirtualnoexcept

Gets the surface the device is rendering to.

Returns
The ISurface the device is rendering to.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ swapChain() [1/2]

const VulkanSwapChain & spark::render::vk::VulkanDevice::swapChain ( ) const
nodiscardoverridevirtualnoexcept

Gets the graphics adapter that contains the front and back buffers used for presentation.

Returns
A reference to the ISwapChain the device uses for presentation.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ swapChain() [2/2]

VulkanSwapChain & spark::render::vk::VulkanDevice::swapChain ( )
nodiscardoverridevirtualnoexcept

Gets the graphics adapter that contains the front and back buffers used for presentation.

Returns
A reference to the ISwapChain the device uses for presentation.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ ticksPerMillisecond()

double spark::render::vk::VulkanDevice::ticksPerMillisecond ( ) const
nodiscardoverridevirtualnoexcept

Gets the number of GPU ticks per millisecond.

Returns
The number of GPU ticks per millisecond.

Implements spark::render::IGraphicsDevice.

◆ transferQueue()

const VulkanQueue & spark::render::vk::VulkanDevice::transferQueue ( ) const
nodiscardoverridevirtualnoexcept

Gets the queue instance used for device-device transfers (e.g. between render-passes).

Returns
The ICommandQueue used for device-device transfers.
Note
This can be the same as the graphicsQueue if the device does not support dedicated transfer queues.

Implements spark::render::GraphicsDevice< VulkanFactory, VulkanSurface, VulkanGraphicsAdapter, VulkanSwapChain, VulkanQueue, VulkanRenderPass >.

◆ wait()

void spark::render::vk::VulkanDevice::wait ( ) const
overridevirtual

Waits until the device is idle.

The complexity of this operation may depend on the graphics API that implements this method. Calling this method guarantees, that the device resources are in an unused state and may safely be released.

Implements spark::render::IGraphicsDevice.