From e86bb48e0aa57fb85865447c8d573cc724d71920 Mon Sep 17 00:00:00 2001 From: Gabríel Arthúr Pétursson Date: Tue, 20 Mar 2018 21:52:06 +0000 Subject: layers: Destroy object tracking after reporting undestroyed objects Fixes a memleak in VkLayerTest.LeakAnObject. --- scripts/object_tracker_generator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'scripts') diff --git a/scripts/object_tracker_generator.py b/scripts/object_tracker_generator.py index e5475ec7..00b9bcd6 100644 --- a/scripts/object_tracker_generator.py +++ b/scripts/object_tracker_generator.py @@ -331,6 +331,7 @@ class ObjectTrackerOutputGenerator(OutputGenerator): # Check if the parameter passed in is a pointer to an array def paramIsArray(self, param): return param.attrib.get('len') is not None + # # Generate the object tracker undestroyed object validation function def GenReportFunc(self): @@ -342,6 +343,19 @@ class ObjectTrackerOutputGenerator(OutputGenerator): output_func += ' DeviceReportUndestroyedObjects(device, %s, error_code);\n' % (self.GetVulkanObjType(handle)) output_func += '}\n' return output_func + + # + # Generate the object tracker undestroyed object destruction function + def GenDestroyFunc(self): + output_func = '' + output_func += 'void DestroyUndestroyedObjects(VkDevice device) {\n' + output_func += ' DeviceDestroyUndestroyedObjects(device, kVulkanObjectTypeCommandBuffer);\n' + for handle in self.object_types: + if self.isHandleTypeNonDispatchable(handle): + output_func += ' DeviceDestroyUndestroyedObjects(device, %s);\n' % (self.GetVulkanObjType(handle)) + output_func += '}\n' + return output_func + # # Called at beginning of processing as file is opened def beginFile(self, genOpts): @@ -401,8 +415,12 @@ class ObjectTrackerOutputGenerator(OutputGenerator): # Build undestroyed objects reporting function report_func = self.GenReportFunc() self.newline() + # Build undestroyed objects destruction function + destroy_func = self.GenDestroyFunc() + self.newline() write('// ObjectTracker undestroyed objects validation function', file=self.outFile) write('%s' % report_func, file=self.outFile) + write('%s' % destroy_func, file=self.outFile) # Actually write the interface to the output file. if (self.emit): self.newline() -- cgit v1.2.3