core::data::buffer_t class

container class for GPU data.

core::data::buffer_t is a data container for anything that will be uploaded to the GPU. This means that this can not contain any complex types (such as indirections). core::data::buffer_t can be incorrectly set up when giving incompatible memory::region bundled with core::gfx::memory_usage.

constructors, destructors, conversion operators

buffer_t
public noexcept

member-functions

size
const public
usage
const public
memoryPropertyFlags
const public
region
const public
segments
const public
allocate
public
deallocate
public

Function documentation

core::data::buffer_t::buffer_t(core::resource::cache_t& cache, const core::resource::metadata& metaData, psl::meta::file* metaFile, core::gfx::memory_usage usage, core::gfx::memory_property memoryPropertyFlags, memory::region&& memory_region) noexcept

Details

will do the minimal setup needed, no allocations happen at this point yet.

Parameters
cache in which cache this object has been allocated in
metaData in the metadata that is assigned to this object
metaFile in the metafile associated with this instance
usage in the usage flags that signify how the resource should be used by the GPU
memoryPropertyFlags in what are the properties of the memory (i.e. where does it live)
memory_region in what is the owning region of this memory. Note that this parameter also will dictate the size and alignment of the resource.

size_t core::data::buffer_t::size() const

Returns the total size in the memory::region that this buffer occupies.

core::gfx::memory_usage core::data::buffer_t::usage() const

Returns the core::gfx::memory_usage of this instance, showing the type of resource this is for the GPU

core::gfx::memory_property core::data::buffer_t::memoryPropertyFlags() const

Returns the core::gfx::memory_property, so you know where the data lives.

const memory::region& core::data::buffer_t::region() const

Details

Returns the associated memory::region, where the data lives.

const std::vector<memory::segment>& core::data::buffer_t::segments() const

Returns all committed memory::segments in the memory::region. Using this you can calculate fragmentation, and allocated size.

std::optional<memory::segment> core::data::buffer_t::allocate(size_t size)

Details

Will try to allocate a new memory::segment of atleast the given size. This method will adhere to the alignment requirements of the underlaying memory::region.

Parameters
size in the minimum expected size, this will auto-align/grow to the alignment requirements.
Returns optionally, a new allocated memory::segment of atleast the given size.

bool core::data::buffer_t::deallocate(memory::segment& segment)

Details

Parameters
segment in the target segment to deallocate.
Returns true in case the deallocation was successful.