Mandrill 2025.6.0
Loading...
Searching...
No Matches
Mandrill::Pass Class Reference

Pass class that abstracts the use of dynamic rendering (no render passes) in Vulkan. Passes can either be created with explicit color and depth attachments, or with implicit attachments that are created based on a given extent and format. The pass can be used to begin and end rendering commands, as well as transitioning images for rendering or blitting. More...

#include <Pass.h>

Public Member Functions

MANDRILL_API Pass (ptr< Device > pDevice, std::vector< ptr< Image > > colorAttachments, ptr< Image > pDepthAttachment)
 Create a pass with explicit color and depth attachments.
 
MANDRILL_API Pass (ptr< Device > pDevice, VkExtent2D extent, VkFormat format, uint32_t colorAttachmentCount=1, bool depthAttachment=true, VkSampleCountFlagBits sampleCount=VK_SAMPLE_COUNT_1_BIT)
 Create a pass with implicit attachments, given a certain extent and format. Same format will be used for all color attachments.
 
MANDRILL_API Pass (ptr< Device > pDevice, VkExtent2D extent, std::vector< VkFormat > formats, bool depthAttachment=true, VkSampleCountFlagBits sampleCount=VK_SAMPLE_COUNT_1_BIT)
 Create a pass with implicit attachments, given a certain extent and format. The list of formats will create mathcing color attachments.
 
MANDRILL_API ~Pass ()
 Destructor for pass.
 
MANDRILL_API void transitionForRendering (VkCommandBuffer cmd, ptr< Image > pImage) const
 Transition an image for rendering. Call before begin() in an explicit pass.
 
MANDRILL_API void transitionForBlitting (VkCommandBuffer cmd, ptr< Image > pImage) const
 Transition an image for blitting. Call after end() and before Swapchain::present(..., pImage) in an explicit pass.
 
MANDRILL_API void begin (VkCommandBuffer cmd)
 Begin a pass without clearing the color attachments.
 
MANDRILL_API void begin (VkCommandBuffer cmd, glm::vec4 clearColor, VkAttachmentLoadOp loadOp=VK_ATTACHMENT_LOAD_OP_CLEAR)
 Begin a pass with clearing of the color attachments.
 
MANDRILL_API void begin (VkCommandBuffer cmd, ptr< Image > pImage)
 Begin a pass but override the color attachments with an image. The image is expected to be usable as a color attachment.
 
MANDRILL_API void end (VkCommandBuffer cmd) const
 End a pass.
 
MANDRILL_API void end (VkCommandBuffer cmd, ptr< Image > pImage) const
 End a pass and transition a given image for blitting.
 
MANDRILL_API void update (std::vector< ptr< Image > > colorAttachments, ptr< Image > pDepthAttachment)
 Update an explicit pass with new attachments. Typically call on swapchain recreation.
 
MANDRILL_API void update (VkExtent2D extent)
 Update an implicit pass with a new extent. Typically call on swapchain recreation.
 
MANDRILL_API VkPipelineRenderingCreateInfo getPipelineRenderingCreateInfo () const
 Get the pipeline rendering create info. This is needed for pipeline creation when using dynamic rendering.
 
MANDRILL_API const std::vector< ptr< Image > > & getColorAttachments () const
 Get the list of color attachments of the pass.
 
MANDRILL_API ptr< ImagegetOutput () const
 Get the output image of the pass. If multi-sampling was used, the resolve images is returned, otherwise the first color attachment is assumed to be the output.
 
MANDRILL_API VkExtent2D getExtent () const
 Get the extent of the pass.
 
MANDRILL_API VkSampleCountFlagBits getSampleCount () const
 Get the sample count of the pass. If VK_SAMPLE_COUNT_1_BIT is set, that means that there is no resolve happening in the pass.
 

Detailed Description

Pass class that abstracts the use of dynamic rendering (no render passes) in Vulkan. Passes can either be created with explicit color and depth attachments, or with implicit attachments that are created based on a given extent and format. The pass can be used to begin and end rendering commands, as well as transitioning images for rendering or blitting.

Constructor & Destructor Documentation

◆ Pass() [1/3]

Pass::Pass ( ptr< Device pDevice,
std::vector< ptr< Image > >  colorAttachments,
ptr< Image pDepthAttachment 
)

Create a pass with explicit color and depth attachments.

Parameters
pDeviceDevice to use
colorAttachmentsVector of image to use as color attachments
pDepthAttachmentDepth attachment to use, can be nullptr

◆ Pass() [2/3]

Pass::Pass ( ptr< Device pDevice,
VkExtent2D  extent,
VkFormat  format,
uint32_t  colorAttachmentCount = 1,
bool  depthAttachment = true,
VkSampleCountFlagBits  sampleCount = VK_SAMPLE_COUNT_1_BIT 
)

