Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
ComputeBuffer Class Referenceabstract

Buffer that can be read from / written to by a compute shader. More...

#include <ComputeBuffer.h>

Inheritance diagram for ComputeBuffer:
RefTarget< ComputeBuffer > NonCopyable

Public Types

enum class  EType {
  UploadBuffer , ReadbackBuffer , ConstantBuffer , Buffer ,
  RWBuffer
}
 Type of buffer. More...
 
enum class  EMode { Read , Write }
 Mode in which the buffer is accessed. More...
 

Public Member Functions

 ComputeBuffer (EType inType, uint64 inSize, uint inStride)
 Constructor / Destructor.
 
virtual ~ComputeBuffer ()
 
EType GetType () const
 Properties.
 
uint64 GetSize () const
 
uint GetStride () const
 
void * Map (EMode inMode)
 Map / unmap buffer (get pointer to data).
 
template<typename T >
T * Map (EMode inMode)
 
void Unmap ()
 
virtual ComputeBufferResult CreateReadBackBuffer () const =0
 
- Public Member Functions inherited from RefTarget< ComputeBuffer >
 RefTarget ()=default
 Constructor.
 
 RefTarget (const RefTarget &)
 
 ~RefTarget ()
 assert no one is referencing us
 
void SetEmbedded () const
 
RefTargetoperator= (const RefTarget &)
 Assignment operator.
 
uint32 GetRefCount () const
 Get current refcount of this object.
 
void AddRef () const
 Add or release a reference to this object.
 
void Release () const
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Protected Member Functions

virtual void * MapInternal (EMode inMode)=0
 
virtual void UnmapInternal ()=0
 

Protected Attributes

EType mType
 
uint64 mSize
 
uint mStride
 
- Protected Attributes inherited from RefTarget< ComputeBuffer >
atomic< uint32mRefCount
 Current reference count.
 

Additional Inherited Members

- Static Public Member Functions inherited from RefTarget< ComputeBuffer >
static int sInternalGetRefCountOffset ()
 INTERNAL HELPER FUNCTION USED BY SERIALIZATION.
 
- Static Protected Attributes inherited from RefTarget< ComputeBuffer >
static constexpr uint32 cEmbedded
 A large value that gets added to the refcount to mark the object as embedded.
 

Detailed Description

Buffer that can be read from / written to by a compute shader.

Member Enumeration Documentation

◆ EMode

enum class ComputeBuffer::EMode
strong

Mode in which the buffer is accessed.

Enumerator
Read 

Read only access to the buffer.

Write 

Write only access to the buffer (this will discard all previous data in the buffer)

◆ EType

enum class ComputeBuffer::EType
strong

Type of buffer.

Enumerator
UploadBuffer 

Buffer that can be written on the CPU and then uploaded to the GPU.

ReadbackBuffer 

Buffer to be sent from the GPU to the CPU, used to read back data.

ConstantBuffer 

A smallish buffer that is used to pass constants to a shader.

Buffer 

Buffer that can be read from by a shader. Must be initialized with data at construction time and is read only thereafter.

RWBuffer 

Buffer that can be read from and written to by a shader.

Constructor & Destructor Documentation

◆ ComputeBuffer()

ComputeBuffer::ComputeBuffer ( EType inType,
uint64 inSize,
uint inStride )
inline

Constructor / Destructor.

◆ ~ComputeBuffer()

virtual ComputeBuffer::~ComputeBuffer ( )
inlinevirtual

Member Function Documentation

◆ CreateReadBackBuffer()

virtual ComputeBufferResult ComputeBuffer::CreateReadBackBuffer ( ) const
pure virtual

Create a readback buffer of the same size and stride that can be used to read the data stored in this buffer on CPU. Note that this could also be implemented as 'return this' in case the underlying implementation allows locking GPU data on CPU directly.

◆ GetSize()

uint64 ComputeBuffer::GetSize ( ) const
inline

◆ GetStride()

uint ComputeBuffer::GetStride ( ) const
inline

◆ GetType()

EType ComputeBuffer::GetType ( ) const
inline

Properties.

◆ Map() [1/2]

void * ComputeBuffer::Map ( EMode inMode)
inline

Map / unmap buffer (get pointer to data).

◆ Map() [2/2]

template<typename T >
T * ComputeBuffer::Map ( EMode inMode)
inline

◆ MapInternal()

virtual void * ComputeBuffer::MapInternal ( EMode inMode)
protectedpure virtual

◆ Unmap()

void ComputeBuffer::Unmap ( )
inline

◆ UnmapInternal()

virtual void ComputeBuffer::UnmapInternal ( )
protectedpure virtual

Member Data Documentation

◆ mSize

uint64 ComputeBuffer::mSize
protected

◆ mStride

uint ComputeBuffer::mStride
protected

◆ mType

EType ComputeBuffer::mType
protected

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