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

Vulkan implementation of IFrameBuffer. More...

#include <VulkanFrameBuffer.h>

Inheritance diagram for spark::render::vk::VulkanFrameBuffer:
spark::render::FrameBuffer< VulkanCommandBuffer > spark::render::Resource< VkFramebuffer > spark::render::IFrameBuffer spark::render::IResource< VkFramebuffer >

Classes

struct  Impl
 

Public Member Functions

 VulkanFrameBuffer (const VulkanRenderPass &render_pass, unsigned buffer_index, const math::Vector2< unsigned > &render_area, unsigned command_buffers=1)
 Initializes a new VulkanFrameBuffer.
 
 VulkanFrameBuffer (const VulkanFrameBuffer &other)=delete
 
 VulkanFrameBuffer (VulkanFrameBuffer &&other) noexcept=delete
 
VulkanFrameBufferoperator= (const VulkanFrameBuffer &other)=delete
 
VulkanFrameBufferoperator= (VulkanFrameBuffer &&other) noexcept=delete
 
const VkSemaphore & semaphore () const noexcept
 Gets a reference of the semaphore, that can be used to signal, that the frame buffer is finished.
 
std::size_t & lastFence () const noexcept
 Gets a reference of the last fence value for the frame buffer.
 
unsigned bufferIndex () const noexcept override
 Gets the index of the frame buffer within the IRenderPass.
 
spark::math::Vector2< unsigned > size () const noexcept override
 Gets the current size of the frame buffer.
 
void resize (const spark::math::Vector2< unsigned > &render_area) override
 Invalidate and resize the frame buffer with given render_area.
 
std::vector< std::shared_ptr< const VulkanCommandBuffer > > commandBuffers () const noexcept override
 Gets all command buffers of the frame buffer.
 
std::shared_ptr< const VulkanCommandBuffercommandBuffer (unsigned index) const override
 Gets the command buffer that records draw commands for the frame buffer.
 
std::vector< const IVulkanImage * > images () const noexcept override
 Gets all images storing the output attachments for the render targets of the IRenderPass.
 
const IVulkanImageimage (unsigned location) const override
 Gets the image storing the output attachment for the render target mapped at given location.
 
- Public Member Functions inherited from spark::render::IFrameBuffer
std::vector< std::shared_ptr< const ICommandBuffer > > commandBuffers () const noexcept
 Gets all command buffers of the frame buffer.
 
std::shared_ptr< const ICommandBuffercommandBuffer (unsigned int index) const
 Gets the command buffer that records draw commands for the frame buffer.
 
std::vector< const IImage * > images () const noexcept
 Gets all images storing the output attachments for the render targets of the IRenderPass.
 
const IImageimage (unsigned int location) const
 Gets the image storing the output attachment for the render target mapped at given location.
 
