ci skip
Build / build (push) Has been skipped
Test / build_and_test (push) Has been skipped

This commit is contained in:
2026-05-01 22:12:39 +02:00
parent 354c9891d6
commit f87fae29e8
13 changed files with 506 additions and 221 deletions
+47
View File
@@ -0,0 +1,47 @@
const std = @import("std");
const vk = @import("vulkan");
const VkError = @import("../error_set.zig").VkError;
const Device = @import("../Device.zig");
const DeviceMemory = @import("../DeviceMemory.zig");
const Image = @import("../Image.zig");
pub const State = enum {
Available,
Drawing,
Presenting,
};
const Self = @This();
image: *Image,
memory: *DeviceMemory,
state: State,
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.ImageCreateInfo) VkError!Self {
const image = try device.createImage(allocator, info);
errdefer image.destroy(allocator);
const requirements: vk.MemoryRequirements = undefined;
try image.getMemoryRequirements(&requirements);
const memory = try device.allocateMemory(allocator, &.{
.allocation_size = requirements.size,
.memory_type_index = requirements.memory_type_bits,
});
errdefer memory.destroy(allocator);
try image.bindMemory(memory, 0);
return .{
.image = image,
.memory = memory,
.state = .Available,
};
}
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
self.image.destroy(allocator);
self.memory.destroy(allocator);
}