Skip to content

Commit 11e7a8f

Browse files
committed
Refactor: remove wait fences for loop
1 parent 32c37c1 commit 11e7a8f

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/main/java/net/vulkanmod/vulkan/Renderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ private void submitFrame() {
299299

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

302-
vkResetFences(device, stack.longs(inFlightFences.get(currentFrame)));
302+
vkResetFences(device, inFlightFences.get(currentFrame));
303303

304304
Synchronization.INSTANCE.waitFences();
305305

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

src/main/java/net/vulkanmod/vulkan/Synchronization.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ public synchronized void addFence(long fence) {
3838
}
3939

4040
public synchronized void waitFences() {
41-
42-
if (idx == 0) return;
41+
if (idx == 0)
42+
return;
4343

4444
VkDevice device = Vulkan.getVkDevice();
4545

4646
fences.limit(idx);
4747

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

5250
this.commandBuffers.forEach(CommandPool.CommandBuffer::reset);
5351
this.commandBuffers.clear();

0 commit comments

Comments
 (0)