Skip to content

Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4) - #1793

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
WHOISJARDAS:fix-d3d12-draw-bundle-fence
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
WHOISJARDAS:fix-d3d12-draw-bundle-fence

Conversation

@WHOISJARDAS

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #1745 (comment) (new TEST item)

What and why

d3d12_draw fails on main 89b047c on every GPU: bundle blend pixel (0, 0): got 255,0,0,255, expected red 64. It was reported on #1660 for an RTX 4070 SUPER and an Intel UHD 770, and an RX 9070 XT fails the same way here.

The cause is a fence value, not the blend:

So the check reads the readback buffer before the draws have run. Pixel (0, 0) is still the red top-left quad from the last strip-cut pass.

This PR makes the block signal 21 instead. Only the test changes.

Tested

AMD Radeon RX 9070 XT (RDNA4), AMD 26.11.2 (LLPC), Windows 11, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363.0. The runtime was built with scripts/build_runtime.ps1 from main 89b047c plus this commit.

  • d3d12_draw_test.exe: passes on 3 of 3 runs, and the runtime's "not above 20" line is gone. Without this commit it failed on every run with the message above.
  • I also checked that the test now catches a regression. With Runtime: carry bundle blend factors back to parent draws #1660's 4-line change to runtime/shims/d3d12_com.cpp reverted, it fails at strip 1, the explicit zero factor: bundle blend pixel (16, 0): got 64,0,0,255, expected red 0. Before this fix it couldn't catch that, because it never read the draws' output.
  • ctest: 0 failed out of 101. 4 are skipped (bink_decode, fsr_dispatch, bvh_builder, bink_audio) and gameinput is disabled, the same as without this commit. Before, d3d12_draw was the only failure.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No translator rule changes.

AI-assisted (Claude Code): it found the fence clash, wrote the change and ran everything above on the RX 9070 XT.

🤖 Generated with Claude Code

ItsNotRexed#1583's strip-cut passes leave the fence at 20, and ItsNotRexed#1660's bundle blend
block then signalled 4. SetEventOnCompletion(4) returns at once when the
fence has already passed 4, on native D3D12 too, so the check read the
readback buffer before the draws had run. It saw the last strip-cut
pass's red quad: "bundle blend pixel (0, 0): got 255,0,0,255, expected
red 64", on every GPU.

Signal 21 instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent check on AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release. I found the same thing before seeing this PR. Before the fix, the strips read 255 / 255 / blue / blue (want 64 / 0 / 255 / 64), and [rt] d3d12: fence signal 4 is not above 20; Vulkan timelines cannot go back is in the log, so the readback runs before the bundle draws finish. With 4 → 21 (the same one-line change as here): d3d12_draw passes 5 runs out of 5, and the "cannot go back" line is gone. 👍

Side note: the layer returns S_OK for the lower Signal and only logs, so EXPECT(SUCCEEDED(Signal(...))) couldn't catch it. Asserting fence->GetCompletedValue() >= value after the wait would make a future clash like this fail at the line that causes it. That's optional, not needed for this PR.

@Thatters

Copy link
Copy Markdown
Contributor

