VPP  0.8
A high-level modern C++ API for Vulkan
vpp::TexelArray< BufferT > Struct Template Reference

Provides shader code access to a binding point for a buffer holding array of formatted texels. These data objects are either simple scalars or vectors, defined by vpp::format object. More...

#include <vppLangIntImages.hpp>

Public Member Functions

 TexelArray (const BufferT &buf)
 Constructs accessor for given texel buffer binding point. More...
 
auto operator[] (const Int &index) const
 Provides read and write access to specified item. More...
 
Int Size () const
 Returns GPU-side value equal to the size of the array. More...
 

Detailed Description

template<class BufferT>
struct vpp::TexelArray< BufferT >

Provides shader code access to a binding point for a buffer holding array of formatted texels. These data objects are either simple scalars or vectors, defined by vpp::format object.

Place TexelArray inside your shader code to access the data in uniform or storage texel buffer. This is a simpler alternative to use image access functions directly.

Texel buffers are a hybrid of images and buffers. They are one-dimensional, can hold only arrays of simple data and are accessed via image functions (e.g. ImageStore or TexelFetch). VPP provides the TexelArray accessor to allow using these buffers like regular buffers, with indexing operator instead of function calls.

The template argument should be the decltype of accessed binding point. It accepts the following binding points: inTextureBuffer, ioImageBuffer. Also specify the binding point in the constructor of TexelArray. The binding point should be an object inside PipelineConfig subclass and the shader should be a method in the same subclass - or some code called from it.

Texel buffers are somewhat similar to uniform buffers accessed via UniformSimpleArray. There are however the following differences:

  • Texel buffers are more limited regarding the item type. They require a type covered by vpp::format. For that reason, matrices are not supported directly (although you can encode them over ranges of vectors).
  • Texel buffers have less size restrictions. Usually the hardware limits maximum size of both uniform buffers and texel buffers, however limits for the latter are much higher.
  • Texel buffers allow some tight data packaging schemes (according to vpp::format used). Caution: you must check whether the hardware actually supports such a format. Use PhysicalDevice::supportsFormat() for that, with PhysicalDevice::BUFFER usage argument.

The GPU-side type (returned by indexing operators) is automatically inferred from the vpp::format type of the buffer binding point.

Constructor & Destructor Documentation

◆ TexelArray()

template<class BufferT>
vpp::TexelArray< BufferT >::TexelArray ( const BufferT &  buf)

Constructs accessor for given texel buffer binding point.

The constructor of the accessor does not create ny objects in the SPIR-V code. This is a VPP level wrapper over 1D image functions which operate on the buffer.

As the argument, provide reference to the binding point.

Member Function Documentation

◆ operator[]()

template<class BufferT>
auto vpp::TexelArray< BufferT >::operator[] ( const Int index) const

Provides read and write access to specified item.

Returns a type inferred from the host data type, allowing to read or write the array (in case of uniform texel buffers, only read).

Uniform buffers are read-only. It is an error to attempt to write them. Storage texel buffers support both reading and writing.

◆ Size()

template<class BufferT>
Int vpp::TexelArray< BufferT >::Size ( ) const

Returns GPU-side value equal to the size of the array.

The size determined by this function is dynamic. It is equal to actual texel buffer size.


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