Skip to content

Commit 545bcee

Browse files
authored
Align docu in 03_Frames_in_flight.adoc with the sources in 16_frames_in_flight.cpp (#346)
1 parent 053561c commit 545bcee

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

attachments/16_frames_in_flight.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ class HelloTriangleApplication
330330
vk::PipelineShaderStageCreateInfo fragShaderStageInfo{.stage = vk::ShaderStageFlagBits::eFragment, .module = shaderModule, .pName = "fragMain"};
331331
vk::PipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo, fragShaderStageInfo};
332332

333-
334333
vk::PipelineVertexInputStateCreateInfo vertexInputInfo;
335334
vk::PipelineInputAssemblyStateCreateInfo inputAssembly{.topology = vk::PrimitiveTopology::eTriangleList};
336335
vk::PipelineViewportStateCreateInfo viewportState{.viewportCount = 1, .scissorCount = 1};
@@ -392,7 +391,8 @@ class HelloTriangleApplication
392391
{
393392
auto &commandBuffer = commandBuffers[frameIndex];
394393
commandBuffer.begin({});
395-
// Before starting rendering, transition the swapchain image to COLOR_ATTACHMENT_OPTIMAL
394+
395+
// Before starting rendering, transition the swapchain image to vk::ImageLayout::eColorAttachmentOptimal
396396
transition_image_layout(
397397
imageIndex,
398398
vk::ImageLayout::eUndefined,
@@ -420,7 +420,8 @@ class HelloTriangleApplication
420420
commandBuffer.setScissor(0, vk::Rect2D(vk::Offset2D(0, 0), swapChainExtent));
421421
commandBuffer.draw(3, 1, 0, 0);
422422
commandBuffer.endRendering();
423-
// After rendering, transition the swapchain image to PRESENT_SRC
423+
424+
// After rendering, transition the swapchain image to vk::ImageLayout::ePresentSrcKHR
424425
transition_image_layout(
425426
imageIndex,
426427
vk::ImageLayout::eColorAttachmentOptimal,

en/03_Drawing_a_triangle/03_Drawing/03_Frames_in_flight.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ std::vector<vk::raii::Fence> inFlightFences;
4343

4444
Then we need to create multiple command buffers.
4545
Rename `createCommandBuffer` to `createCommandBuffers`.
46-
Next we need to resize the command buffers vector to the size of `MAX_FRAMES_IN_FLIGHT`, alter the `VkCommandBufferAllocateInfo` to contain that many command buffers, and then change the destination to our vector of command buffers:
46+
Next we need to resize the command buffers vector to the size of `MAX_FRAMES_IN_FLIGHT`, alter the `vk::CommandBufferAllocateInfo` to contain that many command buffers, and then change the destination to our vector of command buffers:
4747

4848
[,c++]
4949
----
50-
void createCommandBuffers() {
51-
commandBuffers.clear();
52-
vk::CommandBufferAllocateInfo allocInfo{ .commandPool = commandPool, .level = vk::CommandBufferLevel::ePrimary,
53-
.commandBufferCount = MAX_FRAMES_IN_FLIGHT };
50+
void createCommandBuffers()
51+
{
52+
vk::CommandBufferAllocateInfo allocInfo{.commandPool = commandPool, .level = vk::CommandBufferLevel::ePrimary, .commandBufferCount = MAX_FRAMES_IN_FLIGHT};
5453
commandBuffers = vk::raii::CommandBuffers( device, allocInfo );
5554
}
5655
----
@@ -59,7 +58,8 @@ The `createSyncObjects` function should be changed to create all the objects:
5958

6059
[,c++]
6160
----
62-
void createSyncObjects() {
61+
void createSyncObjects()
62+
{
6363
assert(presentCompleteSemaphores.empty() && renderFinishedSemaphores.empty() && inFlightFences.empty());
6464
6565
for (size_t i = 0; i < swapChainImages.size(); i++)
@@ -80,7 +80,7 @@ We will use a frame index for that purpose:
8080

8181
[,c++]
8282
----
83-
uint32_t frameIndex 0;
83+
uint32_t frameIndex = 0;
8484
----
8585

8686
The `drawFrame` function can now be modified to use the right objects:
@@ -133,7 +133,7 @@ be known with a fence whether the semaphore is ready for re-use.
133133
We've now implemented all the necessary synchronization to ensure that there
134134
are no more than `MAX_FRAMES_IN_FLIGHT` frames of work enqueued and that
135135
these frames are not stepping over each other.
136-
Note that it is fine for other parts of the code, like the final cleanup, to rely on more rough synchronization like `vkDeviceWaitIdle`.
136+
Note that it is fine for other parts of the code, like the final cleanup, to rely on more rough synchronization like `vk::raii::Device::waitIdle`.
137137
You should decide on which approach to use based on performance requirements.
138138

139139
Additionally, we could use timeline semaphores instead of the binary

0 commit comments

Comments
 (0)