Recompiler: keep a draw's descriptor heaps alive until the list has run #553
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!553
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-553"
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?
@us3r40456 on GitHub · 2026-11-24 01:43 UTC · original
us3r40456:recompiler-draw-heap-lifetime→main· +30 −1 · 2 files · 3 commits · openDraws with no textures or samplers released their descriptor heaps right after
SetDescriptorHeaps, before the command list ran. On D3DMetal (CrossOver on Apple Silicon) such a list never completes: this is the draw hang reported for Apple Silicon in #42.What is in it
draw_indexed_onbinds its heaps withbind_viewsin every case and keeps them until the fence wait. The no-texture case went throughbind_resources(...).map(|_| Vec::new()), which dropped theBoundand its heaps at once, and D3D12 command lists do not keep the heaps they bind alive.bind_viewsalready handles the empty case (2 CBV/SRV/UAV slots, 1 sampler slot).gpu_draw_keeps_its_descriptor_heaps(Kalmarv's test from the report below, co-authored): a plain HLSL VS / PS triangle throughrunner::draw, gated only on an adapter and DXC, so it runs on the CI runner's WARP, where the seven draw tests skip.Tested
mainb7aa9f3has 723 passed, 0 failed on WARP and on an RTX 5070 Ti.gpu_draw_keeps_its_descriptor_heapson D3DMetal (Apple M5 Pro): 3 of 3 passed with the change; no result after 60 s without it.XCL_DXC_DIR). Unit-test binary run under CrossOver'swine.gpu_graphics_vs_ps_draw,gpu_rect_list_corners,gpu_rect_list_flat_outputs,gpu_rect_list_fullscreen_order,gpu_wave64_ps_spill_slots,gpu_wave64_ps_whole_wave_reductions,gpu_wave64_vs_spill_slots_and_identity), one per process with--exact: on this PR (be2b06c), 7 passed, about 0.5 s each. On main508a0c7,gpu_graphics_vs_ps_drawhas no result after 60 s; on2b4bb43(samerunner.rs) none of the 7 had a result after 2 minutes.gpu::recomp(200 tests) with this change on2b4bb43(runner.rs,tests.rsandfence.rsare unchanged on508a0c7): 160 passed (2 of them printSKIPPED: no wave64), 22 failed, 18 ignored. Without it: 153 passed, 22 failed, 7 hung, 18 ignored. The 22 failures are the same tests in both runs (FP64,OpenExistingHeapFromAddressand the others listed in #42).tests/gpu_pso_e2e.rs: 7 passed;tests/console_shaders.rs: 3 passed, 4 ignored. WithoutXCL_SAMPLE_RPF/XCL_SAMPLE_DXCthey return early, so they do not draw here.Regression run
Not run: I have no Xbox title to run
scripts/smoke.ps1on.runner.rsis undercrates/xcl/src, but the changed function is only reached from tests (runner::draw,draw_on,draw_on_multi); the runtime uses onlyadapter(),wave64_supported()andgraphics_wave32()from this file.Not tested
cargo test --workspace.gpu::recompin one process with--test-threads=4did not finish: after 139 results,gpu_unified_memory_arena(fails on D3DMetal withE_NOTIMPL) and three other tests stayed "running for over 60 seconds" at 100 % CPU. One per process, the other three pass. Not investigated; I could not compare it without this change, because the draw tests hang first there.AI use
For a draw with no textures or samplers, draw_indexed_on bound its CBV/SRV/UAV and sampler heaps through `bind_resources(...).map(|_| Vec::new())`, which drops the returned `Bound`, and the heaps with it, right after SetDescriptorHeaps. D3D12 command lists hold no reference to the heaps they bind, so the list was executed with released heaps. On D3DMetal (CrossOver 26.3, Apple M5 Pro) such a list never completes: the fence wait times out after 10 s, then GetDeviceRemovedReason blocks, so the seven graphics tests that draw without textures hang (gpu_graphics_vs_ps_draw, the three gpu_rect_list_* tests and the three gpu_wave64_{ps,vs}_* tests). bind_views handles the empty case the same way (two CBV/SRV/UAV slots, one sampler slot) and returns the heaps, so every draw now goes through it and keeps them until the fence wait. The compute paths already keep theirs.@us3r40456 on GitHub · 2026-11-24 01:47 UTC · original
Overlap with #239: this is the same empty-draw heap fix as in #239 (
draw_indexed_onkeeping the heaps thatbind_resources(...).map(|_| Vec::new())dropped), on its own, without the device-removal changes that #239's review asks to revise. On D3DMetal (Apple M5 Pro) it is what makes the 7 draw tests stop hanging (see Tested). I missed #239 before opening this; if you'd rather take the fix through #239, I'll close this one.@thehollowedone on GitHub · 2026-11-24 01:47 UTC · original
Tested
The seven draw tests listed in the PR description passed on both exact parent 508a0c7 and PR head be2b06c on native Windows D3D12. Each revision had 7 passed, 0 failed, 0 ignored, and no reported skips or timeouts. The CrossOver hang did not occur here.
RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, debug. I built each revision separately with
cargo test --offline --locked -p xcl --lib --no-run, then ran each test in its own process with--exact gpu::recomp::tests::<name> --nocapture,XCL_ADAPTER=3080 Ti, and a 15-second timeout.Not tested
D3DMetal, the D3D12 debug layer, full workspace, and retail titles.
AI use
Codex with GPT-6.2 Sol ran the tests and drafted this report.
@eizispark on GitHub · 2026-11-24 02:20 UTC · original
Hardware check of
be2b06c99b0f83773ecd3dc867c71a6cc9cf12bc(verified clean merge withmain9ce2070): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:680 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)gpu::recomp::tests(gpu_graphics_vs_ps_draw,gpu_rect_list_corners,gpu_rect_list_flat_outputs,gpu_rect_list_fullscreen_order,gpu_wave64_ps_spill_slots,gpu_wave64_ps_whole_wave_reductions,gpu_wave64_vs_spill_slots_and_identity): 7 passedRegression run
main(9ce2070):PR (
be2b06c):Not tested
runner::draw_indexed_onis exercised by the GPU test suite above rather than retail title runs)AI use
scripts/smoke.ps1harness on this machine and formatted this report.@us3r40456 on GitHub · 2026-11-24 11:22 UTC · original
@ivall: could this one get the
test-onlylabel (#507)? The diff is inrunner.rs, but only indraw_indexed_on, which nothing outside the tests reaches (runner::draw,draw_onanddraw_on_multiare called fromgpu/recomp/tests.rsandtests/only, still so onmain47efa2e). That is why there is noxcl-smokepair: I have no Xbox title to make one with.What it has instead: the Windows runs above, on an RTX 3080 Ti and on an RX 9070 XT (full suite, 680 passed, 0 failed), and on D3DMetal it is what stops the 7 draw tests from hanging. It still merges cleanly onto
main47efa2e.@shortside on GitHub · 2026-11-24 11:56 UTC · original
Test report from a second Mac, head
be2b06cagainst its merge base508a0c7.Tested
x86_64-pc-windows-msvcwith clang-cl / lld-link 23.1.6 and an xwin SDK 10.0.26100, Rust 1.100.0, debug. The lib test binary run under Wine, one test per process (--exact --nocapture, 60 s cap).gpu_graphics_vs_ps_draw,gpu_rect_list_corners,gpu_rect_list_flat_outputs,gpu_rect_list_fullscreen_order,gpu_wave64_ps_spill_slots,gpu_wave64_ps_whole_wave_reductions,gpu_wave64_vs_spill_slots_and_identity): base 7 of 7 with no result at the 60 s cap; head 7 of 7 passed.main9aec53d: a macOSsampleof the hung process shows the test thread waiting inside D3DMetal while D3DMetal's own "Async Queue" thread sits in a fault handler; the queue completes when theSetDescriptorHeapsheaps are kept alive, which is this change.Not tested
AI use
@Lucasyudi on GitHub · 2026-11-24 13:07 UTC · original
Test report from a second Apple silicon Mac (different chip and toolchain), plus an independent bisection that lands on the same cause.
Tested
x86_64-pc-windows-gnuwith mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug, DXC 1.9.2609. Your diff applied onmain47efa2e(it applies cleanly;runner.rsthere is the same around the change). Lib test binary under CrossOver'swine, one test per process, 60 s cap.mainhere, allokwith the diff (about 0.5 s each): the 7 in your list plusgpu_ps_p0_reads_flat_integer_selectors, which goes through the samerunner::drawwith no textures and hung in my sweep on64b3f35too.gpu_mesh_mode_two_passespasses,gpu_ps_image_sample_offset_implicit_lod_between_mipsfails at the same assertion as onmain(that one is #982).Bisection, before I found this PR (on
main47efa2e, a temporary test that reads the VS / PS HLSL from files and draws throughrunner::draw, with switches indraw_indexed_on):bind_resources(...).map(|_| Vec::new())heaps: still hangs. Skipping the root UAVs or the finalCopyTextureRegion: still hangs.bind_resources(noSetDescriptorHeaps): completes, with the expected pixels.wait_for_submission/fence::wait:Signalreturns,GetCompletedValuestays 0, the 10 sWaitForSingleObjecttimes out, thenGetDeviceRemovedReasonnever returns, the same thing the #42 notes describe.Not tested
be2b06c(I applied the diff on a newermain), Windows, the rest of the suite.AI-assisted (Claude Code, Claude Opus 5.5): bisected, built and ran the tests, wrote this report.
@Kalmarv on GitHub · 2026-11-24 16:57 UTC · original
Windows test report for
be2b06cagainst its base508a0c7: on WARP (the software adapter the CI runner has) a draw throughrunner::drawremoves the device or crashes the test process on the base and passes on this PR. On an RTX 5070 Ti nothing changes. We ran into the same line from the other side today: it was the cause of #1426's CI failure at065aef3.Tested
XCL_ADAPTER=warp, d3d10warp.dll 10.0.26100.9711) and NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74); inbox D3D12Core 10.0.26100.9549; DXC 1.9.2609 (XCL_DXC_DIR); Rust 1.99.0, debug.cargo test -p xcl --lib --no-runat508a0c7and atbe2b06c. Each test in its own process,<exe> --exact gpu::recomp::tests::<name> --test-threads=1, 3 runs each.SKIPPED ...: no wave64on both commits, 3 of 3 runs. Each of them skips on an adapter that runs neither 64- nor 32-lane waves, so on WARP they never reach the draw. That is why CI has not seen this bug.508a0c7and 7 passed onbe2b06c, 3 of 3 runs each. The released heaps go unnoticed on this driver.gpu_draw_keeps_its_descriptor_heaps, below: a plain HLSL VS/PS triangle throughrunner::draw, gated only on an adapter and DXC):508a0c7draw: D3D12 device removed (0x887a0020 ...); run 3: access violation, the process exits without a test resultbe2b06c0x887A0005, so one such draw takes the rest of a CI run with it (seen on #1426: 6 failures from 2 draws).be2b06cas it is (no local test),<exe> --test-threads=4:mainb7aa9f3, with the test below: WARP 723 passed, 0 failed, 21 ignored (206 SKIPPED, no wave64); RTX 5070 Ti 723 passed, 0 failed, 21 ignored (2 SKIPPED). The test alone without the change onb7aa9f3, WARP, 3 runs: one access violation, twodevice removed (0x887a0020).runner.rsline): access violation in 3 of 3 runs before the change, 0 messages in 3 runs with it.Not tested
scripts/smoke.ps1: the changed function is only reached from tests, as the description says.cargo test --workspace(tests/gpu_pso_e2e.rs,tests/console_shaders.rs) andscripts/test.ps1.be2b06crebased onto today'smain(it is 1 commit on508a0c7; the line is unchanged onb7aa9f3, where the same change was tested as above).Follow-up offered
The 7 draw tests cannot catch this on CI because they skip on WARP. The test we used does run there, and fails on the base. If you want it in this PR, take it as it is (it goes into
crates/xcl/src/gpu/recomp/tests.rs); otherwise we can send it as a separate PR after this one merges.AI use: Claude Code (Claude Fable 5.2, Claude Opus 5.5)
@iLucasRT on GitHub · 2026-11-24 18:28 UTC · original
Test report for this PR (
bbbb8de, its diff onmain9e3831e), and a related gap in the same function, with a patch on top of this PR in case you want to take it.Tested
XCL_SAMPLE_RPF,XCL_SAMPLE_DLLSandXCL_SAMPLE_BVH4set.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4:XCL_HEAP_WINDOWS=1main9e3831e41 ignored in every run. SKIPPED: none with the variable;
heap_window_out_of_memory_falls_back_to_the_switch_formwithout it.gpu_draw_keeps_its_descriptor_heapspasses.The gap (not caused by this PR): since #680, with
XCL_HEAP_WINDOWS=1a pipeline built by the backend's hook reads the memory windows through descriptorsMEM_HEAP_BASE.. of the bound heap.draw_indexed_onbinds one without them, and the textures of the textured test sit in those slots, so threegpu_pso_e2etests (they needXCL_SAMPLE_RPF, so CI does not run them) keep the clear colour:retail_vs_ps_through_the_pso_hook_render_and_read_back,retail_pipelines_built_in_the_background_behind_a_stand_in,retail_textured_ps_decoded_descriptors_and_a_descriptor_change_between_draws.run_in_regionanddispatch_withalready make those views. It is a test-harness gap, not a driver problem.The change is small and touches the line this PR rewrites, so here it is on top of it: the raw views of
memfirst, the textures after them, and only for draws of hook-built pipelines (draw_on_multi). With heap windows off nothing changes. Take it, change it or leave it for later, whatever suits you. The same for plainmain, as a commit: https://github.com/iLucasRT/xcl/tree/tests-heap-windows-draws (72b98dc).Patch on top of this PR (+33 −10)
Not tested
Own brain use: Double-checked code and tests. It works on my RX 7900 XTX but still needs a run on other GPUs (NVIDIA, Intel, RDNA2/RDNA4).
AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the patch, ran the tests on this machine and wrote this report.
@Toons29 on GitHub · 2026-11-25 02:57 UTC · original
Regression run of
bbbb8defon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 90 % of
main's frames, 99 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@upipibi on GitHub · 2026-11-25 07:33 UTC · original · edited 2026-11-25 08:50 UTC
NVIDIA run of your table, since your report lists NVIDIA as not tested. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug,
cargo test --workspace --no-fail-fast -- --test-threads=4. Your patch only builds on your base, so all rows are onmain9e3831e: alone, with this PR merged (bbbb8de), and with this PR and your patch.XCL_HEAP_WINDOWS=1main9e3831e41 ignored in every run. SKIPPED:
gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).gpu_pso_e2etests pass in every row with the variable set, includingretail_textured_ps_decoded_descriptors_and_a_descriptor_change_between_drawsonmain. Heap windows were active: the backend logged one fallback to the switch form after the driver ran out of memory on a pipeline. So the gap shows on AMD but not on this NVIDIA card. Presumably whatever the draw reads from the unwritten window descriptors happens to work here; I haven't checked that. Your patch neither helps nor hurts on NVIDIA.test_title_runs_and_game_folder_is_untouchedin every row, which failed because my build step ran onlycargo build --workspace --tests, soxcl_testtitle.exeandtestgame_mw.dll, built from the repository'stests/testtitle, were missing (the panic says "build first: cargo build --workspace"). So the end-to-end test did not run here; and one XAudio2 playback-timing test, a different one in each run (opus_source_voice…onmain,xma2_source_voice…with the PR; #1600).main568e7dbandXCL_HEAP_WINDOWS=1: 1154 passed, 1 failed (the same e2e test, for the same reason).AI-assisted (Claude Code). Synthetic tests only.
@DavidM1911 on GitHub · 2026-11-25 13:30 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.