class
buffer_tmaps a memory region and interfaces with the driver for read/writes
buffers are used to map regions of memory that the driver should know about, either because they will be used to map GPU resources (geometry, textures, etc..), or because they are used for synchronising information between CPU/GPU (compute results). This class will handle most of the needs for synchonising, and how-to upload the data to the relevant locations as well as managing the internals.
constructors, destructors, conversion operators
member-functions
Function documentation
core:: ivk:: buffer_t:: buffer_t(core:: resource:: cache_t& cache,
const core:: resource:: metadata& metaData,
psl:: meta:: file* metaFile,
core:: resource:: handle<core:: ivk:: context> context,
core:: resource:: handle<core:: data:: buffer_t> buffer_data,
std::optional<core:: resource:: handle<core:: ivk:: buffer_t>> staging_buffer = std::nullopt)
Brief
constructs a buffer from the given buffer_data, as well as optionally sets a staging resource.
Details
Parameters | |
---|---|
cache | |
metaData | |
metaFile | |
context | |
buffer_data in | the data source to bind to this buffer. (see note for more info) |
staging_buffer in | the staging buffer to use in case staging is needed. (see warning for more info) |
std::optional<memory:: segment> core:: ivk:: buffer_t:: reserve(vk::DeviceSize size)
Brief
tries to reserve a region of memory of at least the given size in thye buffer.
Parameters | |
---|---|
size in | the minimum size to allocate |
Returns | a memory:: |
std::vector<std::pair<memory:: segment, memory:: range_t>> core:: ivk:: buffer_t:: reserve(std::vector<vk::DeviceSize> sizes,
bool optimize = false)
Brief
tries to reserve all requested sizes in the memory::
Details
optmized version of reserve() that works on a batch of data. It will try to satisfy allocating regions of memory of atleast the given accumulative size. Depending on the optimize boolean parameter's value this can be in one optimized memory::
Parameters | |
---|---|
sizes in | a container with minimum sizes you want to request. |
optimize in | signifies if we should we try to collapse multiple memory::segments into one segment if possible, avoiding fragmentation and overhead. |
Returns | a vector with as many contained elements as the requested sizes container has. |
bool core:: ivk:: buffer_t:: commit(std::vector<core:: gfx:: commit_instruction> instructions)
Brief
tries to find the appropriate method to update the buffer with the commit instructions.
Details
this method tries to commit the given instruction into the buffer. depending on the type of buffer how this does that can differ greatly.
Parameters | |
---|---|
instructions in | all the instructions you wish to send to the GPU in this batch. |
Returns | success if the instruction has been sent. |
bool core:: ivk:: buffer_t:: deallocate(memory:: segment& segment)
Brief
marks the specific region of memory available again.
Details
Parameters | |
---|---|
segment in | the region you wish to free up. |
Returns | success in case the region was freed. note that in case the buffer was not the owner of the memory:: |
bool core:: ivk:: buffer_t:: copy_from(const buffer_ t& other,
const std::vector<vk::BufferCopy>& copyRegions)
Brief
allows you to copy from one buffer into another.
Parameters | |
---|---|
other in | the buffer to copy from into this instance. |
copyRegions in | the batch of copy instructions. |
Returns | true in case the instructions were successfully uploaded to the GPU. |
std::optional<resource:: handle<buffer_ t>> core:: ivk:: buffer_t:: copy_to_host(bool compressed_copy = true) const
Brief
makes the buffer available on the host.
Parameters | |
---|---|
compressed_copy in | when compressed is true, then the buffer will collapse all empty regions and return a buffer that is the size of all actual committed memory. |
Returns | a handle to a HOST_VISIBLE buffer on success. |
std::optional<resource:: handle<buffer_ t>> core:: ivk:: buffer_t:: copy_to_host(const std::vector<vk::BufferCopy>& copyRegions) const
Brief
makes the buffer available on the host.
Parameters | |
---|---|
copyRegions in | the regions the new buffer will consist out of. The new buffer will be the size of the accumulate size of the copyRegions (+ alignment rules). |
Returns | a handle to a HOST_VISIBLE buffer on success. |
const vk::Buffer& core:: ivk:: buffer_t:: gpu_buffer() const
Returns | the vk::Buffer handle. |
---|
core:: resource:: handle<core:: data:: buffer_t> core:: ivk:: buffer_t:: data() const
Returns | the internal buffer data. |
---|
vk::DescriptorBufferInfo& core:: ivk:: buffer_t:: buffer_info()
Returns | the vulkan descriptor buffer info. |
---|