Skip to content

GTA VI on macOS: watchdog, kernel-panic, memory, GPU-hang, DirectStorage and Rosetta fixes - #4

Open
eLGatoRDV wants to merge 35 commits into
utkarshxdev:mainfrom
eLGatoRDV:gta6-mac-fixes
Open

eLGatoRDV wants to merge 35 commits into
utkarshxdev:mainfrom
eLGatoRDV:gta6-mac-fixes

Conversation

@eLGatoRDV

Copy link
Copy Markdown

This is the PR you asked for: our fork's work on GTA VI 1.0.2.1 under CrossOver and D3DMetal, with main (8862fc3) merged in. In our runs on a MacBook Pro (M5 Pro, 24 GB, Series S profile), the game used to freeze at its first loading screen, kernel-panic macOS during the world load, hang the GPU at the first world frame, and crash at the intro and right after the first world frame. With this series it runs about 150 s inside the world (run 67), until our memory guard stopped it for swap. It did not crash. The world's 3D scene is still black, and memory still grows (see Still not working).

It is large: 35 commits (the fork's 25, the merge and 9 follow-ups), +34,896 / −1,500 lines in 83 files, about 15,700 of the added lines in test modules. Each commit's message gives the cause, what was measured and the tests. Five commits are cherry-picks from ivall/xcl and keep their authors. main is merged in rather than rebased onto, because both sides changed the same code in 13 files; the merge commit lists the resolutions, and so does How main was merged below. If you would rather review it in parts, we can split it into stacked PRs by theme.

What is in it

  • GTA VI's stall watchdog (eh.rs, log.rs, pso_async.rs). The crash at game+0x23cf683 that your Runs 10, 11 and 13 also report is the title's own watchdog: when the render thread's heartbeat stops, it calls an armed report hook whose store to address 0 ends the game. main resumes that hook only when a ret follows the store. In GTA VI 1.0.2.1 the hooks end add rsp, imm8; ret, so it never matched, and our run 65 ended there at 190.3 s. With XCL_WATCHDOG_BYPASS=1 on a Mac, one rule now covers every report hook: the store, then ret or add rsp, imm8; ret, reached from the watchdog's call rax, in the hook's image. Such a hook is resumed at its epilogue, and the watchdog's own stores, in both of its loops, at its heartbeat check. Any other store to address 0 still ends the title. A test raises the real faults through the handler under Wine. In run 65 the watchdog fired because one thread waited about 27.5 s for pipelines in a single frame, so a thread's pipeline waits with a limit (XCL_PSO_WAIT_MS) are now also capped per frame (XCL_PSO_WAIT_FRAME_MS, 2000 ms). Resuming the watchdog does not help when the GPU itself hangs: see the next item.

  • GPU hangs at the first world frame (indirect.rs, gpu/recomp/emit.rs, gpu/recomp/mod.rs, bind.rs, stall.rs). Our runs 61 and 62 hung the GPU there in the VFX heap defragmentation. df231d75ee930b98 writes the dispatch arguments that 36204a134ee59578 (RelocateVfx) is run with through ExecuteIndirect, and on the Mac those arguments are outside unified memory, so the dispatch read whatever the PC buffer held. Your Runs 11 to 13 name 36204a134ee59578 in the stalled list too. This adds:

    • a GPU pass that checks the group counts of translated compute ExecuteIndirect before the dispatch: more than 2^22 groups, or Y or Z over 65,535, runs none;
    • a dispatch-wide loop budget in translated compute programs (a translator change);
    • a stall watch that logs the submissions in flight after 10 s ([stall]) and can end the title (XCL_GPU_STALL_EXIT);
    • the same kind of GPU check for translated draws' ExecuteIndirect (DRAW / DRAW_INDEXED) whose arguments are outside unified memory or unknown.

    With these, run 62 still hung, but the watch named the work and ended the title. Since run 63 our test runs skip that trio with XCL_SKIP_CS=71f4ac8ad5eba33c,df231d75ee930b98,36204a134ee59578. That is a lever for testing, not a fix: giving those heaps memory the GPU can see is not done.

  • GPU objects and tile mappings wait for the GPU before they go (late_release.rs, real.rs, sparse.rs, list_x.rs, cpu_writes.rs). Three world loads out of three kernel-panicked macOS inside Metal's command-buffer submission (IOGPUFamily / AGX). D3DMetal records command buffers with unretained references, so an object destroyed, or a tile unmapped, while committed work still names it is walked by the driver at submit. Now:

    • on the Mac the deferred-release ledger holds heaps, descriptor heaps, pipelines, allocators, command and DMA lists, command signatures, query heaps and root signatures as well as resources (never queues, fences or the device) until each queue is past the mark taken at their last Release, plus a 100-ms grace;
    • parked sparse tiles wait for their mark;
    • the bottom-of-pipe writes get one worker per queue and never write before their fence.

    With this and D3DM_RETAIN_REFERENCES=1, none of our ten world loads since (runs 58 to 67) panicked. Also, on the Mac a late-released resource is forgotten before its final Release (a use-after-free in poll_unwatched), and XCL's own Release of a held object no longer re-marks it (that piled up 8 GB in a world load).

  • Memory in the world load (lazy_tex.rs, title_textures.rs, kernelx.rs, gpu/texture.rs, gpu/uma.rs). Our memory guard stopped runs 58 to 60. GTA VI streams tens of thousands of sampled textures into a GPU view of its memory, and on D3DMetal each became a committed texture of its full size: Metal memory grew 6 GiB in 15 s.

    • Lazy title textures (XCL_TEX_LAZY=1, off by default) make such BC textures reserved resources that get tiles only where the title's memory has pages. In run 61, 11,389 of them (11.9 GB on the console) took 888 MB of tiles.
    • XCL_SPARSE_64K_MAX_MB (off by default; 2048 for GTA VI) keeps a title's large 64 KiB-page reservation (3.9 GB on Series S) in plain memory instead of the sparse windows.
    • The upload staging buffer is capped at 128 MiB (XCL_UPLOAD_STAGING_MB), and XCL's part of the coherent window at 256 MiB on a Mac (XCL_COHERENT_OWN_MB). Together they took 384 MB off D3DMetal's memory in run 67, against run 66.
  • Pipelines (pso_async.rs, real.rs, bind.rs, list_x.rs, gpu/recomp/pso.rs). Run 64 recorded its first world frame and never presented it. About 415 new compute pipelines were built on the title's own threads with no limit, and one of them, 29 MB of DXIL, was still compiling after 434 s. Now:

    • big compute pipelines that no run has built go to a lane of their own, and binds do not wait for them;
    • programs over 4 MB of DXIL are refused when made;
    • what a run built is kept in a ledger beside used-pipelines.txt, so the next run treats it as known;
    • the workers serve known pipelines before cold ones;
    • a stand-in whose pipeline is not built is never sent to the PC with XCL's root signature: its work is skipped and counted;
    • graphics builds are logged with their translation and driver times.

    With D3DMetal's cache warm, run 67 built 672 pipelines in 3.3 s at its first world frame.

  • DirectStorage (dstorage.rs, dbghelp.rs, eh.rs, kernelx.rs). Run 63 reached the intro and crashed 184 ms later on a garbage pointer in a per-entity table. GTA VI fills its streaming page table for a batch in its own submit path, right before Submit. XCL copied the page array at EnqueueRequest and let a half-full queue submit by itself, so stale entries refused requests or sent data into pages the title had freed and taken again.

    • A request's page array in the title's memory is now read when the request runs.
    • A queue that submits by itself holds everything from the first such request until the title's Submit; a full queue still sends all. Run 64 had 80,234 requests, 0 failed, and 4,077 moved entries went to the pages the title named.
    • The title's MiniDumpWriteDump uses Wine's dbghelp with public symbols only and without the full-memory kinds. Wine's DWARF evaluator divided by zero on XCL's symbols and took the game's crash handler down.
    • A crash report shows the memory around each register, with the DirectStorage request that last wrote that page. That per-page record is kept by default.
  • Rosetta (loader.rs, widestore.rs, isa.rs, eh.rs). Rosetta cannot resume a 256-bit store whose second half faults after the first half has landed. It prints "unexpectedly need to EmulateForward on a synchronous exception", and every later exception of the process waits for ever. GTA VI froze 5 to 10 s into its first loading screen, because vcruntime140's memmove and memset copy with such stores.

    • On a Rosetta host those entry points now jump to rep movsb / rep stosb versions (XCL_RUNTIME_COPIES).
    • The 256-bit stores and VCVTPS2PH stores in the title's image are split into parts Rosetta can resume (XCL_WIDE_STORES). GTA VI has 87,699 of them, and 47 are left to traps. The menu now comes up in 58 s instead of 241 s.
    • A CLZERO zeroing loop calls one helper after its first trap.
    • MONITORX / MWAITX can be patched in place (XCL_PATCH_MWAITX=1, off by default).
  • Display planes (present.rs, compose.rs). As a Series S, GTA VI presents its 3D image at 1920×1080 in plane 0 and its interface at 3840×2160 in plane 1. Plane 0 is transparent black at the menus, so plane 0 alone shows black menus. Two planes or more are now composed into the back buffer by one draw: each source rect is scaled to its place, with premultiplied alpha, over black. After the merge, XCL_PRESENT_PLANE=n shows plane n alone, and every plane goes through main's guarded GetDesc.

  • Ordered CPU copies and readbacks (cpu_writes.rs, list_x.rs). GTA VI stopped submitting at its first loading screen: a CopyMemoryToMemoryX done by the CPU was written after the title had already seen its own fence complete.

    • Such a submission now makes its queue wait on the GPU until the copy is written (XCL_CPU_COPY_ORDERED).
    • A copy out of a title buffer or texture that lives only in a PC resource is read back by the GPU (XCL_GPU_READBACK_COPY).
  • Diagnostics, most of them only with XCL_ACTIVITY or a switch of their own (waitwatch.rs, view_census.rs, outside.rs, skip_roots.rs, kernelx.rs, host.rs, present.rs):

    • XCL_WATCH_WAITS=1: where every thread waits, without stopping it, plus a fault probe. It found the Rosetta freeze.
    • With XCL_ACTIVITY: the census of the views XCL writes and the textures no view names any more, and the census of the memory translated programs cannot see.
    • The root arguments of the programs XCL_SKIP_CS skips.
    • XCL_TRACE_PAGES, and the [indirect] and pipeline-queue lines.
    • Frame dumps from the world's first frame (XCL_FRAME_DUMP_WORLD).
  • Ports from ivall/xcl.

    • The BCPack decoder (ivall/xcl 8cad517; main has the same port as a4b80ec), with the generator its tables come from. scripts/gen_bcpack_victory_tables.py is the script THIRD_PARTY.md already names. python -I scripts/gen_bcpack_victory_tables.py <bcpack-tables.bin> <out.rs>, run on VIctory's bcpack-tables.bin, reproduces tables.rs byte for byte.
    • Five cherry-picks, with their authors:
  • README: the XCL_PRESENT_PLANE row as the merged code reads it, and rows for the two new opt-outs. Three docs are not changed, though they no longer describe this branch:

    • README's DirectStorage line says full queues "block producers";
    • README's poll_unwatched line mentions a release guard this branch does not have;
    • HANDOFF.md's last section ("What stops it now") still names the watchdog's store at game+0x23cf683.

How main was merged

Both sides changed the same code in 13 files. Where both sides fit together, both are kept. Where they could not both stay:

Where Kept main's code changed Why
BCPack tables.rs, tests.rs (both sides ported the same decoder) the generated table BC7 dictionary entry 0's row [2, 1, 0, …] (a4b80ec) is the generator's [1, 0, …]. Your entry-0 test is kept and asserts that row. All 255 BC7 records are 116 bytes. In 254 of them the u16 after the two widths repeats the widths; main's row reads that u16 as an index in entry 0 only. Not checked against a decoded retail stream.
gpu/texture.rs our staging cap; your drop-before-grow and overflow check staging_capacity (16-MiB steps) and large_staging_uses_sixteen_mib_growth_steps are removed. gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels expects the capped buffer and gained a growth case. Run 66's kept buffer grew to 256 MB; run 67's stayed at 128 MB.
d3d12x/title_textures.rs ours (lazy textures, capped batches); your clone_resource check, deferred remaps, BATCH_ITEMS and batch_fits The release gate (RELEASING, ResourceRelease, with_resource_reference) and uploads_do_not_acquire_references_during_resource_release are removed. BATCH_BYTES (32 MiB) is replaced by the staging cap (128 MiB). See real.rs. Batches follow the cap.
d3d12x/real.rs our hooked_release and the deferred-release ledger ResourceRelease::begin (692d902, f7bcad5) is not taken. The Release hook also runs on D3DMetal's own threads, which have no TEB, so no lock, heap or thread-local may be used there. The ledger forgets what XCL keeps by address before the final Release. Slots 73/74 had the same fix on both sides; the lines are yours.
d3d12x/console_heap.rs your unregister_with_resync, tag map and resync signature The per-page ReadProcessMemory snapshot in the resync is removed: slots are read in place, and a copied slot comes from the shared heap. cpu_mirror_srv and global_srv_resolves_only_to_a_live_cpu_mirror are removed. The resync runs at every submit. In GTA VI's world the shared heap spans hundreds of pages, so that is hundreds of ReadProcessMemory calls per submit under Wine, plus a linear search. Translated shaders do not read that copy.
d3d12x/cpu_writes.rs our per-queue workers and ordered CPU copies; your lists in each job, the stall trace and the removed-device rule Your single polling worker is replaced. stalled_queue_keeps_writes_pending_without_blocking_other_queues is ported to our workers. A worker that wrote before its fence let the title free what the GPU still used, and the ordered copies need a worker per queue.
d3d12x/fence_x.rs (merged without a conflict) your 10-ms poll, WakeByAddressAll and failed-event log The skip of UINT64_MAX in refresh (3f3cca2) and its test are removed. With the skip, a removed device's all-ones never reaches the cell, and the title spins on a stale value instead of reaching stop_if_device_removed. The removed test only swapped a local AtomicU64; a new test checks the cell.
hle/dstorage.rs ours (page tables read at the request's turn, held batches), plus AutoSubmitDisabled (5bff7bd) 3247579's wait for room (room, pending_for_enqueue, full_manual_queue_waits_for_submit_cancel_or_close) is not taken. A full queue sends everything. A title thread that enqueues into a full queue before its own Submit would wait for ever.
d3d12x/present.rs your tokens (every plane's), parse_plane, plane-0 fallback, guarded GetDesc and configuration log; our composition requested_plane_index takes any plane number. Unset, two planes or more are composed instead of plane 0 alone. The log line counts composed planes. backbuffer_like_guards_against_invalid_pointers_and_vtables now puts its truncated vtable at the end of a committed page. Plane 0 alone is black at GTA VI's menus. The test's vtable was on the stack, readable past its end; in this build slot 10 held a stack pointer, GetDesc was called through it, and the test run hung.
d3d12x/bind.rs our GPU-checked ExecuteIndirect path first; your fresh_indirect_arguments on the paths you wrap Your direct-arguments arm moved into the closure that both fallbacks of the checked path use. The checked path reads XCL's own copy, which is moved to INDIRECT_ARGUMENT after the check.
eh.rs ours Your tweak of title_watchdog_resumes_fatal_crash_at_world_load went with that test, which our watchdog change replaced. title_watchdog_keeps_stores_to_address_0_it_does_not_know_fatal covers the case.
d3d12x/sparse.rs, vram.rs both diagnostics around the same GPU waits Restructured only. —

After the merge, nine more commits:

  • Composed planes also go through check_resource_desc_slot.
  • The bottom-of-pipe worker calls stop_if_device_removed when its fence reads all ones. Under main's rule alone the writes were left undone, so a title waiting on such a marker would wait for ever.
  • Tests for the fence cell and for the upload buffer's growth.
  • Two opt-out switches for main's changes that GTA VI has not run with yet: XCL_DSTORAGE_AUTO_SUBMIT_DISABLED=0 and XCL_MS_IN_AS_SLOT=0. Both default to main's behaviour.
  • The fixed present.rs test above, the README row, and our stale comment on slots 73/74 dropped.

New switches

Of the new switches, the README lists only the two opt-outs. The others are described in the code and in the commit messages.

All 65, with their defaults

On by default:

Switch Default Change with What it does
XCL_PSO_WAIT_FRAME_MS 2000 0: no cap caps the pipeline waits with a limit (XCL_PSO_WAIT_MS) a thread may spend in one frame
XCL_PSO_TIERS on 0: one FIFO builds known pipelines before cold ones
XCL_PSO_BIG_THREADS 2 0: no big lane threads for big compute pipelines that no run has built
XCL_PSO_BIG_LOW on 0 runs those threads below normal priority
XCL_PSO_WAIT_BIG_MS 0 ms how long a bind waits for such a pipeline
XCL_PSO_MAX_DXIL_KB 4096 0: no limit refuses programs over this size when they are made
XCL_PSO_BUILT_LEDGER on 0 keeps what a run built (built-pipelines-.txt)
XCL_PSO_STILL_BUILDING_S 30 0 logs builds still running every n seconds
XCL_STANDIN_SKIP, XCL_STANDIN_SKIP_DRAWS on 0 skips the work of a stand-in whose pipeline is not built, instead of sending it to the PC
XCL_INDIRECT_SANITIZE on (Mac) 0 checks translated compute ExecuteIndirect group counts on the GPU
XCL_INDIRECT_MAX_GROUPS 2^22 n groups a checked command may have
XCL_INDIRECT_SANITIZE_DRAWS arguments outside unified memory or unknown; everywhere once work was skipped all, own, 0 checks translated draws' ExecuteIndirect on the GPU
XCL_INDIRECT_MAX_DRAW_COUNT, XCL_INDIRECT_MAX_DRAW_WORK 2^23 − 1, 2^26 n caps of a checked draw
XCL_INDIRECT_DRAW_INDICES on 0 keeps a checked DRAW_INDEXED inside the bound index buffer
XCL_BUDGET_TRIP_WAVES 64 0: off (changes the translation) dispatch-wide loop budget
XCL_GPU_STALL_WATCH on 0 watches the fences and logs [stall] lines
XCL_LATE_RELEASE_ALL every kind on a Mac, resources elsewhere 0: resources only; 1: every kind everywhere what the deferred-release ledger holds
XCL_LATE_RELEASE_GRACE_MS 100 on a Mac, 0 elsewhere ms grace after the mark
XCL_UPLOAD_STAGING_MB 128 0: no cap (the old growth) size of the kept upload buffer and of one upload run
XCL_COHERENT_OWN_MB 256 on a Mac, 512 elsewhere MiB XCL's own part of the coherent window
XCL_CPU_COPY_ORDERED on 0 makes a queue wait for the CPU copies of its submission
XCL_GPU_READBACK_COPY on 0 reads copies out of PC-only title memory back on the GPU
XCL_DSTORAGE_LATE_PAGES on 0 reads page arrays at the request's turn and holds batches for Submit
XCL_DSTORAGE_AUTO_SUBMIT_DISABLED on 0 honours AutoSubmitDisabled (main's behaviour)
XCL_DSTORAGE_PAGE_LOG by page address, 0 keeps the last request that wrote each page, for crash reports
XCL_DSTORAGE_OLD_PAGES on 0 classifies the old pages of moved entries (log)
XCL_DSTORAGE_HOLD_WARN_MS 2000 ms names a hold longer than this
XCL_MS_IN_AS_SLOT on 0: refuse translates a console MS in the AS slot as an MS (main's behaviour)
XCL_RUNTIME_COPIES on (Rosetta) 0 runs vcruntime140's memmove / memcpy / memset as rep movsb / rep stosb
XCL_WIDE_STORES on (Rosetta) 0 splits 256-bit stores and VCVTPS2PH
XCL_TITLE_MINIDUMP public symbols, no full-memory kinds (Mac) 0: no dump; full: the kind asked for the title's MiniDumpWriteDump
XCL_VIEW_CENSUS, XCL_OUTSIDE_CENSUS on with XCL_ACTIVITY 0 the census lines
XCL_INDIRECT_CENSUS, XCL_INDIRECT_SUBMITTED on 0 counts ExecuteIndirect calls
XCL_SKIP_CS_ROOTS on with XCL_SKIP_CS 0 logs the root arguments of skipped programs

Off by default:

Switch What it does
XCL_TEX_LAZY=1 or 2, with XCL_TEX_LAZY_FORMATS (bc), XCL_TEX_LAZY_GRAIN (mip, or texture), XCL_TEX_LAZY_MIN_KB (128), XCL_TEX_LAZY_MAX_OVERHEAD (1.25), XCL_TEX_LAZY_MAX_MB (0: no cap) lazy title textures; our GTA VI runs use 1
XCL_SPARSE_64K_MAX_MB=<MB> keeps big 64 KiB-page reservations in plain memory; GTA VI: 2048
XCL_GPU_STALL_EXIT=<s> ends the title after a GPU stall of s seconds (exit code 0x574111ED)
XCL_SKIP_CS=<hash>,… drops those console programs' dispatches
XCL_NO_BUILD_CS=<hash>,… never builds those compute programs
XCL_PSO_BUILT_SEED=<file> counts a list of pipelines as built
XCL_INDIRECT_OWN=skip drops ExecuteIndirect calls whose arguments only PC copies fill
XCL_PATCH_MWAITX=1 patches MONITORX / MWAITX in place
XCL_FRAME_DUMP_WORLD=<every>[,<max>] dumps frames from the world's first frame
XCL_WATCH_WAITS=1, XCL_EXCEPTION_TEST_AT=<s> the waits watch and fault probe, and test exceptions
XCL_TRACE_PAGES=<pages> traces those 64 KiB pages
XCL_WATCHDOG_PROBE=<file> logs the watchdog's state (GTA VI 1.0.2.1 only)
XCL_GPU_VIEW_READBACK=1, XCL_VIEW_MIRRORS=1, XCL_SERIALIZE_TILES=1, XCL_LATE_RELEASE_SERIAL=1, XCL_LATE_RELEASE_TOUCH=1 experiments
XCL_PLAN_IMAGE, XCL_PLAN_DEBUG, XCL_PLAN_SITES, XCL_PLAN_TRAPS used by one ignored widestore test only

Changed meaning: XCL_PRESENT_PLANE (unset composes the planes; n shows plane n alone, so 0 turns composition off), XCL_WATCHDOG_BYPASS=1 (resumes every report hook; still Mac-only and off by default) and XCL_PSO_WAIT_MS (now also bounded per frame).

Tested

  • MacBook Pro with Apple M5 Pro and 24 GB; macOS 26.7.3; CrossOver 26.3 with D3DMetal 3.0, the title's x86-64 code under Rosetta 2; DXC 1.9.2609.5. No other machine.
  • Cross-built on the Mac for x86_64-pc-windows-gnullvm with Rust 1.97.1 and LLVM-MinGW, release, as the Mac cross-build CI does. cargo build --release --locked --target x86_64-pc-windows-gnullvm -p xcl and cargo test --no-run --release --locked --target x86_64-pc-windows-gnullvm build without errors. The 39 checks of scripts/verify_mac_build.sh, run as the same grep commands, pass.

Unit tests: the lib's test binary (cargo test --release --locked --target x86_64-pc-windows-gnullvm -p xcl --lib --no-run), run in the CrossOver bottle with WINEDEBUG=-all XCL_LAZY_PAGES=1, a fresh XCL_DXIL_CACHE folder and --test-threads=6 --skip gpu::recomp::tests::gpu_ --skip gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes. The first skipped group runs separately (below); the second test fails or hangs under Wine here.

Tree Passed Failed Ignored Filtered out
this branch 947 6 25 88
main (8862fc3) 683 8 21 88
  • These 6 fail on both: device_x::tests::console_depth_buffers_and_their_views_are_the_pcs, list_x::tests::write_buffer_immediate_on_open_existing_heap_visible_to_cpu, present::frame_dump_tests::mapped_frame_dump_distinguishes_dark_bright_and_undecoded_content, real::console_format_query_tests::console_formats_are_asked_as_the_pcs, real::console_format_query_tests::gpu_console_depth_formats_are_supported and xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime.
  • main's other 2 failures pass here: bcpack::tests::fixtures_decode_to_their_lanes (main has the test but not tests/data/bcpack) and title_textures::tests::title_bytes_are_used_in_place_when_all_are_readable.
  • SKIPPED here:
    • list_x::tests::timestamps_outside_unified_memory_land_after_the_queue: D3DMetal's timestamp queries read 0. Skipped on main too.
    • dstorage::tests::under_page_log_address_writes_are_kept_by_address_alone: needs XCL_DSTORAGE_PAGE_LOG=address.
    • title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels: there are no shared texture pages on this host.

GPU translator tests (gpu::recomp::tests::gpu_, 87 of them), run on one thread. A test that hung for 90 s was skipped and the group was run again.

Tree Passed Failed Ignored Hung
this branch 63 17 2 5
main 60 17 2 8
  • The same 17 fail on both: FP64, which D3DMetal lacks; float atomics; clamp/omod; 16- and 64-bit VALU; an implicit-LOD sample between mips; and the UMA import check.
  • Hung on both: gpu_graphics_vs_ps_draw, gpu_ps_p0_reads_flat_integer_selectors and the three gpu_rect_list_* tests.
  • Hung on main only: gpu_wave64_ps_spill_slots, gpu_wave64_ps_whole_wave_reductions and gpu_wave64_vs_spill_slots_and_identity.
  • SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware.
  • The BVH and mesh tests the merge touched pass: gpu_bvh_intersect_ray, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing, gpu_built_bvh_nodes_match_the_cpu_node_test, gpu_mesh_mode_reads_memory_windows and gpu_mesh_mode_two_passes.

GTA VI 1.0.2.1 (our own Series dump), Series S profile, on the same Mac. These runs used our fork's builds from before the merge, not this branch's head. Each row adds the fixes named:

Run Build How it ended
50, 56, 57 before the lifetime ledger macOS kernel panic during the world load, in Metal's command-buffer submission
58 to 60 ledger, D3DM_RETAIN_REFERENCES=1 our memory guard, during the world load
61, 62 lazy textures; then the GPU-hang guards GPU hang at the first world frame (the VFX heap defragmentation)
63 XCL_SKIP_CS of that trio reached the intro (frame 1254), then an access violation in the game 184 ms later (stale DirectStorage page tables)
64 page tables at the request's turn first world frame recorded at 214.7 s and never presented (pipeline builds on the title's threads); XCL_RUN_SECONDS ended it at 900 s
65 big-pipeline lane, giant programs refused, stand-in work skipped presents stopped at 160.8 s; the watchdog's store at game+0x23cf683 ended it at 190.3 s
66 watchdog resume, per-frame wait cap went past the first world frame (149 s) and the watchdog; our memory guard stopped it at 199.7 s for swap (+4.5 GB)
67 staging and coherent-window caps, pipeline tiers first world frame at 163 s; the world ran until our memory guard stopped it at 317 s for swap (+4.2 GB)
  • In run 67's world: 62 presents, no crash, no GPU hang, no watchdog report, no device removal. DirectStorage served 128,058 requests with 0 failures.
  • Earlier commits of the series fixed the freeze at the first loading screen (Rosetta), the black menus (planes) and the stop at the first loading screen (ordered CPU copies); those runs are not in the table.

Run 67's environment, besides the Series S profile in the title's xcl.toml:

D3DM_RETAIN_REFERENCES=1 XCL_WATCHDOG_BYPASS=1 XCL_TEX_LAZY=1 XCL_SPARSE_64K_MAX_MB=2048
XCL_SKIP_CS=71f4ac8ad5eba33c,df231d75ee930b98,36204a134ee59578 XCL_GPU_STALL_EXIT=30
XCL_PSO_PRELOAD=0 XCL_PSO_WAIT_MS=1500 XCL_INDIRECT_SANITIZE_DRAWS=all XCL_DXC_THREADS=3 XCL_NETWORK=0
XCL_NO_BUILD_CS=<the game's 1,001 ray-tracing programs> XCL_PSO_BUILT_SEED=<run 64's built pipelines>

It also set logging switches (XCL_ACTIVITY=1, XCL_WATCH_WAITS=1, frame dumps, traces), XCL_RUN_SECONDS=1200 and input through XCL_REMOTE_INPUT.

Regression run

  • None. scripts/smoke.ps1 was not run, so there are no xcl-smoke blocks for main and for this head, and the PR check will say so. The game runs above are longer runs of our fork's builds on one title. They are not smoke runs of main and of this head.

Still not working

  • The world's 3D scene is black. From the first world frame on, every frame is one constant value under the game's dither, and the opening credits draw over it. Our best guess, not proven: the GPU reads zeros where the game keeps data outside the memory translated programs can see, and sampled aliases of GPU-written targets read the CPU copy. In run 67, 15,812 of 23,161 compute ExecuteIndirect calls had their arguments outside unified memory, and 76 % of the root descriptors pointed outside it.
  • Memory grows. D3DMetal's use grows about 20 MB/s in the world (20.7 MB/s in run 67, from 7.2 to 10.3 GB). It is mostly the PC textures XCL keeps for every view address the title names, and none of them is freed yet. On a 24 GB Mac that ends in swap, which is what stopped runs 66 and 67.
  • The world runs at about 0.4 presents/s. 42 % of the draws are skipped, mostly because their pipelines are not built yet, and ray tracing is off.
  • The VFX heap defragmentation trio has to be skipped with XCL_SKIP_CS; without that, the first world frame hangs the GPU.
  • The 6 unit tests listed above fail, as they do on main.

Not tested

  • Windows. This branch was not built with MSVC or run there, and scripts/test.ps1 / cargo test --workspace were not run. Several changes are not limited to a Mac host and change Windows behaviour too:

    • the pipeline lanes, tiers and per-frame wait cap, and the stand-in skip;
    • the GPU stall watch;
    • DirectStorage's page-table timing;
    • the ordered CPU copies and GPU readbacks;
    • the upload staging cap;
    • the translator's dispatch-wide loop budget;
    • the plane composition.
  • The merge with main and the nine commits after it ran the unit suites only, with no title. For GTA VI these changes have not run yet:

    • AutoSubmitDisabled honoured (GTA VI creates its DirectStorage queues with it). A batch that fills a queue (4,159 entries) would take the full-queue escape before the title's Submit, which the log names as "a full queue (qN, …) runs requests into the title's pages".
    • GTA VI's 38 pipelines with an MS in the AS slot translated. Every run of ours refused them.
    • main's translator changes: the empty-BVH miss, v_movrels_b32 and the mesh vertex budget.
    • Batches of at most 256 title textures, the 10-ms fence poll, and the root UAV of a single repacked dispatch.
    • The ExecuteIndirect transitions on the wrapped paths.
    • The removed-device stop in the bottom-of-pipe worker, and the guarded composed planes.

    XCL_DSTORAGE_AUTO_SUBMIT_DISABLED=0 and XCL_MS_IN_AS_SLOT=0 restore the series' behaviour for the first two.

  • The translator's sources differ from main's, so a first run makes the translated shader cache again. For GTA VI that took about an hour on this Mac.

  • BCPack: BC7 entry 0 follows the table's record layout and the generator. It is not checked against a decoded retail stream: bcpack_parity does nothing without XCL_SAMPLE_BCPACK, and we have no samples.

  • The workspace's integration tests were built, not run.

  • Other titles, the Series X profile, a physical controller, AMD and NVIDIA GPUs, and other Macs or macOS and CrossOver versions.

AI use

  • Claude Code with Claude Opus 5.5 wrote the code, the tests and the commit messages of every commit authored by me (the five cherry-picked commits are their authors'). It also resolved the merge with main, ran the builds, the test suites and the game runs, analysed the runs, and wrote this description. Each game run was started with my approval.
  • Most changes went through review passes by the same model, with each finding checked by a second pass before it was fixed; the commit messages say which. The commit trailers name the model.

🤖 Generated with Claude Code

eLGatoRDV and others added 30 commits November 29, 2026 16:54
VIctory's code is GPL-3.0; its author allowed its use in XCL under
GPL-2.0-only (2026-11-24): THIRD_PARTY.md and the decoder's header say so,
with the project's URL. THIRD_PARTY.md also notes that the 128 rANS models
of bcpack-tables.bin are, number for number, those of Microsoft's
silicon-rans sample (MIT), compared against the tables generated from
mdu_minirans.v in #208.

Request::check is the enqueue check again (it had become a test-only
wrapper of check_with_bc1). The README lists DirectStorage with BCPack and
describes XCL_SAMPLE_BCPACK; scripts/test.ps1 lists it with the other
sample variables. HANDOFF.md is left as it is (the PR's edit of it is not
taken).

(cherry picked from commit 8add9a327f60dfe34fcd3a7ea16368c0ec5a7a22)
…ainst the patent

Without XCL_SAMPLE_BCPACK nothing showed that a stream decodes. The 14
fixtures of #208 (tests/data/bcpack, made by generate.py, an encoder
written from the format notes and not from either decoder; all six modes,
up to 64 KiB of output) now go through the lane stage of the ported
decoder, which gives every fixture's symbols; bc1-1-8, whose states are
cut shorter than an encoder can cut them, is refused. With 7 input bytes
per schedule round instead of 8 the test fails.

The 8-bit model 11 is checked against the base table printed in
US 11,234,023, and every model sums to 65536.

Fixtures and generator by Kalmarv (#208).

(cherry picked from commit 10915eb96938d1bbdb111a60058a396f0942ee02)
A request that fails a check in EnqueueRequest (source type, file handle,
destination page array, ...) went into the queue as Entry::Refused, which
had no sequence number. CancelRequestsWithTag removed only pending
Entry::Request entries, and the worker checked the cancel rules only for
those, so a refused request was reported however the title cancelled it:
its HRESULT in the next status entry, a FailureCount and first failure in
the error record, and the error event. DirectStorage's documentation: "a
cancelled request is not counted as a failure in either IDStorageStatusArray
or DSTORAGE_ERROR_RECORD".

Refused entries now get a sequence number from the same counter as
requests (enqueue_refused / enqueue_numbered), CancelRequestsWithTag drops
pending ones with a matching tag, and the worker skips submitted ones the
cancel rules cover. A refused request with another tag, or enqueued after
the cancel, still fails as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 66660bd9478c789959df1e0d3342f1081f778610)
RetrieveErrorRecord filled the first failure's HRESULT, options,
destination, destination size and file name (or memory source), and left
FileOffset @0x230, SourceSize @0x240 and CancellationTag @0x248 at 0. A
title that logs or retries the failed request from its record saw offset
0, size 0 and tag 0.

The layout follows DSTORAGE_ERROR_RECORD in ATG's Win32 implementation
of the console API (Xbox-GDK-Samples, Samples/System/
SimpleDirectStorageCombo/DirectStorageWin32/dstorage_win32.h): after
`WCHAR Filename[MAX_PATH];` (0x24..0x22C) come `UINT64 FileOffset;`
(0x230), `void* Source;` (0x238), `UINT32 SourceSize;` (0x240),
`UINT64 CancellationTag;` (0x248) and `CHAR Name[DSTORAGE_REQUEST_MAX_NAME];`
(0x250, 64 bytes), 0x290 in all, which matches ERROR_RECORD_BYTES and
the offsets XCL already writes. Its MarkRequestError
(DirectStorageWin32WrapperQueue.cpp) copies them from the request:

    m_errorRecord.FirstFailure.FileOffset = m_entries[index].request.FileOffset;
    m_errorRecord.FirstFailure.SourceSize = m_entries[index].request.SourceSize;
    m_errorRecord.FirstFailure.CancellationTag = m_entries[index].request.CancellationTag;

The file offset is written for file requests only: FileOffset shares a
union with Source, so for a memory request those bytes are unused or the
source page offset. Name stays 0: Request does not keep the name pointer.

The new test reads 16 bytes past the end of an 8-byte file with tag
0xABCD and fails without the fix (FileOffset: left 0, right 256).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2e17d3dedd954f4cd487296c1919e62708f77b39)
CreateStatusArray made every slot E_PENDING, so IsComplete(i) was false
for a slot nothing was ever enqueued into. A title that waits for
IsComplete before it reuses a ring slot, including the slot's first use,
waits forever.

ATG's Win32 implementation of the console API (Xbox-GDK-Samples,
Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/
DirectStorageWin32WrapperStatusArray.cpp) starts every slot complete:

    m_completeFlags.resize(capacity, true);
    m_resultCodes.resize(capacity, HRESULT_FROM_WIN32(S_OK));

and its EnqueueStatus marks the slot not complete (`MarkState(index,
false, S_OK)`). dstorage_win32.h says a status entry "can be enqueued
again" once IsComplete() for it returns true.

Slots now start at S_OK. Enqueueing a status still stores E_PENDING
(QueueInner::enqueue), so a slot behaves as before once it is enqueued;
no code or test read a slot that was never enqueued. EnqueueStatus on a
closed queue leaves the slot as it was, which is now complete instead of
pending forever.

The new test creates an array of 4 and checks that slot 3 is complete
with S_OK; it fails without the fix (`status_is_complete(s, 3)`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5bd7cd8e73129e3cc22e17802a185940bfaf549f)
…f title buffers/textures, watchdog/cpu_writes probes, lock-free thread dump
…; page/resource tracing

- CopyMemoryToMemoryX out of a GPU view of the title's memory (its page pool) is copied by the
  CPU from where the CPU has the pages again (cpu_copy, as upstream), unless the GPU wrote a
  texture there; XCL_GPU_VIEW_READBACK=1 reads back the PC texture instead.
- XCL_VIEW_MIRRORS=1 (off by default): SRV/CBV buffer views outside unified memory read through
  a mirror refreshed page by page before each submit. Too slow under Wine/Rosetta (the title's
  heaps are not write-watched on a Mac: 290 MB compared per submit), kept for experiments.
- XCL_TRACE_PAGES=a,b,... (addresses above 4 GiB or physical page numbers): mappings, moves,
  unmappings, allocations and frees of those 64 KiB pages, DirectStorage writes reaching them,
  queue #31 GPU-view mappings, views / descriptors / copies / uploads / Map of resources over
  them, with the title's call stacks. Every hook returns at once when tracing is off.
- Diagnostics: a CopyMemoryToMemoryX out of a GPU view logs the physical page, where the CPU
  has it, its bytes and the DirectStorage request that last wrote it; the watchdog probe logs
  the DirectStorage queues (pending, in flight, run).

GTA VI 1.0.2.1: the 16 KiB read at the first loading screen is a 128x4 R16G16B16A16 texture the
game looks up by name hash and reads back asynchronously into a float4 table; nothing writes
its page before the read (a fresh pool page) and the read does not block - not the hang.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diagnostics for a stuck title (all off unless XCL_WATCH_WAITS=1):
- The title's waits (handles, condition variables, WaitOnAddress, sleeps, completion ports,
  contended SRW / critical-section locks) are wrapped at import resolution and GetProcAddress;
  xcl.exe's own WaitOnAddress / WaitForSingleObject / WaitForMultipleObjects / Sleep imports
  go through wrappers of their own (Rust's locks, condition variables, channels, parking).
- Each thread notes in a lock-free slot what it waits in, since when, and the call stack; a
  watcher thread logs threads held 10 s or more, and every 30 s a snapshot of every thread
  (in a wait, polling one, or RUNNING since its last wait), title fences behind what their
  queues were told, the CPU-copy worker, the pipeline builds, the DirectStorage queues,
  MWAITX loops by address, and GPU queue waits whose fence has not reached the value.
- XCL's own blocking points are marked (GPU fence waits, WaitFrameEventX, pipeline builds and
  waits, sparse-window waits, the DXIL cache mutex), and 30 entry points of D3D12.X say which
  one a thread is inside (`waitwatch::api`, no stack: cheap).
- XCL_SERIALIZE_TILES=1 (off): XCL's tile mappings and its submissions to D3DMetal one at a
  time – tried against GTA VI's loading stop; it did not keep it from stopping.

GTA VI 1.0.2.1 on CrossOver 26 / D3DMetal 3: about 5 s after the first loading screen starts
the render and streaming threads stop together, each inside a wait of the Win32 lock family
(NtWaitForAlertByThreadId) that neither the title's nor XCL's imports make (D3DMetal's or
Wine's own); every fence the queues were told to signal has completed, no XCL lock is
contended, and the present thread waits for work that never comes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b / rep stosb

Rosetta cannot resume a 256-bit store that faults past its first half: it stores the two
halves apart, and when the second faults after the first has landed it prints "rosetta error:
unexpectedly need to EmulateForward on a synchronous exception" and never delivers that
exception. Its exception server stays with it, so every later exception of the process waits
for ever – XCL's emulated instructions, Wine's write-watch faults, the title's own.

vcruntime140.dll's memmove (= memcpy) and memset copy with unaligned 32-byte VMOVDQU; one of
them crossing into a write-watched page of unified memory was enough. GTA VI 1.0.2.1 froze
5-10 s into its first loading screen at vcruntime140.dll+0x1597 in every run (render and
streaming threads, then the watchdog, all stopped at their next exception).

When vcruntime140.dll is mapped on a Rosetta host (before any of its code runs), the entry
points of memmove, memcpy and memset jump to XCL's rep movsb / rep stosb versions, which stop
at the byte that faults and go on from it. XCL_RUNTIME_COPIES=0 leaves them. With this the
title goes on past that screen to its first-run pages (navigation, legal notices, terms).

Tests: memmove forward/backward over overlaps and lengths, memset, return values; the
patched entry points reach working copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…MWAITX in place on request

- `clzero; add rax, 0x40; cmp rax, r64; jb -12` (12 bytes) gets a helper that runs the whole
  loop – the same stores, RAX and the flags of the last compare – and returns past it; the
  call replaces the CLZERO in one aligned store. GTA VI clears five ranges per call this way,
  five traps per call and hundreds a second before.
- The race that kept CLZERO thunks off (a thread stepped onto the instruction after a CLZERO
  while another writes the call there) cannot happen for a whole loop: its emulation steps
  past the loop, an end not past its start included; only the huge/wrapping fallback steps
  into the body, and it then stops loop redirection for good (checked under the patch lock).
- XCL_PATCH_MWAITX=1: MONITORX becomes a 3-byte NOP and MWAITX PAUSE; NOP after their first
  use, in one locked 16-byte compare-exchange (GTA VI's MONITORX straddles an 8-byte
  boundary). Off by default: the trap is what makes the title's wait loop wait.

Tests: the loop helper run on the host (RDX and R10 ends, lengths, end <= start, registers
kept, return past the loop); the in-place replacement across an 8-byte boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… probe, the last exceptions

Diagnostics (all off unless XCL_WATCH_WAITS=1):
- The waits of every loaded module's imports are wrapped too (K32EnumProcessModules, every
  5 s), nested waits counted once; a thread in EnterCriticalSection names the owner.
- A thread running since its last wait has its syscall frame read (TEB + 0x378 in
  CrossOver 26's ntdll.so): the syscall or Unix call it is in, its registers, a critical
  section one of them holds, and the return addresses on its stack – without suspending it.
- A fault probe thread takes a zero-fill fault, a section fault, a handled access violation,
  a VirtualQuery and a VirtualAlloc every 100 ms; a stage that does not come back is logged
  with the time the process stopped taking that kind of fault.
- A vectored handler keeps the last 256 exceptions (thread, code, address, fault address,
  stack, the title's code bytes), logged when the probe stops coming back.
- XCL_EXCEPTION_TEST_AT=<s>: ud2, int3, hlt, a non-canonical load, an unmasked SIMD divide
  and an integer divide by zero, each raised and handled in turn.

These found the GTA VI loading freeze: exception delivery stopping process-wide, then the
runtime's 32-byte store Rosetta cannot resume (see the vcruntime140 commit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rosetta 2 cannot deliver a fault in a 256-bit unaligned store whose second half
faults after the first has landed (a write-watched page re-armed by every
submit, next to one already written), nor in VCVTPS2PH m64/m128: it prints
"unexpectedly need to EmulateForward on a synchronous exception" and every later
exception of the process waits for ever. GTA VI froze within seconds of its
first loading screen.

widestore plans each image at load: every such store becomes the same
instruction at VEX.L=0 plus VEXTRACTF128 m128 (VCVTPS2PH through a saved
scratch register), in a helper with unwind data. Five-byte stores call it in
place; four-byte ones go through int3 padding, or a run: a call before the
store whose helper does the straight run up to and past it (moved instructions,
RSP-based operands +8, RIP-relative ones re-aimed, mov r64,rsp as lea,
conditional jumps inside, a loop whose head only its back branch reaches run
whole), merges with a neighbour where every branch is known, and a trap (int3,
a VEH, a stub) for the rest – also under every anchored store, for a branch
into a run nothing could see. GTA VI: 87,699 stores, 47 left to traps (from
1,764), none hot in the runs so far; the menu comes up in 58 s (241 s before).

XCL_WIDE_STORES=0 leaves them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… black)

PresentX takes several planes and the console's display composes them; XCL showed
plane 0's first resource alone. GTA VI as a Series S presents its 3D image at
1920x1080 in plane 0 and its interface at 3840x2160 in plane 1 – plane 0 was
transparent black at the menus, so every frame XCL showed was black.

Two planes or more are now composed into the back buffer by one full-screen draw:
each plane's source rect scaled to its place on the screen (linear filter), each
over the ones before it with premultiplied alpha, over black, written opaque – at
the size of the largest plane. The plane layout (0x48 bytes: token, resource
count, resources, source rects, destination, color space, flags) is logged when
the plane count changes; XCL_PRESENT_PLANE=n shows plane n alone for diagnosis.
One plane keeps the plain copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… panics on the Mac)

GTA VI's world load kernel-panicked macOS three times out of three (26.4 and
26.7.3) inside Metal command-buffer submission (IOGPUFamily / AGX,
IOGPUCommandQueueSubmitCommandBuffers; once an MTE tag-check fault). D3DMetal
records command buffers with unretained references, so an object destroyed,
or a sparse tile unmapped, while committed work still names it is walked by
the driver at submit. An audit confirmed several such paths in XCL; this
closes them with one mechanism.

