![]() |
VPP
0.8
A high-level modern C++ API for Vulkan
|
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... | |
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:
The GPU-side type (returned by indexing operators) is automatically inferred from the vpp::format type of the buffer binding point.
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.
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.
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.