VPP  0.7
A high-level modern C++ API for Vulkan
Public Member Functions | Public Attributes | List of all members
vpp::outAttachment< FormatT > Struct Template Reference

Output attachment binding point. More...

#include <vppLangIntImages.hpp>

Public Member Functions

 outAttachment (const Attachment< FormatT > &attachmentNode)
 Creates the binding point. More...
 
 outAttachment (const Display &attachmentNode)
 Creates the binding point. More...
 
void operator= (const rvalue_type &value)
 Writes output color value to the attachment. More...
 
void assign (const rvalue_type &value, int index=0)
 Writes output color value to the attachment. More...
 

Public Attributes

typedef< implementation_defined > rvalue_type
 The type of the pixel color value. More...
 

Detailed Description

template<class FormatT>
struct vpp::outAttachment< FormatT >

Output attachment binding point.

This is the primary means to generate images in fragment shaders.

Each outAttachment binding point is associated with corresponding node in render graph. You must provide a reference to that node in the constructor. Both Display and Attachment nodes are accepted.

You also do not bind an image view to the output attachment (as with other binding points). Instead, images are bound to Attachment and Display nodes in the render graph. This binding occurs either directly (providing surface or image view reference to the attachment constructor), or indirectly, through explicit FrameBuffer object. The simplest method is to use the constructor.

The template argument should be a typedef to vpp::format template instance. It should be exactly the same format as used for the Attachment node. For display nodes use FormatF32x4 format as defined in the example below (assume RGBA order).

An example:

typedef vpp::format< float, float, float, float > FormatF32x4;
class MyRenderGraph : public vpp::RenderGraph
{
public:
MyRenderGraph ( const vpp::Surface& hSurface ) :
m_display ( hSurface )
{
m_render.addColorOutput ( m_display );
}
public:
vpp::Process m_render;
vpp::Display m_display;
};
class MyRenderPipeline : public vpp::PipelineConfig
{
public:
MyRenderPipeline (
const vpp::Process& pr,
const vpp::Device& dev,
const vpp::Display& outImage ) :
vpp::PipelineConfig ( pr ),
m_outColor ( outImage ),
// ...
m_fragmentShader ( this, & MyRenderPipeline::fFragmentShader )
{}
// ...
void fFragmentShader ( vpp::FragmentShader* pShader )
{
using namespace vpp;
const Vec4 color = ... ; // compute color value
m_outColor = color;
}
private:
// ...
vpp::fragmentShader m_fragmentShader;
};

This binding point can not be used in any image functions. Use assignment operator to write the pixel value to it.

Constructor & Destructor Documentation

◆ outAttachment() [1/2]

template<class FormatT>
vpp::outAttachment< FormatT >::outAttachment ( const Attachment< FormatT > &  attachmentNode)

Creates the binding point.

This constructor applies to regular (memory output) attachments.

Specify the attachment node (from render graph) as the only argument.

◆ outAttachment() [2/2]

template<class FormatT>
vpp::outAttachment< FormatT >::outAttachment ( const Display attachmentNode)

Creates the binding point.

This constructor applies to display attachments.

Specify the display node (from render graph) as the only argument.

Member Function Documentation

◆ assign()

template<class FormatT>
void vpp::outAttachment< FormatT >::assign ( const rvalue_type value,
int  index = 0 
)

Writes output color value to the attachment.

Use this function inside fragment shader code to set resulting color for currently processed pixel. It is equivalent to the assignment operator, however it accepts one additional argument.

The index argument can have value 0 or 1 and specifies which input of the blending unit the color value will be directed to. See chapter 14.3 of the official Vulkan specification for more detail.

◆ operator=()

template<class FormatT>
void vpp::outAttachment< FormatT >::operator= ( const rvalue_type value)

Writes output color value to the attachment.

Use the operator inside fragment shader code to set resulting color for currently processed pixel.

Note that the meaning of the assignment operator is different here than for other binding points.

Member Data Documentation

◆ rvalue_type

template<class FormatT>
typedef<implementation_defined> vpp::outAttachment< FormatT >::rvalue_type

The type of the pixel color value.

This is a typedef indicating the type of the value this attachment expects as output value in the shader. It depends on the image format provided as the template argument. It can be vector or scalar.

The number of vector components corresponds to the format component count. Individual component type can be Float, Double, Int or UInt depending also on the format. Most formats use Float type (e.g. float, vpp::float16_t, vpp::unorm_t, vpp::snorm_t). Formats defined from standard integer or unsigned integer types yield Int or UInt shader types. In case of vectors we have e.g. Vec4 for RGBA formats, Vec3 for RGB, etc. (and respectively IVec4, IVec3, UVec4, UVec3).


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