Remove legacy render passes and frambebuffers in favor of dynamic rendering

Somehow, some way, we ended up with net positive lines changed
This commit is contained in:
2026-05-13 17:28:16 +02:00
parent e736c0df34
commit 36434f8107
6 changed files with 231 additions and 219 deletions

View File

@@ -61,11 +61,25 @@ pub const PipelineBarrier = struct {
image_memory_barriers: []const vk.ImageMemoryBarrier = &.{},
};
pub const RenderPassBeginInfo = struct {
render_pass: vk.RenderPass,
framebuffer: vk.Framebuffer,
pub const RenderingAttachmentInfo = struct {
image_view: vk.ImageView = .null_handle,
image_layout: vk.ImageLayout,
resolve_mode: vk.ResolveModeFlags = .{},
resolve_image_view: vk.ImageView = .null_handle,
resolve_image_layout: vk.ImageLayout = .undefined,
load_op: vk.AttachmentLoadOp,
store_op: vk.AttachmentStoreOp,
clear_value: vk.ClearValue,
};
pub const RenderingInfo = struct {
flags: vk.RenderingFlags = .{},
render_area: vk.Rect2D,
clear_values: []const vk.ClearValue = &.{},
layer_count: u32,
view_mask: u32,
color_attachments: []const RenderingAttachmentInfo = &.{},
depth_attachment: ?RenderingAttachmentInfo = null,
stencil_attachment: ?RenderingAttachmentInfo = null,
};
pub const VertexBufferBinding = struct {
@@ -81,14 +95,53 @@ pub fn beginCommandBuffer(self: CommandBuffer) !void {
});
}
pub fn beginRenderPass(self: CommandBuffer, render_pass_begin: RenderPassBeginInfo, contents: vk.SubpassContents) void {
self.proxy.beginRenderPass(&.{
.render_pass = render_pass_begin.render_pass,
.framebuffer = render_pass_begin.framebuffer,
.render_area = render_pass_begin.render_area,
.clear_value_count = @intCast(render_pass_begin.clear_values.len),
.p_clear_values = render_pass_begin.clear_values.ptr,
}, contents);
pub fn beginRendering(self: CommandBuffer, rendering_info: RenderingInfo) !void {
var arena: std.heap.ArenaAllocator = .init(self.allocator);
defer arena.deinit();
const allocator = arena.allocator();
const color_attachments = try allocator.alloc(vk.RenderingAttachmentInfo, rendering_info.color_attachments.len);
for (color_attachments, rendering_info.color_attachments) |*x, color_attachment| {
x.* = .{
.image_view = color_attachment.image_view,
.image_layout = color_attachment.image_layout,
.resolve_mode = color_attachment.resolve_mode,
.resolve_image_view = color_attachment.resolve_image_view,
.resolve_image_layout = color_attachment.resolve_image_layout,
.load_op = color_attachment.load_op,
.store_op = color_attachment.store_op,
.clear_value = color_attachment.clear_value,
};
}
self.proxy.beginRendering(&.{
.flags = rendering_info.flags,
.render_area = rendering_info.render_area,
.layer_count = rendering_info.layer_count,
.view_mask = rendering_info.view_mask,
.color_attachment_count = @intCast(color_attachments.len),
.p_color_attachments = color_attachments.ptr,
.p_depth_attachment = if (rendering_info.depth_attachment) |x| &.{
.image_view = x.image_view,
.image_layout = x.image_layout,
.resolve_mode = x.resolve_mode,
.resolve_image_view = x.resolve_image_view,
.resolve_image_layout = x.resolve_image_layout,
.load_op = x.load_op,
.store_op = x.store_op,
.clear_value = x.clear_value,
} else null,
.p_stencil_attachment = if (rendering_info.stencil_attachment) |x| &.{
.image_view = x.image_view,
.image_layout = x.image_layout,
.resolve_mode = x.resolve_mode,
.resolve_image_view = x.resolve_image_view,
.resolve_image_layout = x.resolve_image_layout,
.load_op = x.load_op,
.store_op = x.store_op,
.clear_value = x.clear_value,
} else null,
});
}
pub fn bindDescriptorSet(
@@ -163,8 +216,8 @@ pub fn endCommandBuffer(self: CommandBuffer) !void {
try self.proxy.endCommandBuffer();
}
pub fn endRenderPass(self: CommandBuffer) void {
self.proxy.endRenderPass();
pub fn endRendering(self: CommandBuffer) void {
self.proxy.endRendering();
}
pub fn copyBuffer(