Cogs.Core
Public Member Functions | List of all members
Cogs::Core::BufferResource Struct Reference

Buffer resource. More...

#include <Buffer.h>

Inheritance diagram for Cogs::Core::BufferResource:
Cogs::Core::ResourceBase

Public Member Functions

 BufferResource ()
 Construct an empty buffer resource.
 
void set (size_t offset, size_t size, const uint8_t *data)
 
void invalidate (size_t offset, size_t size)
 Invalidates buffer contents, signaling data should be updated/transfered to GPU.
 
size_t size () const
 Size of the buffer in bytes.
 
bool empty () const
 If the buffer is empty. Note that an empty buffer may still have reserved storage.
 
void resize (size_t size)
 Resize the buffer to accomodate the given number of bytes.
 
void reset (size_t size, Memory::Allocator *allocator)
 Reset the buffer, resizing to size bytes using the given allocator.
 
void * data ()
 Get a pointer to the buffer data.
 
const void * data () const
 Get a pointer to the buffer data.
 
void * map (uint32_t flags)
 Map the buffer data backing storage, returning a writable pointer.
 
void unmap ()
 Unmap the buffer, signaling writes to mapped buffer memory are done.
 
void clear ()
 Clear the buffer contents. Note that the buffer may retain reserved storage after clearing.
 
void setBindFlags (uint16_t flags)
 Set the bind flags for the buffer determining how the buffer data may be uploaded to GPU.
 
uint16_t getBufferFlags () const
 Get the buffer flags.
 
uint16_t getBindFlags () const
 Get the bind flags.
 
bool isVertexBuffer () const
 Gets if the buffer data is usable as a vertex data.
 
bool isIndexBuffer () const
 Gets if the buffer data is usable as index buffer data.
 
- Public Member Functions inherited from Cogs::Core::ResourceBase
 ResourceBase ()=default
 Constructs a new resource base.
 
 ResourceBase (const ResourceBase &other)=delete
 Disable trivial copies of resources.
 
ResourceBaseoperator= (const ResourceBase &other)=delete
 Disable copy-assignment of resources.
 
 ResourceBase (ResourceBase &&other)
 Move constructs a resource base from other.
 
ResourceBaseoperator= (ResourceBase &&other)
 Move assign the resource from the given ResourceBase other.
 
 ~ResourceBase ()
 Destructs the resource.
 
void setInitialized ()
 
void setChanged ()
 
bool hasChanged () const
 
void setLoading ()
 
void setLoaded ()
 
void setFailedLoad ()
 
void setActive ()
 
void setResident ()
 
void setProxy ()
 
void setKeepStorage ()
 
bool isInitialized () const
 
bool isLoaded () const
 
bool isActive () const
 
bool isResident () const
 
bool isDependency () const
 
bool isDeleted () const
 
bool isOrphaned () const
 
bool isProxy () const
 
bool hasFailedLoad () const
 
bool hasFailedActivation () const
 
bool keepStorage () const
 
void setType (ResourceTypes type)
 Set the type enumeration of the resource.
 
ResourceTypes getType () const
 Gets the type enumeration of the resource.
 
void setId (ResourceId resourceId)
 Set the resource id of the resource.
 
ResourceId getId () const
 Get the resource id of this instance.
 
void setFlag (ResourceFlags flags)
 Set the given resource flag.
 
void setFlags (ResourceFlags flags)
 
void unsetFlag (ResourceFlags flag)
 Unset the given flag.
 
bool isSet (ResourceFlags flag) const
 Check if the given flag is currently set.
 
ResourceFlags getFlags () const
 Get the current flags of the resource.
 
void attachResource (RenderResource *attachment)
 Attach the given GPU resource to the resource.
 
bool hasAttachedResource () const
 Check if the resource has an attachment.
 
RenderResourcegetAttachedResource () const
 Get the attached resource.
 
void setOwner (IResourceManager *owner)
 Sets the owner of this resource instance.
 
IResourceManagergetOwner () const
 
void setName (const StringView &name)
 Set the user friendly name of the resource.
 
StringView getName () const
 Get the name of the resource.
 
void setSource (const StringView &source)
 
StringView getSource () const
 
void increment ()
 Increments the reference count of the resource.
 
void decrement ()
 Decrement the reference count of the resource.
 
uint32_t referenceCount () const
 Get the current reference count.
 
void incrementGeneration ()
 Increment the generation count.
 
uint32_t getGeneration () const
 Get the generation count.
 
void setSlot (uint32_t slot)
 Sets the slot at which the resource is internally tracked.
 
uint32_t getSlot () const
 Gets the slot where the resource is tracked internally.
 

Additional Inherited Members

