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

#include <vk_buffer.hh>

Inherits blender::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, const char *debug_name="VKBuffer", size_t alignment=0)
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 ()
int64_t size_in_bytes () const
int64_t allocated_size_in_bytes () const
const VKResourceWithHandle< VkBuffer > & resource () const
VkBuffer vk_handle () const
void * mapped_memory_get () const
VkDeviceAddress device_address_get () const
bool has_device_address () const
bool is_mapped () const
VkDeviceMemory export_memory_get (size_t &memory_size)
void flush_mapped_memory ()
void invalidate_mapped_memory ()
Public Member Functions inherited from blender::blender::NonCopyable
 NonCopyable (const NonCopyable &other)=delete
NonCopyable & operator= (const NonCopyable &other)=delete
 NonCopyable ()=default
 NonCopyable (NonCopyable &&other)=default
NonCopyable & operator= (NonCopyable &&other)=default

Detailed Description

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

Definition at line 25 of file vk_buffer.hh.

Constructor & Destructor Documentation

◆ VKBuffer()

◆ ~VKBuffer()

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

Definition at line 22 of file vk_buffer.cc.

References free(), and is_allocated().

Member Function Documentation

◆ allocated_size_in_bytes()

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

Definition at line 99 of file vk_buffer.hh.

◆ async_flush_to_host()

void blender::gpu::VKBuffer::async_flush_to_host ( VKContext & context)

Start a async read-back.

Definition at line 183 of file vk_buffer.cc.

References blender::BLI_assert(), blender::gpu::RENEW_RENDER_GRAPH, and blender::gpu::SUBMIT.

Referenced by read_async(), and VKBuffer().

◆ clear()

◆ 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

◆ flush_mapped_memory()

void blender::gpu::VKBuffer::flush_mapped_memory ( )

Flush the mapped memory after writing to it on the host. Only has an effect if the memory is not host coherent.

Definition at line 251 of file vk_buffer.cc.

References blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), and blender::gpu::VKDevice::mem_allocator_get().

Referenced by blender::gpu::VKTexture::update_sub().

◆ 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 265 of file vk_buffer.cc.

References blender::gpu::render_graph::VKResourceStateTracker::deref_resource(), blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), is_mapped(), and blender::gpu::VKDevice::resources.

Referenced by blender::gpu::VKDevice::deinit(), VKBuffer(), and ~VKBuffer().

◆ has_device_address()

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

Definition at line 125 of file vk_buffer.hh.

◆ invalidate_mapped_memory()

void blender::gpu::VKBuffer::invalidate_mapped_memory ( )

Invalidates the mapped memory after writing to it on the device. Only has an effect if the memory is not host coherent.

Definition at line 258 of file vk_buffer.cc.

References blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), and blender::gpu::VKDevice::mem_allocator_get().

Referenced by blender::gpu::VKTexture::read_sub().

◆ is_allocated()

◆ is_mapped()

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

Is this buffer mapped (visible on host)

Definition at line 164 of file vk_buffer.hh.

Referenced by free(), mapped_memory_get(), read(), blender::gpu::VKIndexBuffer::read(), blender::gpu::VKVertexBuffer::read(), read_async(), and update_sub_immediately().

◆ 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 191 of file vk_buffer.cc.

References async_flush_to_host(), BLI_assert_msg, blender::data, blender::gpu::VKBackend::device, blender::gpu::VKBackend::get(), is_mapped(), and blender::gpu::VKDevice::wait_for_timeline().

Referenced by VKBuffer().

◆ resource()

◆ size_in_bytes()

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

Definition at line 94 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 157 of file vk_buffer.cc.

References blender::BLI_assert(), blender::data, blender::gpu::render_graph::VKUpdateBufferData::data, blender::gpu::render_graph::VKUpdateBufferData::data_size, blender::gpu::render_graph::VKUpdateBufferData::dst_buffer, and resource().

Referenced by VKBuffer().

◆ 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 149 of file vk_buffer.cc.

References BLI_assert_msg, blender::data, and is_mapped().

Referenced by update_immediately(), and VKBuffer().

◆ vk_handle()

VkBuffer blender::gpu::VKBuffer::vk_handle ( ) const
inline

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