CUGL 4.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cugl::graphics::RenderPass Class Reference

#include <CURenderPass.h>

Public Member Functions

 RenderPass ()
 
 ~RenderPass ()
 
void dispose ()
 
bool init (bool depthStencil=true)
 
bool init (size_t attachments, bool depthStencil=true)
 
bool initWithFormats (const std::vector< TexelFormat > &formats, bool depthStencil=true)
 
bool initWithFormats (const TexelFormat *formats, size_t size, bool depthStencil=true)
 
RenderPassData * getImplementation ()
 
size_t getColorAttachments () const
 
const std::vector< TexelFormat > & getColorFormats () const
 
TexelFormat getColorFormat (size_t pos) const
 
bool hasDepthStencil () const
 
TexelFormat getDepthStencilFormat () const
 
bool isCompatible (const std::shared_ptr< RenderPass > &pass)
 
bool isDefaultCompatible ()
 
const std::vector< Color4f > & getClearColors () const
 
Color4f getClearColor (size_t pos) const
 
void setClearColor (size_t pos, const Color4f &color)
 
float getClearDepth () const
 
void setClearDepth (float value)
 
Uint32 getClearStencil () const
 
void setClearStencil (Uint32 value)
 

Static Public Member Functions

static std::shared_ptr< RenderPassalloc (bool depthStencil=true)
 
static std::shared_ptr< RenderPassalloc (size_t attachments, bool depthStencil=true)
 
static std::shared_ptr< RenderPassallocWithFormats (const std::vector< TexelFormat > &formats, bool depthStencil=true)
 
static std::shared_ptr< RenderPassallocWithFormats (const TexelFormat *formats, size_t size, bool depthStencil=true)
 
static std::shared_ptr< RenderPassgetDisplay ()
 

Detailed Description

This is a class representing a render pass.

A render pass defines the basic structure of a drawing pass. This includes the layout of the color attachment(s), whether there is a depth buffer, and the clear values. Note that this is not the same as FrameBuffer. It does not define the framebuffers. Instead, it provides type information about what kinds of framebuffers are supported by a given render pass.

This class is necesary for Vulkan, and implements a Vulkan render pass behind the scenes. In OpenGL, this class primarily works as a form of type checking to ensure that our choice of target for the GraphicsShader is valid.

Constructor & Destructor Documentation

◆ RenderPass()

cugl::graphics::RenderPass::RenderPass ( )
inline

Creates an uninitialized render pass.

You must initialize the render pass to use it.

◆ ~RenderPass()

cugl::graphics::RenderPass::~RenderPass ( )
inline

Deletes this render pass, disposing all resources.

Member Function Documentation

◆ alloc() [1/2]

static std::shared_ptr< RenderPass > cugl::graphics::RenderPass::alloc ( bool  depthStencil = true)
inlinestatic

Returns a newly allocated render pass with a single COLOR_RGBA attachment.

The color attachment will be assigned to location 0. If depthStencil is true, a depth/stencil attachment will be added to position 1.

Parameters
depthStencilWhether to include a depth/stencil attachment
Returns
a newly allocated render pass with a single COLOR_RGBA attachment.

◆ alloc() [2/2]

static std::shared_ptr< RenderPass > cugl::graphics::RenderPass::alloc ( size_t  attachments,
bool  depthStencil = true 
)
inlinestatic

Returns a newly allocated render pass with multiple COLOR_RGBA attachments.

The attachments will be assigned locations 0..attachments-1. If depthStencil is true, a depth/stencil attachment will be added to position attachments. If attachments is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
attachmentsThe number of color attachments
depthStencilWhether to include a depth/stencil attachment
Returns
a newly allocated render pass with multiple COLOR_RGBA attachments.

◆ allocWithFormats() [1/2]

static std::shared_ptr< RenderPass > cugl::graphics::RenderPass::allocWithFormats ( const std::vector< TexelFormat > &  formats,
bool  depthStencil = true 
)
inlinestatic

Returns a newly allocated pass with color attachments for the given formats.

