Skip to content

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

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

ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
carlcdx:fix/d3d12-draw-bundle-fence

Conversation

@carlcdx

@carlcdx carlcdx commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

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

Fixes #1966

What and why

Follow-up to #1793 (01a61764). In runtime/test/d3d12_draw_test.cpp, line 580 already signals and waits on timeline fence value 30 before the bundle blend pass at line 634 signals and waits on 21. Because 21 <= 30, the Vulkan timeline semaphore ignores the signal (fence signal 21 is not above 30; Vulkan timelines cannot go back) and SetEventOnCompletion(21, nullptr) returns immediately before the GPU finishes the bundle blend draws, causing d3d12_draw to read stale pixels (128,0,128,255) instead of the expected red strip (64).

Bumping the fence value at line 634 from 21 to 31 makes the test wait for the bundle blend draws to complete.

Tested

Built d3d12_draw_test (RelWithDebInfo, MSVC 19.44, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0) on Windows 11 (26300) with VK_LOADER_LAYERS_DISABLE=~implicit~ and ran ctest --test-dir runtime/build -C RelWithDebInfo -R "^d3d12_draw$" --output-on-failure -V:

  • AMD Radeon RX 9070 XT (RDNA 4, Adrenalin 26.10.44 LLPC, driverVersion 2.0.395, Vulkan 1.4.349): failed before (bundle blend pixel (0, 0): got 128,0,128,255, expected red 64), passed after (0.19 sec, no timeline fence warning).
  • AMD Radeon(TM) Graphics (Ryzen 7 9800X3D RDNA 2 iGPU, AMD 24.30.18 SC, driverVersion 2.0.331, Vulkan 1.3.302): failed before with the same symptom, passed after (0.16 sec, no timeline fence warning).

AI-assisted.

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. (N/A — runtime test fix only)

@Yourrespawn

Copy link
Copy Markdown
Contributor

Tested ed25f93b on NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), driver 617.14, Vulkan API 1.4.351, Windows 11 Pro 10.0.26200: pass — and this closes the loop on the failure I reported from the other side.

I hit exactly this bug earlier today while testing #1799: on upstream/main (003e7812), d3d12_draw fails with fence signal 4 is not above 30; Vulkan timelines cannot go back and bundle blend pixel (0, 0): got 127,0,127,255, expected red 64. (My comment on #1799 pointed at #1807 for it; both this PR and #1807 target the same broken wait.)

With this branch: the direct d3d12_draw_test run shows neither message and exits 0, and ctest -R d3d12_draw is 100% pass. 2 lines, does what it says.

Note for the maintainers: #1807 and #1995 both fix the same broken wait — per the coordination rules the first to land wins and the other rebases or closes.

AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine.

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

This diff is the same fence fix as #1807: both change the bundle-pass signal/wait at line 634 to value 31, and #1807 already contains multiple independent GPU runs. #1995 is based on current main and has a fresh validation report, while #1807 is the earlier claim but needs a rebase. The coordination thread says to keep one implementation and rebase or close the other. Please coordinate with @Vonsek/maintainers so only one PR lands; if #1995 is chosen as the replacement, it would be useful to carry over the broader #1807 validation reports.

VictorJulianiR added a commit to VictorJulianiR/Leonida that referenced this pull request Nov 22, 2026
@carlcdx

carlcdx commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Yourrespawn for confirming on the RTX 4080, and thanks @Flyander for catching the overlap with #1807 — I missed #1807 since it predates #1793 and wasn't clean against current main.

@Vonsek / maintainers: happy to handle this whichever way is easiest for merging:

VictorJulianiR added a commit to VictorJulianiR/Leonida that referenced this pull request Nov 22, 2026
…ending bundle fence fix

Preserve the upstream readbacks, run the D3D-54 pixel filter on its own graphics pipeline and read its output separately. The upstream parent includes the existing ProjectLeonida#1995 fence fix by carlcdx.
@adriaespii

Copy link
Copy Markdown
Contributor

Confirmed on Windows 11 with AMD Radeon RX 9070 (RDNA4, driver 26.10.1, MSVC 14.44):

No game files used. This review is AI-assisted.

@TricksterG

Copy link
Copy Markdown
Contributor

