Skip to content

D3D12.X: arm intermediate pre-cell fence signals and initialise cell before publishing - #1297

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/fence-x-intermediate-signals
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/fence-x-intermediate-signals

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

fence_x::note_queue_signal only recorded the maximum signalled value (f.signalled) before completed_value_address was first called. If a queue signalled V1 and then V2 (V2 > V1) before completed_value_address, only V2 was armed: when the GPU completed V1 and paused before V2, the completion event never fired and *cell stayed stale at 0 even though GetCompletedValue() == V1 (deadlocking any caller waiting on *cell >= V1).

In addition, completed_value_address published Cell(0) into FENCES before calling refresh(), allowing a concurrent caller of completed_value_address to observe 0 instead of the fence's current GetCompletedValue().

This records pre-cell queued signal values in a pruned BTreeSet<u64> so completed_value_address arms every pending value > initial, and initialises the cell from GetCompletedValue() before inserting it.

What is in it

  • crates/xcl/src/hle/d3d12x/fence_x.rs: track pre-cell queued signals in Fence::pending (pruning completed values when pending.len() >= 16), initialise Cell with GetCompletedValue() before publishing, and arm all pending values > initial; add GPU test intermediate_signal_queued_before_completed_value_address_updates_cell (verified failing before the fix with cell stayed at 0 while fence GetCompletedValue() == 1).

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib intermediate_signal_queued_before_completed_value_address_updates_cell and the_cell_follows_the_fence: both pass (first timed out at cell == 0 before the fix)

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: cb60656233fc6537600105941ba65124f211e733
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1644 (PresentX 1644)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14606 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited fence_x.rs, wrote the fix and GPU test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

…before publishing

Fence::note_queue_signal only stored the maximum signalled value before
completed_value_address was first called. If a queue signalled V1 and
then V2 (V2 > V1) before completed_value_address, only V2 was armed:
when the GPU reached V1 and paused before V2, the event never fired and
the cell stayed stale at 0 even though GetCompletedValue() == V1.

completed_value_address also published Cell(0) into FENCES before
calling refresh(), allowing a concurrent caller to read 0 instead of
the fence's current completed value.

Record pre-cell queued signal values in a pruned BTreeSet so
completed_value_address arms every pending value > initial, and
initialise the cell from GetCompletedValue() before inserting it.

Assisted-by: OpenCode (Gemini 4 Neon)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head cb60656 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: intermediate_signal_queued_before_completed_value_address_updates_cell.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1286-xcl-dev#1291, xcl-dev#1294, xcl-dev#1296-xcl-dev#1297, xcl-dev#1300

Prevent background shader preloading and concurrent DXC/RADV compiles from exhausting host RAM under Wine, and integrate 11 open upstream PRs:
- dxc.rs & real.rs: check free physical RAM (ullAvailPhys.min(ullAvailPageFile)) under Wine instead of swap-inclusive ullAvailPageFile, avoid bypassing the guard after 60 s under Wine, and serialize giant (>= 4 MiB DXIL) driver compiles with BIG_COMPILES under Wine.
- pso_async.rs: cap background preload workers to 1 under Wine.
- title_textures.rs: use real::create_raw_fence in submit_on_title_queue and read coherent-window hash bytes safely via with_title_bytes.
- Integrate upstream PRs xcl-dev#968 (sparse::queue lock-free for late_release), xcl-dev#1286 (v_dot2_f32_f16 NEG_HI abs), xcl-dev#1287 (XMA >8 channels), xcl-dev#1288 (Sleep pauses during PSO bind waits), xcl-dev#1289 (pipeline stream bounds check), xcl-dev#1290 (root signature MAX_ARGS cap), xcl-dev#1291 (console UAV clears xcl-dev#53/xcl-dev#54), xcl-dev#1294 (shadowed PENDING accuracy), xcl-dev#1296 (16-bit compare low halves), xcl-dev#1297 (fence_x pre-cell signal arming), xcl-dev#1300 (log driver compute PSO refusal).

Verified on RX 9060 XT under GE-Proton11-14 (MemoryMax=12G, 80 s): committed RAM stays flat at 4830 MB (down from 27.6 GB OOM), 1493 frames shown, exit 0x0.

Assisted-by: Antigravity (Google DeepMind)
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…fallbacks

Incorporate targeted upstream fixes from ivall/xcl PRs and local diagnostics
to resolve world-loading E_ACCESS_VIOLATION streaming errors, fence monitor
deadlocks, and mesh/compute PSO visibility:

