Blender V5.0
blender::gpu::VKBuffer Class Reference

#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
NonCopyableoperator= (const NonCopyable &other)=delete
 NonCopyable ()=default
 NonCopyable (NonCopyable &&other)=default
NonCopyableoperator= (NonCopyable &&other)=default

Detailed Description

Class for handing vulkan buffers (allocation/updating/binding).

Definition at line 23 of file vk_buffer.hh.

Constructor & Destructor Documentation

◆ VKBuffer()

blender::gpu::VKBuffer::VKBuffer ( )
default

References data, and size().

◆ ~VKBuffer()

blender::gpu::VKBuffer::~VKBuffer ( )
virtual

Definition at line 20 of file vk_buffer.cc.

References free(), and is_allocated().

Member Function Documentation

◆ async_flush_to_host()

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().

◆ clear()

void blender::gpu::VKBuffer::clear ( VKContext & context,
uint32_t clear_value )

◆ create()

◆ device_address_get()

VkDeviceAddress blender::gpu::VKBuffer::device_address_get ( ) const
inline

◆ export_memory_get()

VkDeviceMemory blender::gpu::VKBuffer::export_memory_get ( size_t & memory_size)

◆ flush()

void blender::gpu::VKBuffer::flush ( ) const

◆ free()

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().

◆ free_immediately()

void blender::gpu::VKBuffer::free_immediately ( VKDevice & device)

◆ is_allocated()

bool blender::gpu::VKBuffer::is_allocated ( ) const
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().

◆ is_mapped()

bool blender::gpu::VKBuffer::is_mapped ( ) const
inline

◆ mapped_memory_get()

void * blender::gpu::VKBuffer::mapped_memory_get ( ) const
inline

◆ read()

void blender::gpu::VKBuffer::read ( VKContext & context,
void * data ) const

◆ read_async()

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().

◆ size_in_bytes()

int64_t blender::gpu::VKBuffer::size_in_bytes ( ) const
inline

Definition at line 96 of file vk_buffer.hh.

Referenced by create(), and flush().

◆ update_immediately()

void blender::gpu::VKBuffer::update_immediately ( const void * data) const

◆ update_render_graph()

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.

◆ update_sub_immediately()

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().

◆ vk_handle()


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