Cogs.Core
Public Types | Public Member Functions | Public Attributes | List of all members
Cogs::BuffersCommon Struct Reference
Inheritance diagram for Cogs::BuffersCommon:
Cogs::IBuffers Cogs::BuffersD3D11 Cogs::BuffersD3D12 Cogs::BuffersGL20 Cogs::BuffersGLES30 Cogs::BuffersNull Cogs::BuffersVK Cogs::BuffersWebGPU

Public Types

enum struct  BufferType {
  Vertex , Index , Constant , Unclassified ,
  Count
}
 

Public Member Functions

virtual VertexFormatHandle createVertexFormat (const VertexElement *elements, size_t count) override
 
virtual const VertexFormatgetVertexFormat (VertexFormatHandle handle) override
 
virtual VertexArrayObjectHandle loadVertexArrayObject (const EffectHandle effectHandle, const VertexBufferHandle *vertexBufferHandles, const size_t vertexBufferCount, const VertexFormat *const *vertexFormats=nullptr, const uint32_t *vertexBufferStrides=nullptr, const uint32_t *vertexBufferOffsets=nullptr, const IndexBufferHandle indexBufferHandle=IndexBufferHandle::NoHandle, uint32_t indexBufferStride=0) override
 
virtual void releaseVertexArrayObject (VertexArrayObjectHandle) override
 
void recordBufferCreate (BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes)
 
void recordBufferRelease (BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes)
 
void updateResourceStatistics (ResourceStatistics &stats) const
 
