Coder Social home page Coder Social logo

Comments (6)

AndreiNego avatar AndreiNego commented on August 21, 2024 1

Added two callbacks in the main function to solve the issue, although just one should be enough.

glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", nullptr, nullptr);
if (!glfwVulkanSupported())
{
printf("GLFW: Vulkan Not Supported\n");
return 1;
}

glfwSetWindowSizeCallback(window, [](GLFWwindow* window, int width, int height){g_SwapChainRebuild = true;});
glfwSetFramebufferSizeCallback(window, [](GLFWwindow* window, int width, int height){g_SwapChainRebuild = true;});

from imgui.

AndreiNego avatar AndreiNego commented on August 21, 2024

More info on the issue:
"(VK_SUBOPTIMAL_KHR happens only on X11/XCB or/and xWayland)
In Wayland resize logic completely different from other WM, and way too many platforms to support if you rly care about crossplatform. (and Wayland has too many features that I left untested, I have no idea how application will react to those WM features(exampel I was talking about “zoom” part of screen, what application do in this case how it rendered… no idea))"
https://community.khronos.org/t/vk-suboptimal-khr-is-it-safe-to-use-it-as-window-resize-detection/107848/5

from imgui.

ocornut avatar ocornut commented on August 21, 2024

I am wondering if we could simply fix it by changing:

        // Resize swap chain?
        if (g_SwapChainRebuild)
        {
            int width, height;
            glfwGetFramebufferSize(window, &width, &height);
            if (width > 0 && height > 0)
            {
                ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
                ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
                g_MainWindowData.FrameIndex = 0;
                g_SwapChainRebuild = false;
            }
        }

to

        // Resize swap chain?
        int fb_width, fb_height;
        glfwGetFramebufferSize(window, &fb_width, &fb_height);
        if (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height)
            if (fb_width > 0 && fb_height > 0)
            {
                ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
                ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
                g_MainWindowData.FrameIndex = 0;
                g_SwapChainRebuild = false;
            }

Could you test it?

Can you already see if things works correctly on your system with the SDL+Vulkan example?

Thank you!

from imgui.

AndreiNego avatar AndreiNego commented on August 21, 2024

Hi,
I've tested it and it worked perfectly.
Unfortunately, for SDL I am unable to get SDL.h to install on my system. I have two potential packages that provide the header but none of them actually install it.

from imgui.

ocornut avatar ocornut commented on August 21, 2024

Pushed fixes as a47bfb1 and 7538ca6
Looking at equivalent SDL example it seemed clear the same thing would happen.
If you get around to install SDL please verify it before and after 🙏

from imgui.

AndreiNego avatar AndreiNego commented on August 21, 2024

For SDL the problem does not exist.
SDL does not open a Wayland native window but an X window.
The flag is raised for VK_ERROR_OUT_OF_DATE_KHR during resize
image

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.