Skip to content

Commit

Permalink
Refactor: remove wait fences for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
xCollateral committed Jul 26, 2024
1 parent 32c37c1 commit 11e7a8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/vulkanmod/vulkan/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ private void submitFrame() {

submitInfo.pCommandBuffers(stack.pointers(currentCmdBuffer));

vkResetFences(device, stack.longs(inFlightFences.get(currentFrame)));
vkResetFences(device, inFlightFences.get(currentFrame));

Synchronization.INSTANCE.waitFences();

if ((vkResult = vkQueueSubmit(DeviceManager.getGraphicsQueue().queue(), submitInfo, inFlightFences.get(currentFrame))) != VK_SUCCESS) {
vkResetFences(device, stack.longs(inFlightFences.get(currentFrame)));
vkResetFences(device, inFlightFences.get(currentFrame));
throw new RuntimeException("Failed to submit draw command buffer: %s".formatted(VkResult.decode(vkResult)));
}

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/vulkanmod/vulkan/Synchronization.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ public synchronized void addFence(long fence) {
}

public synchronized void waitFences() {

if (idx == 0) return;
if (idx == 0)
return;

VkDevice device = Vulkan.getVkDevice();

fences.limit(idx);

for (int i = 0; i < idx; i++) {
vkWaitForFences(device, fences.get(i), true, VUtil.UINT64_MAX);
}
vkWaitForFences(device, fences, true, VUtil.UINT64_MAX);

this.commandBuffers.forEach(CommandPool.CommandBuffer::reset);
this.commandBuffers.clear();
Expand Down

0 comments on commit 11e7a8f

Please sign in to comment.