Create a pass with implicit attachments, given a certain extent and format. Same format will be used for all color attachments.

Parameters
pDeviceDevice to use
extentResolution of attachments
formatFormat of color attachment
colorAttachmentCountNumber of color attachments
depthAttachmentIf depth attachment should be created
sampleCountMultisampling count
Returns

◆ Pass() [3/3]

Pass::Pass ( ptr< Device pDevice,
VkExtent2D  extent,
std::vector< VkFormat >  formats,
bool  depthAttachment = true,
VkSampleCountFlagBits  sampleCount = VK_SAMPLE_COUNT_1_BIT 
)

Create a pass with implicit attachments, given a certain extent and format. The list of formats will create mathcing color attachments.

Parameters
pDeviceDevice to use
extentResolution of attachments
formatsList of formats
depthAttachmentIf depth attachment should be created
sampleCountMultisampling count
Returns

◆ ~Pass()

Pass::~Pass ( )

Destructor for pass.

Returns

Member Function Documentation

◆ begin() [1/3]

void Pass::begin ( VkCommandBuffer  cmd)

Begin a pass without clearing the color attachments.

Parameters
cmdCommand buffer
Returns

◆ begin() [2/3]

void Pass::begin ( VkCommandBuffer  cmd,
glm::vec4  clearColor,
VkAttachmentLoadOp  loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR 
)

Begin a pass with clearing of the color attachments.

Parameters
cmdCommand buffer
clearColorClearing color
loadOpLoad operation for color attachments
Returns

◆ begin() [3/3]

void Pass::begin ( VkCommandBuffer  cmd,
ptr< Image pImage 
)

Begin a pass but override the color attachments with an image. The image is expected to be usable as a color attachment.

Parameters
cmdCommand buffer
pImageOverriding image
Returns

◆ end() [1/2]

void Pass::end ( VkCommandBuffer  cmd) const

End a pass.

Parameters
cmdCommand buffer
Returns

◆ end() [2/2]

void Pass::end ( VkCommandBuffer  cmd,
ptr< Image pImage 
) const

End a pass and transition a given image for blitting.

Parameters
cmdCommand buffer
pImageImage to transition
Returns

◆ getColorAttachments()

MANDRILL_API const std::vector< ptr< Image > > & Mandrill::Pass::getColorAttachments ( ) const
inline

Get the list of color attachments of the pass.

Returns
List of images

◆ getExtent()

MANDRILL_API VkExtent2D Mandrill::Pass::getExtent ( ) const
inline

Get the extent of the pass.

Returns
Resolution of the attachments

◆ getOutput()

MANDRILL_API ptr< Image > Mandrill::Pass::getOutput ( ) const
inline

Get the output image of the pass. If multi-sampling was used, the resolve images is returned, otherwise the first color attachment is assumed to be the output.

Returns
Pass output image

◆ getPipelineRenderingCreateInfo()

MANDRILL_API VkPipelineRenderingCreateInfo Mandrill::Pass::getPipelineRenderingCreateInfo ( ) const
inline

Get the pipeline rendering create info. This is needed for pipeline creation when using dynamic rendering.

Returns
Pipeline rendering create info

◆ getSampleCount()

MANDRILL_API VkSampleCountFlagBits Mandrill::Pass::getSampleCount ( ) const
inline

Get the sample count of the pass. If VK_SAMPLE_COUNT_1_BIT is set, that means that there is no resolve happening in the pass.

Returns
Sample count

◆ transitionForBlitting()

void Pass::transitionForBlitting ( VkCommandBuffer  cmd,
ptr< Image pImage 
) const

Transition an image for blitting. Call after end() and before Swapchain::present(..., pImage) in an explicit pass.

Parameters
cmdCommand buffer
pImageImage to transition
Returns

◆ transitionForRendering()

void Pass::transitionForRendering ( VkCommandBuffer  cmd,
ptr< Image pImage 
) const

Transition an image for rendering. Call before begin() in an explicit pass.

Parameters
cmdCommand buffer
pImageImage to transition
Returns

◆ update() [1/2]

void Pass::update ( std::vector< ptr< Image > >  colorAttachments,
ptr< Image pDepthAttachment 
)

Update an explicit pass with new attachments. Typically call on swapchain recreation.

Parameters
colorAttachmentsVector with new color attachments
pDepthAttachmentNew depth attachment, can be nullptr
Returns

◆ update() [2/2]

void Pass::update ( VkExtent2D  extent)

Update an implicit pass with a new extent. Typically call on swapchain recreation.

Parameters
extentNew attachment extent
Returns

The documentation for this class was generated from the following files: