adding some base commadns
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user