adding base depth buffers
This commit is contained in:
@@ -10,8 +10,19 @@ const Device = @import("Device.zig");
|
||||
const Self = @This();
|
||||
pub const ObjectType: vk.ObjectType = .render_pass;
|
||||
|
||||
const SubpassDescription = struct {
|
||||
flags: vk.SubpassDescriptionFlags,
|
||||
pipeline_bind_point: vk.PipelineBindPoint,
|
||||
input_attachments: ?[]const vk.AttachmentReference,
|
||||
color_attachments: ?[]const vk.AttachmentReference,
|
||||
resolve_attachments: ?[]const vk.AttachmentReference,
|
||||
depth_stencil_attachments: ?vk.AttachmentReference,
|
||||
preserve_attachments: ?[]const u32,
|
||||
};
|
||||
|
||||
owner: *Device,
|
||||
attachments: []vk.AttachmentDescription,
|
||||
subpasses: []SubpassDescription,
|
||||
|
||||
vtable: *const VTable,
|
||||
|
||||
@@ -33,14 +44,52 @@ pub fn init(device: *Device, allocator: std.mem.Allocator, info: *const vk.Rende
|
||||
return VkError.ValidationFailed;
|
||||
}
|
||||
|
||||
const subpasses = allocator.alloc(SubpassDescription, info.subpass_count) catch return VkError.OutOfHostMemory;
|
||||
errdefer allocator.free(subpasses);
|
||||
|
||||
for (subpasses[0..], info.p_subpasses[0..]) |*subpass, subpass_info| {
|
||||
subpass.* = .{
|
||||
.flags = subpass_info.flags,
|
||||
.pipeline_bind_point = subpass_info.pipeline_bind_point,
|
||||
.input_attachments = if (subpass_info.p_input_attachments) |subpass_attachments|
|
||||
allocator.dupe(vk.AttachmentReference, subpass_attachments[0..subpass_info.input_attachment_count]) catch return VkError.OutOfHostMemory
|
||||
else
|
||||
null,
|
||||
.color_attachments = if (subpass_info.p_color_attachments) |subpass_attachments|
|
||||
allocator.dupe(vk.AttachmentReference, subpass_attachments[0..subpass_info.color_attachment_count]) catch return VkError.OutOfHostMemory
|
||||
else
|
||||
null,
|
||||
.resolve_attachments = if (subpass_info.p_resolve_attachments) |subpass_attachments|
|
||||
allocator.dupe(vk.AttachmentReference, subpass_attachments[0..subpass_info.color_attachment_count]) catch return VkError.OutOfHostMemory
|
||||
else
|
||||
null,
|
||||
.depth_stencil_attachments = if (subpass_info.p_depth_stencil_attachment) |subpass_attachment|
|
||||
subpass_attachment.*
|
||||
else
|
||||
null,
|
||||
.preserve_attachments = if (subpass_info.p_preserve_attachments) |subpass_attachments|
|
||||
allocator.dupe(u32, subpass_attachments[0..subpass_info.preserve_attachment_count]) catch return VkError.OutOfHostMemory
|
||||
else
|
||||
null,
|
||||
};
|
||||
}
|
||||
|
||||
return .{
|
||||
.owner = device,
|
||||
.attachments = attachments,
|
||||
.subpasses = subpasses,
|
||||
.vtable = undefined,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn destroy(self: *Self, allocator: std.mem.Allocator) void {
|
||||
allocator.free(self.attachments);
|
||||
for (self.subpasses[0..]) |subpass| {
|
||||
if (subpass.input_attachments) |attachments| allocator.free(attachments);
|
||||
if (subpass.color_attachments) |attachments| allocator.free(attachments);
|
||||
if (subpass.resolve_attachments) |attachments| allocator.free(attachments);
|
||||
if (subpass.preserve_attachments) |attachments| allocator.free(attachments);
|
||||
}
|
||||
allocator.free(self.subpasses);
|
||||
self.vtable.destroy(self, allocator);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ pub const VkError = error{
|
||||
InvalidHandleDrv,
|
||||
InvalidPipelineDrv,
|
||||
InvalidDeviceMemoryDrv,
|
||||
InvalidAttachmentDrv,
|
||||
};
|
||||
|
||||
pub inline fn errorLogger(err: VkError) void {
|
||||
|
||||
Reference in New Issue
Block a user