- DirectStorage (ivall/xcl PR xcl-dev#549; relates to xcl-dev#289, xcl-dev#476, xcl-dev#1164):
  * crates/xcl/src/hle/dstorage.rs: Add Pending::late and refill_late_pages()
    so queues with 0 entries in destination physical-page arrays do not
    auto-submit at half capacity before the title calls Submit() and fills
    the page entries. Add unit test
    a_late_page_array_holds_a_half_full_queue_until_the_titles_submit.
  * Ensure lazy physical pages via kernelx::lazy::ensure() in
    snapshot_page_array() and before re-reading stale destination page tables
    on execute() failure, logging failing snapshot/live entries (adds test
    dest_physical_pages_rereads_stale_snapshot).

- D3D12.X fences (ivall/xcl PR xcl-dev#1297):
  * crates/xcl/src/hle/d3d12x/fence_x.rs: Track all intermediate queued signal
    values in Fence::pending (BTreeSet<u64>) before completed_value_address()
    creates the cell, initialize the cell from GetCompletedValue() before
    publishing, and arm all pending values > initial so *cell cannot remain
    stale at 0 and deadlock callers waiting on intermediate fence values.
    Adds test intermediate_signal_queued_before_completed_value_address_updates_cell.

- D3D12.X PSOs (ivall/xcl PR xcl-dev#1300 / xcl-dev#1035 and PR xcl-dev#1298):
  * crates/xcl/src/hle/d3d12x/real.rs: Log driver rejections of translated
    compute PSOs (hr, DXIL byte size, elapsed compile ms) directly via
    xlog_warn! so refusals are not masked after note_translation_error's
    40-reason limit is consumed (PR xcl-dev#1300).
  * Update fallback_stream() to handle subobject types 24/25 (AS/MS) so
    mesh pipelines with MS in slot 24 rewrite cleanly with stand-in mesh
    shaders instead of invalid null AS payloads (PR xcl-dev#1298).

Assisted-by: Antigravity (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@thehollowedone

Copy link
Copy Markdown
Contributor

Independent Windows run on cb60656. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC.

cargo build --workspace --offline --locked -j 4 passed. cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4 finished with 752 passed, 0 failed, 41 ignored, including two wave64 runtime skips in Cargo’s pass count. The PR's intermediate-signal regression passed.

With the D3D12 debug layer enabled, cargo test --offline --locked -j 4 -p xcl --lib local_signal_x_keeps_intermediate_fence_values_observable -- --nocapture --test-threads=1 passed 1 of 1 without skips. The scratch fixture called XCL's SignalX implementation on a native queue. The first completed-value address read was 16. As the fixture released five queue gates in turn, the value at that address followed the native fence through 17, 18, 19, 20 and 21. Signals 17–20 were queued before the address was requested. Signal 21 was queued after. When the scratch control armed only the highest pre-address value, the native fence reached 17 while the value at the address stayed 16. The control edit was restored. Synthetic queue coverage only.

AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.

@SzczepanGrela

Copy link
Copy Markdown

Linux/RADV + Wine GPU test report on PR #1297 head cb60656 (cb60656233fc6537600105941ba65124f211e733, local merge c374a88d6b8a0ed5c522057456eb565d07bdb3e4 onto origin/main 568e7db7729c8fa6c8f0f4b32d798faaf11462bb).

Setup

  • OS/kernel: CachyOS Linux (7.3.0-5-cachyos)
  • GPU/driver: AMD Radeon RX 9070 (RADV GFX1201, native wave64) (device 0x7550, Vulkan 1.4.354, Mesa RADV 26.2.5-arch3.1)
  • Wine/DX: GE-Proton11-12 (wine-11.0 (Staging)), vkd3d-proton v3.1, DXVK dxgi.dll, DXC 1.9.2602.17 (21d28f72)
  • Build/env: rustc 1.97.1, cargo test --target x86_64-pc-windows-gnu --release --workspace --no-run (43.42s, exit 0, zero compiler warnings), XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0

Results

  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::fence_x::tests -- --nocapture: 2 passed, 0 failed, 0 ignored (0.09s, exit 0; both the_cell_follows_the_fence and new intermediate_signal_queued_before_completed_value_address_updates_cell passed), vs baseline 568e7db (hle::d3d12x::fence_x) 1 passed, 0 failed, 0 ignored (0.08s, exit 0).
  • hle::d3d12x::fence_x::tests -- --nocapture under concurrent Vulkan compute load (vk_tool burn burner.spv gfx 2048 4096 256 30, 803 dispatches, avg dispatch 6.34-6.81 ms): 5 of 5 consecutive runs passed (2 passed, 0 failed, 0 ignored in 0.07s per run, exit 0).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::late_release: 2 passed, 0 failed, 0 ignored (0.18s, exit 0), matching baseline 568e7db 2 passed, 0 failed, 0 ignored (0.19s, exit 0).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::real -- --test-threads=1: 45 passed, 1 failed, 0 ignored (1.18s, exit 101; dma_list_release_cleans_up_list_state at crates/xcl/src/hle/d3d12x/real.rs:6752:120 with HRESULT(0x80070057)), matching baseline 568e7db 45 passed, 1 failed, 0 ignored (1.12s, exit 101, same file, line, and error).
  • cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x -- --test-threads=4: 157 passed, 21 failed, 2 ignored (1.72s, exit 101), vs baseline 568e7db 156 passed, 21 failed, 2 ignored (1.63s, exit 101; +1 passed from fence_x::tests, identical set of 21 pre-existing failures).
  • cargo test --target x86_64-pc-windows-gnu --release --test d3d12_resource_and_sync (default and -- --test-threads=1): 2 passed, 1 failed, 0 ignored in both (0.62s and 0.64s, exit 101; fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console failed at crates/xcl/tests/d3d12_resource_and_sync.rs:481:118 with HRESULT(0x80070057)), matching baseline 568e7db 2 passed, 1 failed, 0 ignored in both (0.25s and 0.26s, exit 101, same file, line, and error).
  • cargo test --target x86_64-pc-windows-gnu --release --test gpu_compute_e2e: 2 passed, 2 failed, 0 ignored (1.49s, exit 101; console_wave64_compute_through_the_pso_hook_dispatch_and_read_back failed with 0x80070057 and heap_window_out_of_memory_falls_back_to_the_switch_form failed with no heap windows, but XCL_REQUIRE_GPU=wave64), matching baseline 568e7db 2 passed, 2 failed, 0 ignored (1.03s, exit 101, same 2 failures).

Not tested

  • No retail game workload and no scripts/smoke.ps1 (no retail title files locally).
  • XCL_HEAP_WINDOWS=1 (left unset) and --lib / --test targets outside those listed above.
  • d3d12_resource_and_sync (fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console) and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back hit the pre-existing Wine real::init() HRESULT(0x80070057) failure present on baseline 568e7db.

AI use

  • Diff audit, test execution, and comment drafting used Antigravity (Gemini 4 Neon) multi-agent verification, reviewed by me before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants