Blender V4.3
blender::gpu::render_graph::VKResourceStateTracker Class Reference

#include <vk_resource_state_tracker.hh>

Public Member Functions

ResourceWithStamp get_image_and_increase_stamp (VkImage vk_image)
 
ResourceWithStamp get_buffer_and_increase_stamp (VkBuffer vk_buffer)
 
ResourceWithStamp get_buffer (VkBuffer vk_buffer) const
 
ResourceWithStamp get_image (VkImage vk_image) const
 
void reset_image_layouts ()
 
VKResourceType resource_type_get (ResourceHandle resource_handle) const
 
Remove resources
void remove_image (VkImage vk_image)
 
void remove_buffer (VkBuffer vk_buffer)
 

Public Attributes

std::mutex mutex
 

Friends

class VKCommandBuilder
 
struct VKRenderGraphLink
 
class VKScheduler
 

Adding resources

void add_buffer (VkBuffer vk_buffer, const char *name=nullptr)
 
void add_image (VkImage vk_image, uint32_t layer_count, VkImageLayout vk_image_layout, ResourceOwner owner, const char *name=nullptr)
 

Detailed Description

Class to track resources.

Resources are tracked on device level. Their are two kind of resources, namely buffers and images. Each resource can have multiple versions; every time a resource is changed (written to) a new version is tracked.

Definition at line 121 of file vk_resource_state_tracker.hh.

Member Function Documentation

◆ add_buffer()

void blender::gpu::render_graph::VKResourceStateTracker::add_buffer ( VkBuffer vk_buffer,
const char * name = nullptr )

◆ add_image()

◆ get_buffer()

◆ get_buffer_and_increase_stamp()

ResourceWithStamp blender::gpu::render_graph::VKResourceStateTracker::get_buffer_and_increase_stamp ( VkBuffer vk_buffer)

Return the current stamp of the resource, and increase the stamp.

When a node writes to a buffer, this method is called to increase the stamp of the buffer. The node that writes to the buffer will use the current stamp as its input, but generate the new stamp for future nodes.

This function is called when adding a node to the render graph, during building resource dependencies. See VKNodeInfo.build_links

Definition at line 141 of file vk_resource_state_tracker.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup().

Referenced by blender::gpu::render_graph::VKCopyBufferNode::build_links(), blender::gpu::render_graph::VKCopyImageToBufferNode::build_links(), blender::gpu::render_graph::VKFillBufferNode::build_links(), blender::gpu::render_graph::VKResourceAccessInfo::build_links(), and blender::gpu::render_graph::VKUpdateBufferNode::build_links().

◆ get_image()

ResourceWithStamp blender::gpu::render_graph::VKResourceStateTracker::get_image ( VkImage vk_image) const

Return the current stamp of the resource.

When a node reads from an image, this method is called to get the current stamp the image.

This function is called when adding a node to the render graph, during building resource dependencies. See VKNodeInfo.build_links

Definition at line 155 of file vk_resource_state_tracker.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup().

Referenced by blender::gpu::render_graph::VKBlitImageNode::build_links(), blender::gpu::render_graph::VKCopyImageNode::build_links(), blender::gpu::render_graph::VKCopyImageToBufferNode::build_links(), and blender::gpu::render_graph::VKResourceAccessInfo::build_links().

◆ get_image_and_increase_stamp()

ResourceWithStamp blender::gpu::render_graph::VKResourceStateTracker::get_image_and_increase_stamp ( VkImage vk_image)

Return the current stamp of the resource, and increase the stamp.

When a node writes to an image, this method is called to increase the stamp of the image. The node that writes to the image will use the current stamp as its input, but generate a new stamp for future nodes.

This function is called when adding a node to the render graph, during building resource dependencies. See VKNodeInfo.build_links

Definition at line 134 of file vk_resource_state_tracker.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup().

Referenced by blender::gpu::render_graph::VKBlitImageNode::build_links(), blender::gpu::render_graph::VKClearColorImageNode::build_links(), blender::gpu::render_graph::VKClearDepthStencilImageNode::build_links(), blender::gpu::render_graph::VKCopyBufferToImageNode::build_links(), blender::gpu::render_graph::VKCopyImageNode::build_links(), blender::gpu::render_graph::VKResourceAccessInfo::build_links(), blender::gpu::render_graph::VKSynchronizationNode::build_links(), and blender::gpu::render_graph::VKUpdateMipmapsNode::build_links().

◆ remove_buffer()

void blender::gpu::render_graph::VKResourceStateTracker::remove_buffer ( VkBuffer vk_buffer)

Remove an registered buffer.

When a buffer is destroyed by calling vmaDestroyBuffer, a call to remove_buffer is needed to unregister the resource from state tracking.

Definition at line 91 of file vk_resource_state_tracker.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), lock, mutex, and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::pop().

Referenced by blender::gpu::VKDiscardPool::destroy_discarded_resources(), and blender::gpu::VKBuffer::free_immediately().

◆ remove_image()

void blender::gpu::render_graph::VKResourceStateTracker::remove_image ( VkImage vk_image)

Remove an registered image.

When a image is destroyed by calling vmaDestroyImage, a call to remove_image is needed to unregister the resource from state tracking.

Definition at line 103 of file vk_resource_state_tracker.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), lock, mutex, and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::pop().

Referenced by blender::gpu::VKDiscardPool::destroy_discarded_resources().

◆ reset_image_layouts()

void blender::gpu::render_graph::VKResourceStateTracker::reset_image_layouts ( )

Reset the swap chain image layouts to its original layout.

The layout of swap chain images are externally managed. When they are reused we need to ensure the correct state.

NOTE: This is also needed when working with external memory (Cycles, OpenXR, multi device rendering).

Definition at line 162 of file vk_resource_state_tracker.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup(), blender::gpu::render_graph::SWAP_CHAIN, and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::values().

Referenced by blender::gpu::render_graph::VKCommandBuilder::build_nodes().

◆ resource_type_get()

VKResourceType blender::gpu::render_graph::VKResourceStateTracker::resource_type_get ( ResourceHandle resource_handle) const
inline

Get the resource type for the given handle.

Definition at line 317 of file vk_resource_state_tracker.hh.

Friends And Related Symbol Documentation

◆ VKCommandBuilder

friend class VKCommandBuilder
friend

Definition at line 124 of file vk_resource_state_tracker.hh.

◆ VKRenderGraphLink

friend struct VKRenderGraphLink
friend

Definition at line 125 of file vk_resource_state_tracker.hh.

◆ VKScheduler

friend class VKScheduler
friend

Definition at line 126 of file vk_resource_state_tracker.hh.

Member Data Documentation

◆ mutex

std::mutex blender::gpu::render_graph::VKResourceStateTracker::mutex

Device resource mutex

The mutex is stored in resources due to:

  • It protects resources and their state.
  • Allowing test cases to do testing without setting up a device instance which requires ghost.
  • Device instance isn't accessible in test cases.

Definition at line 223 of file vk_resource_state_tracker.hh.

Referenced by add_buffer(), add_image(), blender::gpu::VKDevice::current_thread_data(), blender::gpu::VKDevice::discard_pool_for_current_thread(), remove_buffer(), remove_image(), blender::gpu::render_graph::VKRenderGraph::submit_buffer_for_read(), blender::gpu::render_graph::VKRenderGraph::submit_for_present(), and blender::gpu::render_graph::VKRenderGraph::submit_synchronization_event().


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