Skip to content

Commit d2f420a

Browse files
committed
Advance buffer manager frame in beginFrame
Synchronize the buffer manager's frame at the start of each frame for staging synchronization. Calls buffer_manager.beginFrame with the current frame fence and logs a warning on error. This prevents untracked staging ring fences and subsequent GPU hangs (e.g. VK_ERROR_DEVICE_LOST -> SwapchainAcquireFailed).
1 parent 916cba6 commit d2f420a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/client/world/ChunkManager.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,16 @@ pub const ChunkManager = struct {
556556
pub fn beginFrame(self: *Self) void {
557557
// Synchronize slot allocator's frame counter
558558
self.render_system.advanceSlotAllocatorFrame();
559+
560+
// CRITICAL: Advance buffer manager's frame for staging synchronization
561+
// Without this, staging ring fences aren't tracked and buffer reuse
562+
// causes GPU hangs (VK_ERROR_DEVICE_LOST -> SwapchainAcquireFailed)
563+
if (self.buffer_manager) |buf_mgr| {
564+
const frame_fence = self.render_system.getCurrentFrameFence();
565+
buf_mgr.beginFrame(frame_fence) catch |err| {
566+
logger.warn("Failed to begin frame for buffer manager: {}", .{err});
567+
};
568+
}
559569
}
560570

561571
fn processCompletedTerrain(self: *Self) void {

0 commit comments

Comments
 (0)