The attachments will be assigned locations 0..#formats-1, with each attachment assigned the given format. If depthStencil is true, a depth/stencil attachment will be added to position #formats.

If the size of the formats parameter is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
formatsThe list of desired image formats
depthStencilWhether to include a depth/stencil attachment
Returns
a newly allocated pass with color attachments for the given formats.

◆ allocWithFormats() [2/2]

static std::shared_ptr< RenderPass > cugl::graphics::RenderPass::allocWithFormats ( const TexelFormat formats,
size_t  size,
bool  depthStencil = true 
)
inlinestatic

Returns a newly allocated pass with color attachments for the given formats.

The attachments will be assigned locations 0..size-1, with each attachment assigned the given format. If depthStencil is true, a depth/stencil attachment will be added to position size.

If the size of the formats parameter is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
formatsThe list of desired image formats
sizeThe number color attachments
depthStencilWhether to include a depth/stencil attachment
Returns
a newly allocated pass with color attachments for the given formats.

◆ dispose()

void cugl::graphics::RenderPass::dispose ( )

Deletes the render pass and resets all attributes.

You must reinitialize the render pass to use it.

◆ getClearColor()

Color4f cugl::graphics::RenderPass::getClearColor ( size_t  pos) const

Returns the clear color for the given attachment.

This value used to clear the appropriate color attachments when the method FrameBuffer#clear is called.

Parameters
posThe attachment location
Returns
the clear color for the given attachment.

◆ getClearColors()

const std::vector< Color4f > & cugl::graphics::RenderPass::getClearColors ( ) const

Returns the clear color(s) for this render pass.

These values are used to clear the color attachments when the method FrameBuffer#clear is called.

Returns
the clear color(s) for this render pass.

◆ getClearDepth()

float cugl::graphics::RenderPass::getClearDepth ( ) const

Returns the clear value for the depth buffer

This value is used to clear the depth buffer when the method FrameBuffer#clear is called.

Returns
the clear value for the depth buffer

◆ getClearStencil()

Uint32 cugl::graphics::RenderPass::getClearStencil ( ) const

Returns the clear value for the stencil buffer

This value is used to clear the stencil buffer when the method FrameBuffer#clear is called.

Returns
the clear value for the stencil buffer

◆ getColorAttachments()

size_t cugl::graphics::RenderPass::getColorAttachments ( ) const
inline

Returns the number of color attachments for this render pass

This number does not include optional depth/stencil attachment or resolve attachment for MSAA.

◆ getColorFormat()

TexelFormat cugl::graphics::RenderPass::getColorFormat ( size_t  pos) const

Returns the color attachment format at the given position

Parameters
posThe attachment position
Returns
the color attachment format at the given position

◆ getColorFormats()

const std::vector< TexelFormat > & cugl::graphics::RenderPass::getColorFormats ( ) const
inline

Returns the color attachment formats for this render pass

This vector does not include the format for optional depth/stencil attachment or resolve attachment for MSAA.

◆ getDepthStencilFormat()

TexelFormat cugl::graphics::RenderPass::getDepthStencilFormat ( ) const
inline

Returns the format for the depth/stencil attachment to this render pass

This will return VK_FORMAT_UNDEFINED if this render pass does not support a depth/stencil attachment.

Returns
the format for the depth/stencil attachment to this render pass

◆ getDisplay()

static std::shared_ptr< RenderPass > cugl::graphics::RenderPass::getDisplay ( )
static

Returns the render pass for the primary display.

This render pass is guaranteed to have a color attachment at location 0 and a depthStencil attachment at location 1.

Returns
the render pass for the primary display.

◆ getImplementation()

RenderPassData * cugl::graphics::RenderPass::getImplementation ( )
inline

Returns the platform-specific implementation for this render pass

The value returned is an opaque type encapsulating the information for either OpenGL or Vulkan.

Returns
the platform-specific implementation for this render pass

◆ hasDepthStencil()

bool cugl::graphics::RenderPass::hasDepthStencil ( ) const
inline

