Vertical movement, deinit logs, persistent global uniform transfers
This commit is contained in:
@@ -71,6 +71,8 @@ pub fn init(engine: *Engine) !Swapchain {
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Swapchain, engine: *Engine) void {
|
||||
std.log.debug("Deinitializing {*} with {*}", .{ self, engine });
|
||||
|
||||
const allocator = engine.vk_allocator.allocator;
|
||||
|
||||
for (self.swapchain_images) |swapchain_image| {
|
||||
@@ -197,7 +199,18 @@ pub fn recreate(self: *Swapchain, engine: *Engine) !void {
|
||||
self.semaphore_image_acquired = semaphore_image_acquired;
|
||||
}
|
||||
|
||||
pub fn present(self: *Swapchain, engine: *Engine, command_buffer: vk.CommandBuffer) !PresentResult {
|
||||
pub const WaitSemaphore = struct {
|
||||
semaphore: vk.Semaphore,
|
||||
stage_flags: vk.PipelineStageFlags = .{ .top_of_pipe_bit = true },
|
||||
};
|
||||
|
||||
pub const PresentInfo = struct {
|
||||
command_buffer: vk.CommandBuffer,
|
||||
wait_semaphores: []const WaitSemaphore,
|
||||
};
|
||||
|
||||
pub fn present(self: *Swapchain, engine: *Engine, present_info: PresentInfo) !PresentResult {
|
||||
const allocator = engine.vk_allocator.allocator;
|
||||
const device = engine.device;
|
||||
const mode = &engine.mode.surface;
|
||||
|
||||
@@ -213,28 +226,30 @@ pub fn present(self: *Swapchain, engine: *Engine, command_buffer: vk.CommandBuff
|
||||
|
||||
// --- SUBMIT COMMAND BUFFER -----------------------------------------------
|
||||
|
||||
const wait_semaphores = [_]vk.Semaphore{
|
||||
current_swapchain_image.semaphore_image_acquired,
|
||||
};
|
||||
var wait_semaphores = std.MultiArrayList(WaitSemaphore){};
|
||||
defer wait_semaphores.deinit(allocator);
|
||||
try wait_semaphores.ensureTotalCapacity(allocator, 1 + present_info.wait_semaphores.len);
|
||||
|
||||
const pipeline_stages_flags = [_]vk.PipelineStageFlags{
|
||||
.{ .top_of_pipe_bit = true },
|
||||
};
|
||||
|
||||
std.debug.assert(wait_semaphores.len == pipeline_stages_flags.len);
|
||||
wait_semaphores.appendAssumeCapacity(.{
|
||||
.semaphore = current_swapchain_image.semaphore_image_acquired,
|
||||
.stage_flags = .{ .top_of_pipe_bit = true },
|
||||
});
|
||||
for (present_info.wait_semaphores) |wait_semaphore| {
|
||||
wait_semaphores.appendAssumeCapacity(wait_semaphore);
|
||||
}
|
||||
|
||||
const signal_semaphores = [_]vk.Semaphore{
|
||||
current_swapchain_image.semaphore_render_finished,
|
||||
};
|
||||
|
||||
current_swapchain_image.command_buffer = command_buffer;
|
||||
current_swapchain_image.command_buffer = present_info.command_buffer;
|
||||
try device.queueSubmit(engine.graphics_queue.handle, 1, &.{
|
||||
.{
|
||||
.wait_semaphore_count = wait_semaphores.len,
|
||||
.p_wait_semaphores = &wait_semaphores,
|
||||
.p_wait_dst_stage_mask = &pipeline_stages_flags,
|
||||
.wait_semaphore_count = @intCast(wait_semaphores.len),
|
||||
.p_wait_semaphores = wait_semaphores.items(.semaphore).ptr,
|
||||
.p_wait_dst_stage_mask = wait_semaphores.items(.stage_flags).ptr,
|
||||
.command_buffer_count = 1,
|
||||
.p_command_buffers = @ptrCast(&command_buffer),
|
||||
.p_command_buffers = @ptrCast(&present_info.command_buffer),
|
||||
.signal_semaphore_count = signal_semaphores.len,
|
||||
.p_signal_semaphores = &signal_semaphores,
|
||||
},
|
||||
@@ -393,6 +408,8 @@ const SwapchainImage = struct {
|
||||
}
|
||||
|
||||
fn deinit(self: SwapchainImage, engine: *Engine) void {
|
||||
std.log.debug("Deinitializing {*} with {*}", .{ &self, engine });
|
||||
|
||||
engine.waitForFence(self.fence) catch {};
|
||||
engine.destroyFramebuffer(self.framebuffer);
|
||||
engine.destroyFence(self.fence);
|
||||
|
||||
Reference in New Issue
Block a user