fixing leaks
This commit is contained in:
@@ -86,8 +86,8 @@ pub fn create(device: *base.Device, allocator: std.mem.Allocator, info: *const v
|
||||
|
||||
pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) void {
|
||||
const self: *Self = @alignCast(@fieldParentPtr("interface", interface));
|
||||
allocator.destroy(self);
|
||||
_ = self.command_allocator.reset(.free_all);
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
pub fn execute(self: *Self, device: *ExecutionDevice) void {
|
||||
|
||||
@@ -96,8 +96,9 @@ pub fn destroy(interface: *Interface, allocator: std.mem.Allocator) VkError!void
|
||||
if (!self.device_allocator.detectLeaks()) {
|
||||
std.log.scoped(.vkDestroyDevice).debug("No device memory leaks detected", .{});
|
||||
}
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
pub fn allocateMemory(interface: *Interface, allocator: std.mem.Allocator, info: *const vk.MemoryAllocateInfo) VkError!*base.DeviceMemory {
|
||||
|
||||
@@ -58,13 +58,16 @@ pub fn submit(interface: *Interface, infos: []Interface.SubmitInfo, p_fence: ?*b
|
||||
const allocator = soft_device.device_allocator.allocator();
|
||||
const io = soft_device.interface.io();
|
||||
|
||||
const runners_counter = allocator.create(RefCounter) catch return VkError.OutOfDeviceMemory;
|
||||
errdefer allocator.destroy(runners_counter);
|
||||
runners_counter.* = .init;
|
||||
runners_counter.setRef(infos.len);
|
||||
|
||||
for (infos) |info| {
|
||||
// Cloning info to keep them alive until command execution ends
|
||||
const cloned_info: Interface.SubmitInfo = .{
|
||||
.command_buffers = info.command_buffers.clone(allocator) catch return VkError.OutOfDeviceMemory,
|
||||
};
|
||||
const runners_counter = allocator.create(RefCounter) catch return VkError.OutOfDeviceMemory;
|
||||
runners_counter.* = .init;
|
||||
self.group.async(io, Self.taskRunner, .{ self, cloned_info, p_fence, runners_counter });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user