Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to signal fence and flush on draw_on_image #66

Open
RA3236 opened this issue Mar 23, 2024 · 2 comments
Open

Failed to signal fence and flush on draw_on_image #66

RA3236 opened this issue Mar 23, 2024 · 2 comments

Comments

@RA3236
Copy link

RA3236 commented Mar 23, 2024

Failed to signal fence and flush: a validation error occurred

Caused by:
    access to a resource has been denied (resource use: Some(ResourceUseRef { command_index: 0, command_name: "begin_rendering", resource_in_command: DepthStencilAttachment, secondary_use_ref: None }), error: the resource is already in use, and there is no tracking of concurrent usages)

I’m not so clear on why this happens, but this is fixed by heading to line 671 (line 673 for #53) in renderer.rs and replacing:

let future =
        after_main_cb.then_signal_fence_and_flush().expect("Failed to signal fence and flush");
// Return our future
Box::new(future)

with

Box::new(after_main_cb)

i.e. not signalling and flushing. I'm not enough of a Vulkan expert to understand why this works - I think it has something to do with how the swapchain is set up. I don't know if this happens on the main branch here, but it definitely occurs on #53, and there aren't code changes that would suggest otherwise.

My submission code is as follows:

let buffer = command_buffer.end()?;
let future = self
    .previous_frame_end
    .take()
    .unwrap()
    .join(self.acquire_future.take().unwrap())
    .then_execute(self.queue.clone(), buffer)?;
let future = self.gui.draw_on_image(future, self.egui_image_views[self.image_index as usize].clone())
    .then_swapchain_present(
        self.queue.clone(),
        SwapchainPresentInfo::swapchain_image_index(
            self.swapchain.clone(),
            self.image_index,
        ),
    )
    .then_signal_fence_and_flush();

match future {
    Ok(future) => {
        info!("Frame submitted successfully");
        self.previous_frame_end = Some(future.boxed());
    }
    Err(Validated::Error(VulkanError::OutOfDate)) => {
        info!("Swapchain out of date");
        self.recreate_swapchain = true;
        self.previous_frame_end = Some(vulkano::sync::now(self.device.clone()).boxed());
    }
    Err(e) => {
        error!("Failed to flush future: {:?}", e);
        self.previous_frame_end = Some(vulkano::sync::now(self.device.clone()).boxed());
    }
}
@hakolao
Copy link
Owner

hakolao commented Mar 23, 2024

It should be better to let the user control then_signal_fence_and_flush, and to get rid of that line. I don't think it's needed anymore, or if it ever was...

I'm also not sure what goes wrong in the synchronization, and would probably need more debugging.

@hakolao
Copy link
Owner

hakolao commented Mar 23, 2024

#67 implementing the fix...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants