Public Member Functions | Protected Attributes | List of all members
BufferBindingInstance Class Referenceabstract

#include <bufferbindinginstance.h>

Public Member Functions

 BufferBindingInstance (const std::string &bindingName, const BufferBindingChangedCallback &bindingChangedCallback)
virtual ~BufferBindingInstance ()=default
virtual const ShaderVariableDeclarationgetDeclaration () const =0
bool hasBuffer () const
const GPUBuffergetBuffer () const
GPUBuffergetBuffer ()
const std::string & getBindingName () const

Protected Attributes

const std::string mBindingName
BufferBindingChangedCallback mBindingChangedCallback
GPUBuffermBuffer = nullptr


Instantiated version of nap::BufferBinding. Every buffer binding 'resource' has an associative 'instance', ie: nap::BufferBindingNumeric -> nap::BufferBindingNumericInstance. An instance can be updated / inspected at run-time and is associated with a declaration.

Buffer bindings, unlike standard uniforms, store a reference to the underlying data as opposed to the data itself. This allows for any compute shader to read from and write to the same data storage. Buffer bindings always refer to a single nap::GPUBuffer, whether this is simple a nap::GPUBufferNumeric or a more complex nap::StructGPUBuffer.

A single vec4 array can be addressed as a nap::VertexBufferVec4:

layout(std430) buffer PositionSSBO //<- binding name
vec4 positions[100000]; //<- buffer declaration name
} pos_ssbo;
layout(std430) buffer NormalSSBO
vec4 normals[100000];
} norm_ssbo;

If you intend to pack some data types together, you can do so with a nap::StructGPUBuffer:

struct Item
vec4 position;
vec4 normal;
layout(std430) buffer ItemSSBO
Item items[100000];
} item_ssbo;

Declaring multiple shader variables outside of a struct is currently not supported:

layout(std430) buffer ExampleComputeBuffer
vec4 positions[100000];
vec4 normals[100000];
Inheritance diagram for BufferBindingInstance:
Collaboration diagram for BufferBindingInstance:

Constructor & Destructor Documentation

◆ BufferBindingInstance()

BufferBindingInstance ( const std::string &  bindingName,
const BufferBindingChangedCallback bindingChangedCallback 

◆ ~BufferBindingInstance()

virtual ~BufferBindingInstance ( )

Member Function Documentation

◆ getBindingName()

const std::string& getBindingName ( ) const
binging name

◆ getBuffer() [1/2]

GPUBuffer& getBuffer ( )
base buffer

◆ getBuffer() [2/2]

const GPUBuffer& getBuffer ( ) const
base buffer

◆ getDeclaration()

virtual const ShaderVariableDeclaration& getDeclaration ( ) const
pure virtual

Required virtual, needs to be implemented in derived classes

the declaration associated with this uniform instance

Implemented in BufferBindingNumericInstance, and BufferBindingStructInstance.

◆ hasBuffer()

bool hasBuffer ( ) const
if the buffer is set

Member Data Documentation

◆ mBindingChangedCallback

BufferBindingChangedCallback mBindingChangedCallback

◆ mBindingName

const std::string mBindingName

◆ mBuffer

GPUBuffer* mBuffer = nullptr