diff --git a/src/Game.zig b/src/Game.zig index ac5a684..b813c04 100644 --- a/src/Game.zig +++ b/src/Game.zig @@ -22,6 +22,7 @@ const Player = @import("Player.zig"); const Skybox = @import("engine/Skybox.zig"); const StagingBuffer = @import("engine/StagingBuffer.zig"); const Swapchain = @import("engine/Swapchain.zig"); +const Texture = @import("engine/Texture.zig"); const Textures = @import("assets/Textures.zig"); allocator: std.mem.Allocator, @@ -401,8 +402,10 @@ pub fn init(allocator: std.mem.Allocator, io: std.Io, engine: *Engine, swapchain .dynamic_states = &.{ .viewport, .scissor }, }, .layout = pipeline_layout, - .render_pass = swapchain.render_pass, - .subpass = 0, + .view_mask = 0, + .color_attachment_formats = &.{swapchain.params.surface_format.format}, + .depth_attachment_format = Texture.Usage.depth.vkFormat(), + .stencil_attachment_format = .undefined, }); errdefer engine.destroyPipeline(pipeline); engine.setObjectName(pipeline, "P Main", .{}); @@ -638,10 +641,10 @@ pub fn init(allocator: std.mem.Allocator, io: std.Io, engine: *Engine, swapchain var skybox = try Skybox.load( "skybox.hdr", engine, + swapchain, &stbi, 512, global_uniforms.buffer, - swapchain.render_pass, allocator, io, ); @@ -650,8 +653,8 @@ pub fn init(allocator: std.mem.Allocator, io: std.Io, engine: *Engine, swapchain var gui = try Gui.init( allocator, engine, + swapchain, global_uniforms.buffer, - swapchain.render_pass, ); errdefer gui.deinit(engine, allocator); @@ -896,28 +899,94 @@ fn render(self: *Game) !void { try command_buffer.beginCommandBuffer(); { - command_buffer.beginRenderPass(.{ - .render_pass = self.swapchain.render_pass, - .framebuffer = self.swapchain.swapchain_images[self.swapchain.image_index.?].framebuffer, + const swapchain_image = &self.swapchain.swapchain_images[self.swapchain.image_index.?]; + + command_buffer.pipelineBarrier(.{ + .src_stage_mask = .{ .color_attachment_output_bit = true }, + .dst_stage_mask = .{ .color_attachment_output_bit = true }, + .image_memory_barriers = &.{ + .{ + .src_access_mask = .{}, + .dst_access_mask = .{ + .color_attachment_read_bit = true, + .color_attachment_write_bit = true, + }, + .old_layout = .undefined, + .new_layout = .color_attachment_optimal, + .src_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .dst_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .image = swapchain_image.image, + .subresource_range = .{ + .aspect_mask = .{ .color_bit = true }, + .base_mip_level = 0, + .level_count = 1, + .base_array_layer = 0, + .layer_count = 1, + }, + }, + }, + }); + + command_buffer.pipelineBarrier(.{ + .src_stage_mask = .{ .late_fragment_tests_bit = true }, + .dst_stage_mask = .{ .early_fragment_tests_bit = true }, + .image_memory_barriers = &.{ + .{ + .src_access_mask = .{ + .depth_stencil_attachment_write_bit = true, + }, + .dst_access_mask = .{ + .depth_stencil_attachment_write_bit = true, + }, + .old_layout = .undefined, + .new_layout = .depth_stencil_attachment_optimal, + .src_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .dst_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .image = self.swapchain.depth_texture.?.image, + .subresource_range = .{ + .aspect_mask = .{ .depth_bit = true }, + .base_mip_level = 0, + .level_count = 1, + .base_array_layer = 0, + .layer_count = 1, + }, + }, + }, + }); + + try command_buffer.beginRendering(.{ .render_area = .{ .offset = .{ .x = 0, .y = 0 }, .extent = extent, }, - .clear_values = &.{ + .layer_count = 1, + .view_mask = 0, + .color_attachments = &.{ .{ - .color = .{ - .float_32 = .{ 0, 0, 0, 0 }, + .image_view = swapchain_image.image_view, + .image_layout = .color_attachment_optimal, + .load_op = .clear, + .store_op = .store, + .clear_value = .{ + .color = .{ + .float_32 = .{ 0, 0, 0, 0 }, + }, }, }, - .{ + }, + .depth_attachment = .{ + .image_view = self.swapchain.depth_texture.?.image_view, + .image_layout = .depth_attachment_optimal, + .load_op = .clear, + .store_op = .dont_care, + .clear_value = .{ .depth_stencil = .{ .depth = 0, .stencil = 0, }, }, }, - }, .@"inline"); - defer command_buffer.endRenderPass(); + }); command_buffer.setViewport(0, &.{ .{ @@ -936,7 +1005,7 @@ fn render(self: *Game) !void { }, }); - // --- SUBPASS 0 (MAIN) --- + // --- RENDER 3D SCENE --- command_buffer.bindPipeline(.graphics, self.pipeline); try command_buffer.bindVertexBuffers(0, &.{ @@ -955,11 +1024,35 @@ fn render(self: *Game) !void { try self.skybox.draw(command_buffer); - // --- SUBPASS 1 (GUI) --- - - command_buffer.nextSubpass(.@"inline"); + // --- RENDER GUI --- try self.gui.draw(self.engine, command_buffer); + + // --- FINALIZE --- + + command_buffer.endRendering(); + command_buffer.pipelineBarrier(.{ + .src_stage_mask = .{ .color_attachment_output_bit = true }, + .dst_stage_mask = .{ .bottom_of_pipe_bit = true }, + .image_memory_barriers = &.{ + .{ + .src_access_mask = .{ .color_attachment_write_bit = true }, + .dst_access_mask = .{}, + .old_layout = .color_attachment_optimal, + .new_layout = .present_src_khr, + .src_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .dst_queue_family_index = vk.QUEUE_FAMILY_IGNORED, + .image = swapchain_image.image, + .subresource_range = .{ + .aspect_mask = .{ .color_bit = true }, + .base_mip_level = 0, + .level_count = 1, + .base_array_layer = 0, + .layer_count = 1, + }, + }, + }, + }); } try command_buffer.endCommandBuffer(); diff --git a/src/Gui.zig b/src/Gui.zig index 30743e6..9741aa2 100644 --- a/src/Gui.zig +++ b/src/Gui.zig @@ -9,6 +9,7 @@ const CommandBuffer = @import("engine/CommandBuffer.zig"); const Engine = @import("engine/Engine.zig"); const GenericBuffer = @import("engine/GenericBuffer.zig").GenericBuffer; const Swapchain = @import("engine/Swapchain.zig"); +const Texture = @import("engine/Texture.zig"); const Textures = @import("assets/Textures.zig"); pub const Draw = struct { @@ -75,8 +76,8 @@ pub const max_batches = 1024; pub fn init( allocator: std.mem.Allocator, engine: *Engine, + swapchain: *Swapchain, global_uniforms_buffer: vk.Buffer, - render_pass: vk.RenderPass, ) !Gui { var box_gpu_buffer: GenericBuffer(void, Draw.Box) = try .init(engine, .{ .usage = .storage, @@ -220,6 +221,33 @@ pub fn init( .alpha_to_coverage_enable = .false, .alpha_to_one_enable = .false, }, + .depth_stencil_state = .{ + .depth_test_enable = .false, + .depth_write_enable = .false, + .depth_compare_op = .always, + .depth_bounds_test_enable = .false, + .stencil_test_enable = .false, + .front = .{ + .fail_op = .keep, + .pass_op = .keep, + .depth_fail_op = .keep, + .compare_op = .never, + .compare_mask = 0, + .write_mask = 0, + .reference = 0, + }, + .back = .{ + .fail_op = .keep, + .pass_op = .keep, + .depth_fail_op = .keep, + .compare_op = .never, + .compare_mask = 0, + .write_mask = 0, + .reference = 0, + }, + .min_depth_bounds = 0, + .max_depth_bounds = 1, + }, .color_blend_state = .{ .logic_op_enable = .false, .logic_op = .copy, @@ -246,8 +274,10 @@ pub fn init( .dynamic_states = &.{ .viewport, .scissor }, }, .layout = box_pipeline_layout, - .render_pass = render_pass, - .subpass = 1, + .view_mask = 0, + .color_attachment_formats = &.{swapchain.params.surface_format.format}, + .depth_attachment_format = Texture.Usage.depth.vkFormat(), + .stencil_attachment_format = .undefined, }); errdefer engine.destroyPipeline(box_pipeline); engine.setObjectName(box_pipeline, "P GUI Box", .{}); diff --git a/src/engine/CommandBuffer.zig b/src/engine/CommandBuffer.zig index 8b5c09c..69473b3 100644 --- a/src/engine/CommandBuffer.zig +++ b/src/engine/CommandBuffer.zig @@ -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( diff --git a/src/engine/Engine.zig b/src/engine/Engine.zig index 9ccb3a9..f22b351 100644 --- a/src/engine/Engine.zig +++ b/src/engine/Engine.zig @@ -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); } diff --git a/src/engine/Skybox.zig b/src/engine/Skybox.zig index f8e6bec..9705e4c 100644 --- a/src/engine/Skybox.zig +++ b/src/engine/Skybox.zig @@ -10,6 +10,8 @@ const CommandBuffer = @import("CommandBuffer.zig"); const Engine = @import("Engine.zig"); const GenericBuffer = @import("GenericBuffer.zig").GenericBuffer; const StagingBuffer = @import("StagingBuffer.zig"); +const Swapchain = @import("Swapchain.zig"); +const Texture = @import("Texture.zig"); image: vk.Image, image_view: vk.ImageView, @@ -28,10 +30,10 @@ pipeline: vk.Pipeline, pub fn load( filename: []const u8, engine: *Engine, + swapchain: *Swapchain, stbi: *media.stbi, cube_size: u32, global_uniforms_buffer: vk.Buffer, - render_pass: vk.RenderPass, temp_allocator: std.mem.Allocator, io: std.Io, ) !Skybox { @@ -735,8 +737,10 @@ pub fn load( .dynamic_states = &.{ .viewport, .scissor }, }, .layout = pipeline_layout, - .render_pass = render_pass, - .subpass = 0, + .view_mask = 0, + .color_attachment_formats = &.{swapchain.params.surface_format.format}, + .depth_attachment_format = Texture.Usage.depth.vkFormat(), + .stencil_attachment_format = .undefined, }); return .{ diff --git a/src/engine/Swapchain.zig b/src/engine/Swapchain.zig index 112de43..638eaf7 100644 --- a/src/engine/Swapchain.zig +++ b/src/engine/Swapchain.zig @@ -10,7 +10,6 @@ const Texture = @import("Texture.zig"); const WaitSemaphore = @import("WaitSemaphore.zig"); params: Params, -render_pass: vk.RenderPass, extent: vk.Extent2D = .{ .width = 0, .height = 0 }, swapchain: vk.SwapchainKHR = .null_handle, @@ -27,106 +26,8 @@ pub const PresentResult = enum { pub fn init(engine: *Engine) !Swapchain { const params: Params = try .init(engine); - - const render_pass = try engine.createRenderPass(.{ - .attachments = &.{ - .{ - .format = params.surface_format.format, - .samples = .{ .@"1_bit" = true }, - .load_op = .clear, - .store_op = .store, - .stencil_load_op = .dont_care, - .stencil_store_op = .dont_care, - .initial_layout = .undefined, - .final_layout = .present_src_khr, - }, - .{ - .format = Texture.Usage.depth.vkFormat(), - .samples = .{ .@"1_bit" = true }, - .load_op = .clear, - .store_op = .dont_care, - .stencil_load_op = .clear, - .stencil_store_op = .dont_care, - .initial_layout = .undefined, - .final_layout = .depth_stencil_attachment_optimal, - }, - }, - .subpasses = &.{ - // Main - .{ - .pipeline_bind_point = .graphics, - .color_attachments = &.{ - .{ - .attachment = 0, - .layout = .color_attachment_optimal, - }, - }, - .depth_stencil_attachment = .{ - .attachment = 1, - .layout = .depth_stencil_attachment_optimal, - }, - }, - // GUI - .{ - .pipeline_bind_point = .graphics, - .color_attachments = &.{ - .{ - .attachment = 0, - .layout = .color_attachment_optimal, - }, - }, - }, - }, - .dependencies = &.{ - .{ - .src_subpass = 0, - .dst_subpass = 0, - .src_stage_mask = .{ - .color_attachment_output_bit = true, - .late_fragment_tests_bit = true, - }, - .dst_stage_mask = .{ - .color_attachment_output_bit = true, - .early_fragment_tests_bit = true, - }, - .src_access_mask = .{ - .depth_stencil_attachment_write_bit = true, - }, - .dst_access_mask = .{ - .color_attachment_write_bit = true, - .depth_stencil_attachment_write_bit = true, - }, - .dependency_flags = .{ - .by_region_bit = true, - }, - }, - .{ - .src_subpass = 0, - .dst_subpass = 1, - .src_stage_mask = .{ - .color_attachment_output_bit = true, - }, - .dst_stage_mask = .{ - .color_attachment_output_bit = true, - }, - .src_access_mask = .{ - .color_attachment_write_bit = true, - }, - .dst_access_mask = .{ - .color_attachment_write_bit = true, - }, - .dependency_flags = .{ - .by_region_bit = true, - }, - }, - }, - }); - errdefer engine.destroyRenderPass(render_pass); - engine.setObjectName(render_pass, "RP", .{}); - var swapchain: Swapchain = .{ .params = params, - .render_pass = render_pass, }; try recreate(&swapchain, engine); @@ -151,7 +52,6 @@ pub fn deinit(self: *Swapchain, engine: *Engine) void { engine.destroySwapchain(self.swapchain); } - engine.destroyRenderPass(self.render_pass); engine.destroySemaphore(self.semaphore_image_acquired); engine.destroyFence(self.fence); @@ -258,7 +158,6 @@ pub fn recreate(self: *Swapchain, engine: *Engine) !void { swapchain_images.appendAssumeCapacity(try SwapchainImage.init(engine, .{ .image = image, .format = self.params.surface_format.format, - .render_pass = self.render_pass, .extent = extent, .depth_stencil_image_view = new_depth_texture.image_view, .index = index, @@ -414,12 +313,10 @@ const SwapchainImage = struct { image_view: vk.ImageView, semaphore_image_acquired: vk.Semaphore, semaphore_render_finished: vk.Semaphore, - framebuffer: vk.Framebuffer, const InitProps = struct { image: vk.Image, format: vk.Format, - render_pass: vk.RenderPass, extent: vk.Extent2D, depth_stencil_image_view: vk.ImageView, @@ -450,29 +347,17 @@ const SwapchainImage = struct { errdefer engine.destroySemaphore(semaphore_render_finished); engine.setObjectName(image_view, "S Rendered[{d}]", .{props.index}); - const framebuffer = try engine.createFramebuffer(.{ - .render_pass = props.render_pass, - .attachments = &.{ image_view, props.depth_stencil_image_view }, - .width = props.extent.width, - .height = props.extent.height, - .layers = 1, - }); - errdefer engine.destroyFramebuffer(framebuffer); - engine.setObjectName(image_view, "FB Swapchain[{d}]", .{props.index}); - return .{ .image = props.image, .image_view = image_view, .semaphore_image_acquired = semaphore_image_acquired, .semaphore_render_finished = semaphore_render_finished, - .framebuffer = framebuffer, }; } fn deinit(self: *SwapchainImage, engine: *Engine) void { std.log.scoped(.deinit).debug("Deinitializing {*} with {*}", .{ self, engine }); - engine.destroyFramebuffer(self.framebuffer); engine.destroySemaphore(self.semaphore_render_finished); engine.destroySemaphore(self.semaphore_image_acquired); engine.destroyImageView(self.image_view);