Skip to content

fix(test): use monotonic fence value (31) for bundle blend pass in d3d12_draw_test - #1807

Closed
Vonsek wants to merge 1 commit into
ItsNotRexed:mainfrom
Vonsek:ag/fix-draw-test-bundle-fence
Closed

Vonsek wants to merge 1 commit into
ItsNotRexed:mainfrom
Vonsek:ag/fix-draw-test-bundle-fence

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

What and why

After #1591 (4× MSAA) and #1660 (bundle blend factor) both merged into main, runtime/test/d3d12_draw_test.cpp signaled fence value 30 on the no-viewport pass and then signaled/waited on fence value 4 for the bundle blend pass. Because the timeline fence had already reached 30, SetEventOnCompletion(4, nullptr) returned immediately without waiting for the GPU, so the CPU readback saw stale MSAA purple pixels (127, 0, 127, 255) instead of the expected bundle blend red 64.

This 1-line fix bumps the bundle blend pass fence value from 4 to 31 so fence values stay strictly monotonic.

Reproduction before the fix

On upstream/main (003e7812), running d3d12_draw_test.exe on RTX 5080 failed immediately:

bundle blend pixel (0, 0): got 127,0,127,255, expected red 64
exit=1

Tested

Commit 54da5dde on upstream/main 003e7812, Windows 11, MSVC 19.44, Ninja RelWithDebInfo, VK_LOADER_LAYERS_DISABLE=~implicit~ (synthetic scene only; no game data):

  • NVIDIA GeForce RTX 5080 (driver 616.92, Vulkan 1.4.351): d3d12_draw_test.exe PASS (exit=0) — all passes (M1, XOR/fullscreen, strip cut, 4× MSAA, bundle blend) matched.
  • AMD Radeon(TM) Graphics (driver 26.10.1, Vulkan 1.4.315): d3d12_draw_test.exe PASS (exit=0).
  • Note: VK_LAYER_KHRONOS_validation is not installed locally; CI runs Vulkan validation on this commit.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Test fix only.)

AI Assisted.

…d12_draw_test

After ItsNotRexed#1591 (4x MSAA) and ItsNotRexed#1660 (bundle blend factor) both merged into main,
d3d12_draw_test signaled fence value 30 for the no-viewport pass and then
signaled/waited on fence value 4 for the bundle blend pass. Because the fence
had already passed 4, SetEventOnCompletion(4) returned immediately without
waiting for the GPU, causing readback to see stale MSAA pixels (127,0,127,255)
instead of expected red 64.

Bump the bundle blend pass fence value from 4 to 31.

AI Assisted.
@Rossrocha

Copy link
Copy Markdown

Tested 54da5dd 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: pass. This GPU fails the bundle-blend check deterministically on main, so it makes a good check for this fix.

d3d12_draw_test, clean scripts\build_runtime.ps1 build each time:

build result, 10 runs first failing pixel
main 89b047c 0/10 (3 of 3 checked by hand) bundle blend pixel (0, 0): got 255,0,0,255, expected red 64
main 003e781 + #1793 (fence 21) 0/10 got 128,0,128,255, expected red 64
main 003e781 + this PR (fence 31) 10/10 —

With LEONIDA_VK_VALIDATION=1, this PR exits 0 with no VUIDs. On main, the early exit also leaves VUID-vkDestroyPipeline-pipeline-00765 (pipeline destroyed while the command buffer is still in flight), which fits the wait returning too early.

Why 21 isn't enough any more: main now signals fence 30 before this block (d3d12_draw_test.cpp:580). A wait on 21 is already satisfied, so the test reads the previous pass's pixels (the 128,0,128). 31 is above every earlier value. I'll note the same on #1793.

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

@liamarguedas

Copy link
Copy Markdown

Tested 54da5dd on RTX 4070 SUPER, driver 610.47, Windows 11 (MSVC 17.14, Vulkan SDK 1.4.363): d3d12_draw_test passes 3/3. Current main (003e781) fails 3/3 with got 127,0,127,255, expected red 64.

