Skip to content

replay: Add --serialize-queue-submissions option#2827

Open
antonio-lunarg wants to merge 3 commits intoLunarG:devfrom
antonio-lunarg:antonio-serialize-submissions
Open

replay: Add --serialize-queue-submissions option#2827
antonio-lunarg wants to merge 3 commits intoLunarG:devfrom
antonio-lunarg:antonio-serialize-submissions

Conversation

@antonio-lunarg
Copy link
Copy Markdown
Contributor

Add a new replay option that serializes queue submissions by inserting semaphores so each submit waits for the previous, preventing concurrent execution of multiple submissions during replay.

Implement serialization in VulkanSubmitJobExecutor with Serialize overloads for VkSubmitInfo and VkSubmitInfo2, and call Serialize from OverrideQueueSubmit/OverrideQueueSubmit2 when the option is set.

Wire the option through CLI parsers, replay_settings, and help text, and update desktop/android usage docs. Refactor submit executor storage to map submit pointers to semaphore storage to avoid multiple injections.

@antonio-lunarg antonio-lunarg marked this pull request as ready for review March 27, 2026 13:25
@antonio-lunarg antonio-lunarg requested a review from a team as a code owner March 27, 2026 13:25
@antonio-lunarg antonio-lunarg added the approved-to-run-ci Can run CI check on internal LunarG machines label Mar 27, 2026
@antonio-lunarg antonio-lunarg force-pushed the antonio-serialize-submissions branch from 4666252 to b5d10b2 Compare March 27, 2026 13:49

for (VkSubmitInfo& submit_info : submit_infos)
{
if (!previous_submit_signal_semaphores.empty())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ouch. This is still incomplete. If submit i has no signal semaphores, then submit i+1 has no dependency object to wait on, so serialization stops there. The current code only propagates existing signals forward. Need fix.

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.

the fix would be to create (+own somewhere) additional glue-semaphores?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes -> 3c428af

@antonio-lunarg antonio-lunarg marked this pull request as draft March 27, 2026 14:06
// Original waits stripped from each submit before injection.
std::vector<VulkanSubmitSemaphores> original_wait_semaphores_;
/// Original waits stripped from each submit before injection, keyed by either `VkSubmitInfo*` or `VkSubmitInfo2*`.
std::unordered_map<void*, VulkanSubmitSemaphores> original_wait_semaphores_;
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.

the void* as key raised the question about lifetime of pointees:

  • this looks like it's pointing into DecodeAllocator memory, valid only for this block before the allocator reuses it.
  • VulkanSubmitJobExecutor only ever lives on the stack, so the validity of acquired VkSubmitInfo(2) pointers seems guaranteed here.

so, my verdict is this should be safe with the current usage pattern.
it 'would' be problematic when VulkanSubmitJobExecutor had a persistent lifetime.

roughly correct? does this line up with what you have in mind?

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.

yes, you even mention it in the doc:
"It (VulkanSubmitJobExecutor) must outlive the queue submit that consumes those structs."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworked a bit: now the "execution" use used within the scope of the queue-submit, and the "executor" is a per-device object which keeps track of semaphores created on the fly to force synchronisation.

@antonio-lunarg antonio-lunarg force-pushed the antonio-serialize-submissions branch from b5d10b2 to 08b8064 Compare March 30, 2026 10:05
@antonio-lunarg antonio-lunarg marked this pull request as ready for review March 30, 2026 15:02
Add a new replay option that serializes queue submissions by inserting
semaphores so each submit waits for the previous, preventing concurrent
execution of multiple submissions during replay.

Implement serialization in VulkanSubmitJobExecutor with SerializeExecution
overloads for VkSubmitInfo and VkSubmitInfo2, and call SerializeExecution
from OverrideQueueSubmit/OverrideQueueSubmit2 when the option is set.

Wire the option through CLI parsers, replay_settings, and help text,
and update desktop/android usage docs. Refactor submit executor storage
to map submit pointers to semaphore storage to avoid multiple injections.
Ensure that when `--serialize-queue-submissions` is used, consecutive
submits within a single `vkQueueSubmit()` / `vkQueueSubmit2()` call are
reliably serialized even if some submits do not originally signal any
semaphores.
@antonio-lunarg antonio-lunarg force-pushed the antonio-serialize-submissions branch from 3c428af to 76b08a2 Compare April 1, 2026 13:32
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