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

Storage (read-write) image binding point. More...

#include <vppLangIntImages.hpp>

Public Member Functions

 ioImage (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...
 
auto operator= (bind(const ImageViewT &view, VkImageLayout layout))
 Binds an image view to the binding point. More...
 
Pointer< scalar_typeGetPointer (const pointer_coord_type &coords)
 Creates a pointer to specified texel within the image. More...
 
Pointer< scalar_typeGetPointer (const pointer_coord_type &coords, const Int &nSample)
 Creates a pointer to specified texel sample within the image. More...
 

Public Attributes

typedef< implementation_defined > scalar_type
 The type of the atomic variable which can be stored in the image. More...
 
typedef< implementation_defined > pointer_coord_type
 Type of coordinates within the image used to locate texels for making pointers. More...
 

Detailed Description

template<class ImageViewT, unsigned int MEMFLAGS = 0>
class vpp::ioImage< ImageViewT, MEMFLAGS >

Storage (read-write) image binding point.

Place inside your custom PipelineConfig (or ComputePipelineConfig) derived class to define a binding point for storage image, which can be read or written to.

The binding point template is parameterized by the view type. In order to construct the proper type to be used as an argument here, you need to do two things.

The first thing is to define an image format. The recommended way is to make a typedef of vpp::format< ... > template. For example:

typedef vpp::format<
vpp::unorm8_t,
vpp::unorm8_t,
vpp::unorm8_t,
vpp::unorm8_t > MyImageFormat;

Having defined the format type, declare view type as follows:

MyImageFormat, // your defined format
RENDER, // always use RENDER for textures
IMG_TYPE_2D, // number of dimensions
// for storage images, always include STORAGE, other flags are optional
VK_IMAGE_TILING_OPTIMAL, // most of the time use OPTIMAL
VK_SAMPLE_COUNT_1_BIT, // usually textures have 1 sample per pixel
false, // whether mip-mapped
false // whether arrayed
> MyImageAttr;
typedef vpp::Image< MyImageAttr > MyStorageImage;

Now you can use these types as follows:

  • MyStorageImage as runtime image class,
  • MyImageView as runtime image view class, to bind views to binding points,
  • also MyImageView as the parameter to the binding point.
class MyPipelineConfig : public vpp::PipelineConfig
{
// ...
// ...
};

This binding point can be used in the following image functions: ImageLoad(), ImageStore(), ImageSize(), ImageQuerySamples(), ImageQueryLevels().

Constructor & Destructor Documentation

◆ ioImage()

template<class ImageViewT, unsigned int MEMFLAGS = 0>
vpp::ioImage< ImageViewT, MEMFLAGS >::ioImage ( unsigned int  set = 0,
int  binding = -1 
)

Creates the binding point.

Typically you do not need to specify any 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

◆ GetPointer() [1/2]

template<class ImageViewT, unsigned int MEMFLAGS = 0>
Pointer< scalar_type > vpp::ioImage< ImageViewT, MEMFLAGS >::GetPointer ( const pointer_coord_type coords)

Creates a pointer to specified texel within the image.

This method allows to place atomic variables inside an image.

Caution: atomic variables can be quite slow.

◆ GetPointer() [2/2]

template<class ImageViewT, unsigned int MEMFLAGS = 0>
Pointer< scalar_type > vpp::ioImage< ImageViewT, MEMFLAGS >::GetPointer ( const pointer_coord_type coords,
const Int nSample 
)

Creates a pointer to specified texel sample within the image.

This method allows to place atomic variables inside an image. The overload allows to specify sample index, and this way to access individual samples within multisampled images.

Caution: atomic variables can be quite slow.

◆ operator=() [1/2]

template<class ImageViewT, unsigned int MEMFLAGS = 0>
auto vpp::ioImage< ImageViewT, MEMFLAGS >::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 variant assumes the image is in VK_IMAGE_LAYOUT_GENERAL layout.

◆ operator=() [2/2]

template<class ImageViewT, unsigned int MEMFLAGS = 0>
auto vpp::ioImage< ImageViewT, MEMFLAGS >::operator= ( bind(const ImageViewT &view, VkImageLayout layout)  )

Binds an image view to the binding point.

Same as the other assignment operator, but allows to explicitly specify the layout the image is in. For storage images however, Vulkan always requires VK_IMAGE_LAYOUT_GENERAL layout, hence using this overload is deprecated.

Member Data Documentation

◆ pointer_coord_type

template<class ImageViewT, unsigned int MEMFLAGS = 0>
typedef<implementation_defined> vpp::ioImage< ImageViewT, MEMFLAGS >::pointer_coord_type

Type of coordinates within the image used to locate texels for making pointers.

This can be Int, IVec2, IVec3 or depending on number of image dimensions. Image arrays add one extra dimension. Also cube map images add one extra dimension.

◆ scalar_type

template<class ImageViewT, unsigned int MEMFLAGS = 0>
typedef<implementation_defined> vpp::ioImage< ImageViewT, MEMFLAGS >::scalar_type

The type of the atomic variable which can be stored in the image.

Caution: only scalar (single component) formats may support atomic variables. In fact the only formats that are required by Vulkan to support atomic variables are: vpp::format<int> (VK_FORMAT_R32_SINT) and vpp::format<unsigned int> (VK_FORMAT_R32_UINT).


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