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

Vulkan implementation of IRenderPass. More...

#include <VulkanRenderPass.h>

Inheritance diagram for spark::render::vk::VulkanRenderPass:
spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping > spark::render::Resource< VkRenderPass > spark::render::StateResource spark::render::IRenderPass spark::render::InputAttachmentMappingSource< VulkanFrameBuffer > spark::render::IResource< VkRenderPass > spark::render::IStateResource spark::render::IStateResource

Classes

struct  Impl
 

Public Member Functions

 VulkanRenderPass (const VulkanDevice &device, std::span< RenderTarget > render_targets, unsigned command_buffers=1, MultiSamplingLevel samples=MultiSamplingLevel::X1, std::span< VulkanInputAttachmentMapping > input_attachments={})
 Initializes a VulkanRenderPass.
 
 VulkanRenderPass (const VulkanDevice &device, const std::string &name, std::span< RenderTarget > render_targets, unsigned command_buffers=1, MultiSamplingLevel samples=MultiSamplingLevel::X1, std::span< VulkanInputAttachmentMapping > input_attachments={})
 Initializes a VulkanRenderPass.
 
 VulkanRenderPass (const VulkanRenderPass &other)=delete
 
 VulkanRenderPass (VulkanRenderPass &&other) noexcept=delete
 
VulkanRenderPassoperator= (const VulkanRenderPass &other)=delete
 
VulkanRenderPassoperator= (VulkanRenderPass &&other) noexcept=delete
 
const VulkanDevicedevice () const noexcept
 Gets the parent VulkanDevice that provides the queue.
 
void begin (unsigned buffer) override
 Begins the render pass.
 
void end () const override
 Ends the render pass.
 
const VulkanFrameBufferactiveFrameBuffer () const override
 Gets the active frame buffer from the render pass.
 
const VulkanFrameBufferframeBuffer (unsigned buffer) const override
 Gets the frame buffer with the index provided in buffer.
 
std::vector< const VulkanFrameBuffer * > frameBuffers () const noexcept override
 Gets all frame buffers owned by the render pass.
 
void resizeFrameBuffers (const math::Vector2< unsigned > &new_render_area) override
 Resets the frame buffers owned by the render pass.
 
std::vector< const VulkanRenderPipeline * > pipelines () const noexcept override
 Gets all render pipelines owned by the render pass.
 
const RenderTargetrenderTarget (unsigned location) const override
 Gets the render target at the specified location.
 
std::span< const RenderTargetrenderTargets () const noexcept override
 Gets all render targets the render pass is rendering to.
 
bool hasPresentRenderTarget () const noexcept override
 Checks if one of the render targets is used for presentation in a ISwapChain.
 
MultiSamplingLevel multiSamplingLevel () const noexcept override
 Gets the number of samples the render targets are sampled with.
 
std::span< const VulkanInputAttachmentMappinginputAttachments () const noexcept override
 Gets the input attachments the render pass is consuming.
 
void updateAttachments (const VulkanDescriptorSet &descriptor_set) const override
 Resolves the input attachments mapped to the render pass and updates them on the descriptor set provided with descriptor_set.
 
- Public Member Functions inherited from spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >
virtual void updateAttachments (const descriptor_set_type &descriptor_set) const=0
 Resolves the input attachments mapped to the render pass and updates them on the descriptor set provided with descriptor_set.
 
- Public Member Functions inherited from spark::render::StateResource
 StateResource (std::string_view name) noexcept
 Initializes a new StateResource instance.
 
 StateResource (const StateResource &other)=delete
 
 StateResource (StateResource &&other) noexcept
 
StateResourceoperator= (const StateResource &other)=delete
 
StateResourceoperator= (StateResource &&other) noexcept
 
const std::string & name () const noexcept final
 Gets the name of the state resource.
 
- Public Member Functions inherited from spark::render::IRenderPass
virtual void begin (unsigned int buffer)=0
 Begins the render pass.
 
const IFrameBufferactiveFrameBuffer () const
 Gets the active frame buffer from the render pass.
 
std::vector< const IFrameBuffer * > frameBuffers () const noexcept
 Gets all frame buffers owned by the render pass.
 
