clear to red with one frame in flight
This commit is contained in:
@@ -8,6 +8,7 @@ alloc: std.mem.Allocator,
|
||||
cinfo: vk.SwapchainCreateInfoKHR,
|
||||
handle: vk.SwapchainKHR = .null_handle,
|
||||
images: std.ArrayListUnmanaged(vk.Image) = .{},
|
||||
views: std.ArrayListUnmanaged(vk.ImageView) = .{},
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator) !Self {
|
||||
const caps = try au.I.getPhysicalDeviceSurfaceCapabilitiesKHR(au.device_config.pdev, au.W.surface);
|
||||
@@ -41,7 +42,13 @@ pub fn init(alloc: std.mem.Allocator) !Self {
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
for (self.views.items) |view| {
|
||||
au.D.destroyImageView(view, null);
|
||||
}
|
||||
self.views.deinit(self.alloc);
|
||||
|
||||
self.images.deinit(self.alloc);
|
||||
|
||||
au.D.destroySwapchainKHR(self.handle, null);
|
||||
}
|
||||
|
||||
@@ -68,11 +75,29 @@ pub fn rebuild(self: *Self) !bool {
|
||||
try self.images.resize(self.alloc, count);
|
||||
_ = try au.D.getSwapchainImagesKHR(self.handle, &count, self.images.items.ptr);
|
||||
|
||||
for (self.views.items) |view| {
|
||||
au.D.destroyImageView(view, null);
|
||||
}
|
||||
try self.views.resize(self.alloc, count);
|
||||
for (self.images.items, self.views.items) |image, *view| {
|
||||
view.* = try au.D.createImageView(&vk.ImageViewCreateInfo{ .image = image, .view_type = .@"2d", .format = self.cinfo.image_format, .components = .{ .r = .identity, .g = .identity, .b = .identity, .a = .identity }, .subresource_range = .{
|
||||
.aspect_mask = .{ .color_bit = true },
|
||||
.base_mip_level = 0,
|
||||
.level_count = 1,
|
||||
.base_array_layer = 0,
|
||||
.layer_count = 1,
|
||||
} }, null);
|
||||
}
|
||||
|
||||
// todo repopulate images and synchronization
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
pub fn get(self: Self, idx: u32) vk.Image {
|
||||
pub fn getImage(self: Self, idx: u32) vk.Image {
|
||||
return self.images.items[idx];
|
||||
}
|
||||
|
||||
pub fn getView(self: Self, idx: u32) vk.ImageView {
|
||||
return self.views.items[idx];
|
||||
}
|
||||
|
Reference in New Issue
Block a user