adding some base commadns
Build / build (push) Successful in 59s
Test / build_and_test (push) Successful in 19m48s

This commit is contained in:
2026-04-23 02:50:18 +02:00
parent 2862ab1e33
commit ed8a60b539
15 changed files with 310 additions and 95 deletions
+26 -4
View File
@@ -1,16 +1,22 @@
const std = @import("std");
const vk = @import("vulkan");
const NonDispatchable = @import("NonDispatchable.zig");
const NonDispatchable = @import("NonDispatchable.zig").NonDispatchable;
const VulkanAllocator = @import("VulkanAllocator.zig");
const VkError = @import("error_set.zig").VkError;
const Device = @import("Device.zig");
const ImageView = @import("ImageView.zig");
const Self = @This();
pub const ObjectType: vk.ObjectType = .framebuffer;
owner: *Device,
width: usize,
height: usize,
layers: usize,
attachments: []*ImageView,
vtable: *const VTable,
@@ -19,14 +25,30 @@ pub const VTable = struct {
};
pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.FramebufferCreateInfo) VkError!Self {
_ = allocator;
_ = info;
const object_allocator = VulkanAllocator.from(allocator).cloneWithScope(.object);
const attachments = object_allocator.allocator().alloc(*ImageView, info.attachment_count) catch return VkError.OutOfHostMemory;
errdefer object_allocator.allocator().free(attachments);
if (info.p_attachments) |base_attachements| {
for (base_attachements, attachments, 0..info.attachment_count) |base_attachment, *attachment, _| {
attachment.* = try NonDispatchable(ImageView).fromHandleObject(base_attachment);
}
} else {
return VkError.ValidationFailed;
}
return .{
.owner = device,
.width = @intCast(info.width),
.height = @intCast(info.height),
.layers = @intCast(info.layers),
.attachments = attachments,
.vtable = undefined,
};
}
pub inline fn destroy(self: *Self, allocator: std.mem.Allocator) void {
pub fn destroy(self: *Self, allocator: std.mem.Allocator) void {
allocator.free(self.attachments);
self.vtable.destroy(self, allocator);
}