mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #354] [CLOSED] vulkan_replay: order back-to-back buffer copies, as image copies already are (VK-BUFCOPY-ORDER) #407
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#407
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/354
Author: @natterman12
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:vulkan/order-back-to-back-buffer-copies📝 Commits (1)
b89bab1vulkan_replay: order back-to-back buffer copies, as image copies already are📊 Changes
3 files changed (+47 additions, -4 deletions)
View changed files
📝
runtime/src/vulkan_replay.h(+7 -0)📝
runtime/test/replay_copy_offset_test.cpp(+35 -4)📝
runtime/test/replay_query_edges_test.cpp(+5 -0)📄 Description
Claimed in the coordination issue as: VK-BUFCOPY-ORDER (#14)
What and why
D3D12 runs consecutive copies on a buffer in order with no barrier from the application: the buffer stays in
COPY_DEST/COPY_SOURCE, and that holds within one list and across lists on a queue. Vulkan orders nothing unless a barrier says so.The replay already handles this for images.
copy_layoutsays: "D3D12 orders back-to-back copies and resolves on a resource that stays in COPY_DEST or COPY_SOURCE without a barrier from the application; Vulkan does not", and emits a memory barrier after earlier transfer writes. The plain buffer-to-buffer copy had no such barrier, so two copies into the same buffer are unordered as far as Vulkan is concerned.Synchronization validation reports it. On
maind478a92dwithLEONIDA_VK_VALIDATION=1,vk_queuefails with ten of these from its backlog case (the same 16 MiB copy submitted repeatedly):The change is one barrier ahead of a plain buffer copy: earlier
TRANSFER_WRITEat the transfer stage, to this copy'sTRANSFER_READ | TRANSFER_WRITEat the transfer stage, through the existingdetail::memory_barrier(so it is restricted to the queue's stages like the others). It covers the read side too: a copy that reads what the copy before it wrote.Cost: one transfer-to-transfer memory barrier per buffer copy, the same price image copies already pay.
Tests
replay_copy_offset_test(GPU-free, fake Vulkan): its barrier callback now records whether a transfer-write barrier came before eachvkCmdCopyBuffer. It checks that for a singleCopyResource, and for two overlappingCopyBufferRegioncalls into the same buffer, where each copy needs its own barrier. Both checks fail without the change.replay_query_edges_test: its fake Vulkan table setcopy_bufferbut nopipeline_barrier, so it crashed on the new call. It gets a no-op entry; nothing it asserts changes.Tested
Windows 11 10.0.26300.9974, NVIDIA GeForce RTX 3080 Ti, driver 621.24, Vulkan SDK 1.4.363.0 (validation layer from the SDK), MSVC 19.44.35230. No game files. Everything recompiled for the "after" numbers.
maind478a92d)vk_queue,LEONIDA_VK_VALIDATION=1WRITE_AFTER_WRITEvalidation errors: 0,vk_queue_test: OKreplay_copy_offsetctest,LEONIDA_VK_VALIDATION=1The five that remain fail the same way without this change:
d3d12_vulkan_device(#262 / #238),d3d12_execute_indirect_validation(#337 / #306),d3d12_depth_resolve(#66), and two that only fail under validation and that I am reporting separately in #14 rather than fixing here:d3d12_clear(VUID-VkClearDepthStencilValue-depth-00022) andd3d12_mesh(VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076).Not tested: other GPUs, Linux, and the full suite without validation on this branch (the validation run executes the same tests).
AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (not applicable: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.