NAP
Public Member Functions | List of all members
BufferBindingStructInstance Class Referencefinal

#include <bufferbindinginstance.h>

Public Member Functions

 BufferBindingStructInstance (const std::string &bindingName, const ShaderVariableStructBufferDeclaration &declaration, const BufferBindingChangedCallback &bindingChangedCallback)
 
 BufferBindingStructInstance (const BufferBindingStructInstance &)=delete
 
BufferBindingStructInstance & operator= (const BufferBindingStructInstance &)=delete
 
virtual const ShaderVariableDeclaration & getDeclaration () const override
 
const ShaderVariableStructBufferDeclaration & getStructDeclaration () const
 
const StructBuffer & getBuffer () const
 
StructBuffer & getBuffer ()
 
void setBuffer (StructBuffer &buffer)
 
void setBuffer (const BufferBindingStruct &resource)
 
- Public Member Functions inherited from BufferBindingInstance
 BufferBindingInstance (const std::string &bindingName, const BufferBindingChangedCallback &bindingChangedCallback)
 
virtual ~BufferBindingInstance ()=default
 
bool hasBuffer () const
 
const GPUBuffer & getBuffer () const
 
GPUBuffer & getBuffer ()
 
const std::string & getBindingName () const
 

Additional Inherited Members

- Protected Attributes inherited from BufferBindingInstance
const std::string mBindingName
 
BufferBindingChangedCallback mBindingChangedCallback
 
GPUBuffer * mBuffer = nullptr
 

Description

Instantiated version of nap::BufferBindingStruct.

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 struct array can be addressed as a nap::GPUStructBuffer:

struct Particle
{
vec4 position;
vec4 velocity;
}
layout(std430) buffer ParticleSSBO
{
Particle particles[100000];
} pos_ssbo;
Inheritance diagram for BufferBindingStructInstance:
[legend]
Collaboration diagram for BufferBindingStructInstance:
[legend]

Constructor & Destructor Documentation

◆ BufferBindingStructInstance() [1/2]

BufferBindingStructInstance ( const std::string &  bindingName,
const ShaderVariableStructBufferDeclaration &  declaration,
const BufferBindingChangedCallback &  bindingChangedCallback 
)

◆ BufferBindingStructInstance() [2/2]

Member Function Documentation

◆ getBuffer() [1/2]

StructBuffer& getBuffer ( )
Returns
struct buffer

◆ getBuffer() [2/2]

const StructBuffer& getBuffer ( ) const
Returns
struct buffer

◆ getDeclaration()

virtual const ShaderVariableDeclaration& getDeclaration ( ) const
overridevirtual

Required virtual, needs to be implemented in derived classes

Returns
the declaration associated with this uniform instance

Implements BufferBindingInstance.

◆ getStructDeclaration()

const ShaderVariableStructBufferDeclaration& getStructDeclaration ( ) const
Returns
the uniform declaration, used to create the uniform instance.

◆ operator=()

◆ setBuffer() [1/2]

void setBuffer ( const BufferBindingStruct &  resource)

Updates the buffer from a resource

Parameters
resourceresource to set buffer from.

◆ setBuffer() [2/2]

void setBuffer ( StructBuffer &  buffer)

Binds a new buffer to the uniform instance

Parameters
buffernew buffer to bind