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:
@@ -768,15 +768,6 @@ pub const DescriptorSetsUpdateInfo = struct {
|
||||
copies: []const vk.CopyDescriptorSet = &.{},
|
||||
};
|
||||
|
||||
pub const FramebufferCreateInfo = struct {
|
||||
flags: vk.FramebufferCreateFlags = .{},
|
||||
render_pass: vk.RenderPass,
|
||||
attachments: []const vk.ImageView = &.{},
|
||||
width: u32,
|
||||
height: u32,
|
||||
layers: u32,
|
||||
};
|
||||
|
||||
pub const GraphicsPipelineCreateInfo = struct {
|
||||
flags: vk.PipelineCreateFlags = .{},
|
||||
stages: []const PipelineShaderStageCreateInfo = &.{},
|
||||
@@ -790,8 +781,10 @@ pub const GraphicsPipelineCreateInfo = struct {
|
||||
color_blend_state: ?PipelineColorBlendStateCreateInfo = null,
|
||||
dynamic_state: ?PipelineDynamicStateCreateInfo = null,
|
||||
layout: vk.PipelineLayout = .null_handle,
|
||||
render_pass: vk.RenderPass = .null_handle,
|
||||
subpass: u32,
|
||||
view_mask: u32,
|
||||
color_attachment_formats: []const vk.Format = &.{},
|
||||
depth_attachment_format: vk.Format = .undefined,
|
||||
stencil_attachment_format: vk.Format = .undefined,
|
||||
base_pipeline_handle: vk.Pipeline = .null_handle,
|
||||
};
|
||||
|
||||
@@ -1066,19 +1059,6 @@ pub fn createFence(self: *Engine, create_info: vk.FenceCreateInfo) !vk.Fence {
|
||||
return fence;
|
||||
}
|
||||
|
||||
pub fn createFramebuffer(self: *Engine, create_info: FramebufferCreateInfo) !vk.Framebuffer {
|
||||
const framebuffer = try self.device.createFramebuffer(&.{
|
||||
.flags = create_info.flags,
|
||||
.render_pass = create_info.render_pass,
|
||||
.attachment_count = @intCast(create_info.attachments.len),
|
||||
.p_attachments = create_info.attachments.ptr,
|
||||
.width = create_info.width,
|
||||
.height = create_info.height,
|
||||
.layers = create_info.layers,
|
||||
}, &self.vk_allocator.interface);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
pub fn createGraphicsPipeline(self: *Engine, create_info: GraphicsPipelineCreateInfo) !vk.Pipeline {
|
||||
var arena = self.makeArena();
|
||||
defer arena.deinit();
|
||||
@@ -1108,8 +1088,17 @@ pub fn createGraphicsPipeline(self: *Engine, create_info: GraphicsPipelineCreate
|
||||
};
|
||||
}
|
||||
|
||||
const pipeline_rendering_create_info: vk.PipelineRenderingCreateInfo = .{
|
||||
.view_mask = create_info.view_mask,
|
||||
.color_attachment_count = @intCast(create_info.color_attachment_formats.len),
|
||||
.p_color_attachment_formats = create_info.color_attachment_formats.ptr,
|
||||
.depth_attachment_format = create_info.depth_attachment_format,
|
||||
.stencil_attachment_format = create_info.stencil_attachment_format,
|
||||
};
|
||||
|
||||
const graphics_pipeline_create_infos = [_]vk.GraphicsPipelineCreateInfo{
|
||||
.{
|
||||
.p_next = &pipeline_rendering_create_info,
|
||||
.flags = create_info.flags,
|
||||
.stage_count = @intCast(stages.len),
|
||||
.p_stages = stages.ptr,
|
||||
@@ -1146,8 +1135,7 @@ pub fn createGraphicsPipeline(self: *Engine, create_info: GraphicsPipelineCreate
|
||||
.p_dynamic_states = dynamic_state.dynamic_states.ptr,
|
||||
} else null,
|
||||
.layout = create_info.layout,
|
||||
.render_pass = create_info.render_pass,
|
||||
.subpass = create_info.subpass,
|
||||
.subpass = 0,
|
||||
.base_pipeline_handle = create_info.base_pipeline_handle,
|
||||
.base_pipeline_index = -1,
|
||||
},
|
||||
@@ -1211,39 +1199,6 @@ pub fn createPipelineLayout(self: *Engine, create_info: PipelineLayoutCreateInfo
|
||||
return pipeline_layout;
|
||||
}
|
||||
|
||||
pub fn createRenderPass(self: *Engine, create_info: RenderPassCreateInfo) !vk.RenderPass {
|
||||
var arena = self.makeArena();
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const subpasses = try allocator.alloc(vk.SubpassDescription, create_info.subpasses.len);
|
||||
for (subpasses, create_info.subpasses) |*x, *subpass| {
|
||||
x.* = .{
|
||||
.flags = subpass.flags,
|
||||
.pipeline_bind_point = subpass.pipeline_bind_point,
|
||||
.input_attachment_count = @intCast(subpass.input_attachments.len),
|
||||
.p_input_attachments = subpass.input_attachments.ptr,
|
||||
.color_attachment_count = @intCast(subpass.color_attachments.len),
|
||||
.p_color_attachments = subpass.color_attachments.ptr,
|
||||
.p_resolve_attachments = if (subpass.resolve_attachments) |resolve_attachments| resolve_attachments.ptr else null,
|
||||
.p_depth_stencil_attachment = if (subpass.depth_stencil_attachment) |*y| y else null,
|
||||
.preserve_attachment_count = @intCast(subpass.preserve_attachments.len),
|
||||
.p_preserve_attachments = subpass.preserve_attachments.ptr,
|
||||
};
|
||||
}
|
||||
|
||||
const render_pass = try self.device.createRenderPass(&.{
|
||||
.flags = create_info.flags,
|
||||
.attachment_count = @intCast(create_info.attachments.len),
|
||||
.p_attachments = create_info.attachments.ptr,
|
||||
.subpass_count = @intCast(subpasses.len),
|
||||
.p_subpasses = subpasses.ptr,
|
||||
.dependency_count = @intCast(create_info.dependencies.len),
|
||||
.p_dependencies = create_info.dependencies.ptr,
|
||||
}, &self.vk_allocator.interface);
|
||||
return render_pass;
|
||||
}
|
||||
|
||||
pub fn createSampler(self: *Engine, create_info: vk.SamplerCreateInfo) !vk.Sampler {
|
||||
const sampler = try self.device.createSampler(&create_info, &self.vk_allocator.interface);
|
||||
return sampler;
|
||||
@@ -1312,10 +1267,6 @@ pub fn destroyFence(self: *Engine, fence: vk.Fence) void {
|
||||
self.device.destroyFence(fence, &self.vk_allocator.interface);
|
||||
}
|
||||
|
||||
pub fn destroyFramebuffer(self: *Engine, framebuffer: vk.Framebuffer) void {
|
||||
self.device.destroyFramebuffer(framebuffer, &self.vk_allocator.interface);
|
||||
}
|
||||
|
||||
pub fn destroyImage(self: *Engine, image: vk.Image) void {
|
||||
self.device.destroyImage(image, &self.vk_allocator.interface);
|
||||
}
|
||||
@@ -1332,10 +1283,6 @@ pub fn destroyPipelineLayout(self: *Engine, pipeline_layout: vk.PipelineLayout)
|
||||
self.device.destroyPipelineLayout(pipeline_layout, &self.vk_allocator.interface);
|
||||
}
|
||||
|
||||
pub fn destroyRenderPass(self: *Engine, render_pass: vk.RenderPass) void {
|
||||
self.device.destroyRenderPass(render_pass, &self.vk_allocator.interface);
|
||||
}
|
||||
|
||||
pub fn destroySampler(self: *Engine, sampler: vk.Sampler) void {
|
||||
self.device.destroySampler(sampler, &self.vk_allocator.interface);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user