Confirmed on RTX 5090 (Blackwell, driver 621.24), Windows 11 Pro 26300, MSVC 14.44 (VS 2022), Vulkan SDK 1.4.363.0 with validation layers, VS generator, Release, -DLEONIDA_SDL3=OFF, with the fix applied to current main (4eb6155, via #1996's branch, which is 0 behind):

AI-assisted (Claude Code): it ran the tests and wrote this comment.

  • Without this PR: d3d12_draw_test fails 5 of 5 runs, deterministically: 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.
  • With this PR's change to runtime/test/d3d12_draw_test.cpp: 5 of 5 pass, LEONIDA_VK_VALIDATION=1, 0 VUIDs, no "not above" message: "M1: five draws and a culled triangle matched all 4096 pixels".

So on an RTX 5090 this isn't a flaky race but a reliable failure on main, and the fix removes it.

@airp1ane

Copy link
Copy Markdown
Contributor

Tested on Windows 11, RTX 4060 Ti (Ada), NVIDIA 621.24: d3d12_draw fails on main 6a6704d (fence signal 21 is not above 30, then bundle blend pixel (0, 0): got 127,0,127,255, expected red 64) and passes with this PR (ed25f93b). Full ctest with this PR and #1898 merged on top: 110/110 passed. #1807 makes the same change but conflicts with main now.

AI-assisted (Claude Code).

@Gabzinnn12

Copy link
Copy Markdown

Tested ed25f93 on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0: d3d12_draw passes.

  • d3d12_draw_test: passed 5 of 5 runs without validation and 5 of 5 with LEONIDA_VK_VALIDATION=1 (+ VK_LAYER_VALIDATE_SYNC=1), no Vulkan validation errors reported.
  • On main 4eb6155 (without this PR), ctest failed d3d12_draw here with bundle blend pixel (0, 0): got 128,0,128,255, expected red 64. After a full incremental rebuild it failed the same way in 10 more runs (5 standalone, 5 through ctest; one earlier standalone run had passed). A validation run there also reported VUID-vkDestroyPipeline-pipeline-00765, which did not appear in any of the five validation runs with this change.
  • ctest: 1 failed out of 109, d3d12_compute (line 515, device_proxy_ref_count(device.p) == 1). It failed the same way in my earlier run at this PR's base 6a6704d; main includes 499c608 and passes it.

AI-assisted (Claude Code, reviewed with Codex). No game files.

@kacper-serewis

Copy link
Copy Markdown
Contributor

Independent RTX 5070 validation (AI-assisted).

Tested the exact two-line patch from PR head ed25f93 applied locally to baseline 4eb6155 (not a checkout of the PR head). The resulting d3d12_draw_test.cpp diff matches this PR.

Environment: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 5070, driver 32.0.16.1656, MSVC 19.50.35721.0, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0; RelWithDebInfo.

Before: d3d12_draw failed in the baseline suite, passed once in isolation, then failed again on the first repeat. The bundle blend pixel was 127,0,127,255 instead of red 64, with the fence-21-after-30 warning.

After:

  • cmake --build runtime/build --config RelWithDebInfo --parallel 6: passed.
  • ctest --test-dir runtime/build -C RelWithDebInfo -R '^d3d12_draw$' --repeat until-fail:50 --output-on-failure --timeout 120: all 50 runs passed.
  • Full configured CTest suite: 102 passed, 1 failed, 7 skipped, 1 disabled. d3d12_draw passed. The failure was the separate xbox_present test at runtime/test/xbox_present_test.cpp:586 (real-time cycling-colour pixel assertion); 10 subsequent isolated repetitions of xbox_present all passed. This test's source was unchanged.

Game-dependent tests were left disabled via unset LEONIDA_GAME_DIR; no game files were used. SDL3 and llvm-mc-dependent coverage was unavailable. This validates the fence fix on this GPU, but does not claim a fully clean runtime suite.

@kapitche

Copy link
Copy Markdown
Collaborator

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): this fixes d3d12_draw on both the RTX 4080 SUPER and the Intel UHD 770. It fails on main on both (bundle blend pixel (0, 0): got 255,0,0,255, expected red 64, bisected to #1660's merge in #2078) and passes with this. The remaining failures on this base are unrelated: d3d12_compute (#1714's refcount, which passes on newer main), plus the known Intel d3d12_present, d3d12_m3_frame and d3d12_subgroup.

@ItsNotRexed
ItsNotRexed merged commit 54176d2 into ProjectLeonida:main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

10 participants