NVIDIA confirmation plus a bisect: 01a61764 passes on an RTX 5070 Ti (621.24), Windows 11 Pro 25H2, MSVC 14.51 + Ninja.

  • d3d12_draw_test, LEONIDA_VK_VALIDATION=1: pass, 0 VUIDs, no "cannot go back" fence line. Full ctest -j 4 with validation: 101/101, 0 VUIDs.
  • On main 89b047c (built with only Runtime: test the shader lookup against a translated corpus (EGEN-SHADERLIB-CORPUS) #1757's new test on top), it fails here the same way: got 255,0,0,255, expected red 64, plus VUID-vkDestroyPipeline-pipeline-00765 (the pipeline freed while the unwaited draws still run). That's 6/6 runs, with validation on or off.

I bisected it before seeing this PR, merging #1660's tip 5f7caad4 into each first-parent main commit and building:

main commit + 5f7caad4 d3d12_draw
5f7caad4 alone (#1660's tip) pass
df311d79 (#1582 merged) pass
8c350796 (#1583 merged) fail
f5d31f02 (the real #1660 merge) fail

So it starts exactly where #1583's strip passes, which end at fence 20, meet #1660's block signalling 4. That matches your diagnosis; neither PR fails alone.

AI-assisted.

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

Re-reviewed the fence change. The wait now targets value 21, after the strip passes signal through 20, so the test cannot continue early because a lower fence value was already complete. No automated checks are visible for this head.

@AimLogin

Copy link
Copy Markdown
Contributor

@WHOISJARDAS, tested on an RTX 4060 Ti (621.01), Windows 11 26200, LEONIDA_VK_VALIDATION=1, implicit layers off. Your fix is right for its base, but current main has moved past it.

Tree d3d12_draw
#1793 head 01a61764 (on 89b047cd) pass
current main 003e7812, without the fix fail: fence signal 4 is not above 30, then bundle blend pixel (0, 0): got 127,0,127,255, expected red 64
current main + this PR's diff (applies cleanly) still fails: fence signal 21 is not above 30, same pixel, and vkDestroyPipeline of a pipeline still in use
current main + the same line with 31 pass, 3 of 3 runs, 0 validation messages, also with VK_LAYER_VALIDATE_SYNC=1

Why. After 89b047cd, the MSAA work (merged through 79cd04d2, the SampleDesc limits) added a block before the bundle blend case. It has ms_fence starting at 20 and a Signal(fence.p, 30), so 21 is again below the fence's completed value. The Vulkan layer drops the lower signal, the wait returns at once, and the readback runs before the draws finish. Git doesn't flag it: the merge is clean textually, so it only shows at run time.

Suggestion. Bump to 31 when you rebase; the bundle blend signal is the last one in the test. Since d3d12_draw_test.cpp is the tracker's hot spot (21 open PRs and branches), a single counter would stop this from coming back with the next merge: UINT64 fence_value = 0; and Signal(fence.p, ++fence_value) / SetEventOnCompletion(fence_value, nullptr) everywhere, instead of the fixed 1/2/10../20../30/4. That's your call, it's your item. I only tested it.

AI-assisted (Claude Code).

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested 01a6176 on NVIDIA GeForce RTX 5080 (616.92) and AMD Radeon RDNA2 iGPU (26.10.1), Windows 11: pass.

Red on main (89b047c), ctest -R ^d3d12_draw$, same message on both GPUs:

[rt] d3d12: fence signal 4 is not above 20; Vulkan timelines cannot go back
bundle blend pixel (0, 0): got 255,0,0,255, expected red 64
device: AMD Radeon(TM) Graphics            (LEONIDA_VK_DEVICE=radeon)
device: NVIDIA GeForce RTX 5080            (LEONIDA_VK_DEVICE=5080)

On this PR (RelWithDebInfo, Ninja, -j 4, VK_LOADER_LAYERS_DISABLE=~implicit~):

  • LEONIDA_VK_DEVICE=radeon ctest -R ^d3d12_draw$: Passed, no "fence signal" line in the output.
  • LEONIDA_VK_DEVICE=5080 ctest -R ^d3d12_draw$: Passed, no "fence signal" line in the output.
  • LEONIDA_VK_DEVICE=radeon, full ctest: d3d12_draw passes. 1 of 98 fails, d3d12_vulkan_device ("invalid arguments format 67 RT: ours 0x00000000, host 0x80070057"). That failure also happens on main on this PC (two-GPU adapter mismatch, see Tests: compare d3d12_vulkan_device with the host on the layer's own adapter (EGEN-HOST-ADAPTER-LUID) #1785) and is unrelated to this change. 4 skipped (bink_decode, fsr_dispatch, bvh_builder, bink_audio), gameinput disabled.

AI-assisted.

@Rossrocha

Copy link
Copy Markdown

Tested 01a6176 merged onto main 003e781 on AMD Radeon RX 6600 (RDNA2, Navi 23), AMD proprietary 26.11.2 (Vulkan 1.4.315), Windows 11 Pro 10.0.26300: fails on current main. 0/10 runs pass, each with bundle blend pixel (0, 0): got 128,0,128,255, expected red 64, plus VUID-vkDestroyPipeline-pipeline-00765 under LEONIDA_VK_VALIDATION=1.

The cause is a main change after this branch: main now signals fence 30 before the bundle block (runtime/test/d3d12_draw_test.cpp:580), so 21 is already reached. The wait returns at once and the readback sees the previous pass's pixels.

#1807 uses 31 and passes 10/10 here with no VUIDs. Bumping this one to 31 (or above any later value) would do the same. The two PRs fix the same thing (TEST-266), so one of them can close.

AI-assisted (Claude Code): it built both fixes, ran the test and wrote this comment.

@liamarguedas

Copy link
Copy Markdown

Tested on RTX 4070 SUPER, 610.47, Win11: passes on its base (89b047c), but applied to current main (003e781) it still fails 3/3. The pass before it now signals 30 (line 580), so 21 is already reached. #1807 (fence 31) passes on current main. This one looks superseded.

ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
…ulkan_replay.h)

The test's global `constexpr UINT extent = 64` is hidden by a local `extent` in runtime/src/vulkan_replay.h,
so every MSVC build of the runtime prints `warning C4459: declaration of 'extent' hides global declaration`.
It came in with #907, whose earlier fix renamed the global `size` to `extent` for the same reason. The
global is now `target_extent`, a name nothing under runtime/ uses; the test is otherwise unchanged.

Tested on Windows 11 Pro 25H2, MSVC 14.51 + Ninja (scripts/build_runtime.ps1), RTX 5070 Ti / 621.24: the
build has no C4459 (main's 49x C4456 in vulkan_replay.h remain; #1743 handles them). d3d12_translated_draw_test
passes with validation off and on: three draws, 4064/4096 exact, 32 edge pixels, 0 VUIDs. Full ctest with
validation: 106/107; the one failure is d3d12_draw's bundle-blend check, which fails on main too (#1793).
No game files. AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mesterember104-cpu

mesterember104-cpu commented Nov 22, 2026 •

Copy link
Copy Markdown

Tested 01a6176 on Intel(R) UHD Graphics (Tiger Lake (Xe-LP) iGPU 0x9a78, subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass

d3d12_draw_test.exe also run separately: exit 0 — the bundle blend per-pixel check passes silently, and the failure it shows on main is gone: on this GPU, trees without this fix (my #1786 and #1787 runs, both on 89b047c + their PR) failed with exactly "bundle blend pixel (0, 0): got 255,0,0,255, expected red 64". Full ctest: 86/89 pass — d3d12_draw moves out of the failure list; the remaining 3 failures are pre-existing on main and Intel-side, none touch this test-only change: d3d12_descriptor (minimum-LOD views read one mip too detailed — #1725/D3D-219), d3d12_vulkan_device (placed SRGB-cast clear row 0 byte 1: ours bb, host bc — D3D-221, #1752), d3d12_copy_xfmt (ExecuteCommandLists failed: invalid copy or resolve — D3D-220). Not run: bink_decode, bink_audio (no game package), d3d12_rgb9e5_rtv (no RGB9E5 RTV on this adapter), d3d12_queue_wait (standalone Vulkan device creation failed on this driver), gameinput disabled (no SDL3 installed).

AI-assisted (GLM, operated by the account owner).

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.

10 participants