- Static Public Attributes inherited from Cogs::Core::ResourceBase
static const uint32_t NoAttachment = 0xFFFFFFFF
 Constant used to signal no attachment.
 

Detailed Description

Buffer resource.

Provides storage for untyped data, transferable to GPU/renderer.

Definition at line 49 of file Buffer.h.

Constructor & Destructor Documentation

◆ BufferResource()

Cogs::Core::BufferResource::BufferResource ( )
inline

Construct an empty buffer resource.

Definition at line 52 of file Buffer.h.

Member Function Documentation

◆ clear()

void Cogs::Core::BufferResource::clear ( )
inline

Clear the buffer contents. Note that the buffer may retain reserved storage after clearing.

Definition at line 86 of file Buffer.h.

References Cogs::setChanged().

◆ data() [1/2]

void * Cogs::Core::BufferResource::data ( )
inline

Get a pointer to the buffer data.

Definition at line 74 of file Buffer.h.

Referenced by Cogs::Core::BufferView< T >::data(), and set().

◆ data() [2/2]

const void * Cogs::Core::BufferResource::data ( ) const
inline

Get a pointer to the buffer data.

Definition at line 77 of file Buffer.h.

◆ empty()

bool Cogs::Core::BufferResource::empty ( ) const
inline

If the buffer is empty. Note that an empty buffer may still have reserved storage.

Definition at line 65 of file Buffer.h.

Referenced by Cogs::Core::BufferView< T >::empty().

◆ getBindFlags()

uint16_t Cogs::Core::BufferResource::getBindFlags ( ) const
inline

Get the bind flags.

Definition at line 95 of file Buffer.h.

◆ getBufferFlags()

uint16_t Cogs::Core::BufferResource::getBufferFlags ( ) const
inline

Get the buffer flags.

Definition at line 92 of file Buffer.h.

◆ invalidate()

void Cogs::Core::BufferResource::invalidate ( size_t  offset,
size_t  size 
)

Invalidates buffer contents, signaling data should be updated/transfered to GPU.

Definition at line 12 of file Buffer.cpp.

References Cogs::setChanged().

Referenced by set().

◆ isIndexBuffer()

bool Cogs::Core::BufferResource::isIndexBuffer ( ) const
inline

Gets if the buffer data is usable as index buffer data.

Definition at line 101 of file Buffer.h.

◆ isVertexBuffer()

bool Cogs::Core::BufferResource::isVertexBuffer ( ) const
inline

Gets if the buffer data is usable as a vertex data.

Definition at line 98 of file Buffer.h.

◆ map()

void * Cogs::Core::BufferResource::map ( uint32_t  flags)

Map the buffer data backing storage, returning a writable pointer.

Definition at line 35 of file Buffer.cpp.

References Cogs::Core::BufferFlags::Mapped.

Referenced by Cogs::Core::BufferView< T >::map().

◆ reset()

void Cogs::Core::BufferResource::reset ( size_t  size,
Memory::Allocator allocator 
)

Reset the buffer, resizing to size bytes using the given allocator.

Definition at line 26 of file Buffer.cpp.

References Cogs::Core::BufferFlags::Mapped.

◆ resize()

void Cogs::Core::BufferResource::resize ( size_t  size)

Resize the buffer to accomodate the given number of bytes.

Definition at line 17 of file Buffer.cpp.

References Cogs::Core::BufferFlags::Mapped.

Referenced by Cogs::Core::Mesh::mapStream(), and Cogs::Core::BufferView< T >::resize().

◆ set()

void Cogs::Core::BufferResource::set ( size_t  offset,
size_t  size,
const uint8_t *  data 
)

Set the buffer contents to the given data at the given offset. Buffer must be resized to accomodate data before use.

Definition at line 3 of file Buffer.cpp.

References data(), invalidate(), and size().

◆ setBindFlags()

void Cogs::Core::BufferResource::setBindFlags ( uint16_t  flags)
inline

Set the bind flags for the buffer determining how the buffer data may be uploaded to GPU.

Definition at line 89 of file Buffer.h.

References Cogs::setChanged().

Referenced by Cogs::Core::Mesh::getStream().

◆ size()

size_t Cogs::Core::BufferResource::size ( ) const
inline

Size of the buffer in bytes.

Definition at line 62 of file Buffer.h.

Referenced by set(), and Cogs::Core::BufferView< T >::size().

◆ unmap()

void Cogs::Core::BufferResource::unmap ( )

Unmap the buffer, signaling writes to mapped buffer memory are done.

Definition at line 44 of file Buffer.cpp.

References Cogs::Core::BufferFlags::Mapped.

Referenced by Cogs::Core::BufferView< T >::unmap().


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