late_release.rs is now a ledger of marks:
- every queue made through the adopted device gets a clock at creation (XCL's
  fence on it); a submission reserves its value before it enters the driver
  and signals it after (`submit`), so a mark taken while a submission is in
  progress (D3DMetal releases objects from inside ExecuteCommandLists) waits
  for that very submission. ExecuteCommandLists chunks and KickoffX go
  through it; the sparse queue is an external clock whose next value is
  published before each of its calls;
- a mark is the value reserved on every clock; held entries go once it has
  passed, plus a grace on the Mac (100 ms, XCL_LATE_RELEASE_GRACE_MS: Metal
  retires command buffers after the fence value is written), at most 64 per
  4 ms tick, in order, on the ledger's thread, outside every lock;
- XCL_LATE_RELEASE_SERIAL=1 (an experiment, off): final releases never overlap
  a submission.

real.rs: one hooked_release for every kind. Resources always; on the Mac also
heaps, descriptor heaps, pipelines, allocators, lists, command signatures,
query heaps and root signatures (XCL_LATE_RELEASE_ALL=0/1). The last-reference
test (AddRef, compare, Release) runs under a per-object stripe lock – two
last-but-one releases at once both missed it and the object ended inside the
hook – and holds only when AddRef and Release both give COM counts. What XCL
keeps by an object's address goes when it really ends (release_held), and
only on its true last reference. When XCL lets go of a reference of its own
and one is left (an upload into a texture the title released), the held
entry is touched: it waits for that work too.

