Skip to content

Commit

Permalink
Fix deadlock when resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjglgamedev committed Jan 20, 2024
1 parent 0a1b384 commit 6a0addb
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bookcontents/chapter-05/chapter-05.md
Original file line number Diff line number Diff line change
Expand Up @@ -813,12 +813,11 @@ public class ForwardRenderActivity {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
...
}
```
We just invoke the `fenceWait` and the `reset` on the frame associated to current swap chain image, to prevent acquiring an image, using a semaphore that has not been signaled, that is, previous operations have not finished.
We just invoke the `fenceWait` on the frame associated to current swap chain image, to prevent acquiring an image, using a semaphore that has not been signaled, that is, previous operations have not finished.

The definition of the `recordCommandBuffer` is:
```java
Expand Down Expand Up @@ -863,6 +862,7 @@ public class ForwardRenderActivity {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down
2 changes: 1 addition & 1 deletion bookcontents/chapter-10/chapter-10.md
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ public class GeometryRenderActivity {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand All @@ -676,7 +677,6 @@ public class GeometryRenderActivity {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
...
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public void submit(Queue queue) {
try (MemoryStack stack = MemoryStack.stackPush()) {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.reset();
CommandBuffer commandBuffer = commandBuffers[idx];
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
Expand All @@ -88,6 +89,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand All @@ -157,6 +158,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand All @@ -217,6 +218,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand All @@ -271,6 +272,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -335,6 +336,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -319,6 +320,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -332,6 +333,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -332,6 +333,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -339,6 +340,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -359,6 +360,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public void submit(Queue queue) {
int idx = swapChain.getCurrentFrame();
CommandBuffer commandBuffer = commandBuffers[idx];
Fence currentFence = fences[idx];
currentFence.reset();
SwapChain.SyncSemaphores syncSemaphores = swapChain.getSyncSemaphoresList()[idx];
queue.submit(stack.pointers(commandBuffer.getVkCommandBuffer()),
stack.longs(syncSemaphores.imgAcquisitionSemaphore().getVkSemaphore()),
Expand Down Expand Up @@ -359,6 +360,5 @@ public void waitForFence() {
int idx = swapChain.getCurrentFrame();
Fence currentFence = fences[idx];
currentFence.fenceWait();
currentFence.reset();
}
}

0 comments on commit 6a0addb

Please sign in to comment.