21 if (unused_handles_.is_empty()) {
22 handle = resources_.size();
25 handle = unused_handles_.pop_last();
28 Resource new_resource = {};
29 resources_.add_new(handle, new_resource);
34 bool use_subresource_tracking,
40 "Image resource is added twice to the render graph.");
43 Resource &
resource = resources_.lookup(handle);
44 image_resources_.add_new(vk_image, handle);
48 resource.image.use_subresource_tracking = use_subresource_tracking;
49 resource.barrier_state = barrier_state;
54#ifdef VK_RESOURCE_STATE_TRACKER_VALIDATION
60 bool use_subresource_tracking,
72 VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
81 "Buffer resource is added twice to the render graph.");
84 Resource &
resource = resources_.lookup(handle);
85 buffer_resources_.add_new(vk_buffer, handle);
88 resource.buffer.vk_buffer = vk_buffer;
94#ifdef VK_RESOURCE_STATE_TRACKER_VALIDATION
109 resources_.pop(handle);
110 unused_handles_.append(handle);
112#ifdef VK_RESOURCE_STATE_TRACKER_VALIDATION
121 resources_.pop(handle);
122 unused_handles_.append(handle);
124#ifdef VK_RESOURCE_STATE_TRACKER_VALIDATION
140ResourceWithStamp VKResourceStateTracker::get_and_increase_stamp(
ResourceHandle handle,
151 Resource &
resource = resources_.lookup(handle);
152 return get_and_increase_stamp(handle,
resource);
158 Resource &
resource = resources_.lookup(handle);
159 return get_and_increase_stamp(handle,
resource);
165 const Resource &
resource = resources_.lookup(handle);
172 const Resource &
resource = resources_.lookup(handle);
176#ifdef VK_RESOURCE_STATE_TRACKER_VALIDATION
177void VKResourceStateTracker::validate()
const
197 BLI_assert(resources_.size() == image_resources_.size() + buffer_resources_.size());
203 std::ostream &os = std::cout;
204 os <<
"VKResourceStateTracker\n";
205 os <<
" resources=(" << resources_.size() <<
"/" << resources_.capacity() <<
")\n";
206 os <<
" buffers=(" << buffer_resources_.size() <<
"/" << buffer_resources_.capacity() <<
")\n";
207 os <<
" images=(" << image_resources_.size() <<
"/" << image_resources_.capacity() <<
")\n";
208 os <<
" unused=(" << unused_handles_.size() <<
"/" << unused_handles_.capacity() <<
")\n";
#define BLI_assert_msg(a, msg)
#define UNUSED_VARS_NDEBUG(...)
ValueIterator values() const &
const Value & lookup(const Key &key) const
bool contains(const Key &key) const
ItemIterator items() const &
MapItem< Key, Value > Item
ResourceWithStamp get_image_and_increase_stamp(VkImage vk_image)
ResourceWithStamp get_buffer_and_increase_stamp(VkBuffer vk_buffer)
void add_image(VkImage vk_image, bool use_subresource_tracking, const char *name=nullptr)
ResourceWithStamp get_buffer(VkBuffer vk_buffer) const
void remove_buffer(VkBuffer vk_buffer)
void add_buffer(VkBuffer vk_buffer, const char *name=nullptr)
void remove_image(VkImage vk_image)
void add_swapchain_image(VkImage vk_image, const char *name=nullptr)
ResourceWithStamp get_image(VkImage vk_image) const