Returns true if this render pass supports a depth/stencil attachment

Returns
true if this render pass supports a depth/stencil attachment

◆ init() [1/2]

bool cugl::graphics::RenderPass::init ( bool  depthStencil = true)
inline

Initializes this pass with a single COLOR_RGBA attachment.

The color attachment will be assigned to location 0. If depthStencil is true, a depth/stencil attachment will be added to position 1.

If depthStencil is true, this render pass is guaranteed to be compatible with the default render pass.

Parameters
depthStencilWhether to include a depth/stencil attachment
Returns
true if initialization was successful.

◆ init() [2/2]

bool cugl::graphics::RenderPass::init ( size_t  attachments,
bool  depthStencil = true 
)

Initializes this pass with multiple COLOR_RGBA attachments.

The attachments will be assigned locations 0..attachments-1. If depthStencil is true, a depth/stencil attachment will be added to position attachments. If attachments is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
attachmentsThe number of color attachments
depthStencilWhether to include a depth/stencil attachment
Returns
true if initialization was successful.

◆ initWithFormats() [1/2]

bool cugl::graphics::RenderPass::initWithFormats ( const std::vector< TexelFormat > &  formats,
bool  depthStencil = true 
)
inline

Initializes this pass with color attachments for the given formats.

The attachments will be assigned locations 0..#formats-1, with each attachment assigned the given format. If depthStencil is true, a depth/stencil attachment will be added to position #formats.

If the size of the formats parameter is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
formatsThe list of desired image formats
depthStencilWhether to include a depth/stencil attachment
Returns
true if initialization was successful.

◆ initWithFormats() [2/2]

bool cugl::graphics::RenderPass::initWithFormats ( const TexelFormat formats,
size_t  size,
bool  depthStencil = true 
)

Initializes this pass with color attachments for the given formats.

The attachments will be assigned locations 0..size-1, with each attachment assigned the given format. If depthStencil is true, a depth/stencil attachment will be added to position size.

If the size of the formats parameter is larger than the number of possible shader outputs for this platform, this method will fail.

Parameters
formatsThe list of desired image formats
sizeThe number color attachments
depthStencilWhether to include a depth/stencil attachment
Returns
true if initialization was successful.

◆ isCompatible()

bool cugl::graphics::RenderPass::isCompatible ( const std::shared_ptr< RenderPass > &  pass)
inline

Returns true if this render pass is compatible with the given one.

Compatible render passes can be swapped in a GraphicsShader on demand. Two render passes are compatible if they have the same number of color attachments (even though formats may change) and both agree on the presence of a depth buffer.

Parameters
passThe render pass to compare

Returns true if this render pass is compatible with the given one.

◆ isDefaultCompatible()

bool cugl::graphics::RenderPass::isDefaultCompatible ( )
inline

Returns true if this is compatible with the default render pass.

Default renderpasses can be used on the display.

Returns true if this is compatible with the default render pass.

◆ setClearColor()

void cugl::graphics::RenderPass::setClearColor ( size_t  pos,
const Color4f color 
)

Sets the clear color for the given attachment.

This value used to clear the appropriate color attachments when the method FrameBuffer#clear is called. If this value is changed after a render pass has started, it will not be applied until the next render pass.

Parameters
posThe attachment location
colorThe clear color for the given attachment.

◆ setClearDepth()

void cugl::graphics::RenderPass::setClearDepth ( float  value)

Sets the clear value for the depth buffer

This value is used to clear the depth buffer when the method FrameBuffer#clear is called. If this value is changed after a render pass has started, it will not be applied until the next render pass.

Parameters
valueThe clear value for the depth buffer

◆ setClearStencil()

void cugl::graphics::RenderPass::setClearStencil ( Uint32  value)

Sets the clear value for the stencil buffer

This value is used to clear the stencil buffer when the method FrameBuffer#clear is called. If this value is changed after a render pass has started, it will not be applied until the next render pass.

Parameters
valueThe clear value for the stencil buffer

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