|
Blender V5.0
|
#include <vk_buffer.hh>
Inherits blender::NonCopyable.
Public Member Functions | |
| VKBuffer ()=default | |
| virtual | ~VKBuffer () |
| bool | is_allocated () const |
| bool | create (size_t size, VkBufferUsageFlags buffer_usage, VmaMemoryUsage vma_memory_usage, VmaAllocationCreateFlags vma_allocation_flags, float priority, bool export_memory=false) |
| void | clear (VKContext &context, uint32_t clear_value) |
| void | update_immediately (const void *data) const |
| void | update_sub_immediately (size_t start_offset, size_t data_size, const void *data) const |
| void | update_render_graph (VKContext &context, void *data) const |
| void | flush () const |
| void | read (VKContext &context, void *data) const |
| void | async_flush_to_host (VKContext &context) |
| void | read_async (VKContext &context, void *data) |
| bool | free () |
| void | free_immediately (VKDevice &device) |
| int64_t | size_in_bytes () const |
| VkBuffer | vk_handle () const |
| void * | mapped_memory_get () const |
| VkDeviceAddress | device_address_get () const |
| bool | is_mapped () const |
| VkDeviceMemory | export_memory_get (size_t &memory_size) |
| Public Member Functions inherited from blender::NonCopyable | |
| NonCopyable (const NonCopyable &other)=delete | |
| NonCopyable & | operator= (const NonCopyable &other)=delete |
| NonCopyable ()=default | |
| NonCopyable (NonCopyable &&other)=default | |
| NonCopyable & | operator= (NonCopyable &&other)=default |
Class for handing vulkan buffers (allocation/updating/binding).
Definition at line 23 of file vk_buffer.hh.
|
virtual |
Definition at line 20 of file vk_buffer.cc.
References free(), and is_allocated().
| void blender::gpu::VKBuffer::async_flush_to_host | ( | VKContext & | context | ) |
Start a async read-back.
Definition at line 162 of file vk_buffer.cc.
References BLI_assert, blender::gpu::RENEW_RENDER_GRAPH, and blender::gpu::SUBMIT.
Referenced by read_async().
| void blender::gpu::VKBuffer::clear | ( | VKContext & | context, |
| uint32_t | clear_value ) |
Definition at line 153 of file vk_buffer.cc.
References blender::gpu::render_graph::VKFillBufferData::data, blender::gpu::render_graph::VKFillBufferData::size, and blender::gpu::render_graph::VKFillBufferData::vk_buffer.
| bool blender::gpu::VKBuffer::create | ( | size_t | size, |
| VkBufferUsageFlags | buffer_usage, | ||
| VmaMemoryUsage | vma_memory_usage, | ||
| VmaAllocationCreateFlags | vma_allocation_flags, | ||
| float | priority, | ||
| bool | export_memory = false ) |
Allocate the buffer.
Definition at line 27 of file vk_buffer.cc.
References blender::gpu::render_graph::VKResourceStateTracker::add_buffer(), BLI_assert, ceil_to_multiple_ul(), CLOG_WARN, blender::gpu::VKExtensions::descriptor_buffer, blender::gpu::VKBackend::device, blender::gpu::VKDevice::extensions_get(), blender::gpu::VKMemoryPools::external_memory_pixel_buffer, blender::gpu::VKBackend::get(), is_allocated(), blender::gpu::LOG, blender::gpu::VKExtensions::maintenance4, max_ulul(), blender::gpu::VKDevice::mem_allocator_get(), blender::gpu::VKDevice::physical_device_maintenance4_properties_get(), blender::gpu::VKMemoryPool::pool, blender::gpu::VKDevice::queue_family_get(), blender::gpu::VKDevice::resources, result, size_in_bytes(), blender::gpu::vk_external_memory_handle_type(), blender::gpu::VKDevice::vk_handle(), and blender::gpu::VKDevice::vma_pools.
Referenced by blender::gpu::VKDescriptorBufferUpdator::allocate_new_descriptor_set(), blender::gpu::VKTexture::read_sub(), blender::gpu::VKStreamingBuffer::update(), and blender::gpu::VKTexture::update_sub().
|
inline |
Definition at line 113 of file vk_buffer.hh.
Referenced by blender::gpu::VKDescriptorBufferUpdator::allocate_new_descriptor_set().
| VkDeviceMemory blender::gpu::VKBuffer::export_memory_get | ( | size_t & | memory_size | ) |
Get allocated device memory.
Definition at line 212 of file vk_buffer.cc.
References BLI_assert, blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), and blender::gpu::VKDevice::mem_allocator_get().
| void blender::gpu::VKBuffer::flush | ( | ) | const |
Definition at line 146 of file vk_buffer.cc.
References blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), max_ulul(), blender::gpu::VKDevice::mem_allocator_get(), and size_in_bytes().
| bool blender::gpu::VKBuffer::free | ( | ) |
Free the buffer.
Discards the buffer so it can be destroyed safely later. Buffers can still be used when rendering so we can only destroy them after the rendering is completed.
Definition at line 230 of file vk_buffer.cc.
References blender::gpu::VKDiscardPool::discard_buffer(), blender::gpu::VKDiscardPool::discard_pool_get(), and is_mapped().
Referenced by ~VKBuffer().
| void blender::gpu::VKBuffer::free_immediately | ( | VKDevice & | device | ) |
Destroy the buffer immediately.
Definition at line 244 of file vk_buffer.cc.
References BLI_assert, is_mapped(), blender::gpu::VKDevice::mem_allocator_get(), blender::gpu::render_graph::VKResourceStateTracker::remove_buffer(), and blender::gpu::VKDevice::resources.
|
inline |
Has this buffer been allocated?
Definition at line 145 of file vk_buffer.hh.
Referenced by create(), blender::gpu::VKIndexBuffer::ensure_updated(), blender::gpu::VKStorageBuffer::update(), and ~VKBuffer().
|
inline |
Is this buffer mapped (visible on host)
Definition at line 140 of file vk_buffer.hh.
Referenced by free(), free_immediately(), mapped_memory_get(), read(), blender::gpu::VKIndexBuffer::read(), blender::gpu::VKVertexBuffer::read(), read_async(), and update_sub_immediately().
|
inline |
Get the reference to the mapped memory.
Can only be called when the buffer is (still) mapped.
Definition at line 134 of file vk_buffer.hh.
References BLI_assert_msg, and is_mapped().
Referenced by blender::gpu::VKDescriptorBufferUpdator::allocate_new_descriptor_set(), blender::gpu::VKImmediate::begin(), blender::gpu::VKTexture::read_sub(), blender::gpu::VKStreamingBuffer::update(), blender::gpu::VKTexture::update_sub(), and blender::gpu::VKVertexBuffer::update_sub().
| void blender::gpu::VKBuffer::read | ( | VKContext & | context, |
| void * | data ) const |
Read the buffer (synchronously).
Definition at line 182 of file vk_buffer.cc.
References BLI_assert, BLI_assert_msg, data, is_mapped(), blender::gpu::RENEW_RENDER_GRAPH, blender::gpu::SUBMIT, and blender::gpu::WAIT_FOR_COMPLETION.
Referenced by blender::gpu::VKIndexBuffer::read(), and blender::gpu::VKVertexBuffer::read().
| void blender::gpu::VKBuffer::read_async | ( | VKContext & | context, |
| void * | data ) |
Wait until the async read back is finished and fill the given data with the content of the buffer.
Will start a new async read-back when there is no read back in progress.
Definition at line 170 of file vk_buffer.cc.
References async_flush_to_host(), BLI_assert_msg, data, blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), is_mapped(), and blender::gpu::VKDevice::wait_for_timeline().
|
inline |
Definition at line 96 of file vk_buffer.hh.
| void blender::gpu::VKBuffer::update_immediately | ( | const void * | data | ) | const |
Definition at line 123 of file vk_buffer.cc.
References data, and update_sub_immediately().
Referenced by blender::gpu::VKIndexBuffer::ensure_updated(), and blender::gpu::VKStorageBuffer::update().
| void blender::gpu::VKBuffer::update_render_graph | ( | VKContext & | context, |
| void * | data ) const |
Update the buffer as part of the render graph evaluation. The ownership of data will be transferred to the render graph and should have been allocated using guarded alloc.
Definition at line 136 of file vk_buffer.cc.
References BLI_assert, blender::gpu::render_graph::VKUpdateBufferData::data, data, blender::gpu::render_graph::VKUpdateBufferData::data_size, and blender::gpu::render_graph::VKUpdateBufferData::dst_buffer.
| void blender::gpu::VKBuffer::update_sub_immediately | ( | size_t | start_offset, |
| size_t | data_size, | ||
| const void * | data ) const |
Definition at line 128 of file vk_buffer.cc.
References BLI_assert_msg, data, and is_mapped().
Referenced by update_immediately().
|
inline |
Definition at line 101 of file vk_buffer.hh.
Referenced by blender::gpu::VKDescriptorBufferUpdator::allocate_new_descriptor_set(), blender::gpu::VKVertexAttributeObject::bind(), blender::gpu::VKContext::get_or_create_streaming_buffer(), blender::gpu::VKTexture::read_sub(), blender::gpu::VKStreamingBuffer::update(), and blender::gpu::VKTexture::update_sub().