Skip to content

Logic error in ImGui_ImplVulkan_SwapBuffers() function. #7825

@NostraMagister

Description

@NostraMagister

Version/Branch of Dear ImGui:

Version 1.90.9 Docking branch

Back-ends:

imgui_impl_vulkan.cpp

Compiler, OS:

All

Full config/build information:

All

Details:

Function: ImGui_ImplVulkan_SwapBuffers()

Partial Code:

    err = vkQueuePresentKHR(v->Queue, &info);
    if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR)
    {
        vd->SwapChainNeedRebuild = true;
        return;
    }
    check_vk_result(err);

    wd->FrameIndex = (wd->FrameIndex + 1) % wd->ImageCount;             // This is for the next vkWaitForFences()
    wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->SemaphoreCount; // Now we can use the next set of semaphores
	

Comment:
The return value VK_SUBOPTIMAL_KHR must/should, IMO, be treated like VK_SUCCESS after the SwapChainNeedRebuild
flag has been set. The Vulkan specs qualify it as success which means the vkQueuePresentKHR() has properly
executed and the Frame and Semaphore indices must be increased. In the code above with VK_SUBOPTIMAL_KHR the indices are not increased.

Info Source: [https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html]

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions