Skip to content

Fix offscreen swapchain implicit synchronization#3062

Merged
fabian-lunarg merged 1 commit into
LunarG:devfrom
marius-pelegrin-arm:fix-offscreen-swapchain-implicit-sync
Jul 9, 2026
Merged

Fix offscreen swapchain implicit synchronization#3062
fabian-lunarg merged 1 commit into
LunarG:devfrom
marius-pelegrin-arm:fix-offscreen-swapchain-implicit-sync

Conversation

@marius-pelegrin-arm

Copy link
Copy Markdown
Contributor

The offscreen swapchain needs to emulate the behavior of a WSI. In particular, this implies waiting for and signaling semaphores and fences on image acquisition and queue presentation.

The behavior until now was to submit an empty workload as a queue submission waiting and signaling the correct synchronization primitives.
While this works as expected for queue presentation, this introduces additional synchronizations for image acquisition.

Indeed, image acquisition is queue independent, which means it doesn't need to wait for previous queue submissions to begin. By implementing it as an empty queue submit, we encounter cases where the implicit ordering constraints of Vulkan introduce a slowdown, making offscreen slower than onscreen.

I have currently no solution for Windows and/or Mac (assuming they don't support VK_KHR_external_semaphore_fd and VK_KHR_external_fence_fd).
However, on systems implementing these extensions (mainly Linux and Android systems), I propose to solve this using a technique inspired by Mesa's Vulkan WSI Layer:
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer

The idea is to signal semaphores and fences by importing them as temporary file descriptor system handles using a predefined "invalid" value recognized as an "already signaled primitive".

This behavior is described in the Vulkan specification for the VkImportSemaphoreFdInfoKHR and VkImportFenceFdInfoKHR structures (search for file descriptor value "-1").

@marius-pelegrin-arm
marius-pelegrin-arm requested a review from a team as a code owner June 30, 2026 12:28
@marius-pelegrin-arm
marius-pelegrin-arm force-pushed the fix-offscreen-swapchain-implicit-sync branch 2 times, most recently from 9c64ab8 to cfee1ec Compare June 30, 2026 13:23
@fabian-lunarg fabian-lunarg self-assigned this Jun 30, 2026
@fabian-lunarg fabian-lunarg added the approved-to-run-ci Can run CI check on internal LunarG machines label Jun 30, 2026
Comment thread framework/decode/vulkan_offscreen_swapchain.cpp Outdated
Comment thread framework/decode/vulkan_offscreen_swapchain.cpp Outdated
Comment thread framework/decode/vulkan_offscreen_swapchain.cpp Outdated
Comment thread framework/decode/vulkan_swapchain.cpp Outdated
Comment thread framework/decode/vulkan_replay_consumer_base.h Outdated
@bradgrantham-lunarg
bradgrantham-lunarg force-pushed the fix-offscreen-swapchain-implicit-sync branch from cfee1ec to 0357fe8 Compare July 8, 2026 22:29
@marius-pelegrin-arm
marius-pelegrin-arm force-pushed the fix-offscreen-swapchain-implicit-sync branch from 0357fe8 to cfee1ec Compare July 9, 2026 07:28
@marius-pelegrin-arm

marius-pelegrin-arm commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

I don't understand, what changes are you requesting ? I updated the commit with all changes requested in comments.

@fabian-lunarg

Copy link
Copy Markdown
Contributor

I don't understand, what changes are you requesting ? I updated the commit with all changes requested in comments.

I reopened because from my perspective I did not see any codechanges. maybe a wrong commit got pushed?

@marius-pelegrin-arm

Copy link
Copy Markdown
Contributor Author

Oh, apparently there has been a git mess up. I will re-push the changes.

@fabian-lunarg

Copy link
Copy Markdown
Contributor

Oh, apparently there has been a git mess up. I will re-push the changes.

no worries. but please, before just closing my open concerns, give me opportunity to verify the changes.

@marius-pelegrin-arm

Copy link
Copy Markdown
Contributor Author

Oh, okay, I thought marking conversation as resolved was the proper way to signal that I pushed modifications that should solve the issue.

@fabian-lunarg

Copy link
Copy Markdown
Contributor

Oh, okay, I thought marking conversation as resolved was the proper way to signal that I pushed modifications that should solve the issue.

yes, for trivial concerns or one-liners normally not an issue (if there are actual changes).
the base-class / cleanup concern was not that trivial, so nicer to apply the change and let me catch up first.

The offscreen swapchain needs to emulate the behavior of a WSI.
In particular, this implies waiting for and signaling semaphores
and fences on image acquisition and queue presentation.

The behavior until now was to submit an empty workload as a queue
submission waiting and signaling the correct synchronization
primitives.
While this works as expected for queue presentation, this
introduces additional synchronizations for image acquisition.

Indeed, image acquisition is queue independent, which means it
doesn't need to wait for previous queue submissions to begin.
By implementing it as an empty queue submit, we encounter cases
where the implicit ordering constraints of Vulkan introduce
a slowdown, making offscreen slower than onscreen.

I have currently no solution for Windows and/or Mac (assuming
they don't support `VK_KHR_external_semaphore_fd` and
`VK_KHR_external_fence_fd`).
However, on systems implementing these extensions (mainly Linux
and Android systems), I propose to solve this using a technique
inspired by Mesa's Vulkan WSI Layer:
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer

The idea is to signal semaphores and fences by importing them
as temporary file descriptor system handles using a predefined
"invalid" value recognized as an "already signaled primitive".

This behavior is described in the Vulkan specification for the
`VkImportSemaphoreFdInfoKHR` and `VkImportFenceFdInfoKHR`
structures (search for file descriptor value "-1").

Change-Id: I477a994baca34221b022e9f679c08fc1f260ab7b
@marius-pelegrin-arm
marius-pelegrin-arm force-pushed the fix-offscreen-swapchain-implicit-sync branch from cfee1ec to 67b93aa Compare July 9, 2026 09:24
@marius-pelegrin-arm

Copy link
Copy Markdown
Contributor Author

Pushed.

@fabian-lunarg fabian-lunarg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright!

@fabian-lunarg
fabian-lunarg added this pull request to the merge queue Jul 9, 2026
Merged via the queue into LunarG:dev with commit 366239c Jul 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-to-run-ci Can run CI check on internal LunarG machines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants