bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Resizing windows with pipelined rendering enabled results in flickering and Vulkan validation errors

Open BeastLe9enD opened this issue 2 years ago • 3 comments

Bevy version

Latest version from Github (5d514fb24f2459700f68d8e57d4791bdf5b1b595)

When I have a simple bevy example without the pipelined rendering plugin enabled, everything works fine when resizing the window. When the pipelined rendering plugin is added, the window is flickering while resizing and there are vulkan validation errors:

2023-01-31T12:53:07.394738Z ERROR wgpu_hal::vulkan::instance: VALIDATION [VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 (0x7cd0911d)]
	Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 ] Object 0: handle = 0x22345e91a70, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x7cd0911d | vkCreateSwapchainKHR() called with imageExtent = (1622,750), which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (1620,756), minImageExtent = (1620,756), maxImageExtent = (1620,756). The Vulkan spec states: imageExtent must be between minImageExtent and maxImageExtent, inclusive, where minImageExtent and maxImageExtent are members of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://vulkan.lunarg.com/doc/view/1.3.239.0/windows/1.3-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageExtent-01274)   

I don't know what exactly is going on there, but I can imagine that we need to wait for all frames being finished before resizing the window in the extract_windows system.

Here is the code I used:

use bevy::app::{App, PluginGroup, PluginGroupBuilder};
use bevy::DefaultPlugins;

pub struct SomePlugins;

impl PluginGroup for SomePlugins {
    fn build(self) -> PluginGroupBuilder {
        let mut group = PluginGroupBuilder::start::<Self>();
        group = group
            .add(bevy::log::LogPlugin::default())
            .add(bevy::core::TaskPoolPlugin::default())
            .add(bevy::core::TypeRegistrationPlugin::default())
            .add(bevy::core::FrameCountPlugin::default())
            .add(bevy::time::TimePlugin::default())
            .add(bevy::transform::TransformPlugin::default())
            .add(bevy::hierarchy::HierarchyPlugin::default())
            .add(bevy::diagnostic::DiagnosticsPlugin::default())
            .add(bevy::input::InputPlugin::default())
            .add(bevy::window::WindowPlugin::default());

        group = group.add(bevy::asset::AssetPlugin::default());
        group = group.add(bevy::scene::ScenePlugin::default());
        group = group.add(bevy::winit::WinitPlugin::default());
        group = group.add(bevy::render::RenderPlugin::default())
            .add(bevy::render::texture::ImagePlugin::default());
        //group = group.add(bevy::render::pipelined_rendering::PipelinedRenderingPlugin::default());
        group = group.add(bevy::core_pipeline::CorePipelinePlugin::default());
        group
    }
}

fn main() {
    App::new()
        .add_plugins(SomePlugins)
        .run();
}

BeastLe9enD avatar Jan 31 '23 12:01 BeastLe9enD

In the newest version, the flickering disappeared. The swapchain validation layer error still persists. I have not tested which commit actually fixed it, but it is not flickering anymore.

BeastLe9enD avatar Feb 12 '23 13:02 BeastLe9enD

Duplicate of https://github.com/bevyengine/bevy/issues/3451?

JMS55 avatar Mar 04 '23 16:03 JMS55

Yea, the thing is the flickering was basically some different issue, but since it is fixed now, it is basically the same issue! Maybe we can close this issue then!

BeastLe9enD avatar Mar 04 '23 20:03 BeastLe9enD