Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b857111

Browse files
committed
Add clarification that swap chain extension check is redundant
1 parent a5a7091 commit b857111

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

03_Drawing_a_triangle/01_Presentation/01_Swap_chain.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ extensions. That way we can easily tick them off while enumerating the sequence
7676
of available extensions. Of course you can also use a nested loop like in
7777
`checkValidationLayerSupport`. The performance difference is irrelevant. Now run
7878
the code and verify that your graphics card is indeed capable of creating a
79-
swap chain.
79+
swap chain. It should be noted that the availability of a presentation queue,
80+
as we checked in the previous chapter, implies that the swap chain extension
81+
must be supported. However, it's still good to be explicit about things, and
82+
the extension does have to be explicitly enabled.
8083

8184
Enabling the extension just requires a small change to the logical device
8285
creation structure:
@@ -315,6 +318,26 @@ VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR> avail
315318
}
316319
```
317320
321+
Unfortunately some drivers currently don't properly support
322+
`VK_PRESENT_MODE_FIFO_KHR`, so we should prefer `VK_PRESENT_MODE_IMMEDIATE_KHR`
323+
if `VK_PRESENT_MODE_MAILBOX_KHR` is not available:
324+
325+
```c++
326+
VkPresentModeKHR chooseSwapPresentMode(const std::vector<VkPresentModeKHR> availablePresentModes) {
327+
VkPresentModeKHR bestMode = VK_PRESENT_MODE_FIFO_KHR;
328+
329+
for (const auto& availablePresentMode : availablePresentModes) {
330+
if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR) {
331+
return availablePresentMode;
332+
} else if (availablePresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) {
333+
bestMode = availablePresentMode;
334+
}
335+
}
336+
337+
return bestMode;
338+
}
339+
```
340+
318341
### Swap extent
319342

320343
That leaves only one major property, for which we'll add one last function:

0 commit comments

Comments
 (0)