The hook runs on D3DMetal's own threads as well – a Metal completion handler
on a dispatch queue releases what it kept for a command buffer. Those have no
TEB: the first version read an environment variable there (a OnceLock), the
fault's handler never came back and the queue never signalled its fence (a
unit test hung). So the switches are settled once on a thread of Wine's
(late_release::init, from adopt), the stripe is a spin lock, and a held
reference goes into a fixed ring with its mark inline: atomics only.

sparse.rs: a decommitted tile stays parked and mapped until every queue is
past the work submitted before the decommit (its mark); take_tile never
forces one out (a retired or new pool instead). Pools whose tiles all came
free stay 30 s (the newest two whatever their age) and are then handed to the
ledger, not dropped under the state lock.

list_x.rs / cpu_writes.rs: a CopyMemoryToMemoryX read-back keeps its source
until the copy ran. The CPU writes after the GPU get one worker per queue and
never write before their fence: a stale event wake or the 10 s timeout wrote
early, and the title then freed what the GPU still used. A job goes to its
worker under the lock that gives it its value (two threads could send them
the other way round, and with no timeout left that was a deadlock).

Tests (Wine on D3DMetal): marks and submits, grace/cap/order, touches, the
ring, the stripe race, a release from inside a stalled real submission, every
held kind counts COM references on D3DMetal, a held reference is the last
only when no other is left, parked tiles wait for their mark, retired pools
are handed over. The whole suite (but the GPU recompiler group, which hangs
on D3DMetal) has the same 7 failures as before. An independent review
(4 lenses, adversarial verification) confirmed 4 findings, all fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reservation of 64 KiB pages made with no commit, and a block of physical
pages, over XCL_SPARSE_64K_MAX_MB are plain memory, outside the sparse
windows (unset: as before).

