ImFusion SDK 4.3
AtomicCounterBuffer Class Reference

#include <ImFusion/Core/GL/AtomicCounterBuffer.h>

Specialization of Buffer for OpenGL Atomic Counter Objects. More...

+ Inheritance diagram for AtomicCounterBuffer:

Detailed Description

Specialization of Buffer for OpenGL Atomic Counter Objects.

Note
Requires at least OpenGL 4.2 or the ARB_shader_atomic_counters extension.
See also
https://www.khronos.org/opengl/wiki/Atomic_Counter

Public Member Functions

 AtomicCounterBuffer (int numCounters, Usage usageHint=Usage::DynamicDraw)
 Create an OpenGL buffer for holding the specified number of atomic counters.
 
void bindBase (uint32_t index)
 Bind the buffer to the storage block with the given index.
 
void reset (uint32_t value=0)
 Reset all counters in the buffer to the given value.
 
void setData (Utils::Span< uint32_t > data)
 Upload data to the buffer.
 
std::vector< uint32_t > getData ()
 Download all data from the buffer attached to the given target.
 
- Public Member Functions inherited from Buffer
 Buffer (Target target, Usage usage)
 Creates a new Buffer.
 
void bind () const
 Binds the buffer to the target given during construction.
 
Usage usageHint () const
 Returns the buffer usage hint passed to OpenGL during allocation.
 
void setUsageHint (Usage value)
 Sets the buffer usage hint passed to OpenGL during allocation.
 
uint32_t id () const
 Return a handle to the internal OpenGL buffer object.
 

Static Public Member Functions

static void unbind ()
 Unbind any bound atomic counter buffer.
 
- Static Public Member Functions inherited from Buffer
static void unbind (Target target)
 Binds 0 to the specified target.
 

Additional Inherited Members

- Public Types inherited from Buffer
enum class  Target {
  Array = 0x8892 , AtomicCounter = 0x92C0 , CopyRead = 0x8F36 , CopyWrite = 0x8F37 ,
  DrawIndirect = 0x8F3F , ElementArray = 0x8893 , PixelPack = 0x88EB , PixelUnpack = 0x88EC ,
  ShaderStorage = 0x90D2 , Texture = 0x8C2A , TransformFeedback = 0x8C8E , Uniform = 0x8A11
}
 Enumeration of the different OpenGL buffer types. More...
 
enum class  Usage {
  StreamDraw = 0x88E0 , StreamRead = 0x88E1 , StreamCopy = 0x88E2 , StaticDraw = 0x88E4 ,
  StaticRead = 0x88E5 , StaticCopy = 0x88E6 , DynamicDraw = 0x88E8 , DynamicRead = 0x88E9 ,
  DynamicCopy = 0x88EA
}
 Enumeration for usage pattern hints to provide to the GPU when allocating data. More...
 
- Protected Member Functions inherited from Buffer
void allocateBuffer (int64_t numBytes)
 Allocates storage on the GPU for this buffer object.
 
template<typename... Ts>
void setSubData (size_t offset, Utils::Span< Ts >... data)
 Upload data into the buffer starting at the given offset.
 
template<typename... Ts>
size_t getBufferSize (Utils::Span< Ts >... data) const
 Compute the total number of bytes used by all provided data together.
 
- Static Protected Member Functions inherited from Buffer
static void glBufferSubDataImpl (Target target, int64_t offset, int64_t size, const void *data)
 forwards to OpenGL's glBufferSubData().
 
static void glGetBufferSubDataImpl (Target target, int64_t offset, int64_t size, void *data)
 forwards to OpenGL's glGetBufferSubData().
 
- Protected Attributes inherited from Buffer
const Target m_target
 Target binding point for the buffer, will never change for a Buffer instance.
 
Usage m_usageHint
 Buffer usage hint passed to OpenGL unless explicitly specified otherwise.
 
uint32_t m_id = 0
 Internal OpenGL handle to buffer object.
 
int64_t m_bufferSize = 0
 Number of bytes allocated on the GPU.
 

Constructor & Destructor Documentation

◆ AtomicCounterBuffer()

AtomicCounterBuffer ( int numCounters,
Usage usageHint = Usage::DynamicDraw )
explicit

Create an OpenGL buffer for holding the specified number of atomic counters.

All counters will be initialized with 0.

Parameters
numCountersNumber of counter variables to allocate buffer space for
usageHintExpected usage pattern of the buffer
Exceptions
std::runtime_errorif the corresponding OpenGL buffer object could not be created.

Member Function Documentation

◆ setData()

void setData ( Utils::Span< uint32_t > data)

Upload data to the buffer.

Note
The buffer needs to be bound before this method is called. Any previous data will be deleted.
Parameters
dataContiguous data that should be copied to the buffer.

◆ getData()

std::vector< uint32_t > getData ( )

Download all data from the buffer attached to the given target.

Note
The buffer needs to be bound before this method is called.

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close