Skip to content

Commit d19307d

Browse files
committed
exp/gpu fence impl
1 parent e46ccaf commit d19307d

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/main/java/git/artdeell/artvk/Vk11CommandEncoder.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,25 @@ public void copyTextureToTexture(
594594
}
595595
}
596596

597+
public int getPreviousFrameIndex(int past) {
598+
return Math.floorMod(currentSubmitIndex - past, MAX_SUBMITS_IN_FLIGHT);
599+
}
600+
597601
@Override
598602
public @NotNull GpuFence createFence() {
599603
return new GpuFence() {
600-
// Don't gaf
601-
// Maybe TODO: implement fence for previous frame's submit
604+
private boolean completed = false;
605+
private final long lastFence = frameFences[getPreviousFrameIndex(1)].vkFence();
602606
@Override
603-
public void close() {}
607+
public void close() {
608+
completed = true;
609+
}
604610

605611
@Override
606612
public boolean awaitCompletion(long timeoutNS) {
613+
if(completed) return true;
614+
waitForFences(lastFence);
615+
completed = true;
607616
return true;
608617
}
609618
};

0 commit comments

Comments
 (0)