Bad resize logic
This commit is contained in:
20
src/Game.zig
20
src/Game.zig
@@ -855,6 +855,10 @@ pub fn onMouseUp(self: *Game, button: glfw.MouseButton, mods: glfw.Mods) void {
|
||||
}
|
||||
|
||||
fn render(self: *Game) !void {
|
||||
if (self.swapchain.swapchain == .null_handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
const extent = self.swapchain.extent;
|
||||
|
||||
const command_buffer: CommandBuffer(.graphics, .transient) = try .init(self.engine);
|
||||
@@ -928,5 +932,19 @@ fn render(self: *Game) !void {
|
||||
},
|
||||
});
|
||||
|
||||
_ = res;
|
||||
if (res == .suboptimal) {
|
||||
try self.recreateSwapchain();
|
||||
}
|
||||
}
|
||||
|
||||
fn recreateSwapchain(self: *Game) !void {
|
||||
self.swapchain.recreate(self.engine) catch |err| switch (err) {
|
||||
error.OutOfDateKHR => return self.recreateSwapchain(),
|
||||
else => return err,
|
||||
};
|
||||
for (self.global_uniforms_transfer_semaphores, 0..) |*semaphore, i| {
|
||||
self.engine.destroySemaphore(semaphore.*);
|
||||
semaphore.* = try self.engine.createSemaphore();
|
||||
self.engine.setObjectName(semaphore.*, "S Transfer[{d}]", .{i});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,17 +310,23 @@ pub fn present(self: *Swapchain, engine: *Engine, present_info: PresentInfo) !Pr
|
||||
|
||||
// --- PRESENT CURRENT FRAME -----------------------------------------------
|
||||
|
||||
_ = try device.queuePresentKHR(mode.presentation_queue.handle, &.{
|
||||
_ = device.queuePresentKHR(mode.presentation_queue.handle, &.{
|
||||
.wait_semaphore_count = 1,
|
||||
.p_wait_semaphores = @ptrCast(¤t_swapchain_image.semaphore_render_finished),
|
||||
.swapchain_count = 1,
|
||||
.p_swapchains = @ptrCast(&self.swapchain),
|
||||
.p_image_indices = @ptrCast(&self.image_index),
|
||||
});
|
||||
}) catch |err| switch (err) {
|
||||
error.OutOfDateKHR => return .suboptimal,
|
||||
else => return err,
|
||||
};
|
||||
|
||||
// --- ACQUIRE NEXT FRAME --------------------------------------------------
|
||||
|
||||
const res = try device.acquireNextImageKHR(self.swapchain, std.math.maxInt(u64), self.semaphore_image_acquired, .null_handle);
|
||||
const res = device.acquireNextImageKHR(self.swapchain, std.math.maxInt(u64), self.semaphore_image_acquired, .null_handle) catch |err| switch (err) {
|
||||
error.OutOfDateKHR => return .suboptimal,
|
||||
else => return err,
|
||||
};
|
||||
std.mem.swap(vk.Semaphore, &self.swapchain_images[res.image_index].semaphore_image_acquired, &self.semaphore_image_acquired);
|
||||
self.image_index = res.image_index;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user