Skip to content

Report: a crash reported during a report write is kept; Config: title_memory in any case (#106) - #148

Merged
ivall merged 2 commits into
xcl-dev:mainfrom
mmmharius:fix/report-crash-config-case
Nov 23, 2026
Merged

ivall merged 2 commits into
xcl-dev:mainfrom
mmmharius:fix/report-crash-config-case

Conversation

@mmmharius

Copy link
Copy Markdown
Contributor

Two of the minor items from #106, one commit each.

Report: a crash is no longer dropped (crates/xcl/src/report.rs)

write_final returned as soon as WRITE_LOCK.try_lock() failed, before it stored crash in CRASH. When another thread was writing the report at that moment (WM_CLOSE in present.rs, XCL_RUN_SECONDS in host.rs, DLL_PROCESS_DETACH in loader.rs), a crash reported by eh.rs (unhandled exception filter) or by stop_if_device_removed in real.rs was lost: report.json had no crash and the launcher showed nothing.

Now:

  • the crash is stored in CRASH before the report lock is tried;
  • a call with a crash retries the lock for up to 2 s (10 ms sleeps), then writes the report itself;
  • the wait is bounded, so a crash inside build() on the thread that already holds the lock still ends (the reason for the try_lock);
  • a call without a crash gives way at once, as before.

The retry is a small helper, lock_within, used for both CRASH and WRITE_LOCK; CRASH is never held while waiting for WRITE_LOCK.

Config: title_memory is read in any case (crates/xcl/src/config.rs)

Config::resolve compared title_memory with "auto" and "advanced" as written, while the manifest's value is lowercased and device_type is compared in any case. With title_memory = "Auto" in xcl.toml the manifest was ignored; with "Advanced" uma_mb became 2048 instead of 4095. The value is now trimmed and lowercased once at the start of resolve.

Tests

  • report::tests::a_crash_is_kept_while_another_thread_writes_the_report: another thread holds WRITE_LOCK for about 100 ms while write_final(Some("boom")) is called; CRASH must hold "boom" (no boot record in unit tests, so nothing is written to disk). CRASH is reset afterwards.
  • config::tests::title_memory_is_read_in_any_case: "Auto" with an Advanced manifest and "ADVANCED" without a manifest both give ("advanced", uma_mb 4095).

What was checked: cross-built from Linux for x86_64-pc-windows-gnu at 484dd57. cargo check --workspace --all-targets passes with 0 warnings before and after the change, the test binary builds, and cargo clippy -p xcl --lib reports nothing in the changed lines.

What was not: I had no Windows machine at hand and wine would not start, so the two new tests are compiled but have not been executed, and neither has the rest of the suite. Both are written to fail on the current main. Please run cargo test -p xcl --lib -- report::tests config::tests before merging.

…cl-dev#106)

write_final returned when WRITE_LOCK was taken before it stored the crash, so
a crash reported by the exception filter or a removed device while another
thread wrote the report (WM_CLOSE, XCL_RUN_SECONDS, DLL_PROCESS_DETACH) never
reached report.json. The crash is now stored first, and a crashing thread
waits up to 2 s for the lock to write it itself; a wait never goes on
forever, so a crash inside build() on the writing thread still ends. Calls
without a crash still give way at once.

Unit test: another thread holds the lock while a crash is reported.
resolve compared title_memory with "auto" and "advanced" as written, while
the manifest's value is lowercased and device_type is compared in any case:
title_memory = "Auto" ignored the manifest, "Advanced" got 2048 MiB of
unified memory instead of 4095. The value is trimmed and lowercased once.

Unit test: "Auto" with an Advanced manifest and "ADVANCED" without one.
@ivall
ivall merged commit 2aaf76a into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (main 6da33fa). Checked on an RX 9070 (RDNA4) with the 22 PRs merged together on main eaa36b6: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 582 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed too; and the retail game still reaches its first menu (646 frames in 30 s, no device removal).

BBareth pushed a commit to BBareth/xcl that referenced this pull request Nov 23, 2026
…d title-list BVH builder slots

- Encode RDNA2 BVH descriptors (desc::bvh_words) for RAYTRACING_ACCELERATION_STRUCTURE SRVs in console descriptor heaps instead of zeroing the slot when pResource is NULL, and preserve them across descriptor copies.
- Fix image_bvh64_intersect_ray to use the full 64-bit node pointer (including vaddr[1]) and 48-bit BVH base address when selecting UMA memory windows, so BVH nodes above 4 GiB (including sparse title windows) resolve cleanly.
- Fix axis-aligned grazing rays (0 * inf = NaN) and reject NaN/inverted child boxes in both HLSL bvh_intersect and CPU bvh::intersect_node; add console prebuild_size and compressed-header helpers.
- Wire XboxBvhBuilder.dll command list slots xcl-dev#146 (global UAV barrier) and xcl-dev#148 (AllocateUploadMemory in UMA) into default title command lists (and size extended vtables to cover all console slots).
- Add configurable CheckFeatureSupport(D3D12_OPTIONS5) RaytracingTier reporting (config.raytracing / XCL_RAYTRACING: auto, tier1_1, tier1_0, off) with one-time tier logging in real and null backends.
- Add unit, multi-window GPU, and testtitle end-to-end tests.
BBareth pushed a commit to BBareth/xcl that referenced this pull request Nov 23, 2026
Raytracing SRVs in console heaps, 64-bit multi-window BVH traversal, title-list BVH builder slots (xcl-dev#146 barrier, xcl-dev#148 AllocateUploadMemory). Conflict in bind.rs: both sides kept.
BBareth pushed a commit to BBareth/xcl that referenced this pull request Nov 23, 2026
…and coherent headroom

Follow-up to PR xcl-dev#40 addressing the two remaining issues noted after merge:

1. Sparse window upload & write-watch overhead (XDefiant ~10 GB in 55 s):
   - Replace per-submit synchronous staging + wait_idle() in d3d12x::sparse with an asynchronous 64 MiB ring staging buffer, 16 upload command allocators/lists, a reusable Win32 fence event, and a dedicated 1 MiB pre-zeroed tile-clear buffer (zero CPU stall on uploads; title queues GPU-wait on the upload fence as before).
   - Unify mapped tile tracking into per-tile TileEntry (pool tile + u16 hole bitmask + lazy per-page sent hashes) backed by FxHashMap, replace the serial chunk hash with a 4-way parallel hash + compile-time ZERO_HASHES, and scan directly into a reusable dirty-run scratch buffer without per-page Vec/Box allocations on zero pages.
   - Batch UpdateTileMappings by pool heap with contiguous run merging in map_tiles/unmap_tiles, and eliminate per-run COM AddRef/Release clones in upload loops.
   - Cache watch_ranges in title_textures keyed by atomic generation counters (sparse mapped tiles, textures, graphics reservations), reuse thread-local GetWriteWatch/dirty buffers, merge contiguous sparse windows in Uma::watch_regions(), and skip refresh on empty ExecuteCommandLists(0, null).

2. Coherent Window 3 headroom (complementing bb9f0b5's COHERENT_KEPT for textures):
   - Stop blanket-routing D3D12_HEAP_TYPE_CUSTOM + D3D12_CPU_PAGE_PROPERTY_WRITE_BACK heaps and non-COPY_DEST buffers to coherent Window 3 (on Xbox UMA, CUSTOM+WRITE_BACK is general CPU-cached graphics memory); route them to sparse VRAM and spill oversized/excess readback allocations to sparse VRAM once coherent headroom reaches COHERENT_KEPT, while tracking SPARSE_READBACK so Map(0, NULL, ...) still syncs GPU writes back automatically.
   - Pack small AllocateUploadMemory (xcl-dev#148) calls into the command list Arena and route large ones to sparse VRAM instead of burning 64 KiB coherent grains per call.
vincentes added a commit to vincentes/xcl-wasm that referenced this pull request Nov 24, 2026
The null device becomes `win::d3d12x`, a device that does the memory side
of D3D12.X for real and still renders nothing:

- Unified memory, as on the console: a resource's GPU address is its
  address in the title's address space. Committed resources and heaps get
  graphics memory, placed resources lie in their heap, and
  CreatePlacedResourceX (xcl-dev#44) puts one on memory the title allocated; Map
  returns that address. Read-back buffers up to 64 MiB come from the
  fourth 4 GiB of the region, where XCL's Windows runtime keeps them.
- Command lists record; a queue runs what it is given, in order, at every
  turn of the scheduler (`pump`): buffer copies, the console's memory
  commands (CopyMemoryToMemoryX xcl-dev#60, FillMemoryWith32BitValueX xcl-dev#61,
  Write32 / 64BitValue…X xcl-dev#69 / xcl-dev#70 / xcl-dev#89 with the GPU timestamp) and
  Wait32 / 64BitValueX (xcl-dev#71 / xcl-dev#72), which hold the queue until another
  thread writes the value. KickoffX (xcl-dev#93) starts a list before it is
  closed. A fence moves, and its events are signalled, when the queue
  gets to its Signal.
- The console's layouts: device extensions from slot 44
  (CreateCommandQueueX, CreateCommandListX with the DMA engine's own list
  interface, page pools, pipeline-state creation as objects, …), the
  graphics command list's console slots, AllocateUploadMemory (xcl-dev#148).
- CheckFeatureSupport zeroes the whole structure; a raytracing
  acceleration structure view writes the console's descriptor words.

Draws, pipelines, other views, PresentX and the frame clock do nothing
or are missing. Dev builds optimise `xcl-emu` (the title test: 37 s →
3.3 s).

Measured on macOS (aarch64): the test title passes 40 of its checks (9 of
D3D12.X's 16); the 6 that fail before it aborts in its XG texture check
need HLSL compilation and rendering, the frame clock, or DirectStorage.
`cargo test -p xcl-guest`: 38 passed, 0 failed (the title test now checks
every check by name; the staged tree was built and tested apart from
the working tree). Inside the wasm64 module (1.2 MB, Node 24) the same
run takes 4.4 s: 115 M instructions, most of them the 80 MiB upload check.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
The null device's plain lists ran the console memory slots (xcl-dev#60/xcl-dev#61/
xcl-dev#69-xcl-dev#72/xcl-dev#89/xcl-dev#93) as logging stubs, so the title's console_list_methods
check read back 0x0 on the null backend while the identical immediate
host writes already passed on Vulkan lists. The vtable now wires the
same VulList_* functions into Kind::CommandList; GetDevice (xcl-dev#7),
the UAV barrier (xcl-dev#146) and AllocateUploadMemory (xcl-dev#148) stay
Vulkan-only with their slices (barrier/upload ride with raytracing,
which still fails on null at the OPTIONS5 tail-zero assert).

Failing-first: the new null_list_shares_the_console_memory_methods
test fails pre-route (slot 69 stub writes nothing) and passes now
(write32/fill/copy/timestamp land, pre-satisfied wait returns,
kickoff is a silent no-op), mirroring the title's asserts.
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 797
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null 12->11 FAILs (Write32 fixed, byte-identical remainder), Vulkan 9
unchanged with the real present (640x360 token 0x1 on Intel Arc).
Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20,
0 d3d12).
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
The null device wrote RaytracingTier at +8 but left the oversized-probe
tail untouched, so the title's raytracing_surface check died at the
16-byte 0xAA tail assert on null while the identical probe passed on
Vulkan. Port the Vulkan tail-zero block (bytes past 12 zeroed, 4 KiB
sanity cap) into the null Device_CheckFeatureSupport.

Failing-first: new null_check_feature_support_zeroes_options5_tail test
fails pre-fix ([170 x4] vs [0 x4]) and passes now; other-feature and
short-struct probes pass through untouched on both paths.
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 798
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null stays 11 FAILs (raytracing now clears the tail assert and stops one
leg deeper at the AS SRV descriptor, which needs the Vulkan-only RTAS
view + xcl-dev#146/xcl-dev#148 — that is the unlocked next slice, not this one; all
other null FAILs byte-identical to the pre-fix baseline, 0 non-GPU),
Vulkan 9 unchanged. Retail HOLDS (SIGSEGV exe+0x2237320, exit 139,
called_stubs 20, 0 d3d12).
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…ev#148 (XS)

The null device left slot xcl-dev#18 a logging stub, so the title's
raytracing_surface leg 2 read heap zeros ([0 x4]) instead of the RDNA2
BVH words; legs 3 (xcl-dev#148 upload, xcl-dev#146 barrier) were Vulkan-list-only, so
the default title list had stubs there too. All three are pure
host-memory operations (descriptor-word write, aligned zeroed alloc, a
coherent single-queue no-op barrier), so the null objects share the
Vulkan implementations with no GPU needed — same precedent as the xcl-dev#3
Execute leg sharing the console memory methods.

Failing-first: new null_device_serves_the_raytracing_surface test fails
pre-fix ([0 x4] vs the BVH words) and passes now; other view dimensions
and nulls still pass through untouched (existing Vulkan helper test).
Gates: check -p xcl --tests EXIT 0; check --workspace EXIT 0; lib 799
passed/0 failed/1 ignored (--test-threads=4). Title e2e, fresh roots:
null 12->11 FAILs (raytracing_surface now PASSES; every other FAIL
byte-identical, 0 new non-GPU), Vulkan 10 total incl. files (9 D3D12.X,
raytracing absent — paths untouched). Retail HOLDS (SIGSEGV
exe+0x2237320, exit 139, called_stubs 20, 0 d3d12).
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.

2 participants