GTA VI on Series S reserves its physical-page pool so (3.9 GB in one
reservation; its pages' homes one block). In the windows every page of it got
a 64 KiB tile of video memory the GPU never reads there – its streamed
textures are kept in step from the CPU view – about 4 GB of Metal private
memory at startup (~3 GB more in the world load than Series X), a tile mapping
and a clear for each page at startup, and a decommit, park and unmap for each
page that moved while it loaded. On Series X the same pool lies outside the
windows already, and its menu renders. GTA's other sparse reservations total
about 1.2 GB, so 2048 catches the pool alone.

Test: a reservation over the limit is plain memory, one under it in a sparse
window; a block over it has plain homes; its pages mapped into the pool,
moved, sent home and mapped again keep their bytes, with no tile under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a world load)

GTA VI's world load (runs 58, 59) grew Metal private memory from 4.5 to 14 GB
in 16 s and the memory guard stopped it. The cause: a held object was
re-marked ("touched") whenever XCL let go of a reference of its own and one
was left. XCL looks at the textures it keeps in step every frame (a clone,
then its Release) for as long as they are registered, and a texture the title
had let go of stays registered until its real end – so it was touched again
before its grace was up, every time, and never let go. The game streamed
~750 new textures a second into that.

Touching is now off (XCL_LATE_RELEASE_TOUCH=1 turns it on for experiments);
the case it covered – XCL's last work on a released object – is covered by
D3DM_RETAIN_REFERENCES=1 on the Mac (Metal keeps what a command buffer uses
until it completes) and by upload_batch waiting for its uploads.

