VPP  0.8
A high-level modern C++ API for Vulkan
vpp::inAttachment< ImageViewT, COUNT > Class Template Reference

Input attachment binding point. More...

#include <vppLangIntImages.hpp>

Public Types

typedef ImageViewT::format_type format_type
 
typedef TImageBinding< ImageViewT > assignment_type
 

Public Member Functions

 inAttachment (const Attachment< format_type > &attachmentNode, unsigned int set=0, int binding=-1)
 Creates the binding point. More...
 
auto operator= (const ImageViewT &view)
 Binds an image view to the binding point. More...
 

Detailed Description

template<class ImageViewT, unsigned int COUNT = 1>
class vpp::inAttachment< ImageViewT, COUNT >

Input attachment binding point.

Input attachment is an intermediate image node in complex render graph. The same node is being declared as input and output attachment. One rendering process writes to it (seeing it as output attachment) while others can read from it. For these reading processes declare the node as input and provide corresponding inAttachment binding point in each pipeline.

You must provide a reference to render graph node in the constructor.

The inAttachment must be bound to an image view just as all other input binding points (to the shader data block and by means of assignment operator).

However, as the node is declared both output and input, in order to satisfy the output side requirements, it must be also be initialized with the image view in the Attachment constructor (or provide the view to FrameBuffer object). This must be a view to the same image.

Note that addInput method will automatically add dependency between processes. This ensures that the second process will read complete data from the input attachment.

Example:

class MyRenderGraph : public vpp::RenderGraph
{
public:
MyRenderGraph (
const MyImageView& intView,
const MyImageView& finalView ) :
m_intermediate ( intView ),
m_final ( finalView )
{
m_process1.addColorOutput (
m_intermediate, 0.0f, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL );
m_process2.addInput (
m_intermediate, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL );
m_process2.addColorOutput ( m_final, 0.0f );
}
public:
vpp::Process m_process1;
vpp::Process m_process2;
};
class MyPipeline1 : public vpp::PipelineConfig
{
public:
MyPipeline1 (
const vpp::Process& hProcess1, const vpp::Device& hDevice,
const Attachment< MyImageFormat >& intAtt ) :
vpp::PipelineConfig ( hProcess1, hDevice ),
m_intermediate ( intAtt ),
m_fragmentShader ( this, & MyPipeline1::fragmentShader )
{}
void fragmentShader ( vpp::FragmentShader* pShader );
{
using namespace vpp;
const Vec4 intValue = ...; // compute intValue
m_intermediate = intValue;
}
private:
vpp::fragmentShader m_fragmentShader;
};
class MyPipeline2 : public vpp::PipelineConfig
{
public:
MyPipeline2 (
const vpp::Process& hProcess2, const vpp::Device& hDevice,
const Attachment< MyImageFormat >& finalAtt ) :
vpp::PipelineConfig ( hProcess2, hDevice ),
m_intermediate ( intAtt ),
m_final ( finalAtt ),
m_fragmentShader ( this, & MyPipeline2::fragmentShader )
{}
void setInputImage (
ShaderDataBlock* pDataBlock,
const MyImageView& intImageView )
{
pDataBlock->update ( (
m_intermediate = intImageView
) );
}
{
using namespace vpp;
const Vec4 inValue = SubpassLoad ( m_intermediate );
const Vec4 outValue = ...; // compute outValue from inValue
m_final = outValue;
}
private:
vpp::fragmentShader m_fragmentShader;
};

This binding point can only be used in SubpassLoad() function.

Constructor & Destructor Documentation

◆ inAttachment()

template<class ImageViewT, unsigned int COUNT = 1>
vpp::inAttachment< ImageViewT, COUNT >::inAttachment ( const Attachment< format_type > &  attachmentNode,
unsigned int  set = 0,
int  binding = -1 
)

Creates the binding point.

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

Typically you do not need to specify remaining arguments for the constructor.

Optionally you can force the set and binding index. This feature may be useful if you need to interface VPP binding point with externally supplied shader (written in GLSL and compiled externally to SPIR-V blob).

Member Function Documentation

◆ operator=()

template<class ImageViewT, unsigned int COUNT = 1>
auto vpp::inAttachment< ImageViewT, COUNT >::operator= ( const ImageViewT &  view)

Binds an image view to the binding point.

This operator returns a value that must be passed to ShaderDataBlock::update() method. You can also make a list of more assignments, joining them with comma operator. The update method accepts such a list.

The binding is stored inside ShaderDataBlock instance, immediately when update is called. You select active ShaderDataBlock in your drawing command sequence by calling ShaderDataBlock::cmdBind(). Thus, actual resource binding (to the pipeline) occurs at command execution time, simultaneously for all bindings in that ShaderDataBlock instance.

This overload assumes the image is in VK_IMAGE_LAYOUT_GENERAL layout.


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