Skip to content

D3D12.X: default XCL_INLINE_GUARD_BATCH off to avoid dead 64 KiB scratch allocations and AMD page faults - #2757

Open
Saksukella wants to merge 1 commit into
xcl-dev:amd-devfrom
Saksukella:fix/default-inline-guard-batch-off
Open

Saksukella wants to merge 1 commit into
xcl-dev:amd-devfrom
Saksukella:fix/default-inline-guard-batch-off

Conversation

@Saksukella

Copy link
Copy Markdown

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs:
    • Change inline_guard_batch_on() (XCL_INLINE_GUARD_BATCH) from opt-out (default = true) to opt-in (XCL_INLINE_GUARD_BATCH=1).
    • Why: execute_indirect clears s.inline_guard = None immediately after every ExecuteIndirect, so the 256-slot inline guard batch never batches more than 1 dispatch. Leaving it enabled by default allocates 64 KiB scratch VRAM (INLINE_GUARD_DST_BYTES) + 8,208 B coherent UMA (INLINE_GUARD_JOBS_BYTES) + Dispatch(4,1,1) of PRELUDE_GUARD_HEAP_HLSL per guarded indirect dispatch, and on AMD RDNA 4 (RX 9070 XT) triggers a deterministic DRED GPU page fault (0x887a0006) at 0x1f0060000 during deep 3D frames. A/B testing with XCL_INLINE_GUARD_BATCH=0 eliminated the 0x1f0060000 page fault completely, falling back cleanly to guard_indirect_heap_pipeline (32-bit root constants + 256 B scratch).
    • Add CPU unit test inline_guard_batch_defaults_off_and_opts_in.
  • Target branch: amd-dev (where inline_guard_batch_on lives).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib inline_guard_batch_defaults_off_and_opts_in: 1 passed, 0 failed (0.00s).
  • Paired A/B XCL_DRED=1 + XCL_GPU_CULPRIT=1 3D captures on RX 9070 XT: default (XCL_INLINE_GUARD_BATCH=1) hit DRED page fault at GPU VA 0x1f0060000 (0x887a0006) around xcl prelude_guard_dispatch_args; XCL_INLINE_GUARD_BATCH=0 eliminated that page fault completely.

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: 2eace3e1b82688cb508da22fb58feaed4157b14d
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15082 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini): assisted with A/B DRED + XCL_GPU_CULPRIT fault isolation, writing the opt-in change and unit test, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.

@relativespace2K

Copy link
Copy Markdown

Tested - retail title and the new guard-batch default on native Windows AMD RDNA2, PR head 2eace3e1b82688cb508da22fb58feaed4157b14d on its base amd-dev b5c0275f, plus the current amd-dev c32c91a3 for the same environment switch

Tool: OpenCode with DeepSeek V4.1 Flash 1017

  • AMD Radeon RX 6800 XT (16338 MiB), driver 32.0.21045.29003; Ryzen 5 5600, 31.9 GB;
    Windows 11 IoT Enterprise LTSC 26100; release build; DXC 1.9.2602.17.
  • cargo test --release -p xcl --lib -- inline_guard_batch_defaults_off_and_opts_in:
    1 passed, 0 failed, 0 ignored, 0 skipped, 1571 filtered out.
  • Game: retail title 1.0.2.1, 180 s runs, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=1 XCL_RUN_SECONDS=180, no other XCL_* variables; warm shader/pipeline caches.
tree / setting presents last present draws peak commit result
b5c0275f default (2 runs) 1,734 / 1,714 107.5 / 82.2 s 8.9k / 8.3k 20,917 / 18,831 MB loading stall
b5c0275f XCL_INLINE_GUARD_BATCH=0 (2) 1,890 / 1,890 162.3 / 125.5 s 35.0k / 23.8k 30,715 / 26,505 MB cutscene, then 0x887a0006
PR head, default off (2) 1,775 / 1,813 123.9 / 123.4 s 16.8k / 22.6k 29,709 / 30,153 MB no crash
c32c91a3 default (1) 1,791 106.8 s 16.5k 26,621 MB no crash
c32c91a3 XCL_INLINE_GUARD_BATCH=0 (2) 1,773 / 1,801 95.1 / 103.8 s 20.1k / 23.5k 28,248 / 27,934 MB no crash

On the PR's base, the default (batching on) stopped on the loading screen at 82-107 s. With
XCL_INLINE_GUARD_BATCH=0 the title left the loading screen and played the opening cutscene
(Bink video, observed on screen), reaching 35,016 draws and 19,800 dispatches, last present
162.3 s. Both guard-off runs then lost the device with 0x887a0006, at 173.4 s and 129.4 s,
during 311,208 B and 317,836 B MS PSO driver compiles (one took 4.7 s, the other never
returned). The PR head itself (default off, warm pipeline library) survived 2/2 at
16.8k/22.6k draws, with 12 s graphics-pipeline wait windows.

