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: chap09/chap09.md
+21-36Lines changed: 21 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,23 +18,21 @@ We already have the function pointer from earlier called `fpAcquireNextImageKHR`
18
18
19
19
```cpp
20
20
VkResult vkAcquireNextImageKHR(
21
-
// The device assocated with swapchain.
22
21
VkDevice device,
23
-
// The swapchain from which an image is being acquired.
24
22
VkSwapchainKHR swapchain,
25
-
// Indicates how long the function waits, in nanoseconds,
26
-
// if no image is available.
27
23
uint64_t timeout,
28
-
// VK_NULL_HANDLE or a semaphore to signal.
29
24
VkSemaphore semaphore,
30
-
// VK_NULL_HANDLE or a fence to signal.
31
25
VkFence fence,
32
-
// A pointer to a uint32_t that is set to the index of the
33
-
// next image to use (i.e. an index into the array of images
34
-
// returned by vkGetSwapchainImagesKHR).
35
26
uint32_t* pImageIndex);
36
27
```
37
28
29
+
-`device` is the device assocated with swapchain.
30
+
-`swapchain` is the swapchain from which an image is being acquired.
31
+
-`timeout` indicates how long the function waits, in nanoseconds, if no image is available.
32
+
-`semaphore` is `VK_NULL_HANDLE` or a semaphore to signal.
33
+
-`fence` is `VK_NULL_HANDLE` or a fence to signal.
34
+
-`pImageIndex` is a pointer to a `uint32_t` that is set to the index of the next image to use (i.e. an index into the array of images returned by `vkGetSwapchainImagesKHR`).
35
+
38
36
Now that we know that, all we need to do is call the function and make sure we were successful:
39
37
40
38
```cpp
@@ -57,37 +55,26 @@ In order for the swapchain to present images, we'll have to inform Vulkan of som
57
55
58
56
```cpp
59
57
typedefstructVkPresentInfoKHR {
60
-
// The type of this structure and must be
61
-
// VK_STRUCTURE_TYPE_PRESENT_INFO_KHR.
62
58
VkStructureType sType;
63
-
// NULL or a pointer to an extension-specific structure.
64
59
const void* pNext;
65
-
// The number of semaphores to wait for before issuing the
66
-
// present request. The number may be zero.
67
60
uint32_t waitSemaphoreCount;
68
-
// If non-NULL, is an array of VkSemaphore objects with
69
-
// waitSemaphoreCount entries, and specifies the semaphores to wait
70
-
// for before issuing the present request.
71
61
const VkSemaphore* pWaitSemaphores;
72
-
// The number of swapchains being presented to by this command.
73
62
uint32_t swapchainCount;
74
-
// An array of VkSwapchainKHR objects with swapchainCount entries.
75
-
// A given swapchain must not appear in this list more than once.
76
63
const VkSwapchainKHR* pSwapchains;
77
-
// An array of indices into the array of each swapchain’s
78
-
// presentable images, with swapchainCount entries. Each entry in
79
-
// this array identifies the image to present on the corresponding
80
-
// entry in the pSwapchains array.
81
64
const uint32_t* pImageIndices;
82
-
// An array of VkResult typed elements with swapchainCount entries.
83
-
// Applications that don’t need per-swapchain results can use NULL
84
-
// for pResults. If non-NULL, each entry in pResults will be set to
85
-
// the VkResult for presenting the swapchain corresponding to the same
86
-
// index in pSwapchains.
87
65
VkResult* pResults;
88
66
} VkPresentInfoKHR;
89
67
```
90
68
69
+
- `sType` is the type of this structure and must be `VK_STRUCTURE_TYPE_PRESENT_INFO_KHR`.
70
+
- `pNext` is `NULL` or a pointer to an extension-specific structure.
71
+
- `waitSemaphoreCount` is the number of semaphores to wait for before issuing the present request. The number may be zero.
72
+
- `pWaitSemaphores`, if non-`NUL`L, is an array of `VkSemaphore` objects with `waitSemaphoreCount` entries, and specifies the semaphores to wait for before issuing the present request.
73
+
- `swapchainCount` is the number of swapchains being presented to by this command.
74
+
- `pSwapchains` is an array of `VkSwapchainKHR` objects with `swapchainCount` entries. A given swapchain must not appear in this list more than once.
75
+
- `pImageIndices` is an array of indices into the array of each swapchain’s presentable images, with `swapchainCount` entries. Each entry in this array identifies the image to present on the corresponding entry in the `pSwapchains` array.
76
+
- `pResults` is an array of `VkResult` typed elements with `swapchainCount` entries. Applications that don’t need per-swapchain results can use `NULL` for pResults. If non-`NULL`, each entry in `pResults` will be set to the `VkResult` for presenting the swapchain corresponding to the same index in `pSwapchains`.
77
+
91
78
Our usage will simply look like:
92
79
93
80
```cpp
@@ -105,15 +92,13 @@ As the last part of the `swapchainPresent` method, we actually get to present! W
105
92
106
93
```cpp
107
94
VkResult vkQueuePresentKHR(
108
-
// A queue that is capable of presentation to the target
109
-
// surface’s platform on the same device as the image’s
110
-
// swapchain.
111
-
VkQueue queue,
112
-
// A pointer to an instance of the VkPresentInfoKHR structure
113
-
// specifying the parameters of the presentation.
114
-
const VkPresentInfoKHR* pPresentInfo);
95
+
VkQueue queue,
96
+
const VkPresentInfoKHR* pPresentInfo);
115
97
```
116
98
99
+
- `queue `is a queue that is capable of presentation to the target surface’s platform on the same device as the image’s swapchain.
100
+
- `pPresentInfo` is a pointer to an instance of the `VkPresentInfoKHR` structure specifying the parameters of the presentation.
0 commit comments