[PR #470] [MERGED] vulkan: every submission starts with a full memory barrier, as an ExecuteCommandLists boundary (VK-SUBMIT-BARRIER) #521

Closed
opened 2026-11-26 20:18:09 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/470
Author: @Kokonotcu
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: pr/submission-barrier


📝 Commits (2)

  • 6e81b92 Every submission starts with a full memory barrier (ExecuteCommandLists boundary)
  • 9f9a503 Submission barrier: not on a context without vkCmdPipelineBarrier

📊 Changes

2 files changed (+71 additions, -0 deletions)

View changed files

📝 runtime/src/vulkan_backend.h (+12 -0)
📝 runtime/test/vk_queue_test.cpp (+59 -0)

📄 Description

Claim: VK-SUBMIT-BARRIER (#14).

What was wrong: D3D12 ends every ExecuteCommandLists with its work done and its writes visible to the next submission on the queue. Implicit state decay relies on it, and a list may touch memory an earlier submission wrote without any barrier (two submissions copying into one buffer, say). Vulkan orders submissions on a queue only by their barriers, and nothing in a VulkanQueue's command buffer ordered it after the previous one. Synchronization validation reports it in vk_queue_test's back-to-back copies into one buffer: WRITE_AFTER_WRITE between submissions, 10 errors, the test fails under LEONIDA_VK_VALIDATION=1.

What changed: execute_now records an ALL_COMMANDS -> ALL_COMMANDS memory barrier (MEMORY_WRITE -> MEMORY_READ | MEMORY_WRITE) right after vkBeginCommandBuffer. The second commit skips it on a context without vkCmdPipelineBarrier: replay_query_edges_test's mocked context has none, and the first commit alone crashed that test.

Cost: one global memory barrier per submitted command buffer. Execution order between submissions is unchanged; the barrier only makes writes visible.

Tests: vk_queue_test 4b counts the command buffers begun and those whose first barrier is this one, over two submissions each on the direct and the copy queue: 4 of 4 (0 before).

Tested on Windows 10, i7-11800H, RTX 3080 Laptop (NVIDIA driver), on main 8f481cf16, with LEONIDA_VK_VALIDATION=1: vk_queue passes with 0 validation errors, replay_query_edges passes. On our cumulative branch the GPU tests (^(d3d12_|vk_)) under validation pass with this in place.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/470 **Author:** [@Kokonotcu](https://github.com/Kokonotcu) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `pr/submission-barrier` --- ### 📝 Commits (2) - [`6e81b92`](https://github.com/ubiquitarianism/leonida/commit/6e81b921996cd60f8fa67b5e1247a5b96af51066) Every submission starts with a full memory barrier (ExecuteCommandLists boundary) - [`9f9a503`](https://github.com/ubiquitarianism/leonida/commit/9f9a503406c581320bcd84d5a73dc77ae9626107) Submission barrier: not on a context without vkCmdPipelineBarrier ### 📊 Changes **2 files changed** (+71 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/vulkan_backend.h` (+12 -0) 📝 `runtime/test/vk_queue_test.cpp` (+59 -0) </details> ### 📄 Description Claim: VK-SUBMIT-BARRIER (#14). **What was wrong:** D3D12 ends every `ExecuteCommandLists` with its work done and its writes visible to the next submission on the queue. Implicit state decay relies on it, and a list may touch memory an earlier submission wrote without any barrier (two submissions copying into one buffer, say). Vulkan orders submissions on a queue only by their barriers, and nothing in a `VulkanQueue`'s command buffer ordered it after the previous one. Synchronization validation reports it in `vk_queue_test`'s back-to-back copies into one buffer: WRITE_AFTER_WRITE between submissions, 10 errors, the test fails under `LEONIDA_VK_VALIDATION=1`. **What changed:** `execute_now` records an `ALL_COMMANDS -> ALL_COMMANDS` memory barrier (`MEMORY_WRITE -> MEMORY_READ | MEMORY_WRITE`) right after `vkBeginCommandBuffer`. The second commit skips it on a context without `vkCmdPipelineBarrier`: `replay_query_edges_test`'s mocked context has none, and the first commit alone crashed that test. Cost: one global memory barrier per submitted command buffer. Execution order between submissions is unchanged; the barrier only makes writes visible. **Tests:** `vk_queue_test` 4b counts the command buffers begun and those whose first barrier is this one, over two submissions each on the direct and the copy queue: 4 of 4 (0 before). Tested on Windows 10, i7-11800H, RTX 3080 Laptop (NVIDIA driver), on `main` `8f481cf16`, with `LEONIDA_VK_VALIDATION=1`: `vk_queue` passes with 0 validation errors, `replay_query_edges` passes. On our cumulative branch the GPU tests (`^(d3d12_|vk_)`) under validation pass with this in place. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:09 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#521
No description provided.