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

Vulkan Validation Error when resizing #80570

Closed
darksylinc opened this issue Aug 12, 2023 · 0 comments · Fixed by #80571
Closed

Vulkan Validation Error when resizing #80570

darksylinc opened this issue Aug 12, 2023 · 0 comments · Fixed by #80571

Comments

@darksylinc
Copy link
Contributor

darksylinc commented Aug 12, 2023

Godot version

master [4714e95]

System information

Godot v4.2.dev (4714e95) - Ubuntu 20.04.6 LTS (Focal Fossa) - X11 - Vulkan (Forward+) - dedicated AMD Radeon RX 6800 XT - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Issue description

Sometimes when resizing the window on Linux X11 we may get the following validation error:

ERROR: VALIDATION - Message Id Number: -370888023 | Message Id Name: VUID-vkAcquireNextImageKHR-semaphore-01286
	Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01286 ] Object 0: handle = 0xdcc8fd0000000012, type = VK_OBJECT_TYPE_SEMAPHORE; | MessageID = 0xe9e4b2a9 | vkAcquireNextImageKHR: Semaphore must not be currently signaled or in a wait state. The Vulkan spec states: If semaphore is not VK_NULL_HANDLE it must be unsignaled (https://vulkan.lunarg.com/doc/view/1.2.198.1/linux/1.2-extensions/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01286)

I nailed down the problem. In VulkanContext::prepare_buffers we have the following loop (I simplified to highlight the problem):

do {

err = fpAcquireNextImageKHR(device, w->swapchain, UINT64_MAX,
							w->image_acquired_semaphores[frame_index], VK_NULL_HANDLE, &w->current_buffer);

if (err == VK_SUBOPTIMAL_KHR) {
	// Swapchain is not as optimal as it could be, but the platform's
	// presentation engine will still present the image correctly.
	print_verbose("Vulkan: Early suboptimal swapchain, recreating.");
	Error swap_chain_err = _update_swap_chain(w);
	if (swap_chain_err == ERR_SKIP) {
		break;
	}
} while (err != VK_SUCCESS);

The problem is that vkAcquireNextImageKHR returned VK_SUBOPTIMAL_KHR but it already signaled the semaphore (because it is possible to continue normally with a VK_SUBOPTIMAL_KHR result).

Then we recreate the swapchain and reuse the w->image_acquired_semaphores[frame_index] which is in an inconsistent state.

I will handle this bug.

Steps to reproduce

  1. Open the Editor on any project
  2. Resize the project until it happens

Reproducibility is much more frequent after applying PR #80566

Minimal reproduction project

Any.

@Chaosus Chaosus modified the milestones: 4.x, 4.2 Aug 13, 2023
mandryskowski pushed a commit to mandryskowski/godot that referenced this issue Oct 11, 2023
Sometimes when resizing the window we may get the following validation
error:

ERROR: VALIDATION - Message Id Number: -370888023 | Message Id Name:
VUID-vkAcquireNextImageKHR-semaphore-01286
	Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01286 ]
Object 0: handle = 0xdcc8fd0000000012, type = VK_OBJECT_TYPE_SEMAPHORE;
| MessageID = 0xe9e4b2a9 | vkAcquireNextImageKHR: Semaphore must not be
currently signaled or in a wait state. The Vulkan spec states: If
semaphore is not VK_NULL_HANDLE it must be unsignaled
(https://vulkan.lunarg.com/doc/view/1.2.198.1/linux/1.2-extensions/vkspec.html#VUID-vkAcquireNextImageKHR-semaphore-01286)

In VulkanContext::prepare_buffers the problem was that
vkAcquireNextImageKHR returned VK_SUBOPTIMAL_KHR but it already signaled
the semaphore (because it is possible to continue normally with a
VK_SUBOPTIMAL_KHR result).

Then we recreate the swapchain and reuse the
w->image_acquired_semaphores[frame_index] which is in an inconsistent
state.

Fixed by recreating the semamphores along the swapchain.

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

Successfully merging a pull request may close this issue.

2 participants