Skip to content

Confusion in Chapter "Swapchain recreation" #326

@LordKobra

Description

@LordKobra

In this chapter there are multiple issues:
1.) The code for handling the return value of vk::raii::Queue::presentKHR is duplicated.
2.) The variable framebufferResized is used before it is introduced.
3.) We defined glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); in the past. It should be mentioned to set this to GLFW_TRUE for resizing.
4.) Subsection Fixing a deadlock fixes a problem that doesn't exist in my code. The fence was never reset above the return value handling. I suspect previous chapters already took care of the right structure? If we should get a deadlock, then previous chapters would need to restructure the fence position.
5.) Would be cool to mention how VULKAN_HPP_HANDLE_ERROR_OUT_OF_DATE_AS_SUCCESS has to be defined for the compiler to see it.
E.g. in CMakeLists.txt

target_compile_definitions(Vulkan-HppModule PUBLIC
        ...
        VULKAN_HPP_HANDLE_ERROR_OUT_OF_DATE_AS_SUCCESS=1
  )

Edit 1: Another minor issue in Handling minimization: If the window is closed while minimized, the application will not close.
One solution could be:

  void recreateSwapChain()
  {
    int width = 0, height = 0;
    glfwGetFramebufferSize(window, &width, &height);
    while ((width == 0 || height == 0) && !glfwWindowShouldClose(window))
    {
      glfwGetFramebufferSize(window, &width, &height);
      glfwWaitEvents();
    }
    device.waitIdle();
    if (glfwWindowShouldClose(window))
      return;

    cleanupSwapchain();
    createSwapChain();
    createImageViews();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions