Castor3D 0.12.0
Multiplatform 3D engine
Public Member Functions | Friends | List of all members
castor3d::GpuBufferT< AllocatorT > Class Template Reference

A GPU buffer, that uses a buddy allocator to allocate sub-buffers. More...

#include <GpuBuffer.hpp>

Inheritance diagram for castor3d::GpuBufferT< AllocatorT >:
Inheritance graph
[legend]
Collaboration diagram for castor3d::GpuBufferT< AllocatorT >:
Collaboration graph
[legend]

Public Member Functions

 GpuBufferT (RenderSystem const &renderSystem, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryFlags, castor::String debugName, ashes::QueueShare sharingMode, AllocatorT allocator, bool smallData=false)
 Constructor. More...
 
bool hasAvailable (VkDeviceSize size) const
 
MemChunk allocate (VkDeviceSize size)
 Allocates a memory chunk for a CPU buffer. More...
 
void deallocate (MemChunk const &mem)
 Deallocates memory. More...
 
size_t getMinAlignment () const
 
- Public Member Functions inherited from castor3d::GpuBufferBase
C3D_API GpuBufferBase (RenderSystem const &renderSystem, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryFlags, castor::String debugName, ashes::QueueShare sharingMode, VkDeviceSize allocatedSize, bool smallData=false)
 Constructor. More...
 
C3D_API void upload (ashes::CommandBuffer const &cb)
 Uploads all ready memory ranges to VRAM. More...
 
C3D_API void uploadDirect (ashes::Queue const &queue, ashes::CommandPool const &commandPool, VkDeviceSize offset, VkDeviceSize size, VkAccessFlags dstAccessFlags, VkPipelineStageFlags dstPipelineFlags)
 Uploads a memory range. More...
 
C3D_API void markDirty (VkDeviceSize offset, VkDeviceSize size, VkAccessFlags dstAccessFlags, VkPipelineStageFlags dstPipelineFlags)
 Marks a memory range to be ready for upload. More...
 
bool hasBuffer () const
 
ashes::Buffer< uint8_t > const & getBuffer () const
 
 operator ashes::Buffer< uint8_t > const & () const
 
ashes::Buffer< uint8_t > & getBuffer ()
 
 operator ashes::Buffer< uint8_t > & ()
 
template<typename DataT >
DataT const & getData (VkDeviceSize offset) const
 
template<typename DataT >
DataT & getData (VkDeviceSize offset)
 
castor::ArrayView< uint8_t > const & getDatas () const
 
castor::ArrayView< uint8_t > & getDatas ()
 

Friends

class GpuBufferPool
 

Detailed Description

template<typename AllocatorT>
class castor3d::GpuBufferT< AllocatorT >

A GPU buffer, that uses a buddy allocator to allocate sub-buffers.

Constructor & Destructor Documentation

◆ GpuBufferT()

template<typename AllocatorT >
castor3d::GpuBufferT< AllocatorT >::GpuBufferT ( RenderSystem const &  renderSystem,
VkBufferUsageFlags  usage,
VkMemoryPropertyFlags  memoryFlags,
castor::String  debugName,
ashes::QueueShare  sharingMode,
AllocatorT  allocator,
bool  smallData = false 
)

Constructor.

Parameters
[in]renderSystemThe device on which the storage is allocated.
[in]usageThe buffer targets.
[in]memoryFlagsThe buffer memory properties.
[in]debugNameThe debug name.
[in]sharingModeThe sharing mode.
[in]allocatorThe allocator.
[in]smallDataTells if the memory chunks allocated through this buffer are less than 65536 bytes.

Member Function Documentation

◆ allocate()

template<typename AllocatorT >
MemChunk castor3d::GpuBufferT< AllocatorT >::allocate ( VkDeviceSize  size)

Allocates a memory chunk for a CPU buffer.

Parameters
[in]sizeThe requested memory size.
Returns
The memory chunk offset.

◆ deallocate()

template<typename AllocatorT >
void castor3d::GpuBufferT< AllocatorT >::deallocate ( MemChunk const &  mem)

Deallocates memory.

Parameters
[in]memThe memory chunk.

◆ getMinAlignment()

template<typename AllocatorT >
size_t castor3d::GpuBufferT< AllocatorT >::getMinAlignment ( ) const
Returns
The element aligned size.

◆ hasAvailable()

template<typename AllocatorT >
bool castor3d::GpuBufferT< AllocatorT >::hasAvailable ( VkDeviceSize  size) const
Parameters
[in]sizeThe requested memory size.
Returns
true if there is enough remaining memory for given size.

Friends And Related Function Documentation

◆ GpuBufferPool

template<typename AllocatorT >
friend class GpuBufferPool
friend

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