You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03_Drawing_a_triangle/01_Presentation/01_Swap_chain.md
+13-16Lines changed: 13 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -409,23 +409,26 @@ void createSwapChain() {
409
409
}
410
410
```
411
411
412
-
Now, there is actually one more small thing that need to be decided upon, but it's
413
-
so simple that it's not really worth creating a separate function for. That is
414
-
deciding the number of images in the swap chain, essentially the queue
415
-
length. The implementation specifies the minimum amount of images to function
416
-
properly and we'll try to have one more than that to properly implement triple
417
-
buffering.
412
+
Aside from these properties we also have to decide how many images we would like to have in the swap chain. The implementation specifies the minimum number that it requires to function:
However, simply sticking to this minimum means that we may sometimes have to wait on the driver to complete internal operations before we can acquire another image to render to. Therefore it is recommended to request at least one more image than the minimum:
We should also make sure to not exceed the maximum number of images while doing this, where `0` is a special value that means that there is no maximum:
425
+
426
+
```c++
421
427
if (swapChainSupport.capabilities.maxImageCount > 0 && imageCount > swapChainSupport.capabilities.maxImageCount) {
A value of `0` for `maxImageCount` means that there is no limit besides memory
427
-
requirements, which is why we need to check for that.
428
-
429
432
As is tradition with Vulkan objects, creating the swap chain object requires
430
433
filling in a large structure. It starts out very familiarly:
431
434
@@ -583,9 +586,7 @@ don't need to add any cleanup code.
583
586
584
587
I'm adding the code to retrieve the handles to the end of the `createSwapChain`
585
588
function, right after the `vkCreateSwapchainKHR` call. Retrieving them is very
586
-
similar to the other times where we retrieved an array of objects from Vulkan.
587
-
First query the number of images in the swap chain with a call to
588
-
`vkGetSwapchainImagesKHR`, then resize the container and finally call it again
589
+
similar to the other times where we retrieved an array of objects from Vulkan. Remember that we only specified a minimum number of images in the swap chain, so the implementation is allowed to create a swap chain with more. That's why we'll first query the final number of images with `vkGetSwapchainImagesKHR`, then resize the container and finally call it again
0 commit comments