The activity log's memory line counts the deferred releases (held so far,
let go, waiting), so a ledger that stops letting go shows at once.

Test: a held object XCL keeps looking at (clone and Release every 10 ms while
it is registered) still goes, once, soon after its grace. The arena test
waits for the ledger's other test work like the ledger's own tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…world load on the Mac)

GTA VI's world load on the Mac was stopped by the memory guard three times in a row
(runs 58-60). The title streams its textures into a 16 GiB GPU view of its memory, of which
it maps a 3.9 GiB pool page by page (queue #31), and it places tens of thousands of sampled
textures there: 32 768 by 70 s after the load started, 90 % of the new pages read with
nothing mapped (run 60). On D3DMetal every sampled title texture was a committed texture
of its whole size (reserved textures on shared tiles do not show each other's contents
there, `vram::on_pages`): Metal memory grew by 6 GiB in 15 s.

lazy_tex.rs (new; XCL_TEX_LAZY=1 textures not wholly present when made, 2 every eligible
one, 0 – the default – the committed path as before): a sampled 2D texture (arrays and
cubes, single-sample, no other use, BC formats – XCL_TEX_LAZY_FORMATS –, 128 KiB and up –
XCL_TEX_LAZY_MIN_KB) placed in a GPU view is a reserved resource (64KB_UNDEFINED_SWIZZLE)
with no tile mapped. Its tiles are in groups from GetResourceTiling: each standard mip of
each slice, each slice's packed mips (checked to cover every tile and subresource once,
else one group; XCL_TEX_LAZY_GRAIN=texture). Before an upload, a group gets tiles when it
has them, when the title's GPU work writes the texture (copies, resolves: all of it, before
that submit's lists run), or when at least half of its bytes in the console's layout lie
in 64 KiB pages with memory – textures lie side by side 1-2 KiB apart, so a page mapped
for one texture's mip tail holds the end of the one before it, and "any page" backed that
one's level 0 for a sliver (by mip within a group: a whole texture by
XCL_TEX_LAZY_GRAIN=texture is backed when its small mips are streamed in). An upload with
nothing to back is left out; the tiles are mapped before the detile, which then reads only
what is copied. Tiles come from pool heaps of 1023 tiles (four to one of D3DMetal's 256 MiB
blocks, NOT_ZEROED, never freed), mapped with UpdateTileMappings on XCL's upload queue (one
call a pool heap, inside late_release::submit) ahead of the copy on the same queue, which
copies only subresources that have tiles (texture::upload_batch_masked); the CPU waits for
it before the title's submit. Only what has no copy yet is copied when the texture's memory is as at its last
upload, or the title's GPU work wrote it (what its tiles have holds that work's texels). A
released texture's tiles wait for a mark taken then and serve the next ones. A texture short
of tiles (no more to be had) is tried again only when its pool can serve it – free tiles for
a group it lacks, counted out as the upload will take them (smallest groups first), oldest
first and uploaded first; one probe when a heap may be made, CreateHeap not asked again for
1 s after it failed –, not at every submit. No tile of a live texture is ever unmapped. A shape whose tiles would take more than
XCL_TEX_LAZY_MAX_OVERHEAD (1.25) times its committed size plus a tile a slice stays
committed; XCL_TEX_LAZY_MAX_MB caps the pool. Title MakeResident/Evict (device #34/#35)
leave lazy textures out: a reserved texture is a resource of its own in Metal's residency
set.

Also:
- title_textures: PENDING counted shadowed textures whose source changed and never took
  them back (the fast path of refresh never ran again); now only active ones.
- the census (XCL_ACTIVITY, every 2 s): title textures made by path and by method (#44,
  #133, views by address), with console and PC sizes (the PC's committed size, asked once
  per description); kept now (active / shadowed / lazy / same-range aliases / GPU-written /
  pending); how much memory GPU-view textures had when made; how placements overlapped;
  the lazy textures' tiles and pool; D3DMetal's video memory unwrapped (it reports it
  modulo 4 GiB) and the upload staging buffers.
- texture::copyable_desc: GetCopyableFootprints of a reserved texture with the default
  layout.
- texture::upload_batch_masked_run tells whether the copies were submitted when it fails; a
  Signal failure keeps the list and its upload buffer alive (they were freed under the GPU).
- tests: TEST_LOCK / VRAM_TEST_LOCK poison-tolerant; title_bytes test right on a Mac;
  runner::skip_config for a configuration's skip (the placed-texture test said nothing
  where it tests nothing); the PENDING fix tested through recheck_source.

Tests on D3DMetal under Wine (M5 Pro, macOS 26.7.3), each GPU gate alone first:
- gates: reserved BC1/2/3/4/5/6H/7 and RGBA8 textures (2D 256² – 2048², non-power-of-two,
  all-packed, arrays, cubes; typeless with typed views; cube-as-cube-array views) map from
  two heaps, upload and read back exactly; groups mapped one by one hold their texels and
  the others read as zero; tiles of a released texture serve the next; copies both ways
  with committed textures; 1024 unbacked 1024² BC7 textures +2 MiB, 4 µs each; mapping a
  22-tile texture 0.07 ms.
- end to end through CreatePlacedResourceX on an adopted device, a GPU view and queue #31
  mappings: no memory – no tiles, zeros; the tail's page – the tail's group alone; all of
  it; released and reused; 200 streamed in one or two heaps; a GPU copy and a resolve into
  one; what must stay committed does; 2048 textures streamed side by side, a quarter with
  their tail's pages: 48 MiB of tiles where committed textures take 1600 MiB, the same
  heaps again on a second pass; a full pool that cannot grow (6 tiles free, then 20 given
  back, then the rest): the groups that fit, nothing uploaded again while nothing can be
  had, the older texture served first, a GPU copy's texels kept.
- the whole suite: 707 passed, the 6 known failures (title_bytes… passes now); the real /
  sparse / title_textures / lazy_tex modules in one thread: all pass; the lazy tests again
  with the game's environment (D3DM_RETAIN_REFERENCES=1, XCL_LAZY_PAGES=0) and with
  XCL_TEXTURE_SKIP_UNCHANGED=1: pass.

An independent review in four rounds (five lenses, then the fixes, then the shortage
redesign, then a last check; each finding checked by a skeptic) confirmed 23, 12, 4 and 2
findings – none a kernel-panic risk – all fixed here, among them: a full pool re-uploaded every short texture
at every submit (and tiles coming back woke all of them); the unchanged-content skip ran
before the lazy check; a texture released between the two bookkeepings was uploaded unmasked
into tiles parked for others; a GPU write's texels were copied over after a shortage; a
failed upload left tiles with other textures' texels, or lost a change; the default path
walked every new texture's pages and asked the PC's size for the census alone (now only with
XCL_ACTIVITY, or lazy textures); the lock order of the tile mappings; a Signal failure
freed an upload list under the GPU (pre-existing); "the title's GPU work writes it" is now
what was recorded for this submit (Entry::writes_now), not ever; video memory unwrapped every
250 ms, only on a Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p budget, a watch that names the work and ends the title (GTA VI's first world frame)

GTA VI 1.0.2.1's world load on the Mac (run 61, with 0020) reached its first world frame and
the GPU stayed 100 % busy in compute for minutes: no Metal error, nothing in XCL's log, a title
fence one value short, until the process was killed (macOS freed the GPU 10 s later). No
ray-tracing program had run (the empty BVH descriptors were never read): the frame's new
programs were vfx_triangleClip's heap defragmentation – CS_DefragHeap_ComputeRelocations
(df231d75ee930b98) ends by writing (count, 1, 1) dispatch arguments, and
CS_RelocateVfxStartIndexLocation (36204a134ee59578) indexes its records by group id and copies
a size read from GPU memory. On a Mac much title GPU memory is outside unified memory (its heaps
are plain memory there): what translated programs write at those addresses is dropped, and a PC
ExecuteIndirect reads the title's PC buffer, whatever it held. XCL passed those arguments to
D3DMetal unchecked – the likely cause, not observed: XCL recorded nothing per dispatch. XCL capped
each lane's loops (65 536 iterations); nothing capped a dispatch.

- indirect.rs `Sanitize` (a Mac; XCL_INDIRECT_SANITIZE=0: as before): a translated compute
  ExecuteIndirect with a plain dispatch signature (not in a bundle) runs XCL's pass first – one
  thread a command copies its group counts into a buffer of XCL's (64 KiB chunks per recording,
  reused after the allocator's reset or release), 0 x 0 x 0 for more than
  XCL_INDIRECT_MAX_GROUPS groups (2^22, some 30 full-screen 4K passes of 8 x 8 tiles) or Y / Z
  above 65 535 – and the dispatch reads them there with a 12-byte signature. The pass reads the
  title's arguments where translated programs write them (a UMA window as a UAV), as an upload
  buffer, or from the title's own PC buffer (INDIRECT_ARGUMENT, read in INDIRECT_ARGUMENT |
  NON_PIXEL_SHADER_RESOURCE and back). Everything that can fail is made before anything is
  recorded; a failure logs and passes the arguments as before. The pass's pipeline and signature
  are made once and never replaced (lists may have recorded them). The root-changing repacker
  drops such dispatch commands too.