- Public Member Functions inherited from Cogs::IBuffers
virtual void annotate (BufferHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual void annotate (VertexBufferHandle handle, const StringView &name)
 Associate a name with an object for use in graphics debugging.
 
virtual VertexBufferHandle loadVertexBuffer (const void *vertexData, const size_t count, const VertexFormat &vertexFormat)=0
 Loads a new vertex buffer and populates it with the given data.
 
virtual VertexBufferHandle loadVertexBuffer (const void *vertexData, const size_t count, VertexFormatHandle vertexFormatHandle)=0
 
virtual void releaseVertexBuffer (VertexBufferHandle vertexBufferHandle)=0
 Release the vertex buffer with the given handle.
 
virtual IndexBufferHandle loadIndexBuffer (const void *indexData, const size_t count, const size_t indexSize)=0
 Loads a new index buffer and populates it with the given indexData.
 
virtual void releaseIndexBuffer (IndexBufferHandle indexBufferHandle)=0
 Releases the index buffer with the given handle.
 
virtual VertexArrayObjectHandle loadVertexArrayObject (const EffectHandle effectHandle, const VertexBufferHandle *vertexBufferHandles, const size_t vertexBufferCount, const VertexFormat *const *vertexFormats=nullptr, const uint32_t *vertexBufferStrides=nullptr, const uint32_t *vertexBufferOffsets=nullptr, const IndexBufferHandle indexBufferHandle=IndexBufferHandle::NoHandle, uint32_t indexBufferStride=0)=0
 Create a vertex array object that encapsulates binding of a set of vertex buffers and an optional index buffer.
 
virtual void releaseVertexArrayObject (VertexArrayObjectHandle vertexArrayObjectHandle)=0
 Releases the vertex array object with the given handle.
 
virtual InputLayoutHandle loadInputLayout (const VertexFormatHandle *vertexFormats, const size_t count, EffectHandle effectHandle)=0
 Loads a new input layout to map vertex flow between vertex buffers with the given vertexFormats to effects using the vertex layout of the given effectHandle.
 
virtual void releaseInputLayout (InputLayoutHandle inputLayoutHandle)=0
 Releases the input layout with the given inputLayoutHandle.
 
virtual BufferHandle loadBuffer (const void *data, const size_t size, Usage::EUsage usage, uint32_t accessMode, uint32_t bindFlags, uint32_t stride=0)=0
 Loads a new buffer using the given data to populate the buffer.
 
virtual VertexFormatHandle createVertexFormat (const VertexElement *elements, size_t count)=0
 
virtual const VertexFormatgetVertexFormat (VertexFormatHandle handle)=0
 
virtual void retrieveSubBuffer (void *data, BufferHandle source, const size_t offset, const size_t size)=0
 Retrieves the contents of a buffer.
 
virtual void releaseBuffer (BufferHandle bufferHandle)=0
 Releases the buffer with the given bufferHandle.
 
virtual void * getNativeHandle (BufferHandle bufferHandle)=0
 Get the device-specific handle (D3D buffer pointer, OpenGL buffer ID etc) associated with the given buffer handle.
 
virtual void releaseResources ()=0
 Releases all allocated buffer resources.
 

Public Attributes

struct {
   std::atomic< size_t >   bytes = 0
 
   std::atomic< uint32_t >   count = 0
 
bufferStats [size_t(BufferType::Count)]
 

Detailed Description

Definition at line 11 of file BuffersCommon.h.

Member Enumeration Documentation

◆ BufferType

enum struct Cogs::BuffersCommon::BufferType
strong

Definition at line 44 of file BuffersCommon.h.

Member Function Documentation

◆ createVertexFormat()

Cogs::VertexFormatHandle Cogs::BuffersCommon::createVertexFormat ( const VertexElement elements,
size_t  count 
)
overridevirtual

Implements Cogs::IBuffers.

Definition at line 28 of file BuffersCommon.cpp.

◆ getVertexFormat()

const Cogs::VertexFormat * Cogs::BuffersCommon::getVertexFormat ( VertexFormatHandle  handle)
overridevirtual

Implements Cogs::IBuffers.

Definition at line 33 of file BuffersCommon.cpp.

◆ loadVertexArrayObject()

Cogs::VertexArrayObjectHandle Cogs::BuffersCommon::loadVertexArrayObject ( const EffectHandle  effectHandle,
const VertexBufferHandle vertexBufferHandles,
const size_t  vertexBufferCount,
const VertexFormat *const *  vertexFormats = nullptr,
const uint32_t *  vertexBufferStrides = nullptr,
const uint32_t *  vertexBufferOffsets = nullptr,
const IndexBufferHandle  indexBufferHandle = IndexBufferHandle::NoHandle,
uint32_t  indexBufferStride = 0 
)
overridevirtual

Logs an unsupported error, override to provide support.

Implements Cogs::IBuffers.

Reimplemented in Cogs::BuffersGLES30.

Definition at line 38 of file BuffersCommon.cpp.

References Cogs::Handle_t< VertexArrayObjectTag >::InvalidHandle.

◆ recordBufferCreate()

void Cogs::BuffersCommon::recordBufferCreate ( BufferHandle  handle,
BindFlags::EBindFlags  bindFlags,
size_t  bytes 
)

Records a new buffer created

Parameters
handleA valid handle to the created buffer.
bindFlagsThe bindflags of the buffer.
bytesThe size of the buffer.

Definition at line 52 of file BuffersCommon.cpp.

Referenced by Cogs::BuffersWebGPU::loadBuffer().

◆ recordBufferRelease()

void Cogs::BuffersCommon::recordBufferRelease ( BufferHandle  handle,
BindFlags::EBindFlags  bindFlags,
size_t  bytes 
)

Records an existing buffer is released.

Parameters
handleA valid handle to the buffer that is released.
bindFlagsThe bindflags of the buffer, must match the ones passed to recordBufferCreate.
bytesThe size of the buffer, must match the size passed to recordBufferCreate.

Definition at line 60 of file BuffersCommon.cpp.

Referenced by Cogs::BuffersWebGPU::releaseBuffer().

◆ releaseVertexArrayObject()

void Cogs::BuffersCommon::releaseVertexArrayObject ( VertexArrayObjectHandle  )
overridevirtual

Logs an unsupported error, override to provide support.

Implements Cogs::IBuffers.

Reimplemented in Cogs::BuffersGLES30.

Definition at line 47 of file BuffersCommon.cpp.

◆ updateResourceStatistics()

void Cogs::BuffersCommon::updateResourceStatistics ( ResourceStatistics stats) const

Populates the buffer-related fields of stats with the currently tracked per-type buffer counts and byte sizes.

Definition at line 68 of file BuffersCommon.cpp.

Member Data Documentation

◆ bytes

std::atomic<size_t> Cogs::BuffersCommon::bytes = 0

Definition at line 52 of file BuffersCommon.h.

◆ count

std::atomic<uint32_t> Cogs::BuffersCommon::count = 0

Definition at line 53 of file BuffersCommon.h.


The documentation for this struct was generated from the following files: