Skip to content

Commit

Permalink
Fix upload corruption on altered execution flow
Browse files Browse the repository at this point in the history
  • Loading branch information
xCollateral committed Apr 25, 2024
1 parent 1b68d5e commit a0e6c2d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/net/vulkanmod/vulkan/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static int getCurrentImage() {

private static int currentFrame = 0;
private static int imageIndex;
private static int lastReset = -1;
private VkCommandBuffer currentCmdBuffer;
private boolean recordingCmds = false;

Expand Down Expand Up @@ -362,6 +363,13 @@ public void preInitFrame() {
p.round();
p.push("Frame_ops");

// runTick might be called recursively,
// this check forces sync to avoid upload corruption
if (lastReset == currentFrame) {
Synchronization.INSTANCE.waitFences();
}
lastReset = currentFrame;

drawer.resetBuffers(currentFrame);

Vulkan.getStagingBuffer().reset();
Expand Down

0 comments on commit a0e6c2d

Please sign in to comment.