Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.11k stars 512 forks source link

Changing window states using tutorial code freezes system for some time #166

Open eligt opened 4 years ago

eligt commented 4 years ago

Changing any window state, such as position, size, minimization, etc. causes the system to freeze for a certain amount of time, the time it freezes for seems to be directly related to the amount of time spent doing the window transformation (like move or resize).

This is on Lubuntu 18.04 x64 with kernel 5.2.8-050208-generic, with NVIDIA GeForce GTX 1060 using NVIDIA drivers version 435.21.

I'm using code from latest example, 29_multisampling.cpp and it happens both with/without validation layers enabled.

Might be related to https://github.com/Overv/VulkanTutorial/issues/15

eligt commented 4 years ago

Adding this type of (awful) code to cap the frame rendering to 120 FPS fixes the freezes so maybe too many frames are sent in for rendering when you move/resize the window?

    void mainLoop() {
        auto now = std::chrono::system_clock::now();

        while (!glfwWindowShouldClose(window)) {
            glfwPollEvents();
            drawFrame();
            auto diff = std::chrono::system_clock::now() - now;
            auto micros = std::chrono::duration_cast<std::chrono::microseconds>(diff);
            //std::this_thread::sleep_for( std::chrono::microseconds(16600 - micros.count()) );
            std::this_thread::sleep_for( std::chrono::microseconds(8200 - micros.count()) );
            now = std::chrono::system_clock::now();
        }

        vkDeviceWaitIdle(device);
    }
eligt commented 4 years ago

Just an extra note on this for anyone stumbling upon it: seems like switching the sample from GLFW to SDL2 fixed the freezes for me.

RussellHolgate commented 4 years ago

I was having the same issue running this in Manjaro with X11. I needed to add a 33200 microsecond delay to drag the window smoothly.

RussellHolgate commented 4 years ago

I should also mention that without the delay, I was getting a consistent validation error when resizing the window related to imageExtent being out of bounds on "16_swap_chain_recreation.cpp" before modifying the code.

RussellHolgate commented 4 years ago

I tried using SDL2 instead of GLFW but the problem persists for me.