submit command

This commit is contained in:
2024-06-27 21:08:07 -04:00
parent 1f82923f59
commit 7b80ef4dbf
2 changed files with 88 additions and 44 deletions

View File

@@ -6,7 +6,8 @@ const Self = @This();
alloc: std.mem.Allocator,
cinfo: vk.SwapchainCreateInfoKHR,
handle: vk.SwapchainKHR,
handle: vk.SwapchainKHR = .null_handle,
images: std.ArrayListUnmanaged(vk.Image) = .{},
pub fn init(alloc: std.mem.Allocator) !Self {
const caps = try au.I.getPhysicalDeviceSurfaceCapabilitiesKHR(au.device_config.pdev, au.W.surface);
@@ -36,11 +37,11 @@ pub fn init(alloc: std.mem.Allocator) !Self {
.clipped = vk.TRUE,
.old_swapchain = .null_handle,
},
.handle = .null_handle,
};
}
pub fn deinit(self: *Self) void {
self.images.deinit(self.alloc);
au.D.destroySwapchainKHR(self.handle, null);
}
@@ -62,7 +63,16 @@ pub fn rebuild(self: *Self) !bool {
au.D.destroySwapchainKHR(self.cinfo.old_swapchain, null);
self.cinfo.old_swapchain = self.handle;
var count: u32 = undefined;
_ = try au.D.getSwapchainImagesKHR(self.handle, &count, null);
try self.images.resize(self.alloc, count);
_ = try au.D.getSwapchainImagesKHR(self.handle, &count, self.images.items.ptr);
// todo repopulate images and synchronization
return true;
}
pub fn get(self: Self, idx: u32) vk.Image {
return self.images.items[idx];
}