On the current amd-dev c32c91a3, which has the newer sparse commits, XCL_INLINE_GUARD_BATCH=0
ran 2/2 to 180 s without a device removal (20.1k/23.5k draws), and the default also ran to 180 s
(16.5k draws). The 0x887a0006 does not reproduce there in these 180 s windows.

So the default flip is not what removes the device: it is what lets the title get far enough to
compile the ~300 KB MS PSOs, and the cold compile is where the old base hangs. On the current
branch the change is safe in these windows; a rebase from b5c0275f to c32c91a3 or later would
let the PR be judged against the branch it targets now.

Not tested: the RDNA4 page fault from the description (this is RDNA2), NVIDIA/Intel GPUs,
world/FPS (not reached), full workspace, debug build.

AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and the game runs, read the logs and wrote this comment; the counts and per-run figures were checked against the logs.

@vibryxcx

Copy link
Copy Markdown

Second RDNA2 report, adding what the report above does not have: the workspace suite in debug, the xcl-smoke blocks, and two notes on the diff.

This change is already on amd-dev. 2f91871 (in amd-dev c32c91a3) has the same +/- lines in bind.rs as this PR's head 2eace3e1, so the rebase suggested above would leave the PR empty. It can probably be closed as landed.

Stale comment. On amd-dev and in this PR, bind.rs still says // Inline 256-slot offset-table batching (`XCL_INLINE_GUARD_BATCH=0` opt-out) above if inline_guard_batch_on() (line 2795 on amd-dev). After the change the switch is opt-in (=1), and =0 is the default. This is a comment fix only, with no behaviour change.

Tested

  • AMD Radeon RX 6800 (RDNA2, driver 32.0.21045.5002), Intel Core i5-10600KF, Windows 11 Pro 26200, rustc 1.100.0 (0ef1bc386 2026-11-09). Head 2eace3e1 vs base b5c0275f (merge-base on amd-dev), each in its own worktree.
  • cargo test --workspace -- --test-threads=4 on head: the lib test binary aborts with 0xc0000005 (STATUS_ACCESS_VIOLATION), the same parallel-run abort reported on other amd-dev PRs.
  • cargo test -p xcl --lib -- --test-threads=1 on head: the first attempt hung for over 40 min in title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels. Rerun with --skip on that test: 1533 passed, 11 failed, 27 ignored, 1 filtered out. Run alone with --exact, the hung test passes in about 2.4 s on head and on base, so it hangs only inside the full run.
  • Each of the 11 failures alone (--exact, --test-threads=1) on head and on base: the same 10 fail on both (fuzz_validate_and_gpu_1, dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget, bitset_runs_emit_exact_contiguous_page_ranges, giant_driver_compiles_have_their_own_lane, title_bytes_are_used_in_place_when_all_are_readable, physical_home_without_sparse_windows_uses_coherent_window). two_pass_binds_set_the_shared_view_heap fails only in the full run and passes alone on both. No failure comes from this PR. This is the same set as the RX 7800 XT report in Recompiler: enforce LOOP_BUDGET at loop headers in per-lane lowering #2769.
  • New test inline_guard_batch_defaults_off_and_opts_in: passes.
  • SKIPPED: 4 lines, all f16_programs_on_the_gpu (V_MUL_F16 / V_PK_MUL_F16, gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426).

Regression run (release, a different retail title from the one in the description, warm caches. The first base run had cold caches and gave 452 frames; the base block below is the rerun.)

xcl-smoke v1
commit: b5c0275f82689e38f0c37e121ef37407e4cbb3e2
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1373 (PresentX 1373)
presents per 2 s (last 3): 59 61 60
device removals: 0
crashes: 0
peak commit: 15024 MB
xcl-smoke v1
commit: 2eace3e1b82688cb508da22fb58feaed4157b14d
gpu: AMD Radeon RX 6800
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1233 (PresentX 1233)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15307 MB

The base is b5c0275f on amd-dev, not a commit of main. The PR targets amd-dev, so pr_check.py's rule does not quite fit here.

A/B on head, 300 s, XCL_DRED=1, A pressed every 20 s from 40 s to 180 s

setting frames peak commit device removals DRED page fault
XCL_INLINE_GUARD_BATCH=1 (old default) 2778 30317 MB 0 none
unset (new default) 2490 27535 MB 0 none

Both runs stall the same way, so the stall is not caused by this PR: presents fall to 0 at about 185 s and 205 s, commit grows to about 28-30 GB and local VRAM from about 8 to about 11 GB. The log shows graphics pipeline wait window (12000 ms) spent, ExecuteIndirect with a pipeline that is still being built skipped, and dispatches with no translated console shader. The first ExecuteIndirect calls appear only at about 194 s, and the guard path logs nothing, so these runs do not show that the inline-guard path ran.

Not tested: the RDNA4 page fault from the description; NVIDIA / Intel; the cutscene / world past the loading stall; c32c91a3 directly (the report above covers it).

AI use: Claude Code (Claude Opus 5.5) ran the builds, tests and game runs, read the logs and wrote this comment. Every number comes from those runs on the hardware above.

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.

3 participants