virtual void resizeFrameBuffers (const math::Vector2< unsigned int > &new_render_area)=0
 Resets the frame buffers owned by the render pass.
 
std::vector< const IRenderPipeline * > pipelines () const noexcept
 Gets all render pipelines owned by the render pass.
 
virtual const RenderTargetrenderTarget (unsigned int location) const =0
 Gets the render target at the specified location.
 
void updateAttachments (const IDescriptorSet &descriptor_set) const
 Resolves the input attachments mapped to the render pass and updates them on the descriptor set provided with descriptor_set.
 
- Public Member Functions inherited from spark::render::Resource< VkRenderPass >
 Resource (VkRenderPass 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 VkRenderPass & handle () const final
 Gets the managed resource handle.
 

Additional Inherited Members

- Public Types inherited from spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >
using frame_buffer_type
 
using render_pipeline_type
 
using input_attachment_mapping_type
 
using pipeline_layout_type
 
using descriptor_set_layout_type
 
using descriptor_set_type
 
- Public Types inherited from spark::render::InputAttachmentMappingSource< VulkanFrameBuffer >
using FrameBuffer
 
- Public Types inherited from spark::render::IResource< VkRenderPass >
using handle_type
 
- Protected Member Functions inherited from spark::render::StateResource
 StateResource () noexcept
 Initializes a new StateResource instance with an empty name.
 
std::string & name () noexcept
 Gets the name of the state resource.
 
- Protected Member Functions inherited from spark::render::Resource< VkRenderPass >
VkRenderPass & handle () final
 Gets the managed resource handle.
 

Detailed Description

Vulkan implementation of IRenderPass.

Constructor & Destructor Documentation

◆ VulkanRenderPass() [1/2]

spark::render::vk::VulkanRenderPass::VulkanRenderPass ( const VulkanDevice & device,
std::span< RenderTarget > render_targets,
unsigned command_buffers = 1,
MultiSamplingLevel samples = MultiSamplingLevel::X1,
std::span< VulkanInputAttachmentMapping > input_attachments = {} )
explicit

Initializes a VulkanRenderPass.

Parameters
deviceThe parent VulkanDevice instance.
render_targetsThe render targets that are output by the IRenderPass.
command_buffersThe number of ICommandBuffer in each IFrameBuffer.
samplesThe number of samples to use for multi sampling.
input_attachmentsThe input attachments that are read in the IRenderPass.

◆ VulkanRenderPass() [2/2]

spark::render::vk::VulkanRenderPass::VulkanRenderPass ( const VulkanDevice & device,
const std::string & name,
std::span< RenderTarget > render_targets,
unsigned command_buffers = 1,
MultiSamplingLevel samples = MultiSamplingLevel::X1,
std::span< VulkanInputAttachmentMapping > input_attachments = {} )
explicit

Initializes a VulkanRenderPass.

Parameters
deviceThe parent VulkanDevice instance.
nameThe name of the VulkanRenderPass state resource.
render_targetsThe render targets that are output by the IRenderPass.
command_buffersThe number of ICommandBuffer in each IFrameBuffer.
samplesThe number of samples to use for multi sampling.
input_attachmentsThe input attachments that are read in the IRenderPass.

Member Function Documentation

◆ activeFrameBuffer()

const VulkanFrameBuffer & spark::render::vk::VulkanRenderPass::activeFrameBuffer ( ) const
nodiscardoverridevirtual

Gets the active frame buffer from the render pass.

Returns
A IFrameBuffer used as back buffer by the render pass.
Exceptions
k2::base::RenderPassNotStartedExceptionif the render pass has not been started.

Implements spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >.

◆ begin()

void spark::render::vk::VulkanRenderPass::begin ( unsigned buffer)
override

Begins the render pass.

Parameters
bufferThe index of the back buffer to render to. Typically, the values returned by ISwapChain::swapBackBuffer() is used.
Exceptions
base::RenderPassAlreadyStartedExceptionif the render pass has already been started.
base::ArgumentOutOfRangeExceptionif buffer is out of range.

◆ device()

const VulkanDevice & spark::render::vk::VulkanRenderPass::device ( ) const
nodiscardnoexcept

Gets the parent VulkanDevice that provides the queue.

Returns
The parent VulkanDevice that provides the queue.

◆ end()

void spark::render::vk::VulkanRenderPass::end ( ) const
overridevirtual

Ends the render pass.

Note
If the frame buffer has a present render target, this causes the render pass to synchronize with the swap chain and issue a present command.
Exceptions
base::RenderPassNotStartedExceptionif the render pass has not been started.

Implements spark::render::IRenderPass.

◆ frameBuffer()

const VulkanFrameBuffer & spark::render::vk::VulkanRenderPass::frameBuffer ( unsigned buffer) const
nodiscardoverridevirtual

Gets the frame buffer with the index provided in buffer.

Returns
The IFrameBuffer with the index provided in buffer.
Exceptions
base::ArgumentOutOfRangeExceptionif buffer does not maps to a valid frame buffer.

Implements spark::render::InputAttachmentMappingSource< VulkanFrameBuffer >.

◆ frameBuffers()

std::vector< const VulkanFrameBuffer * > spark::render::vk::VulkanRenderPass::frameBuffers ( ) const
nodiscardoverridevirtualnoexcept

Gets all frame buffers owned by the render pass.

Returns
A std::vector of IFrameBuffer owned by the render pass.

Implements spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >.

◆ hasPresentRenderTarget()

bool spark::render::vk::VulkanRenderPass::hasPresentRenderTarget ( ) const
nodiscardoverridevirtualnoexcept

Checks if one of the render targets is used for presentation in a ISwapChain.

Returns
true if one of the render targets is used for presentation in a ISwapChain, false otherwise.

Implements spark::render::IRenderPass.

◆ inputAttachments()

std::span< const VulkanInputAttachmentMapping > spark::render::vk::VulkanRenderPass::inputAttachments ( ) const
nodiscardoverridevirtualnoexcept

Gets the input attachments the render pass is consuming.

Returns
A std::span of IInputAttachmentMapping the render pass is consuming.

Implements spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >.

◆ multiSamplingLevel()

MultiSamplingLevel spark::render::vk::VulkanRenderPass::multiSamplingLevel ( ) const
nodiscardoverridevirtualnoexcept

Gets the number of samples the render targets are sampled with.

Returns
A MultiSamplingLevel value representing the number of samples the render targets are sampled with.

Implements spark::render::IRenderPass.

◆ pipelines()

std::vector< const VulkanRenderPipeline * > spark::render::vk::VulkanRenderPass::pipelines ( ) const
nodiscardoverridevirtualnoexcept

Gets all render pipelines owned by the render pass.

Returns
A std::vector of IRenderPipeline owned by the render pass.

Implements spark::render::RenderPass< VulkanRenderPipeline, VulkanFrameBuffer, VulkanInputAttachmentMapping >.

◆ renderTarget()

const RenderTarget & spark::render::vk::VulkanRenderPass::renderTarget ( unsigned location) const
nodiscardoverride

Gets the render target at the specified location.

Parameters
locationThe location of the render target to get.
Returns
The RenderTarget at the specified location.

◆ renderTargets()

std::span< const RenderTarget > spark::render::vk::VulkanRenderPass::renderTargets ( ) const
nodiscardoverridevirtualnoexcept

Gets all render targets the render pass is rendering to.

Returns
A std::span of RenderTarget the render pass is rendering to.

Implements spark::render::IRenderPass.

◆ resizeFrameBuffers()

void spark::render::vk::VulkanRenderPass::resizeFrameBuffers ( const math::Vector2< unsigned > & new_render_area)
override

Resets the frame buffers owned by the render pass.

Parameters
new_render_areaThe size of the render area the frame buffers should be resized to.

◆ updateAttachments()

void spark::render::vk::VulkanRenderPass::updateAttachments ( const VulkanDescriptorSet & descriptor_set) const
override

Resolves the input attachments mapped to the render pass and updates them on the descriptor set provided with descriptor_set.

Parameters
descriptor_setThe IDescriptorSet to update the input attachments on.