- The dispatch-wide budget (emit.rs `Em::trip`, `PRELUDE_TRIP`, `TRIP_AT_START`, mod.rs
  `LOOP_GUARD_TRIP`): in compute programs with loops, the lanes of a wave that find their budget
  spent add 1 to the dispatch's `res` word 0, and a wave that starts once XCL_BUDGET_TRIP_WAVES
  (64) such adds were made skips its loops (its budget starts at 0). A wave decides as a whole
  (one atomic read at the start); split wave64 halves that decide apart time their exchanges out
  once (bounded). Not where a group barrier waits for every wave (XCL_WAVE64_SPIN=0,
  XCL_SAFE_BARRIER=0). bind.rs `res_block`: a compute dispatch's block is [0, a serial, the
  threshold] – the windows upload a chunk only when its bytes changed, so a count the GPU left at
  an address must not carry over; a recording submitted again gets [0, a new serial] in its
  blocks on the CPU before the upload (`before_submit`, in ExecuteCommandLists and KickoffX). One
  block serves all commands of an ExecuteIndirect and a bundle's dispatch in all its runs. Graphics
  HLSL is unchanged (its DXIL cache entries stay valid); compute programs compile once more. The
  threshold is read at run time: XCL_BUDGET_TRIP_WAVES keeps the translation caches unless it is 0.
- stall.rs (new; XCL_GPU_STALL_WATCH=0: off): each translated dispatch is noted for its list
  (console program, groups; for ExecuteIndirect where its arguments are and whether they were
  checked; the newest 512 a list), and ExecuteCommandLists / KickoffX hand what a list noted to
  its queue's history (the last 16 submissions of the title's work, with the fence values
  signalled after each). A thread looks at the title's fences every second. A fence's clock runs
  while it is short of what a queue was told to signal and does not move – one complete or moved
  starts again, a gap between looks (the process stopped, the Mac asleep) counts as one look –,
  and nothing is judged while a queue waits for a value nobody was told to signal. After 10 s the
  queues' submissions in flight are logged (`[stall]`), every 30 s while it lasts;
  XCL_GPU_STALL_EXIT=<s> ends the title after s seconds (`real::end_title`; exit code
  0x574111ED). fence_x holds a reference to every fence it was told of (its value is asked from
  another thread), and a CPU Signal below the value a fence had (a rewind) lowers what queues were
  told of. XCL_SKIP_CS=<hash>,… drops a console program's dispatches (a lever for test runs).
