Vulkan: Fix memory leak in render graph
There was a memory leak in the render graph where nodes where freed, but not the data it could keep. Detected during adding support for compute shaders and running the draw tests. Pull Request: https://projects.blender.org/blender/blender/pulls/120906
This commit is contained in:
committed by
Jeroen Bakker
parent
3539cdfbdd
commit
e6fad4b779
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user