fixing leaks
This commit is contained in:
@@ -57,8 +57,8 @@ pub fn allocateCommandBuffers(self: *Self, info: *const vk.CommandBufferAllocate
|
||||
}
|
||||
for (0..info.command_buffer_count) |_| {
|
||||
const cmd = try self.vtable.createCommandBuffer(self, allocator, info);
|
||||
const non_dis_cmd = try Dispatchable(CommandBuffer).wrap(allocator, cmd);
|
||||
self.buffers.appendAssumeCapacity(non_dis_cmd);
|
||||
const dis_cmd = try Dispatchable(CommandBuffer).wrap(allocator, cmd);
|
||||
self.buffers.appendAssumeCapacity(dis_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,20 +85,27 @@ pub fn freeCommandBuffers(self: *Self, cmds: []*Dispatchable(CommandBuffer)) VkE
|
||||
}
|
||||
|
||||
pub fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
for (self.buffers.items) |non_dis_cmd| {
|
||||
non_dis_cmd.intrusiveDestroy(allocator);
|
||||
for (self.buffers.items) |dis_cmd| {
|
||||
dis_cmd.intrusiveDestroy(allocator);
|
||||
}
|
||||
self.buffers.deinit(allocator);
|
||||
self.vtable.destroy(self, allocator);
|
||||
}
|
||||
|
||||
pub inline fn reset(self: *Self, flags: vk.CommandPoolResetFlags) VkError!void {
|
||||
pub fn reset(self: *Self, flags: vk.CommandPoolResetFlags) VkError!void {
|
||||
try self.vtable.reset(self, flags);
|
||||
|
||||
self.first_free_buffer_index = 0;
|
||||
|
||||
if (flags.release_resources_bit) {
|
||||
const allocator = self.host_allocator.allocator();
|
||||
for (self.buffers.items) |non_dis_cmd| {
|
||||
non_dis_cmd.intrusiveDestroy(allocator);
|
||||
for (self.buffers.items) |dis_cmd| {
|
||||
dis_cmd.intrusiveDestroy(allocator);
|
||||
}
|
||||
self.buffers.clearRetainingCapacity();
|
||||
} else {
|
||||
for (self.buffers.items) |dis_cmd| {
|
||||
_ = dis_cmd.object.reset(.{ .release_resources_bit = true }) catch {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ pub inline fn ref(self: *Self) void {
|
||||
_ = self.count.fetchAdd(1, .seq_cst);
|
||||
}
|
||||
|
||||
pub inline fn setRef(self: *Self, count: usize) void {
|
||||
_ = self.count.store(count, .seq_cst);
|
||||
}
|
||||
|
||||
pub inline fn unref(self: *Self) void {
|
||||
_ = self.count.fetchSub(1, .seq_cst);
|
||||
}
|
||||
|
||||
@@ -103,11 +103,12 @@ pub fn detachSurface(self: *Self) VkError!void {
|
||||
}
|
||||
|
||||
pub fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
if (self.surface) |surface| {
|
||||
for (self.images) |*image| {
|
||||
for (self.images) |*image| {
|
||||
if (self.surface) |surface| {
|
||||
surface.detachImage(allocator, image) catch {};
|
||||
image.deinit(allocator);
|
||||
}
|
||||
image.deinit(allocator);
|
||||
}
|
||||
allocator.free(self.images);
|
||||
allocator.destroy(self);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user