- `[indirect]`: the first ExecuteIndirect of each console program (128) and draw pipeline (32)
  with its arguments in each kind of place – unified memory window k, an upload buffer, or outside
  unified memory – whether it was checked, or why it was skipped. The compute PSO line names its
  console program (the translation cache's hash) and threads. XCL_ACTIVITY: translated compute
  ExecuteIndirect so far (checked), dispatches skipped, views given an empty descriptor,
  acceleration structures outside unified memory.
- launcher: XCL_GPU_STALL_EXIT=30.

Tests on D3DMetal under Wine (M5 Pro, macOS 26.7.3):
- the check on the GPU from the three sources (upload SRV, the title's own buffer in
  INDIRECT_ARGUMENT, a window-like UAV), six commands with a 16-byte stride – (2,1,1),
  (4194305,1,1), (2048,2049,1), (1,65536,1), (3,1,0), (65535,1,1): exactly 2 + 65 535 groups ran
  from each; the repacker's test with the cap; `groups_ok` at the limits without overflow.
- the trip on the GPU with the translator's own pieces around a loop that never ends: 16384
  groups of 64 threads – 563 ran their loop, 15821 skipped it, 0.05 s; without the trip
  (threshold 0) all 1024 groups ran theirs; translation: the trip in compute loops only (native
  and split wave64), none in loop-free programs, compiled by DXC; kernels keep the plain guard;
  GTA's five programs of run 61's last frame translate and compile with it.
- the watch: a moving fence never stalls; reported at 10 s then every 30 s; the exit at its
  second (also before the 10 s report); a fence idle for 40 s and then signalled is not a stall;
  a 40 s gap between looks is not counted, and a hang under a sampler's 5 s stops still ends the
  title; a queue held by an unsignalled wait is not a stall, and the clock starts again when it
  is let go; a stall that ends is forgotten; fences: a forward CPU Signal keeps what queues were
  told, a rewind lowers it; the ledger across submissions, lists run again, 16 submissions a
  queue, the newest 512 records a list; a recording run again gets fresh dispatch blocks.
- the whole suite: 724 passed, the 6 known failures.

Two independent reviews (four lenses, each finding checked by a skeptic; then the fixes)
confirmed and fixed, among others: a fence idle for long was judged stuck for all that time the
moment it was signalled again (a false exit at GTA's boot); time the process or the Mac was
stopped counted as no progress; lifetime maxima made a rewound fence short for good, and the
first fix of it also lowered them on forward CPU signals (DirectStorage); the check's cached
pipeline could be replaced and freed while a recorded list still used it; trip counts carried
over to a recording's next run; XCL's own upload queues listed as unfinished; the ledger kept a
list's oldest records; bundles got barriers; a test's stand-in fence asked from another thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… title's Submit; the title's minidump kept off XCL's DWARF; a crash's memory in the log (GTA VI's intro crash)

GTA VI 1.0.2.1's world load on the Mac with the VFX defrag trio skipped (run 63) reached the
intro (frame 1254) and ended 184 ms later in an access violation at game+0x50e2130: a per-entity
table at [[rsi+0x10] + 8 * index] held a garbage tagged pointer (0xb5bfbf25060006e1). GTA fills
its streaming page table for a batch in its own submit path right before Submit
(game+0x1400e88f0 -> 0x140f2c470) and leaves an entry as it was when it frees the page. XCL
copied a request's page array at EnqueueRequest, and a half-full queue submitted by itself: an
entry still 0 refused the request (703 in run 62, 59 in run 63, 51 of those never logged), and an
entry naming a page the title had freed and taken again sent the data there, over whatever lived
in it, without a trace. The game's crash handler then died in Wine's dbghelp (0xc0000094 at
dbghelp.dll+0x157b1) and the process ended with that code.

- dstorage.rs (XCL_DSTORAGE_LATE_PAGES=0: as before): a request's physical page array that lives
  in the title's memory (not on the enqueuing thread's stack) is read when the request runs
  (`pages_now`); its snapshot at EnqueueRequest is used only when it cannot be read. A half-full
  queue still submits by itself but sends only the entries before the first such request; that
  request and everything after it (statuses, signals, in order) wait for the title's Submit –
  unless the queue is full (one slot left: the title cannot Submit while it waits for room), when
  all go. Held batches are counted once each. A cancel sends what a held batch kept back and
  nothing holds back any more – the entries before the first request still waiting for the
  Submit, all of them (the hold ends) when none is left. An auto-submit that finds the queue no
  longer half full (a Submit took the entries meanwhile) sends nothing. Query (DSTORAGE_QUEUE_INFO) counts a held batch's entries as sent and says the
  queue submits by itself when it is full – which it does –: a title that waits for room without
  a Submit is not left waiting on them. (GTA VI never calls Query.) An entry still 0 at the request's turn is looked at again 8 times 1 ms apart (the title
  may be filling it); after 4 requests in a row whose looks found nothing, none looks for a
  second. Counted and shown in the `[waits]` DirectStorage line: entries filled, moved to another
  page and cleared since EnqueueRequest, zeros filled while waiting / left, holds, full-queue
  sends. Every failed request is logged with its options, destination and source – memory, or a
  file and its offset, or the file object of a request refused at EnqueueRequest – (past 4096,
  every 1024th); a page-array write failure names the page not written and the file offset (64 of
  them). The last request that wrote each 64 KiB page is kept by default (XCL_DSTORAGE_PAGE_LOG=0:
  not), for a crash's report: the pages' addresses are found before its lock is taken (they take
  kernelx's), and a crash's report waits for it 100 ms at most in all.
- dbghelp.rs (new; a Mac host): the title's dbghelp.dll is the system's, but for
  MiniDumpWriteDump: Wine's, with dbghelp kept to public symbols for the call
  (SYMOPT_PUBLICS_ONLY, restored after) so that it does not read XCL's DWARF – its DWARF
  expression evaluator divides by zero there –, and without the kinds of dump that copy the
  process's memory wholesale (full, private read-write, private write-copy memory: tens of GB for
  a title here). XCL_TITLE_MINIDUMP=0: no dump (ERROR_NOT_SUPPORTED); =full: the kind asked for.
  hle `HleModule::real_dll`: GetModuleHandle("dbghelp.dll") answers as the system does (NULL
  while it is not loaded) and LoadLibrary gives the system's module or fails – never XCL's
  pseudo handle, which knows only MiniDumpWriteDump.
- eh.rs: after the report of an unhandled exception, the memory around each register that points
  at readable memory (16 qwords; near the start or the end of what is readable, as many from the
  register's on as are) and one step further (what the first 8 qwords there point at, labelled
  from the register, a misaligned one too), each with the DirectStorage request that last wrote
  its 64 KiB page. Copied with ReadProcessMemory: memory another thread unmaps meanwhile fails the
  copy, not the filter (a fault there is a nested exception and the title's own filter never
  runs) – the vtable look of the register report too.
- kernelx.rs (a test): a move to an address the test had just freed could find it reserved by
  another thread first (a test thread suspended in between while another test dumped the
  process); the destination is now in the low 64 KiB, which is never reservable.

Tests on Wine (M5 Pro, macOS 26.7.3):
- DirectStorage: a page table entry changed after EnqueueRequest – the data lands in the page the
  table names at the request's turn and the page it named before keeps what it held; a half-full
  queue (16 slots, 10 requests whose entries name another page at EnqueueRequest) writes nothing
  anywhere before the Submit and everything into the pages the title names when it submits, the
  old page untouched; a full queue (4 slots, 3 requests) runs them without a Submit; an entry 0 at
  its turn – filled by the first look, left 0 after the looks, the looks rest after 4 such
  requests and come back a second later; Query while a batch is held (16 slots, 11 entries: all
  slots, 4 to the full queue's send; 3 pending and no hold: 13 slots, 5 to its own submit) and
  the full queue sending it without a Submit, Query as for an empty queue after; a cancel of half
  of a held batch keeps the hold, of the rest ends it and sends the status kept back without a
  Submit. The tests' queues and pages are closed and freed when dropped, an assertion that fails
  too (the queue's worker is waited for before the buffers it reads go). Mutations: with XCL_DSTORAGE_LATE_PAGES=0 all three of the
  first fail (the snapshot; the self-submit writes into the old page); with late reads but no
  hold the half-full queue writes into the old page; without the full-queue rule the third
  fails; Query as before reports (5, 1), one that ignores the pending entries (16, 5), a hold left
  set by the full queue's send (16, 15); a cancel that leaves the hold set or sends nothing fails
  its test.
- dbghelp: LoadLibrary gives the system's dbghelp, GetProcAddress on it XCL's MiniDumpWriteDump
  and the system's SymInitialize, GetModuleHandle the same module – and NULL for a name of a
  real DLL routed to XCL that is not loaded (with the pseudo handle before, the test fails); the
  kinds of dump kept and
  left out (windows-sys' constants); a minidump of the test process (an executable with DWARF)
  asked with MiniDumpWithFullMemory is written without it, dbghelp's options as before, and none
  under XCL_TITLE_MINIDUMP=0. Without
  SYMOPT_PUBLICS_ONLY the test process dies at dbghelp.dll+0x157b1, as GTA's did. A probe under
  Wine reproduced the run-63 crash with XCL 0021's xcl.exe (SymFromAddr and MiniDumpWriteDump),
  and none with the executable stripped or with SYMOPT_PUBLICS_ONLY.
- the crash's memory: the lines for a register and one step further (a misaligned register's
  labels), the last qwords of a region whose next page is reserved only, unreadable addresses
  and registers that point at nothing skipped.
- the whole suite: 735 passed, the 6 known failures (twice after the last fixes).

Four adversarial reviews (lenses on DirectStorage ordering, the crash path and the tests; then
on the title's flow, Windows and Wine semantics and concurrency; then twice on the last changes;
each finding checked by a skeptic) confirmed and fixed, among others: the minidump type bit for
private write-copy memory (0x10000, not 0x20000); the crash report reading memory with a
check-then-read race inside the exception filter; a misaligned register's labels; GetModuleHandle
of dbghelp giving XCL's pseudo handle; note_written waiting on kernelx's locks under its own;
Query reporting an auto-submit a held batch would not get; the hold flag left set by a cancel,
then a cancel that ended a hold without sending what it kept back, then one that sent from a
stale look at the hold (it looks again under the queue's lock, as the auto-submit does); the
failure log naming memory for a file; tests that could not fail or left a queue's worker reading
freed buffers when they failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stand-in never sent to the PC; indirect draws checked on the GPU; DirectStorage writes kept by page for a crash; diagnostics of the memory the GPU cannot see (GTA VI's first world frame)

GTA VI 1.0.2.1's world load on the Mac with 0022 (run 64) got past run 63's crash point's
DirectStorage problem (0 failed requests, 4,077 page-table entries sent to the pages the title
named) and recorded its first world frame at 214.7 s, but never presented it: the binds of that
frame built their pipelines on the title's threads with no limit – about 415 new compute
programs, one of about 29 MB of DXIL still compiling after 434 s – and the title's job threads
and main thread waited in their idle waits behind them to the end of the run.

- pso_async.rs, real.rs, pso.rs (pipeline scheduling): a compute program of 256 KB of DXIL or
  more that no earlier run built goes to a lane of its own (XCL_PSO_BIG_THREADS, 2 threads
  below normal priority) and its binds do not wait for it (XCL_PSO_WAIT_BIG_MS, default 0: late
  at once); the smaller ones keep the workers and XCL_PSO_WAIT_MS. What a run built is kept in
  built-pipelines-<translated cache identity>.txt beside used-pipelines.txt (XCL_PSO_BUILT_LEDGER=0:
  none) and XCL_PSO_BUILT_SEED=<file> counts a list as built; a known big program is built on
  the workers and waited for like a small one – until three of them take 2 s or more (the
  driver's cache is not what the ledger says), then the ledger is not trusted and what is still
  queued on the workers goes to the big lane. A program over XCL_PSO_MAX_DXIL_KB (4096) is
  refused when it is made, by its translated cache's header, with no driver call, and so is
  every program XCL_NO_BUILD_CS lists; their stand-ins stay and their work is skipped. Builds
  still running are named every XCL_PSO_STILL_BUILDING_S, a build that fails is named (the
  first 16, then at powers of two; a refused one never), and a panicking build is a failed one
  instead of a dead worker.
- bind.rs, list_x.rs (bind gate): a stand-in whose pipeline is not built – late, failed, refused
  or on the big lane – is never sent to the PC with XCL's root signature: its Dispatch,
  DispatchX, DispatchMesh, ExecuteIndirect and draws are skipped and counted, the first 32
  programs named (XCL_STANDIN_SKIP=0, XCL_STANDIN_SKIP_DRAWS=0: as 0022). The depth-bias variant
  of a pipeline (D3DMetal has no dynamic depth bias) is not set while it builds – the base
  pipeline draws without its bias – nor when its build ends between the two looks; the first
  use of that fallback is logged.
- indirect.rs, bind.rs, device_x.rs (indirect draws): a translated draw's ExecuteIndirect with
  a plain DRAW or DRAW_INDEXED signature has its arguments checked on the GPU first – a
  command over XCL_INDIRECT_MAX_DRAW_COUNT (2^23 - 1) vertices or indices an instance, over
  XCL_INDIRECT_MAX_DRAW_WORK (2^26) in all, or reading past the bound index buffer, draws
  nothing – where the arguments are outside unified memory or unknown, and everywhere once any
  stand-in's work was skipped (a skipped producer leaves stale records behind) or with
  XCL_INDIRECT_SANITIZE_DRAWS=all (=own: the first scope only; =0: none). Root-changing
  (repacked) signatures, ones with vertex or index buffer views, and bundles go as they are.
  The check's pipelines are made ahead on xcl-indirect-warm; every ExecuteIndirect is counted
  by kind, place and fate (XCL_INDIRECT_CENSUS); XCL_INDIRECT_OWN=skip drops the ones whose
  arguments only PC copies fill.
- dstorage.rs, kernelx.rs, eh.rs, gpu_views.rs, waitwatch.rs (DirectStorage): the last request
  that wrote each physical page is kept by page (XCL_DSTORAGE_PAGE_LOG=address: by address, as
  0022; =0: none), so a crash's memory lines name the request and the page that is mapped
  there now – or that no page is, and that the memory may still hold what that page left; the
  old pages of moved entries are classified (XCL_DSTORAGE_OLD_PAGES); every hold for the
  title's Submit says how it ended, one held longer than XCL_DSTORAGE_HOLD_WARN_MS (2000) is
  named by xcl-dstorage-holds; the queue workers are xcl-dstorage-q<id>; the [waits] line keeps
  0022's text through "full queues sent N; " and adds each queue's most pending, its holds and
  a Submit histogram. The crash report takes only try-locks under one 100-ms budget in all.
  0022's request handling is unchanged.
- outside.rs (new), real.rs, console_heap.rs, device_x.rs, kernelx.rs, stall.rs, mod.rs, host.rs
  (diagnostics, with XCL_ACTIVITY; XCL_OUTSIDE_CENSUS=0: none): every 30 s, the memory
  translated programs cannot see – views given an empty descriptor by kind and by 64 KiB page,
  buffer V#s the title wrote into its heaps, views made by address, placed buffers and the
  GPU-visible plain allocations that hold them (base, size, flags, protection) –; the stall
  ledger counts ExecuteIndirect by kind and place for recorded and submitted lists
  (XCL_INDIRECT_SUBMITTED) and the [stall] line names a submission's draws; the memory line ends
  with the host's figures.
- skip_roots.rs (new), bind.rs, list_x.rs, kernelx.rs (for the next patch): at the first 2
  skips of each program XCL_SKIP_CS lists (16 in all; XCL_SKIP_CS_ROOTS=0: none), its root
  arguments – constants, root descriptors and the first 8 slots of each descriptor table –
  with each view's V#, its memory's place (a unified-memory window, a placed buffer, the plain
  allocation, other memory, none), who wrote the descriptor (XCL's view or the title's bytes)
  and the first 16 bytes the CPU holds there; DispatchX flags other than 0 (once a value) and
  the title's SetThreadPriority calls (once a thread and an IDLE/LOWEST value) are logged.
- kernelx.rs: FreeTitlePhysicalPages takes the lazy mark of a page it frees with it (lazy pages
  are off on a Mac: no change for the title there; the paging tests no longer see each other's
  marks).

Tests on Wine (M5 Pro, macOS 26.7.3): 835 passed (735 at 0022, 100 new), the 6 known failures,
25 ignored, the same in two runs; the translator's sources are unchanged (source id
6b6d07bbd7308cc4: no translation is made again). Among the new tests: the big lane, the ledger,
its seed and its distrust; a refused program never reaching the driver (D3DMetal); a stand-in's
work skipped on every entry point; the draw check against its CPU rule on a 64-bit grid and on
D3DMetal (window, upload and own sources) – the first triangle-drawing tests here; D3DMetal runs
min(count, max) commands and gives a new committed buffer zeros; DirectStorage holds, the page
record and the crash lines; the census; the root-view lines. Every test was mutation-checked:
of 382 mutations of the Rust code, 5 are equivalent, one showed a defect (fixed here), and every
other one fails its test. An
adversarial review in five parts (pipelines, indirect, DirectStorage, diagnostics, what crosses
them), each finding checked by a second reader, and two more over the fixes found no defect that
could crash, hang or panic a run; what they found is fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ls; pipeline waits with a limit bounded per frame; graphics builds and a frame's waits named (GTA VI's first world frame)

GTA VI 1.0.2.1's world load with 0023 (run 65) reached its first world frame at about 160 s and
presented nothing: one thread bound about 45 pipelines no build had finished, one after another,
each wait bounded by XCL_PSO_WAIT_MS=1500 – about 27.5 s of waits in one frame – while three
graphics pipelines sharing one new 608 KB pixel shader held the three workers for 14.6 s. After 30
one-second checks of the render thread's heartbeat the title's own stall watchdog called its armed
report hook, whose deliberate store to address 0 (game+0x23cf683, 0x4d8bd421) ended it at 190.3 s:
XCL_WATCHDOG_BYPASS resumed such a store only with a `ret` right after it, which this binary's
hooks do not have (they end `add rsp, imm8; ret`), and its test used bytes the binary does not hold.

- eh.rs, log.rs (the watchdog): one rule for the title's report hooks – the store `mov dword [0],
  imm32`, then `ret` or `add rsp, imm8; ret`, its return address right after the watchdog's
  `call rax` and on the watchdog's own store, in the hook's image – resumes at the hook's
  epilogue, which returns into that store; the watchdog's store in its first loop is resumed at
  its heartbeat check as before, and the one in its second loop (+0x2215da9) is resumed there
  too. Any other store to address 0 still ends the title. The hook's code is named (the first 4,
  then at powers of two), and the three lines wait a few ms for a busy log instead of being
  dropped (log::try_write_soon: at most 200 tries over about 5 ms, no blocking wait). A test
  raises the real faults through the handler under Wine: the leaf hook and the hook with a 0x48
  frame, each called through the shapes of the watchdog's two call sites, come back with the
  registers each resume promises.
- pso_async.rs, present.rs (a frame's waits): a thread's waits with a limit for pipelines at its
  binds and draws are bounded per frame too (XCL_PSO_WAIT_FRAME_MS, default 2000; 0: none): each
  gets what the frame has left of it, and once it is spent the binds go on at once without a
  pipeline not yet built (its build goes on) until the title's next Present; the first bind of a
  frame that went on without one is logged with what the frame waited and for which pipelines,
  and a pipeline the frame's budget made late says so in its line. With XCL_PSO_WAIT_MS unset or
  0 a bind waits for its build as at 0023.
- real.rs, host.rs, waitwatch.rs (diagnostics): every graphics, VS+GS or mesh pipeline's build is
  named with its translation and driver times; the "no Present" line ends with the threads that
  waited for pipelines since the last Present (the 4 longest); the waits watch's state of a call
  that merged several ends with their number and this one's age.

Tests: 851 pass, the 6 known failures (835 at 0023), 25 ignored. Mutations at each step of the
patch (52, 102, 12): in the end each is caught by the test meant for it, but one equivalent. Two
rounds of adversarial review, each finding checked by a verifier; every confirmed finding is fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eline builds queued in tiers; upload staging and XCL's part of the coherent window capped; the world's frames dumped (GTA VI's world load on the Mac)

GTA VI 1.0.2.1's world load with 0023.1 (run 66) went past its first world frame (about 149 s) and
the title's stall watchdog, and presents went on until the strict memory guard ended it at 199.7 s
for swap (+4488 MB). D3DMetal's memory grew from 1.9 to 8.8 GB, because MADE keeps a PC texture for
every view address the title names, and keeps it for good. The Mac had also started with 11.6 GB of
other apps' memory. 0023.2 measures what that memory holds before GP2 changes it. It caps two
buffers that only grew and orders the pipeline builds.

- view_census.rs (new), console_heap.rs, real.rs, device_x.rs, title_textures.rs, lazy_tex.rs,
  vram.rs, host.rs (GP1, diagnostics only):
  - A lock-free shadow of the shared descriptor heap's places (16 bytes each, one VirtualAlloc of
    32 MiB at most) follows every PC view XCL writes, copies or clears, after the D3D12 call.
  - MADE keeps how each of its textures was made.
  - Every 10 s, on a thread of its own (xcl-view-census, under XCL_ACTIVITY), the census prints the
    lines "view census: …": the places in use, and the textures MADE holds that no PC descriptor
    names any more (what GP2 may let go), by kind and size. XCL_VIEW_CENSUS=0 turns it off.
  - The title's threads only do relaxed atomic stores. The census never dereferences a map value,
    makes no D3D12 call, and uses uma::made(), so it never creates the unified-memory window.
- pso_async.rs, real.rs, gpu/recomp/pso.rs (PP2): the workers' queue in two tiers.
  - First the pipelines the built-pipelines ledger knows or whose translation is cached, then the
    cold ones.
  - Only one worker at a time waits for commit on a big compute pipeline of the first tier. The
    turn passes on once that build is past its wait.
  - XCL_PSO_TIERS=0 gives one FIFO, as before.
  - The VS/PS precompile fills only the flat DXIL cache, so a precompiled graphics pipeline counts
    as cold, though it needs no DXC (the design's erratum).
- pso_async.rs, host.rs (PP3, MP4, PP6):
  - A "pipeline queue (2 s): …" line: the queue by tier and kind, DXC compiles, big-lane commit
    waits and the programs skipped. Also a clause in the "[waits]" line, and "pipelines at the
    end:".
  - The first use of each pipeline built in this run, at bind time ("[pso] first use of …", 1024
    at most).
  - The built-pipelines file gets each key once.
- gpu/texture.rs, title_textures.rs (GP3): upload staging kept at 128 MiB (XCL_UPLOAD_STAGING_MB;
  0: as before).
  - Batches go in runs of at most the cap, cut by PC staging bytes, through the kept buffer, which
    no longer grows past the cap. A texture bigger than the cap gets a staging buffer of its own
    for its upload only. In run 66 the kept buffer had grown to 256 MiB at 92 s, raising D3DMetal's
    memory by 256 MB.
  - A texture whose own upload fails before its submit gets one later turn (Entry.later), never one
    that would overwrite what the GPU wrote.
- gpu/uma.rs, host.rs, real.rs (GP4): XCL's own part of the coherent window is 256 MiB on a Mac
  (XCL_COHERENT_OWN_MB; 512 elsewhere, as before).
  - A "coherent window: …" line gives its use and its high-water.
  - A committed texture the window has no headroom for is now named by a bounded warning. It gets
    a PC texture of its own, which the title's CPU writes do not reach.
  - XCL_TRACE_MEM's no-room trace gives its count, at 1-16 and then at powers of two.
- present.rs, bind.rs, device_x.rs (DUMPS): XCL_FRAME_DUMP_WORLD=<every>[,<max>] (off; 20 at most
  by default) dumps every n-th Present from the world's mark, the first dispatch XCL_SKIP_CS skips.
  A dump whose copy outlasts its 2-s wait is written at a later present.

Tests: 915 pass, the same 6 failures as before (851 passed at 0023.1), 25 ignored.

Mutations at each step: 181 mutants on the first implementation, 41 on the review's fixes and 15 on
the last fixes. The records under runs/analyses/0023.2-impl list each survivor, each closed test gap
and each equivalent mutant.

Reviews: two rounds of adversarial review (four parts, then the fixes), each finding checked by a
verifier, then a check of the last fixes. Every confirmed finding is fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both sides changed the same code in 13 files. Each conflict was resolved by
hand, keeping both sides wherever they fit together:

- BCPack: the same port on both sides. BC7 dictionary entry 0 stays as
  scripts/gen_bcpack_victory_tables.py writes it from bcpack-tables.bin
  ([1, 0, ...]): every BC7 record has the same 116-byte layout, and the u16
  after the widths is skipped in all of them. The entry-0 test pins that value.
- Upload staging: the cap (XCL_UPLOAD_STAGING_MB) stays. The kept buffer is
  let go before a bigger one is made, and a size past u64 is an error
  (9db0989). Title-texture batches also stop at 256 textures.
- ExecuteIndirect: fresh_indirect_arguments wraps the paths upstream wraps:
  the two-pass mesh path, the PC-pipeline path, the repacked path, and the
  direct call, which here is also both fallbacks of the GPU-checked path. Each
  call gets a transition of XCL's own buffer to INDIRECT_ARGUMENT and back, so
  that it reads the arguments written before it (measured upstream on NVIDIA;
  on the repacked path the repacker's transition of its output does that
  already). The GPU-checked path is not wrapped: it runs on XCL's checked copy,
  which is moved to INDIRECT_ARGUMENT after the check, the same ordering. The
  stall trace (XCL_TRACE_GPU_STALL) is kept everywhere.
- PresentX: two planes or more are still composed by default.
  XCL_PRESENT_PLANE=n shows plane n alone and falls back to plane 0 as
  upstream's selection does; every plane's token is flipped; the plane shown
  alone is read through upstream's guarded GetDesc (a follow-up commit guards
  the composed planes too).
- Descriptor resync: upstream's signature and tag map. Slots are read in
  place and a copied slot comes from the shared heap, as before: the resync
  runs at every submit over hundreds of pages in GTA VI's world, so it takes no
  per-page ReadProcessMemory and no linear search for a mirror.
- Releases: the deferred-release ledger stays the only Release hook. It runs
  on driver threads that may touch atomics only, so the release gate's mutex is
  not taken there; clone_resource's adopted-object check and the deferred
  remaps stay.
- Bottom-of-pipe writes: the per-queue workers and the ordered CPU copies stay.
  The submission's lists in the stall trace come from 9db0989, and so does its
  removed-device rule: the writes of a submission whose fence reads all ones
  are not done (a follow-up commit also stops the title there, as the fences'
  rule below leads to).
- DirectStorage: AutoSubmitDisabled is honoured. A full queue still sends
  everything instead of blocking the producer (3247579's wait for room is not
  taken).
- Fences: the cell follows GetCompletedValue, a removed device's all-ones
  included, so the title's wait ends and reaches stop_if_device_removed. The
  10 ms poll and WakeByAddressAll stay.
- Stall watchdog: the report hooks are recognised by their bytes; upstream's
  test change is covered by the negative tests of the resume.

Tests (lib, Wine + D3DMetal): 942 passed, 6 failed, 25 ignored. The 6 also
fail on our series alone and on upstream main, which fails 2 more that pass
here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment described a Mac-only remap of slots 73 and 74 that upstream
removed itself (692d902). Both sides now map the slots the same way, so the
lines are upstream's again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e after it

backbuffer_like_guards_against_invalid_pointers_and_vtables put its
"truncated" 64-byte vtable on the stack. The bytes past an array there can be
read, so the 88-byte check passed and slot 10 was whatever the stack held. In
a build where that was a pointer into the stack, the guard called GetDesc
through it, the test died on an execute fault and the test run hung. The
vtable is now the last 64 bytes of a committed page with only reserved memory
after it, and the test also checks the reason check_resource_desc_slot gives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream's check_resource_desc_slot (d44cf12) guarded only the plane shown
alone. With XCL_PRESENT_PLANE unset and two planes or more, the default on
GTA VI, compose_planes and the planes' log line (describe_plane) still called
GetDesc on each plane's resource unchecked. Both now go through
get_resource_desc. A plane whose object, vtable or GetDesc entry cannot be read
is left out of the composition, and the log line gives the reason instead of
the size.

Test: planes whose resource has a null vtable, an unmapped vtable or a null
GetDesc entry are not composed and are named with their reason. Nothing is
called through them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The row gave `0` as the default and said to set `1` to try the second plane.
With the merge, unset composes two planes or more, `n` shows plane `n` alone,
and plane 0 is shown when the title presents fewer planes or plane `n` has no
presentable resource. So `0` turns composition off: a user who copied the
documented default lost the composed planes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eLGatoRDV and others added 5 commits November 29, 2026 19:26
The merge took two rules for a removed device. Their fence_x skip of
UINT64_MAX was removed, so a removed device's all-ones ends the title's wait
on a fence cell and its next call reaches stop_if_device_removed. In the
cpu_writes worker, 9db0989's rule was kept: with the fence at all ones, no
write of the job is done. That included Immediate markers and CPU copies,
which do not depend on the GPU. A title waiting on such a bottom-of-pipe
marker would wait for ever instead of being stopped with the report.

The worker now calls real::stop_if_device_removed when its fence reads all
ones, as the title's next submit or present would. It writes the report and
ends the process when the device is gone. While the device still answers, the
job's writes are left out as upstream does, and its done fence is still
signalled.

Test: a job whose fence reads all ones while the device answers. Its write is
not done, its done fence is signalled, and the queue's next job is done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge removed upstream's skip of UINT64_MAX in refresh (3f3cca2), so that
a removed device's all-ones reaches the fence cell. The title's wait on the
cell then ends, and its next call reaches stop_if_device_removed. It also
removed upstream's test of the skip, which swapped a local AtomicU64 and never
called fence_x. Nothing pinned the new rule. The test signals u64::MAX on a
fence with a cell from the CPU and checks that the cell reads u64::MAX after
the refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ount

The merge took 9db0989's order: the kept upload buffer is let go, and taken
off STAGING_BYTES, before a bigger one is made. With the cap,
gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels checked only runs
on a kept buffer of 128 MiB, so no test grew one. In GTA VI the buffer grows
4 -> 8 -> 32 -> 128 MiB.

The test now first uploads the 4 MiB BC7 texture alone, which keeps a buffer
of 4 MiB. It then uploads the 128 MiB RGBA texture alone, which grows the
buffer to 128 MiB. Both read back byte for byte. A per-thread mirror of what
the kept buffers add to and take from STAGING_BYTES (cfg(test) only) shows the
count at 128 MiB after the growth, with a peak of 128 MiB and never 132, and
back to where it started once the uploader is dropped. STAGING_BYTES itself is
the process's, and the other tests change it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…itDisabled

Upstream's 5bff7bd honours a queue's AutoSubmitDisabled option: such a queue
no longer submits by itself at half full, only at the title's Submit or when
full. GTA VI makes its queues that way, so the change alters how its streaming
batches reach the disk and the page tables. No run of the game has seen it
yet, and a build that cannot turn it off cannot compare it with the old
behaviour in one A/B pair of runs. XCL_UPLOAD_STAGING_MB=0 is kept for the
same reason.

XCL_DSTORAGE_AUTO_SUBMIT_DISABLED=0 ignores the option: the queue then submits
by itself at half full, like any other, as before 5bff7bd. Unset, or any other
value, keeps upstream's behaviour. The first CreateQueue1 line says when the
option is ignored. One risk remains with the option honoured: a batch that
fills a queue (4,159 entries for GTA VI's) takes the full-queue escape, which
runs requests into the title's pages before its Submit. The log says so as "a
full queue (qN, ...) runs requests into the title's pages".

Test: the switch's values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream's 5bff7bd translates a console MS container that sits in a stream's
AS slot, with no MS subobject, as the mesh shader it is. Our series refused
those pipelines: translated before the mesh chunk budget was fixed, the title
rendered nothing from then on. GTA VI makes 38 such pipelines in every run,
and none of our runs has drawn with them. A build that cannot refuse them
again cannot compare the two in one A/B pair of runs.

XCL_MS_IN_AS_SLOT=0 refuses them as before: E_INVALIDARG, with the
translation-error line ending "refused (XCL_MS_IN_AS_SLOT=0)". This happens in
translated_mesh_stream before any translation. Unset, or any other value,
keeps upstream's translation.

Test: the switch's values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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