- Public Member Functions inherited from spark::render::Resource< VkFramebuffer >
 Resource (VkFramebuffer 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 VkFramebuffer & handle () const final
 Gets the managed resource handle.
 

Additional Inherited Members

- Public Types inherited from spark::render::FrameBuffer< VulkanCommandBuffer >
using command_buffer_type
 
using image_type
 
- Public Types inherited from spark::render::IResource< VkFramebuffer >
using handle_type
 
- Protected Member Functions inherited from spark::render::Resource< VkFramebuffer >
VkFramebuffer & handle () final
 Gets the managed resource handle.
 

Detailed Description

Vulkan implementation of IFrameBuffer.

Constructor & Destructor Documentation

◆ VulkanFrameBuffer()

spark::render::vk::VulkanFrameBuffer::VulkanFrameBuffer ( const VulkanRenderPass & render_pass,
unsigned buffer_index,
const math::Vector2< unsigned > & render_area,
unsigned command_buffers = 1 )
explicit

Initializes a new VulkanFrameBuffer.

Parameters
render_passThe parent VulkanRenderPass of the frame buffer.
buffer_indexThe index of the frame buffer within the render pass.
render_areaThe initial render area size of the frame buffer.
command_buffersThe number of command buffers the frame buffer stores.

Member Function Documentation

◆ bufferIndex()

unsigned spark::render::vk::VulkanFrameBuffer::bufferIndex ( ) const
nodiscardoverridevirtualnoexcept

Gets the index of the frame buffer within the IRenderPass.

Returns
The index of the frame buffer within the IRenderPass.

A render pass stores multiple frame buffers, each with their own index. Calling IRenderPass::frameBuffer() with this index on the frame buffers render pass returns the current frame buffer instance (i.e. the same instance, as the one, the index has been requested from).

Implements spark::render::IFrameBuffer.

◆ commandBuffer()

std::shared_ptr< const VulkanCommandBuffer > spark::render::vk::VulkanFrameBuffer::commandBuffer ( unsigned index) const
nodiscardoverridevirtual

Gets the command buffer that records draw commands for the frame buffer.

Parameters
indexThe index of the command buffer to get.
Returns
A std::shared_ptr to the command buffer at index.
Exceptions
spark::base::ArgumentOutOfRangeExceptionif the frame buffer does not have a command buffer at given index.

Implements spark::render::FrameBuffer< VulkanCommandBuffer >.

◆ commandBuffers()

std::vector< std::shared_ptr< const VulkanCommandBuffer > > spark::render::vk::VulkanFrameBuffer::commandBuffers ( ) const
nodiscardoverridevirtualnoexcept

Gets all command buffers of the frame buffer.

Returns
A std::vector containing a std::shared_ptr to each command buffer of the frame buffer.

Implements spark::render::FrameBuffer< VulkanCommandBuffer >.

◆ image()

const IVulkanImage & spark::render::vk::VulkanFrameBuffer::image ( unsigned location) const
nodiscardoverridevirtual

Gets the image storing the output attachment for the render target mapped at given location.

Parameters
locationThe location of the render target to get the image for.
Returns
A std::shared_ptr to the image storing the output attachment for the render target mapped at given location.

Implements spark::render::FrameBuffer< VulkanCommandBuffer >.

◆ images()

std::vector< const IVulkanImage * > spark::render::vk::VulkanFrameBuffer::images ( ) const
nodiscardoverridevirtualnoexcept

Gets all images storing the output attachments for the render targets of the IRenderPass.

Returns
A std::vector containing each image of the frame buffer.

Implements spark::render::FrameBuffer< VulkanCommandBuffer >.

◆ lastFence()

std::size_t & spark::render::vk::VulkanFrameBuffer::lastFence ( ) const
nodiscardnoexcept

Gets a reference of the last fence value for the frame buffer.

Returns
A reference of the last fence value for the frame buffer.

The frame buffer must only be re-used, if this fence is reached in the graphics queue.

◆ resize()

void spark::render::vk::VulkanFrameBuffer::resize ( const spark::math::Vector2< unsigned > & render_area)
overridevirtual

Invalidate and resize the frame buffer with given render_area.

Parameters
render_areaThe new size of the frame buffer.

A frame buffer resize causes all render target resources (i.e. images) to be re-created. This is done by the implementation itself, except for present targets, which require a view of an image created on a ISwapChain. If the frame buffer has a present target, it calls ISwapChain::images() on the parent devices' swap chain.

Warning
There should only be one render pass, that contains present targets, otherwise the images are written by different render passes, which may result in undefined behavior.

Implements spark::render::IFrameBuffer.

◆ semaphore()

const VkSemaphore & spark::render::vk::VulkanFrameBuffer::semaphore ( ) const
nodiscardnoexcept

Gets a reference of the semaphore, that can be used to signal, that the frame buffer is finished.

Returns
A reference of the semaphore, that can be used to signal, that the frame buffer is finished.

◆ size()

spark::math::Vector2< unsigned > spark::render::vk::VulkanFrameBuffer::size ( ) const
nodiscardoverridevirtualnoexcept

Gets the current size of the frame buffer.

Returns
A spark::math::Vector2 containing the current size of the frame buffer.

Implements spark::render::IFrameBuffer.