|
Blender V4.3
|
#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) |
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.
| void blender::gpu::render_graph::VKResourceStateTracker::add_buffer | ( | VkBuffer | vk_buffer, |
| const char * | name = nullptr ) |
Register a buffer resource.
When a buffer is created in VKBuffer, it needs to be registered in the device resources so the resource state can be tracked during its lifetime.
Definition at line 62 of file vk_resource_state_tracker.cc.
References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), blender::gpu::render_graph::APPLICATION, BLI_assert_msg, blender::gpu::render_graph::BUFFER, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), lock, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup(), mutex, and UNUSED_VARS_NDEBUG.
Referenced by blender::gpu::VKBuffer::create(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), and blender::gpu::render_graph::TEST().
| void blender::gpu::render_graph::VKResourceStateTracker::add_image | ( | VkImage | vk_image, |
| uint32_t | layer_count, | ||
| VkImageLayout | vk_image_layout, | ||
| ResourceOwner | owner, | ||
| const char * | name = nullptr ) |
Register an image resource.
When an image is created in VKTexture, it needs to be registered in the device resources so the resource state can be tracked during its lifetime.
Definition at line 33 of file vk_resource_state_tracker.cc.
References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), BLI_assert_msg, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), blender::gpu::render_graph::IMAGE, lock, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup(), mutex, and UNUSED_VARS_NDEBUG.
Referenced by blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), blender::gpu::render_graph::TEST(), and blender::gpu::render_graph::TEST().
| ResourceWithStamp blender::gpu::render_graph::VKResourceStateTracker::get_buffer | ( | VkBuffer | vk_buffer | ) | const |
Return the current stamp of the resource.
When a node reads from a buffer, this method is called to get the current stamp the buffer.
This function is called when adding a node to the render graph, during building resource dependencies. See VKNodeInfo.build_links
Definition at line 148 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::VKCopyBufferToImageNode::build_links(), blender::gpu::render_graph::VKDispatchIndirectNode::build_links(), blender::gpu::render_graph::VKDrawIndexedIndirectNode::build_links(), blender::gpu::render_graph::VKDrawIndirectNode::build_links(), blender::gpu::render_graph::VKResourceAccessInfo::build_links(), blender::gpu::render_graph::vk_index_buffer_binding_build_links(), and blender::gpu::render_graph::vk_vertex_buffer_bindings_build_links().
| 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().
| 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().
| 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().
| 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().
| 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().
| 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().
|
inline |
Get the resource type for the given handle.
Definition at line 317 of file vk_resource_state_tracker.hh.
|
friend |
Definition at line 124 of file vk_resource_state_tracker.hh.
|
friend |
Definition at line 125 of file vk_resource_state_tracker.hh.
|
friend |
Definition at line 126 of file vk_resource_state_tracker.hh.
| std::mutex blender::gpu::render_graph::VKResourceStateTracker::mutex |
Device resource mutex
The mutex is stored in resources due to:
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().