Skip to content

Confusion at chapter "Rendering and Presentation" #318

@LordKobra

Description

@LordKobra

In Chapter 03/03/02 "Rendering and presentation" we define the presentation semaphore as

vk::raii::Semaphore presentCompleteSemaphore = nullptr;
...
void createSyncObjects() {
    presentCompleteSemaphore = vk::raii::Semaphore(device, vk::SemaphoreCreateInfo());
    ...
}

then below the text says

Next, let’s grab an image from the framebuffer after the previous frame has finished:

void drawFrame() {
    ...
    auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
}

Where does this array suddenly come from?

Edit 1:
Also the text then says

The next two parameters specify synchronization objects [...]

The last parameter specifies a variable to output the index of the swap chain image that has become available. The index refers to the VkImage in our swapChainImages array. We’re going to use that index to pick the VkFrameBuffer. Then we’ll record into that framebuffer.

But it is not the last parameter. In the code there is no next parameter after the fence. It is the return value imageIndex. So it should be return value, and if the return values are discussed, then the result return value should also be mentioned.

Edit2:
At the end of the chapter i also get the validation error:

validation layer: type { Validation } msg: vkCmdPipelineBarrier2(): the synchronization2 feature was not enabled.

So we need to change the featureChain to

vk::StructureChain<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVulkan13Features,
                       vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT>
        featureChain = {{}, {.synchronization2 = true, .dynamicRendering = true}, {.extendedDynamicState = true}};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions