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: en/03_Drawing_a_triangle/03_Drawing/02_Rendering_and_presentation.adoc
+30-27Lines changed: 30 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,7 +192,7 @@ void createSyncObjects() {
192
192
}
193
193
----
194
194
195
-
Creating semaphores requires filling in the `VkSemaphoreCreateInfo`, but in the current version of the API it doesn't actually have any required fields besides `sType`:
195
+
Creating semaphores requires filling in the `vk::SemaphoreCreateInfo`, but in the current version of the API it doesn't actually have any fields relevant to the tutorial:
196
196
197
197
[,c++]
198
198
----
@@ -210,12 +210,12 @@ Onto the main drawing function!
210
210
== Waiting for the previous frame
211
211
212
212
At the start of the frame, we want to wait until the previous frame has finished, so that the command buffer and semaphores are available to use.
213
-
To do that, we call `vkWaitForFences`:
213
+
To do that, we call `device.waitForFences`:
214
214
215
215
[,c++]
216
216
----
217
217
void drawFrame() {
218
-
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
218
+
auto fenceResult = device.waitForFences(*drawFence, vk::True, UINT64_MAX);
219
219
}
220
220
----
221
221
@@ -234,14 +234,13 @@ void drawFrame() {
234
234
}
235
235
----
236
236
237
-
The first two parameters of `vkAcquireNextImageKHR` are the logical device and the swap chain from which we wish to acquire an image.
238
-
The third parameter specifies a timeout in nanoseconds for an image to become available.
237
+
The first parameter specifies a timeout in nanoseconds for an image to become available.
239
238
Using the maximum value of a 64-bit unsigned integer means we effectively disable the timeout.
240
239
241
240
The next two parameters specify synchronization objects that are to be signaled when the presentation engine is finished using the image.
242
241
That's the point in time where we can start drawing to it.
243
242
It is possible to specify a semaphore, fence or both.
244
-
We're going to use our `imageAvailableSemaphore` for that purpose here.
243
+
We're going to use our `presentCompleteSemaphores` for that purpose here.
245
244
246
245
The last parameter specifies a variable to output the index of the swap chain image that has become available.
247
246
The index refers to the `VkImage` in our `swapChainImages` array.
@@ -263,19 +262,26 @@ already happened, so we know to wait on it later.
263
262
264
263
[,c++]
265
264
----
266
-
device.resetFences(*drawFence);
265
+
device.resetFences(*drawFence);
267
266
----
268
267
269
268
With a fully recorded command buffer, we can now submit it.
270
269
271
270
== Submitting the command buffer
272
271
273
-
Queue submission and synchronization is configured through parameters in the `VkSubmitInfo` structure.
272
+
Queue submission and synchronization is configured through parameters in the `vk::SubmitInfo` structure.
The first two parameters specify which semaphores to wait on before presentation can happen, just like `VkSubmitInfo`.
378
+
The first two parameters specify which semaphores to wait on before presentation can happen, just like `vk::SubmitInfo`.
376
379
Since we want to wait on the command buffer to finish execution, thus our triangle being drawn, we take the semaphores which will be signaled and wait on them, thus we use `signalSemaphores`.
377
380
378
381
The next two parameters specify the swap chains to present images to and the index of the image for each swap chain.
There is one last optional parameter called `pResults`.
387
-
It allows you to specify an array of `VkResult` values to check for every swap chain if presentation was successful.
390
+
It allows you to specify an array of `vk::Result` values to check for every swap chain if presentation was successful.
388
391
It's not necessary if you're only using a single swap chain, because you can use the return value of the present function.
389
392
390
393
[,c++]
391
394
----
392
-
result = presentQueue.presentKHR(presentInfoKHR);
395
+
result = presentQueue.presentKHR(presentInfoKHR);
393
396
----
394
397
395
-
The `vkQueuePresentKHR` function submits the request to present an image to the swap chain.
396
-
We'll add error handling for both `vkAcquireNextImageKHR` and `vkQueuePresentKHR` in the next chapter, because their failure does not necessarily mean that the program should terminate, unlike the functions we've seen so far.
398
+
The `presentKHR` function submits the request to present an image to the swap chain.
399
+
We'll add error handling for both `swapChain.acquireNextImage` and `queue.presentKHR` in the next chapter, because their failure does not necessarily mean that the program should terminate, unlike the functions we've seen so far.
397
400
398
401
If you did everything correctly up to this point, then you should now see something resembling the following when you run your program:
0 commit comments