Suggestion: this is the second time a new pass raised the fence above a later hard-coded value (#1793 picked 21, then the MSAA pass moved to 30). Deriving the value instead, e.g. const UINT64 v = fence->GetCompletedValue() + 1; before Signal(fence.p, v) / SetEventOnCompletion(v, nullptr), or one running counter for every pass in the test, would stop the next added pass from silently turning a wait into a no-op.

@ashiikins

Copy link
Copy Markdown
Contributor

Tested 54da5dd on an Apple M2 Max, arm64 Wine + FEX (CrossOver Preview 20260821, MoltenVK 1.2.10), runtime cross-built with clang-cl + xwin from main 003e781 + #1706 + RT-121: pass. Without it d3d12_draw reads the strips before the bundle draws land (128,0,128 in strips 0–1, the blue clear in 2–3), after fence signal 4 is not above 20. Also passes with MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=1.

AI-assisted.

@dev-ewann

Copy link
Copy Markdown
Contributor

Tested this PR's change (d3d12_draw_test.cpp:634, fence 31) applied to current main 6a6704d on NVIDIA GeForce RTX 5070, driver 621.14, Vulkan 1.4.357, Windows 11 (build 26300), MSVC 19.44, Ninja RelWithDebInfo: pass, 3/3.

main alone, which already has #1793's fence 21, fails 3/3: fence signal 21 is not above 30; Vulkan timelines cannot go back, then bundle blend pixel (0, 0): got 127,0,127,255, expected red 64. Line 580 signals 30 first, so 21 doesn't wait. This PR now conflicts with main on that line. A rebase that keeps 31 still fixes the test. I applied the change by hand, I didn't test 54da5dd itself.

AI-assisted (Claude), on behalf of dev-ewann.

@MelonPy

MelonPy commented Nov 22, 2026

Copy link
Copy Markdown

Tested this PR's change (d3d12_draw_test.cpp:634, fence 31) applied to main 6a6704d on Intel Arc Graphics (Meteor Lake-H iGPU, Xe-LPG, 0x8086:0x7d55), Intel driver 32.0.101.6127, Vulkan 1.3.295, Windows 11 Pro 26H2 (build 26300), VS Build Tools CMake + Ninja via scripts\build_runtime.ps1: d3d12_draw_test passes 5/5.

Without it, main 6a6704d fails 5/5 with [rt] d3d12: fence signal 21 is not above 30; Vulkan timelines cannot go back followed by bundle blend pixel (0, 0): got 128,0,128,255, expected red 64; 003e781 failed the same way with fence 4. The purple is the readback of the 4x MSAA half-mask pass before it, so the check ran before the bundle draws.

Only this test was run with the change; not the PR's branch itself, which conflicts with main.

@enzornd19

Copy link
Copy Markdown

Tested 54da5dd on RTX 5060 Ti (Blackwell), NVIDIA 621.01, Windows 11 Pro (build 26300), MSVC 19.44 + Ninja: the fix works, but the PR now conflicts with main.

  • Tests: wait for the bundle blend draws in d3d12_draw (fence 21, not 4) #1793 was merged, so main 4eb6155 has Signal(fence.p, 21) at runtime/test/d3d12_draw_test.cpp:634, and this PR's 4 → 31 hunk no longer applies (merge conflict on that line).
  • Plain main 4eb6155: d3d12_draw still fails (fence signal 21 is not above 30; Vulkan timelines cannot go back, bundle blend pixel (0, 0): got 127,0,127,255, expected red 64); full ctest 109/110.
  • With the conflict resolved as this PR intends (21 → 31 in both Signal and SetEventOnCompletion): ctest -R ^d3d12_draw$ --repeat until-fail:5 passes 5/5.
  • So a rebase onto main changing 21 → 31 is all it needs.

No game files. AI-assisted.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Closing as a duplicate: the d3d12_draw bundle fence fix (fence 31) landed on main via #1995. Thanks!

@JRamos1993

Copy link
Copy Markdown
Contributor

Measured on main 4eb6155 with an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, fresh RelWithDebInfo build:

  • main as it is: d3d12_draw_test.exe run on its own fails 30 of 30 times, always with fence signal 21 is not above 30 and bundle blend pixel (0, 0): got 127,0,127,255, expected red 64. Under LEONIDA_VK_VALIDATION=1 it also reports VUID-vkDestroyPipeline-pipeline-00765: the pipeline is destroyed while the bundle draw is still in flight.
  • With this PR's value on main's line (line 634: Signal(fence.p, 31) / SetEventOnCompletion(31, …)): 30 of 30 runs pass, and it passes under validation with 0 messages.
  • Under ctest: the unpatched test passed in 2 of 10 full ctest -j 6 runs here, presumably when the GPU finished before the readback. So a single green CI run on main doesn't mean it's fixed.

The rebase only needs line 634's 21 → 31. The comment above it ("Above the strip passes' 20") should then name line 580's 30 instead.

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.

10 participants