Skip to content

vk_command_replay_test: cover a subresource copied twice in one list - #891

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:test/back-to-back-copy-barrier
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
bobcatchris:test/back-to-back-copy-barrier

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #634 (comment)

What and why

copy_layout has to order a transfer write that finds its range already in the transfer layout, because a texture can stay in COPY_DEST and be copied into again: D3D12 orders copies on the queue and needs no barrier from the application, Vulkan does not. That ordering landed in 5ec780c without a test, and the path is reachable — on a tree without it, the BC7 copy case in d3d12_vulkan_device_test reports ten WRITE_AFTER_WRITE hazards under synchronization validation (that is what #775 is hitting on my card).

This adds Part G to vk_command_replay_test: one 4x4 RGBA texture, two buffer-to-image copies into the same subresource in a single list with no transition between them, then a readback. The test already fails on any validation error, so the missing barrier is caught directly instead of showing up as hazards in a differential test.

No implementation change: 5ec780c is on main and does the ordering correctly.

Tested

RX 7900 XTX (RDNA3, gfx1100), AMD 26.10.1, Vulkan 1.4.359, Windows 11 26200.

  • LEONIDA_VK_VALIDATION=1 vk_command_replay_test.exe — exit 0, G: one subresource copied twice in one list, no validation errors; the texels read back as the second copy.
  • Same build with the memory_barrier in copy_layout disabled — validation: vkCmdCopyBufferToImage(): WRITE_AFTER_WRITE hazard detected …, 1 validation error, exit 1. So the part fails exactly when the ordering is missing.
  • LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build — 31/33 pass. The only failure is the existing d3d12_vulkan_device OPTIONS19.SupportedSampleCountsWithNoOutputs: ours 0xf not subset of host 0x1d, which Runtime: OPTIONS19 no-output sample counts are 1/4/8/16 (no 2x) — fixes the red d3d12_vulkan_device_test on AMD #855 addresses and which is unrelated to this change.

Refs #775.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • Not a translator change, so no docs/design.md contract-table entry.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto main d1211d0 (65 commits later) and re-ran it there: build clean, LEONIDA_VK_VALIDATION=1 vk_command_replay_test.exe exit 0 with G: one subresource copied twice in one list, no validation errors, and ctest 31/32 with the only failure being main's existing #854 OPTIONS19 line. The history is a single commit, unchanged apart from the rebase.

AI-assisted.

@dcastell1

Copy link
Copy Markdown
Contributor

Tested 3815be2 on an RTX 5090 (Blackwell), Windows 11 Pro 10.0.26300.9974, NVIDIA 621.24 / Vulkan 1.4.357, MSVC 19.44, clean RelWithDebInfo Ninja build:

  • vk_command_replay_test: exit 0 with LEONIDA_VK_VALIDATION=1 and the 1.4.363 validation layer, 0 VUID-/validation error lines.
  • Parts A–F unchanged; new Part G: one 4x4 RGBA subresource copied twice in one list, reported as “one subresource copied twice in one list, no validation errors”.
  • VK_LOADER_LAYERS_DISABLE=~implicit~ was set because ReShade and the Epic/NVIDIA layers are installed.

No game files were used.

@quackottu quackottu 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.

Tested 85a1b0c on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 32
  • vk_command_replay_test (changed here): exit=0 validation=0 | G: one subresource copied twice in one list, no validation errors
  • 32 test programs in the build pass with 0 validation errors
  • Not run (they take an input file, not covered here): vk_binary_occlusion_test
  • d3d12_clear_test fails (R8G8B8A8_UNORM/SNORM 0.5 ties and a D16 clear byte differ from WARP) exactly as on main 4a36bb1 here, so not from this PR; #521 addresses it

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Rebased onto main 067d3e8 (99 commits since the last rebase, and the test file had no conflicts). Re-ran on the RX 7900 XTX, AMD 26.10.1, Vulkan 1.4.359, MSVC 19.39:

Single commit, unchanged apart from the rebase.

AI-assisted.

@bobcatchris
bobcatchris force-pushed the test/back-to-back-copy-barrier branch from 3815be2 to e315e26 Compare November 22, 2026 05:05
@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

A heads-up before anyone tests or merges this head: e315e26 sits on a second commit, 5d9c7d1 ("Clarify project status in README", unsigned, author metadata "NotRexed"), whose parent is 067d3e8. That commit isn't on main and isn't on any other branch I can see. It adds one line to README.md under the Discord link: a CA followed by a cryptocurrency contract address.

Your comment above says "single commit, unchanged apart from the rebase", so I'd guess it came in with the rebase rather than on purpose. The PR timeline shows a force-push to main at 04:52 UTC, so a local main fetched before that may have still had it. Could you drop it and force-push? git rebase --onto 067d3e8 5d9c7d1 keeps only the test commit. The Part G change itself looks unaffected, and I'm happy to test it once the head is just that commit.

AI-assisted (Claude Code).

copy_layout has to order a transfer write that finds its range already in
the transfer layout, because a texture can stay in COPY_DEST and be copied
into again; D3D12 orders copies on the queue and needs no barrier from the
application. That ordering landed in 5ec780c without a test, and the BC7
copy case in d3d12_vulkan_device_test reaches it: on a tree without it the
case reports ten WRITE_AFTER_WRITE hazards under synchronization
validation.

Part G records two buffer-to-image copies into the same subresource with no
transition between them and reads the texture back, so the missing
dependency shows up as a validation error and as the wrong texels.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@bobcatchris
bobcatchris force-pushed the test/back-to-back-copy-barrier branch from e315e26 to 033192d Compare November 22, 2026 05:27
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Good catch, and thank you — that second commit was not mine and I have dropped it.

The head is now 033192d, a single commit on main 067d3e8, diff runtime/test/vk_command_replay_test.cpp only (+89/−2). git log origin/main..HEAD shows one line; the README commit is gone from the branch.

Where it came from: 5d9c7d1 adds a line under the Discord link in README.md (CA 8T3ztDSKxYK15SUBseqLeviqQwfcG9wUeDGP1wjBpump), is authored NotRexed <notrexed@gmail.com>, and is not on main — but an equivalent commit was on main for a while earlier today, so anything branched in that window, mine included, carried it silently through a rebase that looked clean. I have rewritten the branch rather than cherry-picking, so the commit object is no longer reachable from it.

Re-verified after the rewrite, same machine: build clean, LEONIDA_VK_VALIDATION=1 vk_command_replay_test exit 0 with G: one subresource copied twice in one list, no validation errors, ctest 33/33.

Worth testing whenever you have a window — the code has not changed, only the head.

AI-assisted.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Thanks for dropping it so quickly, and for tracking down where it came from.

Tested 033192d on an NVIDIA GeForce RTX 3070, driver 610.88, Windows 11 (26300), MSVC 19.44 (VS generator, RelWithDebInfo), Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1: pass

Code read: Part G is the right minimal case. Two buffer-to-image copies into the same subresource with no transition between them make copy_layout find the range already in TRANSFER_DST_OPTIMAL, which is exactly the path 5ec780c added the write-after-write barrier for. Reading the texels back as green confirms the second copy won.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants