Vulkan: Fix memory leak in render graph #120906

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:vulkan/render-graph-free-node-data into main 2024-04-22 06:22:40 +02:00
2 changed files with 15 additions and 5 deletions

View File

@ -29,6 +29,9 @@ void VKRenderGraph::remove_nodes(Span<NodeHandle> node_handles)
"nodes, and will use incorrect ordering when not all nodes are removed. This "
"needs to be fixed when implementing a better scheduler.");
links_.clear();
for (VKRenderGraphNode &node : nodes_) {
node.free_data();
}
nodes_.clear();
}

View File

@ -194,12 +194,9 @@ struct VKRenderGraphNode {
}
/**
* Reset nodes.
*
* Nodes are reset so they can be reused in consecutive calls. Data allocated by the node are
* freed. This function dispatches the free_data to the actual node implementation.
* Free data kept by the node
*/
void reset()
void free_data()
{
switch (type) {
case VKNodeType::DISPATCH: {
@ -220,7 +217,17 @@ struct VKRenderGraphNode {
case VKNodeType::SYNCHRONIZATION:
break;
}
}
/**
* Reset nodes.
*
* Nodes are reset so they can be reused in consecutive calls. Data allocated by the node are
* freed. This function dispatches the free_data to the actual node implementation.
*/
void reset()
{
free_data();
memset(this, 0, sizeof(VKRenderGraphNode));
type = VKNodeType::UNUSED;
}