Windows compatibility work from TaynanGT/VIctory, merged with main #2758

Closed
github-bot wants to merge 467 commits from github-bot/gh-2758 into main AGit
Owner

@⁠TaynanGT on GitHub · 2026-11-25 19:49 UTC · original
main → main · +60359 −32501 · 117 files · 467 commits · closed without merging

The Windows compatibility work from TaynanGT/VIctory, merged with VIctory main at 13f91ca. It reaches the controllable prologue room at about 7 FPS on an RTX 4090 (README, "Local test results"), against about 1 FPS in VIctory's own status.

This is one large change (326 commits, 117 files). If you prefer focused PRs, say which parts you want first and I will open them separately against main, each with its own description and tests, as #2716 already does for XGameSave.

What it changes

  • Shaders (victory-shader): wave64 compute programs on 32-lane hosts (NVIDIA, Intel) as two host waves that exchange through LDS, including groups of several console waves; the ray-tracing node test (image_bvh_intersect_ray) as inline DXIL, with a CPU model it is checked against; scalarised light loops (own_bits), jump threading for uniform diamonds, spilled user-data tables; lowering fixes with tests in emit/*_tests.rs.
  • GPU (victory-gpu): descriptor mirroring for heaps the title writes by address, title memory opened as a host heap (inplace) and direct copies of it, texture upload budgets, indirect-draw clamping, host pipelines built off the render thread, and live switches (VICTORY_LIVE) to compare settings in one session.
  • HLE (victory-hle): XGameSave recovery (the same rules as #2716), DirectStorage page lists, XMA looping, memory mapping and async cancel fixes.
  • Loader (victory-loader): the console CPU's instructions an Intel host lacks (clzero loops among them), emulated in the vectored handler.

Cargo.toml, rust-toolchain.toml, rustfmt.toml, .github/workflows/ci.yml, xtask, docs/ and LICENSE are identical to main. The README is main's, with two sections added: the development PC and the local test results.

Known differences from main

The merge kept the fork's interfaces where both sides changed the same code, so this PR also removes ten files that main has and the fork replaced: victory-gpu/src/{bindless,hold,placement,twin}.rs, victory-shader/src/emit/lower/bvh.rs, and the tests emit/{bvh,memory,semantics,stride,synthetic}_tests.rs. Some of main's GPU changes from the last two days (texture placement, list waits on memory values) are therefore not in this branch yet.

Tests

  • cargo clippy --workspace --all-targets --locked -- -D warnings and the same with --all-features: clean.
  • cargo test --workspace --locked on Windows 11 with an RTX 4090, GPU tests included: 903 passed, 0 failed (at def99cf).
  • cargo xtask policy: all files pass.

🤖 Generated with Claude Code

**@⁠TaynanGT** on GitHub · 2026-11-25 19:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2758) `main` → `main` · +60359 −32501 · 117 files · 467 commits · closed without merging The Windows compatibility work from TaynanGT/VIctory, merged with VIctory `main` at `13f91ca`. It reaches the controllable prologue room at about 7 FPS on an RTX 4090 (README, "Local test results"), against about 1 FPS in VIctory's own status. This is one large change (326 commits, 117 files). If you prefer focused PRs, say which parts you want first and I will open them separately against `main`, each with its own description and tests, as #2716 already does for XGameSave. ## What it changes - **Shaders** (`victory-shader`): wave64 compute programs on 32-lane hosts (NVIDIA, Intel) as two host waves that exchange through LDS, including groups of several console waves; the ray-tracing node test (`image_bvh_intersect_ray`) as inline DXIL, with a CPU model it is checked against; scalarised light loops (`own_bits`), jump threading for uniform diamonds, spilled user-data tables; lowering fixes with tests in `emit/*_tests.rs`. - **GPU** (`victory-gpu`): descriptor mirroring for heaps the title writes by address, title memory opened as a host heap (`inplace`) and direct copies of it, texture upload budgets, indirect-draw clamping, host pipelines built off the render thread, and live switches (`VICTORY_LIVE`) to compare settings in one session. - **HLE** (`victory-hle`): XGameSave recovery (the same rules as #2716), DirectStorage page lists, XMA looping, memory mapping and async cancel fixes. - **Loader** (`victory-loader`): the console CPU's instructions an Intel host lacks (`clzero` loops among them), emulated in the vectored handler. `Cargo.toml`, `rust-toolchain.toml`, `rustfmt.toml`, `.github/workflows/ci.yml`, `xtask`, `docs/` and `LICENSE` are identical to `main`. The README is `main`'s, with two sections added: the development PC and the local test results. ## Known differences from `main` The merge kept the fork's interfaces where both sides changed the same code, so this PR also removes ten files that `main` has and the fork replaced: `victory-gpu/src/{bindless,hold,placement,twin}.rs`, `victory-shader/src/emit/lower/bvh.rs`, and the tests `emit/{bvh,memory,semantics,stride,synthetic}_tests.rs`. Some of `main`'s GPU changes from the last two days (texture placement, list waits on memory values) are therefore not in this branch yet. ## Tests - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the same with `--all-features`: clean. - `cargo test --workspace --locked` on Windows 11 with an RTX 4090, GPU tests included: 903 passed, 0 failed (at `def99cf`). - `cargo xtask policy`: all files pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Rust workspace for VIctory: PE analysis, loader, HLE skeleton,
DXBC/DXIL parsing with a GFX10 decoder, conversion cache, CLI and
asset-policy enforcement.
Decode the operand fields of every GFX10 encoding (Instruction::fields)
and print them in SP3 syntax (Instruction::text, shader-info --disasm).
Read the wave size from the FSSM stage record flags.
Loader: map title-shipped DLLs, patch static TLS loads to slot 0, crash
reporter, title paths for GetModuleFileName*.

HLE: task queue and async, XUser (one offline user), system ids,
title id, features, invites, game events, persistent local storage,
GameInput with no devices, xmem, console audio hardware queues, life
cycle (close suspends, then terminates), and a file layer with virtual
drives rewritten in path-taking imports.

GPU: D3D12.X device, DXGI chain, heaps, resources, fences, queues and
command lists translated onto a host D3D12 device; clears, barriers,
copies, resolves and PresentX into the title's window.

Shaders: SGD5 reader and `victory translate`; SSA IR with node
splitting for irreducible flow; structurisation removing EXEC.
GetModuleHandle* and LoadLibrary* find the title's images and our
console modules by file name. LoadLibrary* of a title DLL nothing
imports maps, binds and attaches it on the calling thread (a title's
own loader DLL may load its backends this way). FreeLibrary never
unloads title images.
The prepared images get no DLL_THREAD_ATTACH/DETACH from Windows. A TLS
callback in our exe, called on every thread of the process, passes each
start and end on to the attached images: their TLS callbacks, then a
DLL's DllMain. DisableThreadLibraryCalls stops the DllMain calls and
fails for images with static TLS, as on Windows.
Their TLS callbacks run before std's start routine records the thread,
and std aborts if anything asks for the current thread first (stdout and
stderr locks do, so title code calling our logging functions would).
Threads starting in our exe (the title's main thread and our runtime's
workers) now get no notices; the probe test starts its thread in title
code.
The title now boots through every first-boot and menu screen at its own
30 fps, drawing with translated shaders, with input, sound, saves and
loading served; it reaches the world, where the host GPU path still
fails (see "Not working yet").

Loader and runtime
- Crash reports unwind properly, name C++ throws and host GPU failures,
  carry the title's last debug lines and are appended to crashes.log.
- Thread notices on our own threads, reentrant late DLL loading, exit in
  the console's order, relaunch on a launch-new-game request.
- Offline guard: the title cannot reach the network (sockets, name
  lookups, WinHTTP, the media source resolver); by-name lookups and
  loads follow the import rules.
- Every runtime area the title calls is served (networking hint,
  packages, store, saves, display, UI, speech stubs, user, async pool).
  Saves persist; an update is one rename and survives a kill at any step.
- DirectStorage reads for real: shared worker pool, priorities, zlib and
  BCPack. BCPack is our own decoder; the format's constant tables ship in
  crates/victory-formats/src/bcpack-tables.bin (the asset policy's one
  exception, see docs/asset-policy.md).
- GameInput from XInput pads and the keyboard, with a keyboard stand-in
  pad; console timers (1 ms) for the whole process.
- Audio: XMA2 decoding on the emulated contexts, Opus on the decoder
  queues, the DSP interface as a stub; title memory placed below 2^40.
- Console texture layouts (sizes, tiling, detiling) and the layout
  library's imports.

GPU
- Draws, mesh dispatches and compute dispatches run on the host with
  shaders translated at first use and cached on disk; descriptor heaps,
  views, root signatures, barriers and host texture states; rectangle
  lists; comparison samplers.
- Title memory reaches the host through persistent mirrors that copy
  only pages written since the last copy; shader-written buffers are
  copied back.
- Presentation with frame pacing per event kind; framerate in the window
  caption.

Shaders
- DXIL emission for vertex, pixel, compute and mesh programs from the
  console's native code, with a differential test suite against the PC
  compile. World set: mesh 8,191 of 8,506, vertex/pixel 10,617 of
  12,346, compute 1,643 of 2,539; utility set complete.

Build
- Debugging aids (debug logs, frame capture, stack dumps, scripted keys,
  the host debug layer, the software adapter) exist only with the
  `diagnostics` feature; `[profile.diag]` keeps that build apart.

Not working yet
- In the world the host device is removed within seconds (descriptor
  handling fixes are in, unproven by a surviving run) and frames present
  black.
- 64-bit image atomics, merged geometry stages and the BVH builder's own
  shaders do not translate; reverb is silent.
Says how far the title gets (menus at 30 fps, the world reached but not
rendering), what each subsystem does and still needs, and warns that the
world can reset the display driver on a real GPU. Adds how to run the
title, the translate command, and tables for the keyboard pad and the
debugging switches.
prepare() zeroes the title's TLS AddressOfCallBacks but left the
IMAGE_REL_BASED_DIR64 entry that patches it. When the loader maps the
prepared copy away from its preferred base, that entry turns the 0 into
the rebase delta and the loader reads TLS callbacks from there. On
Windows the copy lands at 0x140000000 so the delta is 0; under Wine,
which maps DYNAMIC_BASE images high, LoadLibraryExW faults in ntdll
before any title code runs.

The entry is now rewritten as IMAGE_REL_BASED_ABSOLUTE (a no-op), and
the prepare test checks that no relocation targets the cleared field.
Loader: keep the cleared TLS callback pointer out of base relocations
The title is built for Zen 2 and uses clzero, monitorx/mwaitx and SSE4a's
extrq/insertq, which Intel CPUs lack: it died at startup with an illegal
instruction on an i7-14700KF. The vectored handler now does their job and
resumes: clzero zeroes the 64-byte line at rax, monitorx is skipped, mwaitx
yields, extrq/insertq run on the saved XMM registers.

Tested: victory-loader crash tests (new one runs each instruction), and the
title now gets past startup on an i7-14700KF with an RTX 4070 SUPER.
next_frame walks the frames before `start` to learn whether the frame at
`start` is the packet's last. A damaged packet whose earlier frame has a
length of 0 never advanced `at`, so the walk spun forever (in a debug build
it overflowed `number` after about 4 billion rounds and panicked).

Apply the rule read_frame already uses: a length that does not cover its
own 15-bit field is not a frame, and the search ends.

Found with a random-input harness. The new test hangs without the fix and
passes at once with it.
The exit code ended the other threads first and then started the
watchdog. A thread that ends can hold the heap lock or the loader lock.
A new thread needs both, so the watchdog did not start and the exit did
not stop.

Now the exit code starts the watchdog and waits until it runs its own
code: only then are its loader notices and Rust's thread set-up done.
The watchdog publishes its thread id, and end_other_threads does not
end it. The wait has the same deadline as the detach, because this
thread, or a thread that waits for it, can hold the loader lock; then
the watchdog cannot start.

After the deadline the watchdog only ends the process. It does not
log, because logging needs the heap and the lock of the log writer.

The exit test now also checks that a thread in `keep` is not ended.
loader: emulate AMD-only instructions on Intel CPUs
Layout::new checked that width, height and depth are non-zero but not that
they are bounded, so values a title passes unchecked (up to u32::MAX)
overflowed the size arithmetic: `offset * depth` in the linear layout,
`slice_size * slices` and the per-mip sizes in the tiled one, and a u32
next_multiple_of in Layout::tiled. Debug builds panicked; release builds
wrapped silently and returned a wrong size.

Refuse anything past 16384 texels per side, the most a GFX10 image
descriptor holds, so no texture the GPU can use is affected.

Found with a random-input harness (four distinct overflow sites, none left
after this change).
Three lowerings gave results the console's GPU does not (issue #2, from
hardware measurements published by another project):

- v_med3_f32/f16: with a NaN operand the hardware gives the minimum of
  the three; we gave the median of the other two.
- v_fract_f32/f16: the hardware never reaches 1.0 (a tiny negative
  input gives the largest value below it); the host's own fract differs
  by vendor and can give 1.0.
- v_bfe_i32/s_bfe_i32: a signed field running past bit 31 extends from
  bit 31; the shift is arithmetic now. Fields that fit are unchanged.

The fract case is asserted in float_semantics_are_the_consoles (the
console compiler emits v_fract_f32 for frac). The other two cannot be
produced from HLSL with the compiler the tests use and rest on the
measured values in the issue.

Still open from the issue: range reduction before sine and cosine, and
denormal operands of the legacy multiply.

Refs #2
v_sin and v_cos (f32 and f16) take an angle in turns. The whole turns
now come off first (x - round_even(x), exact), so a large angle keeps
its fraction of a turn instead of losing it when scaled to radians.
The sine of a half turn and the cosine of a quarter turn are exactly +0,
as the hardware gives; the host's functions of the rounded angle give
about 1e-7. A zero operand passes unreduced, so sin(-0) stays -0.

float_semantics_are_the_consoles asserts the exact zeros (it failed
before this change). The compiler the tests use takes whole turns off
itself, so the large-angle path cannot be reached from HLSL and rests
on the measurements cited in issue #2.

Left from the issue: denormal operands of the legacy multiply, which
needs the float mode register as state first.

Refs #2
The host device was removed seconds into the world because a shader read
a descriptor of the wrong kind: empty slots held a null 2D texture view
where the shader expected a buffer, which gave a garbage heap index and
a read far past the view heap. Null descriptors now have the kind the
shader expects (raw buffer, constant buffer, or a texture of the title's
own dimension). The world then ran to a 240 s time limit with no removal.

Also:
- Host lists hold the textures, pipelines, root signatures and heaps they
  name, and heap slots hold the resource they view (the title releases
  objects before submitting lists that use them).
- The device-removed report places the fault against the host descriptor
  heaps and names our own uploads; VICTORY_D3D12_GBV turns on GPU-based
  validation, VICTORY_DUMP_TARGETS works.
- Indirect execution (draw, indexed draw, dispatch, mesh dispatch): the
  world draws most of its geometry this way. Arguments are clamped and
  charged to a per-list budget by a small compute pass first, so garbage
  cannot hang the GPU. Off by default (VICTORY_INDIRECT=1): with it on
  the title's own GPU watchdog ends the run about 30 s into the world.
- Shader-written ranges are copied back once per submission and only
  where they differ; refreshes beside them copy only stale pages. The
  frame-rate line counts copy-backs and dropped draws.

Not working yet: the world's picture is black (indirect draws off, and
hundreds of draws per frame have no translated shader).
The title's shader-visible view heap has 1,245,184 slots. NVIDIA caps
shader-visible view heaps at 1,000,000, so HostHeap::new falls back to a
heap of 1,000,000 whose title part ends at 934,464, with the dynamic
slots after it. The title binds a per-frame table ring in its top slots
(934,464 to 1,245,184, moving 4,096 slots a frame), so those tables'
host offsets either aliased the dynamic slots or ran past the heap's
end. On NVIDIA the GPU then hangs within the first-boot screens
(DXGI_ERROR_DEVICE_HUNG), after black and glitched frames.

A table that reaches past the host heap's title slots is now made
afresh in dynamic slots, as tables holding constant buffers already
are, and the shader is given the new offset. Hosts that take the whole
heap (AMD) are unchanged. mirror() logs the highest title slot it
meets past the host heap, once per new maximum.

Tested on an RTX 3080 (driver 32.0.16.2114): the first-boot screens and
menus run without glitches, and the title loads into the intro with no
device loss (before: device removed about 45-60 s in, 3 of 3 runs). The
slot warning went from 78 lines to none. cargo test --workspace passes.

Refs #16, #11
xma: stop at a zero-length frame instead of looping forever
A section whose PointerToRawData lies near 4 GiB made
file_offset + delta overflow: a panic in debug builds, a wrong offset in
release ones. The section now yields no offset.
texture: refuse extents past 16384 texels instead of overflowing
The test for the emulation runs the real instructions. AMD CPUs, and
most CI runners, execute them natively, so the emulation was tested
only on Intel CPUs.

The new tests give the emulation instruction bytes and saved registers
directly, so they work on any CPU. They cover clzero, monitorx/mwaitx,
the immediate and register forms of extrq/insertq, xmm8 to xmm15,
length 0, and the instructions and exceptions it must not emulate.

The old test stays: on an Intel CPU it is the only test of the full
path through the vectored handler.
Process exit: start the watchdog before other threads end
GPU: make tables past a capped host view heap afresh (NVIDIA menu hang)
In a wave64 compute program, writing only EXEC's high dword (for
example s_mov_b32 exec_hi, 0) and then running any vector instruction
crashed the whole process with a stack overflow. The new mask is opaque
and keyed by the unchanged low dword, so lowering the instruction's guard
asked for that dword's value, the value is a lane mask read as data, its
ballot needs the mask's lane bit, and that bit needs the value again:
mask_dword -> boolean -> atom -> get -> mask_dword, without end.

mask_dword now notes the masks whose ballot it is building, and a mask
reached again on the way fails with a reason. The instruction then fails
like any other that cannot be expressed: its result is missing, and only
a side effect that uses it stops the translation. A shader the translator
cannot handle must not take the title down at pipeline creation.

Found with a random-input harness over the whole translation (ir,
resource, io, structure, emit) of random decodable compute programs. The
new test overflows the stack without the fix. One million further
programs (about 160,000 fully translated) gave no panic, hang or
overflow.
Translated loops stop after 2^20 iterations per lane so that a loop
over not yet mirrored data (zeros) cannot run four billion times. A pass
where every lane reaches that limit still takes seconds, though: 2^20
iterations times a 4K screen's 8 million pixels is about 10^13 loop
bodies. The world's frames now take 1.5-3 s, and loops spinning to the
limit on data that reads as zeros are one candidate.

A diagnostics build now reads VICTORY_SHADER_LOOP_LIMIT (decimal or 0x
hex, at least 1). If a low value such as 4096 makes world frames much
faster, loops hitting the limit are what makes them slow. If not, they
are ruled out. The limit is part of the translation, so the shader cache
keys on it, and a run that overrides it logs a warning. Release builds
always use 2^20.
Removes the print-only dbg_tls test in image.rs (TLS presence is already asserted in parses_own_test_binary) and switches layout.rs offset helpers (read_u32, read_u64, optional_header_offset, file_header_offset, data_directory_offset) to checked arithmetic so extreme offsets return None instead of overflowing.
Fixes a real-hardware NVIDIA bug in fract() from 008b634 and adds synthetic GFX10 -> DXIL -> GPU/WARP regression tests for the RDNA2 VALU lowerings from #2:

- fract(): select(OGT(r, k), k, r) is folded by NVIDIA's DXIL compiler into FMNMX (minNum), which swallows NaN and turns v_fract_f32(NaN) into 0x3f7fffff (and v_fract_f16(NaN) into 0x3bff). Comparing with pred::OGE against a distinct threshold (1.0 for f32, 1 - 2^-12 for f16) prevents the minNum fold and preserves NaN and +/-inf -> NaN on both NVIDIA hardware and WARP.
- valu_tests.rs: builds minimal synthetic GFX10 compute shaders, lowers them through the full pipeline (ir::build -> resource::track -> io::raise -> structure -> lower), validates with dxil.dll when present, and executes them via Host::dispatch on both hardware GPU and WARP without requiring console dxc. Covers v_fract_f32/f16, v_med3_f32/f16, v_sin/v_cos_f32/f16, and v_bfe_i32/u32 + s_bfe_i32.

Co-authored-by: BlueKaiman <[email protected]>
Windows 10 maps the prepared image with both entries empty. The binder already retains the original slot RVAs, so preparation need not locate a linker-provided terminator.
find_input matched each input element with
`(row and channel in the element).then_some((id, channel - e.col))`.
then_some evaluates its argument first, so the subtraction ran for every
element, also those whose first channel is past the one asked for. In a
build with overflow checks (tests, debug runs) a pixel shader reading a
channel below any element that starts at z or w panicked, whichever row
that element was in, and packed inputs such as a float2 in .zw are
common. Release builds wrapped and threw the value away.

then() computes it only when the element holds the channel.

Found with a random-input harness over pixel, vertex and mesh programs
with matching signatures. The new test panics without the fix.
When a title creates a null buffer view (resource == 0, ViewDimension == BUFFER), buffer_bytes(0) returns None, so null_for() fell through to null_like() / null_view() (or a 2D texture UAV) and emitted a 2D texture descriptor into a slot where a shader expects a buffer.

Check desc[1] == 1 (D3D12_SRV_DIMENSION_BUFFER / D3D12_UAV_DIMENSION_BUFFER) in null_for() for both View::Shader and View::Unordered so null buffer views get a matching null buffer descriptor.
Add lowering for v_xnor_b32 and v_swap_b32 (seen in GTA VI world compute shaders), and record v.dst as a read in ir.rs for v_swap_b32 / v_swaprel_b32 since both operands are read before being swapped.
write_physical mapped, committed and unmapped a view for every 64 KiB
page it wrote, and DirectStorage decoded each page-destination request
into a zeroed buffer first, then copied it. Every unmap flushes every
core's TLB, so with all the workers loading at once these writes were a
serial cost per page.

Pages are now looked up once and grouped into runs of consecutive slices
of one section (how titles allocate them), and each run is written
through one view. When a request's pages form a single run, DirectStorage
inflates or unpacks straight into that view instead of a buffer; pages of
several allocations still go through the buffer, written run by run.

Synthetic release benchmark (16 MiB destinations, Ryzen 9 5900X):
8 threads 3.5 -> 7.8 GiB/s; one thread, buffered then copied 0.96 GiB/s
vs in place 2.1 GiB/s.
With indirect execution the world's first frame asked for over 1,200
pipelines at once and took more than 30 s, so the title's own GPU
watchdog ended the run. Host pipelines are now made by worker threads: a
first use waits at most 0.5 s per title frame, and that pipeline's draws
are dropped until it is ready. The world presents frames again, and
indirect execution is the default (the switch is gone).

Pipelines are cached across runs:
- every host pipeline goes into a pipeline library saved under the cache
  folder (named by a hash of the translated code, our root signature and
  the state; a blob the device rejects starts an empty library);
- the pipelines drawn with are remembered and started during loading on
  the next run.
One cold and one warm run: the last pipeline was ready 38 s after the
world's first frame cold, 1.4 s warm; the first world frame took 3.2 s
cold, 0.37 s warm.

Also:
- Copy-backs of shader-written ranges return only the bytes the GPU
  changed; they used to overwrite what the title's CPU wrote meanwhile,
  which crashed the title.
- Indirect dispatch records are bounded (group counts were not), and the
  console's single-dispatch argument type runs as a dispatch.
- Per-shader counts of dropped draws in the diagnostics log; a switch
  that submits and times each list alone.

Not working yet: the world shows no geometry, and runs end on a GPU page
fault after at most about 55 s.
Expanding a rectangle list makes the fourth corner from the other three,
element by element. An element that reaches past the vertex stride (the
input layout allows it to overlap the next vertex) was read and written
past the vertex's bytes, which panicked at submission. Only the
components inside the vertex are computed now; the rest keep the first
vertex's bytes, as unknown formats already do.
Use the descriptor count already validated by the PE parser, so the directory size need not include the null terminator. Check the OS-assigned static TLS index on a mapped test DLL.
XMemAllocatePhysicalPages makes SEC_RESERVE sections and commits their
pages one view at a time. Under Wine each commit is a wineserver request
that scans every range committed so far, so wineserver ran at full load
while the title's threads waited on it, and loading hardly moved.

Under Wine (detected by ntdll's wine_get_version export) the sections
are now SEC_COMMIT and the per-view commit is skipped. Wine backs a
committed section with a sparse file, so untouched pages still cost
nothing. Windows keeps SEC_RESERVE, since a busy host may be unable to
commit the 6.1 GiB the title asks for in one go.

Tested: Linux (Wine 11.21), i7-12700K, RTX 4070. wineserver load drops
after the first seconds and the title gets to its loading screen,
drawing and dispatching.
The write-fault handler opens the guarded block under the guard lock,
then, if it found none, asks whether the address is writable without
it. Between the two, another thread's fault could open the block and a
copy could guard it again: the handler then saw a read-only block that
is in fact ours, declined the fault, and the title crashed on a plain
write (seen 1-3 minutes into the world under Wine, where exception
dispatch is slow enough to hit it every run).

The lock is now held across both checks, so a block that is not ours
while it is held really is not ours.
A title texture's staging refresh ran as a host step of every list that
sampled it. When several lists in one submission sampled the same
texture, it was checked again for each of them. In physical-page memory,
which cannot be write-watched, each check is a VirtualQuery walk and a
blake3 hash of the whole texture. Every list's GPU copy reads the same
staging buffer after all submission-time steps have run, so checks after
the first one in a submission did nothing unless title memory had been
written in between.

Texture refreshes are now their own step. The submission's Batch, which
already merges buffer refreshes, records the staging buffers it has
refreshed. A Copy into title memory or a Run step (work that may write
title memory) clears that record, so a texture is checked again after
any such write, as buffer refreshes are.

A synthetic benchmark (ignored test, release build, 12 lists sampling
48 textures of 4 MiB): 576 hashes in ~690 ms before, 48 in ~60 ms
after (~11x).
Both returned no carry, so SCC was missing and a branch or select on a 64-bit scalar add or subtract failed to translate. They now share the carry logic of v_add_co_ci_u32 and v_sub_co_ci_u32.
ADVANCE_XMA_READ added the title's block count to the 5-bit read block
in u32 before taking it modulo the ring size, so a count near u32::MAX
overflowed (a panic in debug builds). The count is reduced modulo the
ring first; the result is the same for every count that did not
overflow.
kernel_will_write (fread's size times count, saturated) and
title_memory_remapped added the length to the address unchecked, so a
huge fread count overflowed (a panic in debug builds). The end now
saturates at the top of the address space.
Each rANS symbol scanned all of its model's bucket starts to find the slot's
bucket, then rebuilt the symbol's frequency and start from the symbol. A
per-model table of the bucket at each 256-slot window's first slot now starts
the search, which steps over the few buckets that begin inside the window; the
symbol, frequency and remainder come straight from that bucket. The lane loop
also keeps the record offset instead of dividing by the symbols per block on
every symbol.

Synthetic streams, release, one core (median of 3 runs, 16384 blocks):
BC1 177 -> 128 ns/block, BC4 184 -> 128, BC7 591 -> 452.

Tests: the window lookup against the scan for every slot of every model
(shipped tables, uniform tables, one-slot buckets); a payload step against the
first version's arithmetic on the shipped tables; every format's lane layout
round trips at 1 to 1000 blocks; an ignored throughput benchmark.
loader: emulate clwb on Intel CPUs before Ice Lake, a write-back loop in one exception
CreateFileA, GetFileAttributesA, fopen, fopen_s and the narrow
std::_Fiopen turn the title's virtual-drive path into a host path and
then passed it to our own wide wrapper, which looked it up a second time.
When the host path starts with a letter that is itself mounted, it was
rewritten again: with the game on a host G: drive (say G:\GTA6), the
title's G:\x64\a.rpf became G:\GTA6\x64\a.rpf and then
G:\GTA6\GTA6\x64\a.rpf, so every narrow open of a title file failed.
The same happens for T: when the data folder is on a host T: drive.

They now call the host's wide function directly, as DeleteFileA,
SetCurrentDirectoryA, _open, _stat64i32 and remove already do.
Loader: preserve an empty import table for Windows 10 static TLS
Module::write dropped unread phis by sweeping every instruction until a
sweep changed nothing, allocating an operand Vec per instruction per
sweep. A chain of merges needs one sweep per merge, so the cost grew with
instructions x merges. A worklist now visits each instruction once and
reads operands through a callback; the block DFS, latch folding and the
call/phi/gep records stop allocating too. The written bytes are the same
(pinned by a test against the previous writer's output).
Loader: test the AMD-only instruction emulation on any CPU (including AMD!)
PE: checked offsets in rva_to_file_offset and layout, remove dbg_tls
PE: skip unused export slots instead of reporting them at RVA 0
Guard texture and XMA offsets against overflow
shader: a lane mask that needs its own value fails instead of overflo…
shader: look up an input channel without underflowing
Shaders: lower v_xnor_b32 and v_swap_b32
Shaders: set SCC from the carry of s_addc_u32 and s_subb_u32
shader: decode backward far jumps (signed offset literal)
shader: keep fract(NaN) as NaN on NVIDIA and add synthetic GPU VALU tests
The scalar bit tests decode and are tracked in ir.rs (they write SCC) but the lowering had no case for them, so any shader using one failed to translate with Unsupported.
GPU: emit null buffer SRV/UAV when descriptor names a buffer with null resource
test(gpu): use the SDK root parameter in the serializer fixture
GPU: keep a guarded block's write fault from being declined in a race
GPU: leave rectangle vertex components past the stride alone
GPU: check a sampled texture once per submission, not once per list
Texture: reuse contiguous column runs across rows
xmem: write DirectStorage page destinations one view per run
GPU diagnostics: skip pipelines by shader hash
shader: VICTORY_SHADER_LOOP_LIMIT to find what makes world frames slow
GPU: reject non-software WARP adapters under Proton
xmem: commit physical-page sections whole under Wine
Report Windows commit-limit failures in crashes.log
cargo test --workspace does not compile on main: host.rs declares
#[cfg(test)] mod tests twice, once near the top for the warp adapter test and
once at the end for the Batch::texture_due tests, so rustc rejects the crate
with E0428 before running anything:

    error[E0428]: the name 	ests is defined multiple times
    --> crates\victory-gpu\src\host.rs:1974:1

The second block only touches Batch, so it becomes mod batch and keeps its
two tests. cargo test -p victory-gpu --lib goes from "could not compile" to
43 passed, 0 failed, 1 ignored, and cargo test --workspace compiles again.
Nothing else changes: one line, no test bodies touched.
GPU: rename the second test module in host.rs so the tests compile
Reserve a new staging path and clean it up if writing or publishing fails. Cover a failed publication with a synthetic destination directory.
XMemMapPhysicalPages with a count of 0, and the GPU's page-mapping copy
of a zero-length range, went into unmap with an empty range. Its search
for views starting inside asked the view map for a range that runs
backwards, which BTreeMap panics on once any view exists; in an
extern "system" function that aborts the process. Without that panic
the view holding the address would have been unmapped and mapped again
as two.

unmap now returns at once for a length of 0.
An illegal or privileged instruction is reported by its address only,
which does not say which instruction it was. On an Intel host that is
the question every such report raises (clwb, clzero, rdpru, an SSE4a
form...), and reporters have had to guess or dump the bytes by hand.

The report's first line now ends with up to 15 bytes at the faulting
address, as hex, read no further than the end of that page, so the
report names the instruction by itself.
An access violation is reported with the address it touched and
nothing else, so a read of free memory, a write to memory that was
reserved but whose commit failed, a stack guard page and a write to
code or constants all look the same in a report.

The report now adds what VirtualQuery says is at that address: nothing,
reserved but never committed, a guard page, or the page's protection,
with the module for an image's pages.
When the host cannot make an unordered-access view (no host texture, a
format the host does not allow, a placed texture not mirrored), null_for()
wrote a 2D null UAV whatever the title asked for. A shader that writes a
3D texture through it then has a dimension mismatch: GPU-based validation
reports it ("UAV Dimension Expected: TEXTURE3D, UAV Dimension In
Descriptor: TEXTURE2D") for the world's wind field
(WindNew:CS_CopyWindFieldBeforeUpdateWithSmooth, compute 5bb23d336331db1d,
image_load/image_store dim:SQ_RSRC_IMG_3D). Shader views already get a
null view of the title's dimension (null_like); unordered views did not.

Null texture UAVs now keep the title's dimension: 1D, 1D and 2D arrays,
3D (WSize -1). Multisampled and unnamed dimensions stay 2D. With this,
the validation error is gone on an RTX 5070.

Tests: the dimension mapping, and a null 3D UAV made on the real device
leaves it alive.
A provider's folder is the user's folder plus the configuration id as a
file name. An empty id gave the user's folder itself, where the other
configurations' folders are. Opening the provider converts containers
of the old layout, which are folders without a `~` or a dot in their
name, as a configuration's folder is: each was taken for one, an empty
container was committed in its place and the folder was removed with
every save in it.

An empty id is now treated as no id (the default configuration).
WinHttpGetProxySettingsEx is absent from Windows 10's winhttp.dll, so the
host-presence assertion panicked there. The HLE supplies it itself; skip it
only when the host lacks it, keeping the check for every other export.

Fixes #118
XUserGetGamertag returned the name for every component, the modern
suffix included. The GDK documents the suffix as empty when there is
none, and a title that shows "name#suffix" whenever the suffix is not
empty showed "Player#Player".

The modern suffix (component 2) is now empty; the classic, modern and
unique modern components are still the name.
An unimplemented import with the default Trap policy printed its name
and aborted. abort() is a fast fail: it skips the exception handlers
and the panic hook, which are what append to crashes.log, so the most
common bring-up crash left nothing there, not even which import it was.

The trap now reports through log_crash, which prints the same line,
appends it to the crash log and adds the title's last debug output.
XTaskQueueDispatch with an infinite timeout waited until a callback was
queued. Terminating the queue refuses new callbacks and drained the
queued ones without waking anyone, so a dispatcher thread's loop
(`while (XTaskQueueDispatch(queue, port, INFINITE));`, which ends by
terminating the queue) stayed in its wait for good, and so did whoever
joined that thread. A dispatch begun after the termination did the same.

A dispatch now also ends, returning false, when its queue is
terminated: the termination wakes the port's waiters after draining it.
The flag is the queue's, so a dispatch on another queue that shares the
port waits on.
The SOPP table had s_ttracedata_imm at 0x26, as Mesa's opcode list
does; RDNA2 encodes it at 0x28 (AMD's RDNA2 ISA, LLVM's GFX10 tables
and disassembler tests). A shader with the thread-trace marker decoded
it as an unknown opcode and failed to translate, though the IR drops
the marker as harmless.
f32_to_half rounds to nearest by adding half an ulp to the mantissa,
then or-ed the shifted mantissa into the exponent field. When the
rounding carried out of the mantissa, that carry is the exponent's low
bit: or-ed into an odd exponent it was lost, so values just below a
power of two came out at the power below (2 - 2^-12 gave 1.0, not 2.0).
Rectangle lists use it for the fourth corner of half-float elements.

The carry is now added into the exponent.
The device answers QueryInterface for ID3D12Device and for its newer
levels (Grand Theft Auto VI creates it as ID3D12Device11). A device
child's GetDevice and the DXGI device's QueryInterface knew only the
first: asked for the device by the interface the title holds, they
answered E_NOINTERFACE with a null pointer.

Both now ask the device's own test (is_device).
Reading and loading a title DLL report its path when they fail;
preparing it, in between, did not. A DLL the PE parser refuses ended
the run with just "malformed image: ..." (or the like), without saying
which of the title's DLLs it was.

The prepare step now adds "preparing <path>" like its neighbours.
Typed buffer loads in the 10_11_11, 11_11_10 and 10_10_10_2 families
(GFX10 unified formats 30-49) were refused, failing the shader. Fill in
their channel layouts and decode the unsigned 11- and 10-bit floats by
shifting them into half position for legacyF16ToF32, which is exact for
denormals, infinities and NaNs. Format numbers from LLVM's UfmtGFX10,
channel order from Mesa's ac_formats.c.
A descriptor picked without a branch, as the compiler does when it
hoists both loads (invariant memory) and turns the if/else into a
select, reaches the resource instruction through s_cselect_b64 per half
(or s_cselect_b32 / s_cmov per dword). None of its dwords is then a
load, so tracking stopped with "a descriptor neither loaded nor built"
and the whole program, and every draw using it, was dropped.

Such words are now split by the SCC value they all read: what each is
when SCC is set (S0) and when it is clear (S1, or the old destination
for s_cmov), with words not selected the same on both sides, and each
side traced on its own into a new Source::Select. Selections with
different conditions stop, and a choice that mixes two descriptors
still stops as "a descriptor changed after loading". The lowering picks
the heap index of the two loaded descriptors by SCC and creates one
heap handle, as a phi of loaded descriptors already does per edge.
A descriptor held in VGPRs is used through a waterfall loop: each pass
reads the first active lane's dwords with v_readfirstlane_b32, compares
them with every lane's own (v_cmp_eq), runs the access with the lanes
that match and repeats for the rest. Tracing stopped at the readfirstlane
results ("a descriptor neither loaded nor built").

The tracer now follows the read lanes' dwords to where each lane gets its
own: global_load_dword* from a table or heap at a per-lane address (an
image descriptor's two x4 loads lined up), or a v_cndmask_b32 choice per
lane between such sources (e.g. two s_load descriptors). Other sources
fail naming them (LDS read, buffer load, phi, input, computed VGPRs).
The loop's compares of those reads with their own dwords are recorded.

Lowering gives the access each lane's heap index (its load address over
the descriptor size, or a per-lane select of indices) with
createHandleFromHeap's nonUniformIndex set, lowers the recorded
readfirstlanes as the lane's own dword and their compares as true, so
the loop runs once with all lanes. Wave32 and wave64 are tested.
RtlVirtualUnwind and RtlCaptureContext want a 16-byte aligned CONTEXT,
and windows-sys 0.61 declares the x64 CONTEXT without align(16). In a
debug build the by-value copy in unwind_into, and the test's stack
context, landed 8 bytes off (an address ending in ...838), so
unwinds_like_the_system_walk crashed the whole victory-loader test binary
with a stack-overflow message and STATUS_ACCESS_VIOLATION. Aligning only
the test's context was not enough: the copy in unwind_into, which the
crash handler and stacks.rs also unwind with, faulted as well.

unwind_into now copies its context into an Aligned16 wrapper and unwinds
that; the test captures into one.
When HostHeap::dynamic ran out, State::tables skipped the fresh table and
the stage's user data fell back to the title's table offset. Constant
buffer tables are always made fresh and never mirrored, so the shader read
whatever host descriptor sat at those slots as a constant buffer; on AMD a
texture or null descriptor read as a buffer gives a wild base address and
the device is removed (#59: faults at 0x7000037xxxxx, 0x8000037xxxxx,
0x33c4000, a different pipeline every run, about 60 s in).

bind now reports that a table could not be made, and the draw, mesh
dispatch, dispatch or indirect execution is dropped. The dynamic range grows
from 2^16 to 2^18 slots, which the world did not exhaust on an RX 9070 XT.
XPersistentLocalStorageGetPath documents E_FAIL for a pathSize smaller
than the path on Xbox devices; ERROR_INSUFFICIENT_BUFFER is the PC
result, which put_string gave us.
Frame dumps decoded DXGI format 11 (R16G16B16A16_UNORM) as half floats,
so 0x8000 came out as -0 and 0xffff as -inf, and 12-14 were not handled.
Format 89 (R10G10B10_XR_BIAS_A2_UNORM) went through the B8G8R8A8 swap.
The f16 source (with abs/neg) is clamped to [-1, 1] or [0, 1], scaled by
32767 or 65535 and rounded to nearest even once from the exact product;
NaN gives 0. The product is formed in integers from the f16's bits,
because in f32 it has up to 26 significant bits and would round first.
The pipeline state validation part left PSInfo.SampleFrequency at 0.
DXC sets it when a pixel input is interpolated per sample (modes 6 and
7, which our lowering gives to PERSP_SAMPLE and LINEAR_SAMPLE
barycentrics) or is SV_SampleIndex, and the validator compares the
whole runtime info with what it derives from the module.

The flag is now set for such pixel shaders.
exp mrtz's channel y is lowered to an SV_StencilRef output, but the
module's shader flags never had StencilRef (bit 11) and SFI0 never had
D3D_SHADER_FEATURE_STENCIL_REF (0x200). DXC sets both for a pixel
shader whose output signature has the stencil reference, and the
validator checks the flags against the module.

Both are now set when a pixel shader outputs SV_StencilRef.
They went through a 32-bit conversion, so an f16 past the i16 range
(32768 up to 65504) wrapped, and infinities and NaN were undefined. The
value is now clamped in f32 to the 16-bit range first (every f16 is exact
there) and NaN gives 0, as the hardware's conversions do.
Alt or F10 sends WM_SYSCOMMAND SC_KEYMENU, and the default handling runs
a modal menu loop on the thread that owns the window, which is the
title's. The title stops drawing and reading input until a key ends the
loop, with nothing on screen to say so, and Grand Theft Auto VI aborts
itself about half a minute later (the deliberate write to 0 at
+0x23cf683). The window procedure now drops SC_KEYMENU, next to its
SC_CLOSE handling. The mouse can still open the window menu.
XGameSaveReadBlobDataResult lists E_GS_PROVIDED_BUFFER_TOO_SMALL among
its errors, and the synchronous read already returns it; the result
passed on XAsyncGetResult's E_NOT_SUFFICIENT_BUFFER instead.
An update that fit the user's 256 MB quota but not the host disk failed
with E_GS_QUOTA_EXCEEDED, which tells the player to delete saves. The
documentation keeps the two apart: E_GS_OUT_OF_LOCAL_STORAGE is the
device out of room and can come before the quota is reached. The disk
check also no longer credits the blobs an update replaces, since the
new version is written before the old one is removed.
Compute programs read SGPRs the hardware does not initialize when two
branches make the paths look like they allow a read before a write, even
though the branch that skips the write does not reach the read. That stops
translation with 'a hardware SGPR input is not supported' and drops the
program's dispatches.

ComputeIo::initialized_sgprs() counts the user SGPRs, the enabled system
ones and the scratch wave offset. A read of a general SGPR (0..=105) at or
above that count holds whatever the previous wave left, so no program can
depend on its value: read it as zero, as unset VGPRs already are. Reserved
registers (VCC, trap temporaries, M0, EXEC) keep their current handling.
`cargo test` now and then never finishes: the seven emit::valu_tests
that run on the hardware adapter and on WARP start together on the
test threads, none of their dispatches completes, and the test binary
keeps one core busy until it is killed (the waits spin on the fence).
Any other GPU test running at that moment is stuck with them.

On an RTX 5070 with a Radeon iGPU, `valu_tests` alone in a loop on
main c0876ef: 3 of 30 runs hang. With `run_cases` behind a
process-wide lock: 0 of 60, and the seven tests take under 7 s.

The lock is poison-tolerant, so one failing test does not fail the
rest.
The resource tally in `victory translate` matched every `Source` variant
by hand, so the new `Select`, `Fetched` and `Lanes` kinds left it
non-exhaustive and `cargo check -p victory` failed. A fetched descriptor
is counted with the loaded ones; selections and per-lane choices are
never leaves.
v_max_f32, v_min_f32, their three-operand and f16 forms and the packed
v_pk_max_f16/v_pk_min_f16 were lowered to DXIL's FMax and FMin. DXIL
specifies those as a compare and select, so with a -0 and a +0 either
zero can come out, depending on the operand order and the host; RDNA2
orders -0 below +0, so max(-0, +0) is +0 and min(-0, +0) is -0 in
either order. A -0 that should have been +0 then turns, say, a
following reciprocal square root's +inf into -inf.

A new helper keeps FMax/FMin for everything but two zeros, which it
resolves by their sign bits.
A host that refuses the title's slots plus 2^18 dynamic ones (NVIDIA's
1,000,000-view cap) now gets 2^16 dynamic slots, as before, instead of
losing mirrored title slots to the larger range: at the cap, 2^18 left
737,856 title slots against 934,464, and titles were seen to index slots
up to 917,140. The cap itself is unchanged. Hosts that take the larger
heap (RX 9070 XT) keep 2^18.
A descriptor read with v_readfirstlane_b32 was traced to each lane's
own dwords wherever it was, so a first-lane read outside a loop, or one
without the v_cmp_eq that hands every lane its turn, sampled for lanes
the program skipped (reported on the PR with the back edge of the
fetched waterfall test replaced by s_nop).

Now:
- a compare counts only when it and the v_readfirstlane it reads are in
  one loop (each block reaches the other);
- every descriptor read from the first lane needs each of its dwords
  compared that way, or translation stops with "a descriptor read from
  the first lane outside a waterfall loop".

Two tests cover the missing back edge and the missing compare.
A waterfall loop whose descriptor dwords are VGPR phis stopped with "a
descriptor read from the first lane of a phi" (294 programs of the
title on #307, all at if/else joins of two s_load_dwordx4 descriptors
copied into VGPRs). An EXEC if/else leaves two phis per dword: the
flow block's joins an arm's dwords with what lanes that skipped the arm
held before (inputs, unrelated loads and arithmetic in the title), the
join after the other arm picks per path. Only lanes that never read the
descriptor bring those other values, so tracing every edge fails.

Tracing (resource::track now takes the program's per-lane form):
- per-lane phis of one block are traced on each edge into it that the
  lanes accessing the descriptor can take, from structure's lane
  conditions (new Structured::reach, the exits' conditions, and
  Bools::meet, a read-only satisfiability check); the trace starts from
  what holds in the access's block. Edges no such lane takes are None
  in the new Source::LanePhi { block, args };
- every per-lane write it follows (v_mov_b32 copies, v_cndmask_b32,
  global_load_dword*) must run in all those lanes: a guarded one fails
  with "a per-lane descriptor written where some lanes may keep the old
  one". On #307 an else arm without its s_cbranch_execz traced as the
  second descriptor for every lane;
- a loop header's phi fails with "a descriptor read from the first lane
  of a phi at a loop header", words defined after the join with "a
  descriptor partly joined by control flow"; without the per-lane form
  (structurisation failed) the join is refused.

Lowering computes each traced edge's heap index at its predecessor's end
(through lane_heap_index, so loads, per-lane loads, choices and nested
joins work), joins them with a phi (0 on untaken edges) and makes the
handle non-uniform. The waterfall compares need no change.

Tests: the if/else of two loaded image descriptors, a join of a per-lane
load and a v_cndmask choice, nested arms choosing a buffer descriptor
with lanes that skip both and do not load (pruned only by the access's
condition), a loop header phi, and an unskipped else arm. On #307's head
the three join programs fail with "...of a phi" and the unskipped arm is
traced as one descriptor for all lanes. On an RTX 5070 and WARP, each
lane reads its own arm's texture or buffer; the shaders pass dxil.dll
1.8.2502.11. Reversing the phi's inputs fails validation, flipping the
heap index fails the GPU check.
Pixel programs that write SV_DepthLessEqual or SV_DepthGreaterEqual
failed validation: "Interpolation mode for PS input position must be
linear_noperspective_centroid or linear_noperspective_sample when
outputting oDepthGE or oDepthLE". The position is now declared
linear_noperspective_centroid in those programs, as DXC declares it;
without multisampling the value is the same.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12186
validated; the error is gone from the list.
'victory config' displays game_dir, cache_dir, and test_titles, but omitted data_dir (where saves, persistent local storage, and crashes.log are stored). It also omitted data_dir from the runtime asset-policy check loop in show_config().

Include data_dir in the output and policy check, and add a unit test in victory-core asserting that a data_dir inside the repository is refused.
(cherry picked from commit 4b2ea70f0940a4317dc934000d249dce0fce50f6)
fill_phis treats a phi no one read directly as dead and fills a value
with no DXIL form (an unsupported s_memtime result, say) with zero. When
that value reaches a read through two joins, the first phi is only read
by the second, so it was never marked read: the read lowered with a
zero where the same value read directly is refused with "a scalar
memory read as data".

Mark the incoming phis of every read phi as read, transitively, before
the phis are filled. The reproducer from #604 now agrees for the direct
and the joined read, and the dead control (the timestamp replaced by a
group id) still lowers.
image_sample_o was refused by name. Its offset dword (x in bits 0-5, y
in 8-13, z in 16-21, signed) becomes sample's immediate offsets when it
is a constant within DXIL's -8..7; a computed or wider offset is still
refused, now saying so. Module::int_value reads an integer constant.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12176
validated (all four).
The previous commit proves that a loop's compares select the lanes of
the access and that its retry keeps exactly the lanes still waiting.
Every failure of that proof was reported with one reason. They now say
which part failed:

- the access is in no single-block loop ending in s_cbranch_execnz;
- the loop is nested in another or split over blocks;
- the compares do not select the access's lanes;
- the retry does not keep the lanes still waiting.

Without the per-lane form the proof cannot run. Nothing is emitted then,
and that failure is the one reported, as before.

Tests, all hand-assembled:

- the case ifBars reported on upstream PR #566 (the compares never
  narrow EXEC), an access under a further mask, a retry that keeps other
  lanes than those waiting, a wave64 retry of one half: refused, each
  with its reason;
- the waterfall LLVM writes for GFX10 and later (a v_cmpx_eq chain, the
  retry as todo & !EXEC, also folded into s_andn2_wrexec) is accepted in
  wave32 and wave64, and each lane samples its own texture on the GPU;
- one loop per operand, the sampler's inside the resource's, is refused
  by name. The console gives each lane its own pair there; following the
  outer loop's reads into the inner block is left for later.

Other per-lane work in a waterfall loop is still taken to run once for
each lane; marked as a shortcut.
describe looked only for a host texture, so every UAV over a buffer printed 'uav None' in device-removed reports and drop traces, though the view is made. It now prints the buffer's title range, as a buffer shader view does.
Queue the list-owned D3D12 staging upload as a host fill so Wine does not skip it based on the title-memory VirtualQuery check.
Its only callers (stub_pipeline_is_created, constant_color_validates)
are #[cfg(windows)], so on macOS/Linux the helper is dead code and
cargo check --all-targets warns 'function constant_color is never used'.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
rustdoc warns that the module docs link to the private const MICRO
(rustdoc::private_intra_doc_links). Plain code formatting keeps the
reference without the broken link.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
v_cmp_lg_{f32,f16} ("less or greater") is ordered and not equal: false
when either operand is a NaN, on RDNA2 hardware as in the ISA. It was
lowered to `fcmp one`, which says the same, but the AMD D3D12 driver runs
`fcmp one` as unordered and returns true for a NaN. NVIDIA and WARP get it
right. It now lowers as `olt | ogt`, which all three run alike.

New GPU test v_cmp_lg_is_false_for_nan covers both widths: NaN on either
side, both NaN, a signalling NaN, +0 against -0, inf against inf and
against -inf, and junk in the unread high halves for f16.
GetResultSize and GetResult only treated S_OK as success, so a provider finishing with S_FALSE and a payload left the caller's buffers untouched and the call registered forever. Any nonnegative HRESULT is a success code; return the size, let the provider write the result, report bytes used, and release the call. Add a regression completing with S_FALSE and an eight-byte payload.
Shader: decode the packed typed-buffer formats
fix(gpu): average copy statistics over the full reporting interval
Shaders: find the written instructions with a worklist, not repeated passes
Files: send rewritten narrow paths to the host, not to our wide wrappers
Shaders: lower s_bitcmp0/1_b32 and s_bitcmp0/1_b64
Shaders: lower v_cmp_class_f16 and v_cmpx_class_f16
net: skip newer-Windows-only exports in only_loopback_is_reachable
pipeline: remove staging files when cache publication fails
xmem: mapping or unmapping no pages changes nothing instead of aborting
Crash reports: show the bytes of an instruction the CPU refused
Crash reports: say what an access violation's address holds
GPU: give null texture UAVs the title's view dimension
Game saves: an empty configuration id no longer deletes the other configurations' saves
XUser: a gamertag without a suffix has an empty modern suffix
XTaskQueue: terminating a queue ends a dispatch waiting on it
Loader: a trapped unimplemented import goes into the crash log
GPU: GetDevice and the DXGI device hand out the device at every level
GPU: a half-float rounding carry raises the exponent instead of halving the value
Shaders: s_ttracedata_imm is SOPP opcode 0x28, not 0x26
Loader: a title DLL that fails to prepare is named in the error
loader: unwind a 16-byte aligned copy of the context
GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots
Config: ignore an empty VICTORY_TEST_TITLES
Chore: clear two workspace Clippy errors
GPU diagnostics: order tied drop counts consistently
GPU: replay pending descriptors before publishing the host heap
main moved under #307 and this branch. One conflict, in the test module of
emit/lower.rs: the imports take both sides' names (#117's `half_shift`
beside `Lowered`), and #117's `scalar_bit_tests_lower` sits after this
branch's waterfall tests. No code outside the test module was touched by
hand. A merge rather than a rebase so #307's commits keep their ids.
Storage: a path buffer too small fails with E_FAIL, as on Xbox
Capture: R16G16B16A16_UNORM targets are integers, format 89 is 10:10:10:2
Shaders: lower v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16
Shaders: PSV0 says a pixel shader runs per sample when an input does
Shaders: a pixel shader writing SV_StencilRef declares StencilRef
Shaders: v_cvt_u16_f16 and v_cvt_i16_f16 saturate at 16 bits
GPU: write half subnormals from f32 rectangle outputs
Window: keep Alt and F10 from freezing the title in menu mode
Shaders: lower dynamic v_perm_b32 without requiring INT64
XGameSave: the documented errors for a full disk and a small read buffer
Shaders: reads of uninitialized SGPRs read as zero, as VGPRs do
Shader tests: run the VALU GPU tests one at a time (cargo test hangs now and then)
Shaders: maximums and minimums order -0 below +0, as RDNA2 does
HLE: return XAsync payloads for nonnegative results
Shaders: centroid position with conservative depth
core: show data_dir in config and check its asset policy
Shaders: a phi that only another read phi consumes is live too (#604)
Shaders: image_sample_o with constant offsets
Shaders: decode GFX10 packed inline constants by operand type
GPU diagnostics: describe a buffer UAV by its range, not as uav None
Loader tests: build the probe fixture under CARGO_TARGET_TMPDIR
GPU: upload CPU-written textures before full and region copies
Docs: rustdoc builds the loader, GPU and shader crates without warnings
GPU: use the host upload path for texture staging copies
GPU: unbind vertex buffer slots for null view arrays
Shaders: gate the constant_color test helper to Windows
Docs: drop the private intra-doc link to MICRO in texture.rs
Shaders: v_cmp_lg is ordered on AMD hosts too (olt | ogt, not fcmp one)
Audio, watch: no overflow on huge title sizes (XMA read advance, fread)
BCPack: find a slot's bucket from a window table
A Windows job on the pinned toolchain: clippy with -D warnings on the
default and the --all-features (diagnostics) build, then cargo test
--workspace, which includes the asset-policy test.

main did not build its tests: scalar_bit_tests_lower called lowers()
without the rsrc2 argument a parallel change added (0, no input
registers). Also drops a double parenthesis clippy flagged in an xasync
test.
main now has CI (clippy with -D warnings, then the workspace's tests) and
three new tests that call `resource::track`, which this branch gives a
fourth argument. No textual conflict, but the test target did not build:
those three calls (emit/lower.rs, twice in emit/mod.rs) now structure the
program first and pass it, as this branch's other callers do. Both of
CI's clippy commands are clean on the result.
The four tests of emit/waterfall_tests.rs each dispatch on the hardware
adapter and on WARP. Run in parallel, the test process sometimes died of
an access violation (7 of 24 runs of these four tests on an integration
branch; an image test beside a VALU test does the same on WARP). They now
take the VALU tests' lock, which moves out of `run_cases` to be shared.
With it: 340 workspace tests pass with VICTORY_WARP=1, as on a CI runner,
and the shader tests pass on the RTX 5070.
Shaders: per-lane descriptors chosen by control flow (stacked on #307)
The console compiler loops over a per-lane descriptor by reading the
first active lane's table offset (v_readfirstlane_b32), narrowing EXEC
to the lanes with the same one (v_cmpx_eq_u32), loading that entry
(s_load_dwordx8) and dropping those lanes (s_andn2_wrexec). Such a load
now goes through the waterfall proof; when it holds, each lane loads its
own entry through a non-uniform handle. Unproven, the offset stays the
first lane's, as before.

Translation census over the title's 26,096 programs: none lost, 108 get
past these loops to a later refusal. The 249 programs behind #736 also
need per-lane size queries in loops without an access.
World rendering, lighting, frame-rate and memory work for Grand Theft Auto VI
(Xbox Series X profile) on one Windows PC with an NVIDIA RTX 4070. The README
describes the state, the changes and the credits. Based on VIctory by Marvisak
and contributors (GPL-3.0-or-later); XCL by ivall and contributors was used as
a reference. No game files are included.
- 59 of the 64 trace programs and the irradiance-cache shading program
  translate; 51 programs leave the approximate wave64 forms.
- The workspace passes the lint with warnings as errors in both feature sets;
  a few style lints are let through in Cargo.toml for this fork.
- README status updated (relay and in-place memory results);
  docs/fork-ray-tracing.md describes what the title does and what is built.
Co-authored-by: ZazaJr24 <[email protected]>
- Shader tests: a software adapter given as the default device is not taken
  for a hardware device, so the tests that need a real card skip there.
- Diagnostics: the stencil plane of dumped depth-stencil targets and the
  title's descriptions of its stencil views.
- README: the newest commits lose the GPU device shortly after start on the
  test machine; the cause is not found yet.
The update moved the particle light-atlas compute programs to a form that
puts group barriers inside branches and loops; a dispatch of them stood on
the card until the device was reset. That form is now off unless
VICTORY_WAVE_WIDE=1, and the shader cache key includes the wave switches.
Checked with a plain run of this tree on the test machine.
Hosted runners list a display stub first, so the default device there is the
software adapter; the tests that need a real card now skip it.
- Clean-up passes over each translated module (VICTORY_SHADER_OPT bits: dead
  code, folding, reuse, branch facts, loads within a block, wave64 first-lane
  exchange), part of the shader cache key. About 43 % fewer host instructions
  over the pack; about 20 ms less GPU time per frame on the test machine.
- translate: a census of the emitted code.
- Checked with plain game runs of this tree on the test machine.
The console compiler parks a wave64 lane mask in two lanes of a spare VGPR
and may restore the halves with other instructions between the two
v_readlane_b32. The pair restore now looks ahead in the block (nothing between
may touch the second register, write the first, or save into the lanes), so
the mask comes back as a mask. This lets indirect_light_probes
CS_IrradianceCache_Shade / ShadeSecondary translate: they were dropped every
frame, leaving the irradiance cache unlit and everything in shadow black.

An M0-relative read (v_movrels_b32) names every VGPR from its base up, which
marked the parking VGPR as an ordinary one and turned unspilling off for the
whole program. Relative reads no longer count there (relative writes still
do). billboard_nobump CS_RaytracingResolve_a56bfb9c translates with it.

translate: VICTORY_TRANSLATE_ONLY=<hash prefixes> limits a run to those
containers; VICTORY_HOST_MAX_WAVE=32 translates as on a 32-lane host, so
--pipelines matches what the runtime creates on NVIDIA.
Comments, documents and descriptions now say "the title". No code changes.
(cherry picked from commit 342245e152)
(cherry picked from commit b17b69fd9e)
(cherry picked from commit 61e5f79ac6)
(cherry picked from commit 4d3aaab711)
(cherry picked from commit cb80bf0f9c)
Fixes two gaps in lane_uniform that prevented wave-uniform VGPRs (such as the BVH builder's prefix-sum loop in #16) from lowering v_readfirstlane_b32 on 32-lane hosts without a cross-half exchange:

- Handle unguarded non-d16 ds_read* instructions when their address VGPR is already wave-uniform.
- Bound Operand::Vector reads to reg..reg + dwords instead of x >= reg, so the old value of a higher-numbered destination register (kept in inst.reads for EXEC guards) no longer poisons uniformity; also check all dwords of Operand::Scalar.

Part of #16.

(cherry picked from commit d964ec7a14ec01089526cdd84c1c06b21c18c262)
(cherry picked from commit 15cc76c39f)
(cherry picked from commit 81a8e2e313)
The console ignores blending on integer render targets and the title
leaves it on (the world has a mesh pipeline blending into an R8_UINT
target). D3D12 does not allow it: vkd3d-proton refuses such a pipeline
with E_INVALIDARG and its draws are lost. The host pipeline now turns
blending off on integer targets; with one description for all targets,
each target gets its own copy so the others keep theirs.

(cherry picked from commit eb5061cca6)
PSV0 shared one string-table entry between elements with the same
semantic name. DXC writes one entry per named arbitrary element, in
element order and repeats included. Validators before 1.8 compare the
part byte for byte and refused ours ("Container part 'Pipeline State
Validation' does not match expected for module"); 1.8 compares by
content and took either, which is why the newest SDK never showed it.
This is not specific to mesh shaders: vertex and geometry shaders with
repeated names failed the same way (the rect tests under 1.7).

Fixes #12.

(cherry picked from commit 8bac552616ddd89b9215cfff0b79e2538464668f)
(cherry picked from commit 7545c97978d66c1d04e5ffbeb820ac115a666593)
(cherry picked from commit 8a761ec135d1cd6c53ecfcae672103538fce2295)
(cherry picked from commit fafecfb95eef77ac1a6bd6aa2eb84c072d37b8bd)
(cherry picked from commit c18faa4e44676f8ae7fbb198063f20d10de17925)
(cherry picked from commit 7797679e90dce076552d616976412e02c8b7ee3c)
`dxil.dll` rejects containers with
"Container part 'Program Input/Output Signature' does not match expected
for module" when `ISG1`/`OSG1` diverges from what DXIL reconstructs from
the module metadata.

Fix three mismatches in `container::signature`:
- Sort signature rows by register only (preserving element order within
  the same register instead of sorting by `(row, col)`).
- Emit DXIL's canonical system-value semantic names when `kind != 0`
  (e.g. `SV_Position`, `SV_Target`, `SV_IsFrontFace`) instead of raw
  input casing (e.g. `SV_POSITION`, `SV_TARGET`).
- Do not shift `mask` or `usage` by `col` for unallocated elements
  (`row == None`), matching `StartCol = -1` in the module metadata.

Related to #53.

(cherry picked from commit 3ed5e8918d32c091d36edda94f825ba8f6e30a83)
(cherry picked from commit 442d7c25ab1849a5e25fbf19313ead3c172cddae)
The title writes a request's page list after enqueueing it, and a queue
half full is submitted on its own, so a read can start before the list is
filled. It then names page 0 (no page: numbers start at 0x10_0000) and the
request fails, leaving its model or texture unwritten. The list is now read
again for up to 8 ms; late and still-zero lists are counted.

(cherry picked from commit 7e22f187dd7ec6f632a07857b1fe3718ec350638)
(cherry picked from commit 2765f3d2145c2c5972b69c23443d52d52ecd5afc)
With VICTORY_RELAY_SNAPSHOT=1 (relay only, off by default) the compare that
runs after a flight's lists also copies each 64 KiB piece it finds
differing into a ring in PC memory (CARD_SLOT_BYTES per slot, the count of
slots taken in dword 0), and its result dword becomes 2 + the slot. The
thread that lands the flight merges from the ring with the sends that
flight saw (its plan's sent_as), with no fetch list of its own and no wait
behind the submissions queued since: in the prison-bus scene that wait was
75 ms of the relay's 111 ms a frame and kept 128 lists in the air, the
submitting thread waiting ~85 ms a frame.

A piece the ring had no slot for, or a range not compared, makes the whole
landing fetch as before. A fetch runs behind every submission queued so
far and may bring a later flight's bytes, so the pieces it merged are
noted (MERGED_UPTO) and a ring copy from a flight that ran wholly before it
is left out instead of taking title memory back. Send notes are dropped
only up to the sends the landed flights saw. The ring starts again with the
compare results, when no plan is out; it is drained early when half used.

Tests: the WARP compare test covers the ring (slots, overflow to 1, skewed
copies, a later change not reaching a written slot); a relay test covers
the change from fetching to the ring. Both fail when the behaviour they
check is broken on purpose.
On GFX10/RDNA2, v_writelane_b32 writes its target lane whenever any lane of the console wave is in EXEC, ignoring the target lane's own EXEC bit. Previously, lower.rs wrote the result through int(self, r) -> write_placed(..., guard), which re-masked the write by the target lane's own EXEC bit and dropped the write whenever the target lane was outside EXEC.

Check whether any lane of the console wave is in EXEC via dx.op.waveAnyTrue (and exchange_halves across the two 32-lane host waves when splitting a wave64 shader, refusing if not every lane reaches the block so emit() retries without_skips), combine that with `console_lane == lane`, and write via write_placed(..., None).

Add a wave64 regression test in wave64_tests.rs covering both 32-lane and 64-lane DXIL validation and GPU execution when SM 6.6 hardware is present.

(cherry picked from commit 481569b04f98de68199a3904127bca2e3de58de2)
(cherry picked from commit 6f907589de748aa26eae6488a0454306b0dce436)
(cherry picked from commit 46ea6e5a70637c5031c2199d903be368e8f6310b)
The pixel shaders 7d0f14ce44746d7e and 6b6db9f1a526daeb of the world run read
an image descriptor's size bits with no instruction that samples it, so no use
named its kind and the program was refused. Eight dwords are taken for an image
descriptor (2D) and its size comes from getDimensions. The waterfall test runs
the console loop that ends in v_alignbit_b32 of dwords 1 and 2.

(cherry picked from commit 6236d5785a9751395bb8df737cc89083ab9e2468)
(cherry picked from commit 13733af2820284118ee1d95ae4f2ed6df4f26025)
(cherry picked from commit 25e40e259c2e11e51eed382d7d1656486f3eb497)
A v_fma_mixlo_f16 into the VGPR of an f16 interpolation's first half
(v_interp_p1ll_f16, whose second half writes another VGPR) read the old
value with i32_of(..)?. That value is the first half's Val::Missing, so
the failure reached the colour export and refused the whole program,
reported as "the first half of an interpolation". Nothing reads the kept
high half. write_half and low_half already keep zero for an old value
without one; the v_fma_mix* arm now does the same.

8 of the title's deferred material pixel programs translate and validate
now (14,156 -> 14,164 vertex and pixel programs emitted); no other
program changes.

(cherry picked from commit a6388aa6004e26be7c915168f93922aca44ee7ef)
A 1-thread compute group has no peers sharing LDS without barriers, so
declaring WaveSize(32) for `group == 1` is unnecessary and causes
CreateComputePipelineState to fail with E_INVALIDARG on 64-lane-only AMD GCN
GPUs (e.g. Vega 8 / gfx90c) and on WARP.

Restrict `one_wave` in `crates/victory-shader/src/emit/lower.rs` to
`group > 1 && group <= wave`, add a unit test pinning `threads = [1, 1, 1]`
vs `[2, 1, 1]`, and run `ds_min_max_f32_order_floats_and_return_the_old_value`
on both hardware and WARP.


(cherry picked from commit 39350cae1958ee568e8970a9c535f6193a00c671)
(cherry picked from commit 7ed853ae33d6fef69d22e533fe1be0ada81ce354)
`victory-gpu` backs structured buffer views with raw views (`raw_window`),
and `lower::buffer()` already lowers indexed structured buffer accesses
to `ByteAddressBuffer` (`(11 | u, 0)`) handles.

However, descriptor-size lowering (`getDimensions`) still annotated
`idxen` buffers with `stride >= 4` as `StructuredBuffer` (`(12 | u, stride)`),
skipping the `bytes / stride` division below it. Against a raw host view
this returns the raw byte count instead of the element count (e.g. 128
instead of 8 for a 16-byte-stride buffer).

Use a raw handle (`(11 | u, 0)`) for untyped buffers in `getDimensions`
so the existing `UDiv` by `used.stride` produces the element count.

(cherry picked from commit 79b5a82077b2a6e3715bdd5bbafb917e7644e606)
With VICTORY_RELAY_SNAPSHOT=1 a landing that falls back to a fetch merges
each flagged piece cut to its own plan's span, but MERGED_UPTO noted the
whole 64 KiB piece. A later flight that wrote another range of the same
piece then had its ring copy left out as older, and its shader writes
never reached title memory (its compare had stored the new hash already).
Found by three independent reviewers and confirmed by every verifier.

The note now keeps the byte ranges each fetch merged with the queue order
it ran behind. A ring copy is left out only where fetches that ran after
its flight cover all of its range; where they cover part of it the landing
fetches, which brings the newest bytes of all of it; elsewhere it merges.

The relay test covers two flights writing different ranges of one piece
and a range covered in part, and fails with the old whole-piece note.
Keep DepthBoundsTestEnable from pipeline-stream subobject 21 (DEPTH_STENCIL1), check D3D12_FEATURE_D3D12_OPTIONS2 on the host device, build depth-bounds graphics and mesh PSOs as pipeline-state streams with DEPTH_STENCIL1 (cached in ID3D12PipelineLibrary1 under a distinct state key), and forward command-list depth bounds to ID3D12GraphicsCommandList1::OMSetDepthBounds across list cuts.

(cherry picked from commit 461df561cfc3bf2fa0ebc9fd6cbdafaff1a7e629)
Give placed unordered texture views (2D, array and 3D) a host unordered-access texture at their placed address (reusing an existing compatible target at that address when present), mirror them immediately when written into shader-visible heaps, and keep TARGETS_AT intact when placed shader views carry target flags so cross-format placed SRVs alias the shader-written texels on the GPU.

(cherry picked from commit d5c277ea2ff0c938cd67e1d1e82419202431af20)
The guard protected one view of a texture's physical pages and heard only of faults there, so a write through another view of the same pages, or the runtime's own write into them (write_physical, DirectStorage page destinations), went unseen and the texture kept stale contents until its eighth-frame hash. The guard now protects every view of its pages, and the runtime reports its own writes.

(cherry picked from commit 2ef19e0f8f1e92cbeb6b2d3e7c6d40917cae42dc)
(cherry picked from commit 1ac9b306702e8d333b995ace46909aed513a3216)
(cherry picked from commit e232f2a10abde62d829695824149ad76fa0b8982)
Two gaps kept the ray-tracing programs off on a host whose waves are 32 lanes.

1. Buffer views picked from the view heap at a computed index. The shadow-ray
   trace programs read the address of their structure out of a heap descriptor
   they choose with a per-wave index, and walk the memory behind it. The
   translator could only take such an address from a fixed table position.
   The host now keeps, after the strides of `SLOT_STRIDES`, two more dwords
   per heap slot (low and high of the title address of the buffer view
   there), written where the strides are written, and the shader reads them
   by heap slot (`SLOT_ADDRESSES`). No new root parameter; the table grows
   from 8 MB to 24 MB per view heap.

2. `lane_uniform` proves three more things where no lane of a wave can part
   from the others: `tid >> 6` of the entry thread number (in a group whose x
   size is a multiple of 64) is the same in all lanes of a console wave; an
   `ds_read_b32` at such an address is; and a value joined by a phi, also at
   a loop header, is when its arguments are and every predecessor is entered
   by all the arriving lanes or none (a greatest fixed point over the loop's
   carried values and lane masks). The structure builder's block-scan
   programs fetch a wave-uniform running total with `v_readfirstlane` in
   such a loop; without the proof they asked for an exchange between the two
   host waves where not every lane runs.

Effect, with `VICTORY_HOST_WAVE=32` on a 32-lane card:
- 4 of the 5 shadow-ray trace programs (and their screen-space variants) now
  translate and validate; the adaptive one still stops at a lane mask read
  as data.
- 52 of the 52 structure-builder programs now translate, validate and
  create a host pipeline (3 did not).
Each title-written texture shares a single mapped UPLOAD heap staging buffer (Staging::buffer). Under VICTORY_LATE_WAIT / VICTORY_RELAY, Host::submit only checked whether an earlier flight's shaders wrote the texture's title memory, not whether an earlier unfinished flight was still executing CopyTextureRegion from Staging::buffer on the GPU. When a subsequent flight refreshed the same dynamic texture (e.g. subtitles or glyph atlases), Staging::detile overwrote the mapped upload buffer on the CPU while the GPU was still reading it.

Track the highest late-submission number per Staging (in_flight) and wait via relay_wait / settle before preparing a late submission that refreshes an in-flight staging buffer. Add a unit test in host::late_tests.

(cherry picked from commit f909bf0bd408bd42d246555cd6c7ae17ae223578)
Its programs translate and run, but on the test machine the lighting gain
could not be shown, it costs about 40 ms of GPU time per frame, and the
picture is being re-checked one change at a time from a known-good tree.
It may come back once that is settled.
The previous commit took it out; that was not wanted. The tree is again as
it was before that commit.
The modes of interpolated elements came from DXC's defaults by type
(float: linear, uint: constant), but the console's compiler may pack a
float and a uint element into one signature row, declaring both constant
in its PSV0. Mixed modes in one row are rejected by the validator
("interpolation mode that differs from another element packed into the
same row"). The modes are now read from the console container's PSV0,
keyed by row and column, falling back to the defaults without one.

Ported from Marvisak/VIctory#1208 (its interpolation-mode part and its
test), adapted to this fork's Psv (`geometry`).

(cherry picked from commit b4ee908ee8797a1e166e18168d8253c0f4d92af5)
(cherry picked from commit 08e3d3011653a057cea3691d52be7777fc0d7a74)
Backport the floating-point lowering and regression from Marvisak/VIctory#1326 by fuzeofficial (75d919f32d).

(cherry picked from commit 08cb7edec222e47ecf7ab2ab291bc453abd45eb0)
On top of #154: a PAGE_GUARD page met by the in-process copy raised
STATUS_GUARD_PAGE_VIOLATION, which the handler passed on, and the process
ended (the test process died with 0x80000001 without this). The kernel
copy it replaces reported such a page as unreadable; the handler now does
the same for it as for an access violation or an in-page error.

The test covers a missing source page (what lay before it is copied, the
thread goes on and later copies work), a read-only destination no guard
of ours knows (left as it was), a guard page as the source, and eight
threads faulting at once.
GetProcAddress on one of our pseudo modules returned NULL for a name it
does not export, or for any ordinal, without setting the last error. The
host sets ERROR_PROC_NOT_FOUND (127), and a caller that builds its
failure from GetLastError() got 0, HRESULT_FROM_WIN32(0) being S_OK.

Test: a missing name on kernel32 (the host's, for comparison), and a
missing name and an ordinal on xgameruntime.dll, each after clearing
the last error.

(cherry picked from commit d0662f4952)
(cherry picked from commit c44dbeaabf807027650fb07667dc8a4ee6cdca13)
map_dll lowercased the DLL's name and joined that to the title folder.
On a case-sensitive folder (WSL creates them so, and new subfolders
inherit the flag) GameLib.dll is not gamelib.dll: is_file() was false
and the DLL was skipped without an error, so its imports went to stubs
and a title's own LoadLibrary saw "not a title image".

The lowercased name stays the key (seen, wanted, the returned list).
The file is the name as written or, failing that, the folder's entry
that matches it ignoring ASCII case, as the Windows loader ignores case.

Test: a case-sensitive temp folder (fsutil setCaseSensitiveInfo, no
admin) holding Late.dll, loaded as Late.dll, LATE.DLL and late.dll.
Skipped where Windows cannot make such a folder.

(cherry picked from commit 1e24f34d13)
(cherry picked from commit 7ca232720ae14f353595322279b5bb4247c27b32)
The case-ignoring fallback took the folder's first entry that matched the
name and only then checked it was a file. A folder listed before the file
(NTFS lists LATE.DLL before late.dll) made the DLL not found. It now
takes the first matching entry that is a file.

Found by MichaelSmithAI in Wine on ext4; the same happens on a
case-sensitive NTFS folder.

(cherry picked from commit 22c3d0034f)
(cherry picked from commit 96555176b9430cf226f21900783a4c30985d8bbd)
#141 marked every texture a submission samples as in flight with it, and
made each later submission that samples one of them wait for that flight
before preparing, changed or not: most textures are sampled every frame,
so late/relay submissions waited for each other (confirmed by review).

Now only a list that records a copy from a staging buffer notes it
(staging_copies, from texture::upload's copy path), and only those are
marked in flight at submission. With the relay exact the wait moves to
Staging::detile, which runs only when the texture's memory changed: the
last flight that copies from the buffer lands first (host::staging_wait,
a relay_wait, safe under the submission lock). Without the relay exact
the settle before preparing stays, now for staging buffers a flight
actually copies from.

Test: the first list that uses a texture records the copy and notes its
staging buffer; a later list that only samples the unchanged texture notes
nothing but keeps its check at submission. It fails without the note.

(cherry picked from commit 3907f191ce587aebd86a312c1909e720bfce544f)
ShallowWaterSim:CS_MinTimestepReduce (ceb5eb68cd99cb07) loads table entry
0 and only tests dword 2, the record count, against zero (s_cmp_eq_u32
s2, 0 then a branch to s_endpgm). descriptor_data's branch for a buffer
view whose address alone is taken filled dwords 0 and 1 and left dword 2
missing, so the first read of it stopped the program ("a descriptor's
address or format read as data") and its dispatches were dropped, 6.7 a
frame on average while the water simulation runs.

The table-entry lookup is split out of view_address (buffer_view); in that
branch dword 2 now comes from getDimensions on a raw handle, divided by
the entry's stride when it is over one (as 175c71e does), and the address
is taken only when dword 0 or 1 is read.

Test: a wave32 program that loads entry 0, tests dword 2 against 0 and
stores it, on the card and on WARP, expects 24 for a buffer of 24
four-byte elements; it fails without the fix with the game log's error.
The victory-shader suite passes (243).

(cherry picked from commit c9e59ab9eb8aeed59d1cbeab2c3a6a4f9acd3fe4)
(cherry picked from commit 07616f6c0c70d80109149e805f43eb6e2ebbb141)
(cherry picked from commit 4cc0429f9029b8b348de7c258f9a87297c1d4538)
(cherry picked from commit 71130238c9428fc5ee7eb8c1d00539d82d893aab)
(cherry picked from commit 07259b30cb61b0fd04b2499f22488a840c354eb4)
(cherry picked from commit 5873ea7aac2c5df31db59645918753a2b499abc4)
A shader that reads title memory by address declared every numbered copy written whenever it could store anywhere, through views included. The ray-tracing passes read the structures by address and write their bins and hits through views, so every list holding one snapshotted, compared and copied back all copies of the structures, and a quarantined builder's output still reached title memory through the next such pass.

Translated now keeps stores_by_address (flat or global store or atomic, scalar store or atomic, or code not all known) beside stores, and bind gives the copies of title memory back only after it. A quarantined builder stage gives nothing back, by view or by address, even with VICTORY_WRITE_SKIP=0.

The builder's indirect executions follow its all-or-none rule too: one that does not run (refused by execute_indirect, or a signature the host does not route) turns the builder off, as a dispatch that cannot be bound already did. builder_off says nothing when the builder was never allowed.

Tests: only_global_stores_and_atomics_store_by_address, view_stores_leave_title_memory_by_address_alone (both fail with the fix undone); victory-gpu 128 passed.

(cherry picked from commit 8c75e01e2b94ab9fb16287bcd28aa516bf777cb2)
In the c09fae3 run the bus scene settled flights about twice a frame for "title memory changed under shader writes", 73-77 ms of waiting for the card per frame, while 20-80 thousand changed runs a frame were put in. merge_under_writes has four ways to leave a settle due (a copy not write-watched, title writes not known, more changed runs than copies in the card's memory take, a copy without its snapshot) and none was counted. The frame line of title bytes put in now says how often each one was taken, and how many runs the page past the limit had.

(cherry picked from commit 18d789cd7669bde733314f04dee39420ab0a8595)
(cherry picked from commit 5c7e9c990d59537bc06b7007ce180b7a17e83071)
Every indirect execution was followed by a move of the list's clamped
arguments back to the common state, and the next clamp moved them from
common to unordered access. Drivers may treat a barrier into or out of
the common state as a full wait, so even the window path
(VICTORY_INDIRECT_WINDOW=1), whose draws skip the clamp, still recorded
one barrier between every two draws.

The list now remembers that its scratch buffer was left readable as
indirect arguments: executions read it with no barrier of their own, the
next clamp moves it straight back to unordered access, and it returns to
common once, when the list closes or a bigger buffer replaces it. The
waits for earlier shader writes around the clamp are unchanged.

Tests: two windows of executions with no barrier between them, on WARP
and through a host list; the tracked state across clamps, growth and
reset; the existing clamp tests follow the new states. With
VICTORY_D3D12_DEBUG=1 in a diagnostics build, the host-list tests also
check that the debug layer reports nothing.

(cherry picked from commit cc11cccc57)
A frame's worth (3,200) of one-record indirect draws of our own, clamped
one at a time and in windows of 32, recorded with the old barriers (back
to the common state after every execution) and the new ones, timed with
GPU timestamps around the list. Ignored by default; any machine with a
GPU runs it in seconds, no title files needed:

cargo test -p victory-gpu --release --lib indirect::bench -- --ignored --nocapture

(cherry picked from commit a4a745ed3c)
The clamp charged the list's budget record by record: an atomic read and
a compare-and-swap loop per record on one word, every thread of a window
racing for it, so a group of n records took n rounds and about n*n/2
atomics. The word is CPU-visible memory (zeroed on the CPU at
submission), so on a card of its own each of them crosses the bus. On an
RTX 5070 Ti the benchmark's windows of 32 took 46-50 ms for 3,200 draws
where draws clamped one at a time took 19 ms (#220).

Now the records' costs go to group-shared memory, one thread charges
their sum with one compare-and-swap (retried only if another group got
there first), simulating the same saturation record by record in lane
order, and every thread reads whether its record fitted. The mesh
diagnostics (largest group count asked, groups asked in all) are summed
in the group and added once. What a record costs and when it runs empty
are unchanged; which records of a group fit is now their lane order
instead of the order the GPU served the race.

Test: a group with 300 left of the budget keeps its first draw (100),
empties the second (250, which takes the rest) and the ones after it.

(cherry picked from commit 3db5a0e87f)
- The clamp's charge per group walks the group's own records (one, for a
  record clamped alone) instead of all 64 slots.
- The host-list tests read the debug layer's messages after closing the
  list and before the submission, which moves them to the log (review).
- The benchmark lives in its own file and records five cases: what main
  records, one record at a time and in windows of 32; what this tree
  records, both ways; and windows with the new barriers but main's clamp,
  to tell the two changes apart. main's clamp is kept in the benchmark to
  measure against.

(cherry picked from commit 23daba3650)
Use fixed-size comparisons to skip equal bytes and retain byte-level bounds for the merge. Cover unaligned ranges, partial chunks and both directions against the byte-wise search.

(cherry picked from commit 413bab7e81d8d3c12ad7fa1fe6e4aa7213070bc7)
DXIL's CalculateLOD takes three coordinates and the validator wants those
past the image's spatial dimensions undef: the layer of a 2D array image is
not one. Three pixel programs that read barycentrics directly
(PS_DeferredTextured_AlphaClip and two others) stopped validation with
'out of bound coord must be undef'.

(cherry picked from commit 6e248e45342a3b7d1556298c6a72ab9881128b1d)
(cherry picked from commit 33786e4814027e32d2c06b9b75eef2962856623c)
Static sampler deduplication previously matched only on the four sampler
words, so a constant sampler used by both an ordinary sample and a
comparison sample shared one slot whose metadata was promoted to a
comparison sampler. DXIL validation requires the sampler kind to match
the operation.

Include the comparison flag in static sampler deduplication so ordinary
and comparison uses get separate static sampler slots, and guard against
shifting past the 64-bit cmp_samplers mask.

(cherry picked from commit 2913656394cc5953308807ebfac64924c65f6def)
In the corridor of run c09fae3 a submission settled once a frame for title memory read by a fill of upload memory, 33-41 ms of waiting for the card a frame. Three things fill: a root constant view not on 256 bytes (filled 64 KiB long, a root view having no size), a table's constant view not on 256 bytes or outside copies, and a texture copy from a buffer. The fill that waits is now said with its title range, the range flights may write that it meets and where in the fill that range starts: for the first 32 places, at each one's 1st, 2nd, 4th... time.

(cherry picked from commit 6dcdbf0bfd0185d3a9bd06ff76b31b8fd135203d)
Resolved in crates/victory-shader/src/emit/lower.rs:

- lane_uniform: the PR's greatest fixed point (loop-carried phis and lane masks, tid >> 6 of the entry thread number in groups of whole console waves, guards the lanes agree on), with what the tree added after the PR's base: an operand's VGPRs only up to its own dwords (not the old value of a higher destination register), every dword of a scalar operand, and LDS reads of every ds_read form but _d16 (not only ds_read_b32).
- descriptor_data: a table's buffer view keeps its address and its record count (dword 2 from getDimensions, c9e59ab / 013443b); a buffer view picked from the view heap at a computed index gets its address from the host's table by heap slot (SLOT_ADDRESSES); an image only measured is as before.

Offline on the RTX 4090 with VICTORY_HOST_WAVE=32 the structure builder gives 52 of 52 programs emitted, validated and made into pipelines both with and without the PR: the tree's d07eabc had already brought the three the PR counts. Tests: victory-shader 245 passed, victory-gpu 130 passed (single-threaded); release builds without warnings.
Two concurrent waits for the same frame event kind could pick the same
tick before either advanced LAST, and both returned S_OK after
calling etch_max(tick) without checking its previous value.

Check the previous value returned by etch_max(tick, AcqRel) to ensure
only one waiter claims a given tick; if another waiter already claimed
it, recompute the next tick and retry against the caller's original
deadline so retries never extend the timeout.

(cherry picked from commit 3e9cbe1c86d493fd07a350dcc8295c3250b89782)
Address review feedback on #281:
- Widen `concurrent_flip_retry_does_not_extend_timeout` to a 200 ms interval
  and 285 ms timeout, starting the interval after both threads align at the
  first barrier so thread-spawn scheduling cannot consume the first tick window.
- Use `_tick` directly instead of `let _ = tick;`.

(cherry picked from commit e92e5869bf869f06107655c490d8472ad8b0e162)
(cherry picked from commit 6c835cd4a51ea6f7bcec7b63fda3a760ed4aef0e)
title_memory_remapped dropped the blocks of the range from the guard's tables but left their protection as it was. The runtime tells of a mapping after making it (xmem map: map, commit, then tell), and a refresh on another thread (texture and shadow refreshes guard without the mapping lock) can guard the new view in that gap. The view then stayed read-only with no guard listing it, and the title's next write there was a fault the vectored handler gave up: an access violation that ends the process. The same happened in the watch unit tests whenever a test told the guard after freeing its memory and another test had already mapped and guarded a view at that address (forced interleavings exit with 0xc0000005).

Forgotten blocks are now made read-write again, one VirtualProtect per run of consecutive blocks, block by block where a run spans views; memory that is no longer mapped is left alone.
Three watch tests (kernel reads, a range beginning in an unmapped block, unmapped blocks reported once) unmapped and freed their views first and called title_memory_remapped after. In that gap another test running in parallel could map a view at the freed address: its first guard then found the old test's blocks listed clean (and returned nothing written without guarding), or the late telling forgot the new test's guards and its view registration. That made 10-15% of parallel runs of the watch tests fail on assertions about reported pages, and, where the forgotten block was one the test then wrote, end with an access violation.

They now tell first, as the runtime does (xmem unmap).
Adapt fxceless/victory-fork a803c87c48 to the local upload path. Preserve phase counters and queue priorities, and discard rechecks when the slot changes generation.
The victory-gpu tests ended with STATUS_ACCESS_VIOLATION in some runs of
`indirect::` with the tests in parallel (2 of 20 reported; 6 of 510 here),
never single-threaded and never with one test alone. The fault is WARP's,
on a thread of its pool: d3d10warp.dll's shader compiler reading entry
0xFFFFFFFF of a table, or a null pointer (+0xc7bb9, +0xc8c13, +0xc7b6c,
+0xc85de, +0xa4cdb; an unhandled-exception filter in an instrumented
build). The event log holds another tree's test binary crashed at
+0xc7b6c today.

D3D12 makes one device per adapter (the devices made on EnumWarpAdapter's
adapter and on the Basic Render Driver's are the same object), so every
WarpHarness and inplace's warp() share one device, and WARP compiles a
pipeline's shader when a queue first runs it. In both crashes caught with
a timeline, harnesses' first submissions came within 3 ms of each other
(four of them; the two card compare tests, 0.2 ms apart).

Experiments, instrumented build, 10 runs each: two queues running new
pipelines at the same moment crashed 10/10; one queue running new
pipelines while another thread made pipelines 0/10; two threads only
making pipelines 0/10; two queues running pipelines that had run before
0/10. Harnesses on 8 threads, 20 each: 18/20 crashed; one device kept
alive throughout 19/20 (not device re-creation); bytecode unique to each
harness 10/10 (not shared compiled shaders); bytecode blobs never freed
10/10 (not a freed bytecode read); submissions one at a time 0/20. Pairs
with --test-threads=2, 60 runs each: 3 crashes in 1,260, each pairing
warp_window_executions_read_their_records_with_no_barrier_between with
one of warp_a_group_charges_its_records_in_lane_order,
warp_budget_saturates_without_wraparound_and_preserves_draw_fields,
warp_count_buffer_ignores_garbage_tail_and_preserves_source; the other
18 pairs 0/60.

crate::host::warp_turn is a process-wide turn: WarpHarness holds it for
its life (its last field, given back after its objects are released),
and inplace's warp() returns it with the device.

Tests: warp_harnesses_take_turns failed before ("a second harness was
made while the first was alive"). warp_window_executions_on_eight_threads
(ignored, a reproduction) crashed 10/10 before and passed 5/5 after.
warp_turn_is_taken_again_after_a_test_failed_holding_it covers the
poisoned turn. Side by side, before / after: `indirect::` 3/300 crashed
/ 0/300; the pair warp_a_group_charges_its_records_in_lane_order +
warp_window_executions_read_their_records_with_no_barrier_between with
--test-threads=2, 2/300 crashed / 0/300. Mutations: a fresh mutex per
call fails warp_harnesses_take_turns and the reproduction crashed 4/5;
lock().unwrap() fails the poison test; the turn given back before the
objects are released passed the reproduction 10/10, so that order is a
precaution.
`indirect::` takes 2.8 s instead of 1.2 s (1 s of it the new test's
wait); the crate's tests pass (138, 4 ignored). Clippy as CI runs it is
clean but for host.rs's existing useless_vec at the base.

Not covered: where the default adapter is the software one (a runner
without a card), host() is this same device and tests that submit to the
host's queue do not take the turn.

(cherry picked from commit 5d9843667abeeeb1c734b2ec7b396236213aa0d4)
The sampler word's LOD bias is a 14-bit signed 5.8 field, so it decodes
to anything from -32 to 31.996. D3D12 takes a static sampler's MipLODBias
only from -16 to 15.99 (D3D12_MIP_LOD_BIAS_MIN/MAX) and refuses a root
signature holding one outside that, which would lose the whole pipeline.
Clamp the decoded bias to that range; values inside it are unchanged.

The test covers both clamped ends and in-range values on either side,
and runs on every host.

(cherry picked from commit 3e7c7ace74)
A content check (226156f) that found a whole-uploaded texture changed
put its slot back in the upload queue with looks 0, mapped 0 and the
write number of its view. TextureQueue::due hands a pass the retries,
then the other writes from both ends, the newest and the oldest in
turns, 2,048 of each at most, and the pass serves them in that order
until its bytes (192 MB a frame) or its time (250 ms) run out. A slot
is uploaded soon after its view is written, as the newest write, and
its first check comes 150 ms after the upload. The writes made since
are newer, the backlog's are older: the re-upload sat in the middle
and waited for the backlog to drain to it. The check saw the change at
once; the upload did not follow.

A change a check finds is now queued as a new write (self.writes += 1),
as changed() does for memory the runtime reports written: the newest,
served first by the next pass. A pass still at work on the old write
can no longer take the slot out with done() or uploaded() on that
write (they matched it before). The checks already spent carry over, so
a view still gets five at most. At most 256 checks run per heap and
frame, so at most that many re-uploads go ahead of the frame's writes.

Probe, a_texture_found_changed_by_a_content_check_is_uploaded_next:
3,000 slots wait; slot 7, written after them, is served alone and
uploaded whole; 3,000 more are written; its check finds it changed.
Before, due(3, 4096) handed out 4,096 of the 6,001 due, not slot 7
("slot 7, with 3000 newer writes due, handed out at None"). After, slot
7 is first, and a late done() on its old write leaves it queued.

How long it waited, in a model (not committed) of passes that serve the
first N entries they are handed, one pass a frame, sized from the queue
of the 0813df8 round's scene load (up to 24,800 due, 170-520 uploads a
frame at 1-3 frames a second). Passes until slot 7 was served:
- 3,000 older and 3,000 newer writes, all 4,096 served: 1, the last of
  the 1,905 then due;
- the same, 256 a pass: 23, the last of the 113 then due;
- 15,000 older, 2,000 newer, 256 a pass: 15; with 1,000 new writes a
  frame, 117;
- 23,000 older, 2,000 newer, 1,000 new writes a frame: 359, 179 and 89
  at 128, 256 and 512 a pass (2.4 min, 72 s and 36 s at 2.5 frames a
  second).
After the change: the first pass after the check, first in its order,
in every case.

Tests: changing_contents_do_not_restart_the_texture_check_budget pinned
the old write ([(7, write)]) and failed with the change (left [(7, 2)],
right [(7, 1)]); it now takes the newer write each time, asserts that
it is newer, and still ends with no check left after five changes.
Mutation: with the old write restored, the probe fails again (as above)
and so does that test ("assertion failed: again > write").
descriptor::host: 16 passed. victory-gpu ("::"): 146 passed, 0 failed,
4 ignored (benchmarks and a reproduction).
Adapt the placed-texture key normalization in fxceless c96b4f2 to both the regular and unordered-access texture lookup paths.
Adapt the upload scheduling in fxceless c96b4f2 for offline validation. The early and indexed paths share one recording lock and the bake limits are cumulative per frame. Both early modes are opt-in until measured on the shared build.
lane_uniform (d07eabc's operands bounded to their own dwords, with #156's guards the lanes agree on) let a VGPR result join the wave-uniform set from its named operands alone. The result also depends on the register's old value:
- where the instruction keeps part of it: accumulators (v_fmac_f32, v_mac_f32, v_mac_legacy_f32, v_fmac_f16, v_mac_f16, v_fma_mixlo/hi_f16) and 16-bit results GFX10 writes to one half of the register (v_cvt_f16_f32 and valu16's lists);
- where it may not run: under a guard only proved uniform, every lane may skip it and keep the old values (VALU, ds_read*, tid >> k).
M0-relative moves read or keep registers outside the operand's dwords, v_swap_b32 writes the old destination into its source, and v_div_fmas reads VCC without naming it. With such a value in the set, v_readfirstlane takes this host wave's own first lane without the exchange (the upper host wave reads lane 32 where the console reads lane 0), and in a lane branch it skips the refusal "a first-lane read where not every lane runs" that sends the program to its wave-wide form.

Now valu16's 16-bit lists are module constants (HALF_FLOAT1/2/3, HALF_INT) shared with keeps_old, which also names the accumulators, v_cvt_f16_f32, v_pk_fmac_f16 and the v_dot*c forms. A keeps_old result joins only with its destination's old value alike; under a guard the lanes agree on, an instruction joins only with the old value of every VGPR it writes alike; v_movrel*, v_swap* and v_interp* never join; v_div_fmas also needs VCC alike.

Evidence:
- The new tests fail on 9af3668 for those reasons: v_fmac_f32, v_cvt_f16_f32, v_add_f16, v_movrels_b32, v_movreld_b32 and v_swap_b32 in a lane branch lowered without every lane; a write under a guard false in every lane over a per-lane old v3 (v_mov_b32, ds_read_b32, v_lshrrev_b32 v3, 6, v0) stayed in the set, and so did v_div_fmas_f32 over a per-lane VCC. The controls pass on both: the same reads over an alike old value (v_mov_b32 v8, s16) lower, the guarded writes over an alike old v3 stay in the set, and first_lane_read_of_uniform_lds_load_lowers_on_wave32 still lowers.
- victory-shader: 250 passed, 0 failed, 2 ignored.
- Mutations, each undoing one of the 11 new checks: every one fails exactly its test cases.
- Offline with VICTORY_HOST_WAVE=32 and VICTORY_HOST_MAX_WAVE=32 on the RTX 4090: XboxBvhBuilder.dll gives 52 of 52 programs emitted, validated and made into pipelines, with DXIL byte-identical to 9af3668's for all 52 (the prefix-sum scans never relied on these cases). shaders.rpf (26084 programs): the same outcome for every program, and the same host instruction counts for all 25677 emitted ones, as 9af3668; the 20 emitted of the 23 compute programs the reviews name (RTShadowTrace*, TraceShadowRays_*, the 11 wave64 ones of 6dabcc7, f133e35e) have identical DXIL.

(cherry picked from commit 98020f074ac67fbbdd6af15e15ca4397adeb2432)
walks_with_empty_exec (behind without_early_outs and without_skips) now
proves which scalar SSA values are zero while the lanes that would have
skipped a region walk it with EXEC clear, instead of accepting only EXEC
writes from masks saved in the region. Zero are: EXEC as the
s_cbranch_execz reads it; the mask a *_saveexec_* saves where EXEC is
zero; the mask a v_cmp*/v_cmpx* writes there (lanes outside EXEC get 0:
GCN3 ISA 3.9 "VCC[n] = EXEC[n] & test", kept by RDNA, and already relied
on by emit::tests::a_carry_in_from_a_divergent_join_is_refused); AND,
ANDN1, ANDN2, OR and XOR (plain, saveexec, wrexec), s_mov and s_cselect of
0 or zero operands where the operation gives zero; phis of zero values.
It is a greatest fixpoint over the region in RPO (everything zero first,
what cannot be shown removed until stable), so loop phis of EXEC and of
the exit mask stay zero when their back edges bring zero.

An EXEC write that is not provably zero opens a whole-wave window. It is
accepted only if a provably zero EXEC write closes it in the same block
and nothing inside writes beyond registers (DS, buffer/flat/global/scratch
stores, atomics and LDS loads, image stores and atomics, exports, scalar
stores and atomics, s_sendmsg); every block of the region must end with
EXEC zero. skipped_region and scalars_unchanged are unchanged; the
callers pass the branch block.

Why: 6dabcc7 refused every EXEC write whose source was not a saved copy
of EXEC. That kept every early-out or skip whose region holds the
compiler's whole-wave sum (`s_or_saveexec_b64 s[4:5], -1` ...
`s_mov_b64 exec, s[4:5]`), an if/else (`s_xor_b64 s[2:3], exec, s[2:3]`
then `s_or_saveexec_b64 s[2:3], s[2:3]`) or a divergent loop exit
(`s_or_b64 exec, exec, s[6:7]` with s[6:7] grown by `s_or_b64`), and 11
compute programs bound in game lost their 32-lane forms: 10 came out
with WaveSize 64, which the host refuses, and b22a16a1 stopped
translating.

Still kept (the cases 6dabcc7 fixed): a restore of a mask from before
the branch (`s_mov_b64 exec, s[12:13]`, `s_or_saveexec_b64 sX, s[12:13]`)
is not zero, so it opens EXEC and no zero write closes it in its block:
an_empty_exec_skip_keeps_a_store_behind_a_mask_restore and
emit::tests::masked_vector_output_keeps_the_outer_restore_guard pass
unchanged.

Tests (ir::tests): a_whole_wave_window_that_only_writes_registers_lets_an_early_out_go
(the b22a16a1 pattern leaves 0 skips; a store inside the window, a window
open at the end of its block, and a mask saved inside the window keep
the branch), an_if_else_behind_an_early_out_keeps_exec_clear,
a_divergent_loop_behind_an_early_out_keeps_exec_clear (and a saved mask
brought back around a loop keeps it),
a_compare_writes_a_clear_mask_only_where_exec_is_clear and
a_mask_from_clear_exec_is_clear_only_where_its_operation_keeps_zero. On
9af3668's analysis the first four fail at without_early_outs = None
("left out"); the last passes there and guards the mask rules.
victory-shader suite: 252 passed, 0 failed, 2 ignored. clippy -p
victory-shader --all-targets -D warnings: clean. Mutations, one at a
time, each caught: phi zero if any arg is, no effect check inside a
window, no open-window check at a block end, saveexec save always zero,
v_cmp and v_cmpx results zero whatever EXEC, OR/XOR as AND, AND as OR,
ANDN2 by its negated operand, one sweep instead of the fixpoint.

Offline (victory translate, one program at a time, --jobs 1,
VICTORY_WAVE_WHY=1, VICTORY_HOST_MAX_WAVE=32): the 11 programs come out
exactly as with the revert of 6dabcc7, byte for byte in output and retry
trace, all 32-lane and validated: 55679a05, 89d08e56, 11276d0c local
waves (idiom) without early-outs; 7168dd78 without skips; d2b169b8,
1f1fbd86 without skips, scalars followed; b9688048, 119ee96f, b22a16a1
without early-outs; 71883e40 local waves (APPROXIMATE) and 0a5ecfee
(APPROXIMATE, any mask), as before 6dabcc7.

(cherry picked from commit f6fab7e73bb91fc7479c519c3b15796e7037b050)
walks_with_empty_exec let through two regions that lanes outside EXEC
cannot walk the way the console skips them:

- A window opened with any mask. One restored from before the branch
  runs that mask's lanes, and the join reads what they wrote. A window
  now opens only with `s_or_saveexec sD, -1` or `s_nand_saveexec sD, 0`,
  may be narrowed by constants (a prefix sum's `s_mov_b32 exec_lo,
  0xffff0000`), and closes only with the mask that opening saved.
- A loop that goes on while no running lane wants out. A host lane
  decides by its own bit, so one outside EXEC spins to the loop limit
  and then runs what follows unguarded. A branch whose region has such a
  loop stays.

Of the 2,689 compute shaders in the game's containers, only c4183d3c
(CS_ProjDecalResolve_Vectorized), which has that loop, translates
differently.
Six one-line mutations of lane_uniform passed the suite: dropping
HALF_FLOAT1, HALF_FLOAT3, HALF_INT, the v_fma_mix pair or the v_mac pair
from keeps_old, and checking only the first register a guarded write
leaves. The cases added here (v_rcp_f16, v_fmac_f16, v_fma_f16,
v_add_nc_u16, v_fma_mixlo_f16, v_mac_f32, and ds_read_b64 over a
per-lane old v4) fail under each of them. Tests only.
Upstream: 32d784861a
Upstream: d0d0d23451
Upstream: 467f16843b
Upstream: 708b450157
Upstream: 18df163406
Upstream: 40f30be0b5
Upstream: bbdc3ca724
Upstream: 711d651cca
Upstream: be3202de39
Upstream: a91ef70e0d
Upstream: aa85bb0ffb
Upstream: faca57ec9b
Upstream: 13185f50ac
The module uses windows-sys and console_insn, which exist only on
Windows, so the portable part of the crate did not compile elsewhere.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Since 978764e DirectStorage's plain reads keep their destination writable until the kernel returns (with_kernel_write); the title's own reads only opened it before the call (kernel_will_write). A refresh on another thread can guard the same pages again through another view while the kernel waits for the bytes, and the kernel's write then fails (ERROR_NOACCESS) instead of faulting into our handler. The title retries a failed ReadFile forever (title+0x313fc0).

- ReadFile runs whole inside with_kernel_write, with or without an OVERLAPPED: one on a handle opened for synchronous I/O (for the offset) is done when the call returns. A read still under way when the call returns is exposed after that, as before; the first overlapped read into a title view is logged (info), and the first still under way (warn), to learn whether the title does it. ReadFile hands the title the host's last error: the reopening and a log line can change it (Rust's stderr asks the console about a redirected handle, which fails).
- fread runs inside with_kernel_write.
- _read (libHttpClient's; the host CRT reads straight into the caller's buffer) is bound here and wrapped the same way.
- victory-gpu: title_memory_guard behind a test-support feature, enabled only by victory-hle's dev-dependency (cargo tree: the victory app gets victory-gpu's default features only).

Tests (victory-hle modules::files): an anonymous pipe; a thread reads 13 bytes into a guarded title view; once it has opened its destination, a refresh guards the pages again through the alias view, and only then are the bytes written. On f4016ba: ReadFile (0, error 998); ReadFile with an OVERLAPPED on the synchronous pipe (0, 998); fread on an unbuffered stream (0 items, 998); _read as bound there, straight to the host (-1, 998). Now all four land the bytes and the next refresh reports their page written. A fifth test reads an overlapped named pipe: ERROR_IO_PENDING reaches the caller although the log subscriber changes the last error, and the warning comes once.

Mutations, each failing those tests: ReadFile or fread back to kernel_will_write; _read unwrapped or not exported; ReadFile not restoring the last error, or restoring it before the log line; the log outside views, every time, or never for a read under way; 978764e's pin check removed from protect_here.

victory-hle: 106 unit tests and the integration test pass. victory-gpu watch:: 10/10 serially; in parallel, three older watch tests fail now and then (some free their memory before title_memory_remapped, so a parallel test reusing the addresses meets stale guard state); no code of this commit is compiled into that binary.

(cherry picked from commit 01fa4cd6a6d5bcce906ee4a340a231b5d17504c7)
The read tests put 13 bytes inside one block, so holding a single byte
open passed them, and nothing checked that the hold ends. The
destination now lies in two blocks, fread reads seven items of two
bytes, and the tests (with watch.rs's) check that the next refresh
guards the destination again. Holding one byte, `size` or `count` alone,
or never releasing now fails them.

A pending overlapped read of no bytes no longer uses up the one warning.
Its text and the comment name both outcomes when a refresh guards the
destination first: a cached read fails with ERROR_INVALID_USER_BUFFER,
an unbuffered one lands without a fault and leaves the copy stale.

(cherry picked from commit 721bdfa9976c0f870c0a2299724052c05bb89ba3)
With VICTORY_COPY_NO_WAIT=1 a copy whose source lies in memory that
flights declare written runs at once; if a copy-back then writes over
the source before the copy's own submission lands, the copy is made
again. A copy still waits for its destination. Off by default: not
measured in the game yet.

The title's 174 MiB heap is declared written whole by a table view, and
one 20 KiB copy out of it a frame waited about 40 ms. No copy-back wrote
over the source of any of about 9,000 such copies.

(cherry picked from commit 2ea74f5062552101041f34ce3d0855b9abefa26c)
With the relay, plans are made while earlier ones are in the air, but both areas of the compare started again only when no plan was out: the submitting thread settled every flight (WHY_MOST) once half of the results or of the ring's slots was taken. In the live runs another settle drained the flights about once a frame and reset both; without it the ring (~830 pieces a frame) would settle every ~2.4 frames and the results (~13,900 pieces) every ~9.

The results are now a line of runs, one per plan, taken where the last one ends (from the first dword again when a run would pass the end, the end it skips held with it) and free once the plan and every plan before it are done with. The ring's count is never set back: a piece found differing gets slot count % slots only while the count is below the limit the host keeps in dword 1, slots past the count the compare of the last plan done with left at the end of its run (compare mode 3, after a barrier). Short of 2^32 the limit stops at the last multiple of the slots until the count has gone round. A piece past the limit is fetched, as when the slots ran out before; only an eighth or less of the results left still settles. The frame line counts plans that compared nothing for want of room and pieces found differing past the limit.

Tests: the areas as a plain struct (runs going round, freeing in order, the skipped end, the limit in the queue's order and short of the wrap, what settles); on WARP, compares in a row with the host's limit between them, slots going round without touching those of plans in the air, and across 2^32.

(cherry picked from commit c741781b120f2d96e746c97996d93a0e96acd6c0)
The review of c741781 found the host's side of the ring untested: nothing ran Host::card_before's layout of a plan's run and recording of its compare, or what Host::card_done does with the ring, so the whole suite passed with the limit's store deleted, the count read from another dword, or the count's dword off by one. These are now functions the host and the tests share: CardAreas::lay_out (each compared range's first dword, one after the other, and with the ring the count in the run's last dword), record_card_compare (the barrier, the compares, and after another barrier the count left by compare 3) and card_run_done (the count read where the compare left it, the run given back, the limit written). The WARP test lays out, records and does with every plan through them, with two ranges a plan, and reads the limit where the compares read it. A compare whose counts cross 2^32 while the limit is still at the last multiple below it pins the signed compare: with `limit > taken` the wrapped counts took slots 0 to 3 of plans not merged yet.

The limit moves from dword 1 to byte 256 of the ring's first slot's worth of bytes (CARD_RING_LIMIT, the shader's limitAt; a const assert keeps it inside those bytes), off the count's cache line on the card and on the PC, so the compares' atomics on the count neither hold its line nor write it back. It is written at every plan done with, moved or not, so a write lost on the way is put right by the next.

A plan never done with would only show as waits: its run and every run after it stay out, the results stay low, and every submission sent ahead waits for flights to land. Host::card_before now warns, at the 1st, 2nd, 4th... time, when the runs out pass four times late_most or the results were low for 64 plans in a row. With VICTORY_RELAY=2 a submission that finds the results low waits until they are not, or until nothing is in the air or being landed (where a settle's wait ends, so a plan never done with cannot hold it for good), not for the whole line; at 1 it still settles. The docs of CardAreas and of the count's dispatch now say that the slots' safety, not only the count's exactness, rests on the boundaries between ExecuteCommandLists calls on one queue being full barriers, and why no compare takes a count 2^31 past the limit it reads.

Tests: the layout (ranges one after the other, the count in the run's last dword, also in a run that goes round); card_run_done on plain memory (the count read in its dword, the limit written where the shader reads it, again after a lost write and for a plan with no run, nothing without the ring); the shader and the host on the same limit and slot size; the warning's thresholds and its 1st, 2nd, 4th... times; the wait for room ending with nothing in the air; and the WARP ring test through the host's functions, with the step across 2^32. Each was seen to fail with the mutation it is for.

(cherry picked from commit d557971803f3b12bba0c3316d5b523d4d9a15419)
The review of d557971 found that the CI's clippy (-D warnings, with and without --all-features) failed: manual_is_multiple_of on the limit's const assert, and useless_vec in a test of direct_copy since 17394eb. Both are fixed, and the workspace's clippy passes both ways.

It also found the host's side of the ring with one word between it and memory corruption: Host::card_done passing count_at + 1 (the next run's first dword: a flag 0, 1 or 2 + s, or another plan's count) passed every test, and a value up to 2^31 ahead of the count merged would let the limit past slots of plans not merged yet. And the slots' safety rests on the boundaries between ExecuteCommandLists calls on one queue being full barriers, which WARP cannot test. Each piece a compare flags takes exactly one count of the ring (with a slot or past the limit) and no other piece takes one, so the count a plan of the ring leaves is the count before it and one per nonzero flag in its run. CardAreas now keeps each run's compared pieces and whether it is of the ring; card_run_done reads the count only in the run's last dword as the areas laid it out (a count_at anywhere else is read nowhere) and counts the flags before it; CardAreas::done passes plans of the ring in order and takes a count only if it is the count merged so far and one per piece flagged. That is the bound the review asked for (between 0 and the plan's pieces) made exact: the bound would still take a flag 2 + s read as the count while the count is small, up to the plan's unflagged pieces past the true count. Anything else is refused: the count merged and the limit stay, the slots run out and the landings fetch (correct, and slower), and card_run_done warns at the 1st, 2nd, 4th... refusal. Once a plan that flagged pieces was refused, the counts after it are refused too: the slots stay stopped. A count that holds counts a later submission's compares took, as a boundary that is no full barrier would leave it, is refused the same way: the one look at that premise a real card gives.

The glue the review's mutants G1 to G4 lived in is now code the tests reach on the host device (host()): Host::card_done's body is CardWork::plan_done (the lists back, card_run_done with the work's own mappings, and a debug assertion that a plan of the ring holding a run has the count's dword), Host::card_before's layout is CardPlan::take_run, the wait for room is room_wait_over(&CARD_WORK, line), and Host::make_card_work takes the ring's size instead of reading VICTORY_RELAY_SNAPSHOT_MB. Two new tests make the work with a ring, take runs as card_before takes them, give them back as card_done does, and wait as a submission waits. What no test reaches is the one-line call at each site: card_done calling plan_done, the wait's closure, card_ready's ring size.

The warning for a plan never done with counts results low in a row only with the relay (without it no submission waits for room and card_results_low is not asked, so huge declared ranges in the air could set it off), and says each new time from its first plan. The wait for room still ends when the results are not low, not when the plan's own run fits: its pieces are known only inside card_before, under locks the landing thread takes; documented.

Tests: CardAreas with the count checked (a flag 0, 1 or 2 + s read as the count, the count of the plan before and an older one, the count one more and one fewer, a count holding a later plan's pieces or past the plan's own, the count's dword passed one off even where it holds the right value; the counts after a refused plan; a plan of the ring with nothing left; no plan flagging more than it compared; the normal case going on, also across 2^32 from a jump); card_run_done reading the flags before the count; the count's place as the host looks for it; the warning without the relay and from the first plan of each time; and on the host device the work with its ring, plans taken and given back as card_before and card_done take and give them, a count refused, the debug assertion, and the wait for room. The WARP ring test now has the host take every count its compares leave (only the pass that hashes, with marked dwords and no count taken, is refused). The card filter 22/22 (was 18) in 7 runs; the whole crate 149 passed, 3 ignored, single-threaded 3/3 in release and 1/1 in debug; in parallel 12 of 15 release runs clean and 3 ended in STATUS_ACCESS_VIOLATION with no test failed (the WARP compiler's race; the review saw 5 of 20 at d557971 with the machine loaded), and the debug run in parallel once so. Mutation, each in this tree and target, the file put back by its hash: 37 of 40 caught, among them G1 to G4 at their sites now (G4 word for word), the check made a bound, left out or left uncounted, the flags counted wrong, the count's dword unchecked, and the warning's relay and reset; the debug assertion left out is caught in debug. The three left are the one-line calls named above. Clippy -D warnings on the workspace with and without --all-features, and the release and diag builds: no warnings.

(cherry picked from commit 3416abd8580443075bf7db3bb9039def5b60d9ef)
The host tests built plans with no ranges, so the half of
CardPlan::take_run that gives each compared range its dwords never ran.
Four one-line mutants passed the suite (the ranges not cleared without
room, `at` set to 0, the compared filter dropped, true returned without
room); three of them make a compare write its flags over another run's.
The new test fails under each. Shadow::for_test builds the copy it
needs. Tests only.

(cherry picked from commit add8a96349faf146f25d87ffebc99660974b2c0f)
Bug fixes from a repository-wide audit
- A list named more than once in a submission recorded each of its
  state preludes into the same host list, replacing the queued ones;
  each repeat now has its own.
- The present recorded a transition between equal states when the
  shown texture was already a copy source.
- Copies numbered from shader faults were not brought up to date by
  the list whose call took the faults.
- The run of by-address views was kept by the heap's address after the
  title released the heap, so a heap made at that address got none.
- The staging slice of a texture's last subresource reached past the
  buffer by up to a row pitch.
- The compare of big ranges after a submission skipped its first part
  when the copy starts inside a 64 KiB piece (unsigned underflow).
- Freed title memory left in-place windows longer than 4 MiB in the
  tables.
- The once-per-frame pass over a view heap's buffer views was gated
  for the process, not per heap.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
- s_min/s_max set SCC to whether the first operand is the result, and
  s_lshlN_add_u32 to the carry of the wide sum; all had it as
  "result is not zero".
- image_sample_d on a cube scaled the level by log2(e): the host's
  logarithm is already to base 2.
- ds_swizzle_b32's rotate and FFT modes were lowered as quad picks;
  they are refused now.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
A16 narrows an image instruction's coordinates and its LOD, clamp or
mip. Gradients are 16-bit only in the _g16 opcodes, so image_sample_d
with A16 was decoded with too few address dwords and its gradients and
coordinates were read from the wrong registers.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
- The shader cache did not tell translations made for a capped view
  heap from those made for an uncapped one, nor runs that differ in
  three translation switches.
- An event waiting for a fence was set only by a signal, not when a
  list wrote the value at the fence's address.
- A root constant held in its parameter's first dword counted as an
  address base, so an offset taken from it was refused.
- A shader signature's row count sized an allocation before the part
  was checked to hold the rows, and masks past four components were
  taken as they came.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Title bytes put in under flights (merge_under_writes) went up to a copy in the card's memory as one CopyBufferRegion per changed run, so at most 512 runs a submission were taken and a settle was due past that. The bus scene of run dd56178 put in 20-80 thousand runs of about 3 bytes a frame and still settled for title memory changed under shader writes about twice a frame, 73-77 ms of waiting for the card.

card_before now sends ranges shorter than 256 bytes as patches: per dword of the copy its index, the title's bytes and the mask of those to put in (shadow::dword_patches, a dword two ranges share being one patch), read from the CPU side under its lock, and one compute dispatch (CARD_PATCH) puts them in over what the card holds, between the copies and the rehash. Longer ranges keep their copy. The patches live in a buffer in the PC's memory that the plan holds until its submission has run. The dirty and sent notes the relay skips by are unchanged, as are the rehashed ranges. With the patch compiled, the limit on runs a submission puts in is 262144; without it, 512 as before. The frame line says how many patches went to how many copies.

Tests: patches_put_in_the_ranges_bytes_and_nothing_else (model, against a copy per range), warp_card_patch_puts_in_only_the_title_bytes (the shader on WARP, two dispatches, partial groups); both fail with the mask or the joining of a shared dword undone. victory-gpu 129 passed single-threaded; the parallel suite has an older intermittent access violation in watch:: tests, also at 3907f19.

(cherry picked from commit 0e74ccb15e23aa2684d497115a69a0aeb7dea7b9)
The run budget of 0e74ccb (1<<18 once the patch compiled) counted every run, so runs of 256 bytes or more still went up as a CopyBufferRegion each, tens of thousands per sync list (the review's example: 16 MiB rewritten with fairly random bytes gives 24 thousand of them), and without memory for the patch buffer every range went by a copy, up to 262144. merge_under_writes now takes a submission's Room (shadow::Room): runs of 256 bytes or more take a copy each, 512 at most as before; shorter ones take dword patches, as many as 16 MiB of patches hold (1.4 million; the bus scene of run dd56178 put in 20-80 thousand runs a frame). A run that starts where the one before it ends is counted joined, as card_dirty sends it; a page goes in whole or not at all; past either limit a settle is due, each counted on the frame line. Long runs past the copies are not sent as patches: they cost 3 times their bytes over the bus and an atomic step per dword, and more than 512 of them is a big rewrite, which the settle and the copy of whole pages took before. The buffer the patches go up in (16 MiB, kept or made) is taken in stale_under_flights before any run is put in; without it, or without the patch, every run takes a copy and past 512 a settle is due, as before the patches. card_before sends the short ranges as patches while the plan's buffer holds them, the ones past it by copies.

The pieces hashed again after a send are hashed in joined runs whenever the patch compiled or past 512 ranges, whatever VICTORY_CARD_REHASH_RUNS says (80 thousand runs of 3 bytes were 80 thousand dispatches).

card.dirty and card.sent are CardNotes: each send's ranges as the joined, ordered ranges it took (shared with card_before), and the ranges not sent yet as an ordered part and the part noted since, in order while it comes in order and put in order by a merge's question once it grows past 256 out of order. card_merge_relay finds the notes over its piece by a binary search, not a pass over all of them (15-107 ms a frame on the relay's thread in the review's bench); the bytes left out are the same.

A plan takes the smallest kept buffer that holds its patches and is not four times their size, 64 KiB at least (it was 1 MiB and the first that fit); the pool keeps the ones given back last, up to 64 MiB, and lets go of one no plan took for 256 plans. The patches are made and the buffer taken and filled before QUEUE_ORDER and CARD_WORK: the send's number is the queue order's count and one (only the submitting thread sends, under the submission lock), and the count is set to it under QUEUE_ORDER with the sync list put on the queue, so a fetch before that has a lower count and leaves the send's ranges out, as before; a count that moved meanwhile fails.

CARD_PATCH is InterlockedAnd(at, ~mask | value) then InterlockedOr(at, value & mask): each atomic step changes only the mask's bits, so a write of the dword's other bytes at the same time stays, where a load and a store put the old bytes back. card_patches reads the CPU side's mapping by the card side's size, as the copies do, and cuts ranges past it. Patched bytes count in the MB sent up; the patch line says the patches, their title bytes, the copies recorded and the buffers there was no memory for.

Tests: room, touching runs, a model of room to card_dirty to card_before (300 random rounds: exactly the copies and patches the room counted), the split past the buffer, the cut, the notes against the old pass over all of them (160 thousand random steps: same bytes left out, same ranges sent), the pool, the rehash join, and on WARP patches of one dword in threads side by side. The before-states fail them: the old load and store loses 7680 of 14336 bytes on WARP; without the long/short split 512 long runs take no copy and a model round sends 7361 copies the room never counted. victory-gpu: 138 passed, 2 ignored, with one thread and in parallel (129 before); the parallel suite keeps its older intermittent access violation at the rate it had (whole runs: 8 of 60 for the 8d2e0dc test binary, 7 of 60 for this one). Release and diag build without warnings, and clippy finds nothing on the changed lines. 18 mutations of the core lines each fail a test.

(cherry picked from commit b63a342f4aba1a3b7129314c27cbc5a295a22363)
Host::patch_buffer gave the submission's 16 MiB reserve back to the pool before it chose the plan's buffer, and the reserve lay in the window a plan takes from (its bytes to four times their next power of two): a plan of 2 to 8 MiB of patches took it into the air, and the next submission made another while it flew. The choice is now PatchPool::for_plan, made before the reserve goes back: a kept buffer in the window, else one made of the next power of two (outside any lock), else, without memory, the reserve if it holds the patches, else the biggest of the reserve and those kept; the reserve goes back unless taken. The pool has a lock of its own (PATCH_POOL), so nothing is made under the card's work. The review's rv_a_plan_of_a_few_mib_does_not_take_the_16_mib_reserve now calls PatchPool::reserve and for_plan as Host::patch_reserve and patch_buffer do: eight plans of 2.5 MiB in the air hold 32 MiB and make 48 (128 and 128 at b63a342), and over the window that held the reserve (2 MiB and 12 bytes to 8 MiB) each plan has a buffer of its own, of the next power of two, while one reserve goes round.

merge_under_writes took a copy's busy ranges in the order flights declared them, and Room joined a run only with the one just before it and only where it ended. Two declared ranges that touch, the higher first, gave two short runs the room counted as patches and card_dirty sent as one long range: 600 such pairs went up as 600 copies, none counted (rv_busy_ranges_out_of_order_take_copies_the_room_never_counted). The merge now takes them in order and joined (busy_in, as Shadow::update sorts them; a page is looked at once), and Room::take joins a run that touches or overlaps the group before it, keeping the farther end. The review's test, with those pairs and with threes declared middle last (which the room's join alone still miscounts), sends 512 copies with 512 counted and stops at the 513th; rv_busy_ranges_in_order_are_counted still passes. What can still meet a run uncounted is a refresh's range at a busy range's end, or a merge of what the card wrote: one copy each.

No test reached the path through the host. card_path_tests make a copy in the card's memory by hand (Shadow::on_card_for_test) over write-watched title memory, on the host GPU: two sends numbered with the relay (card_before and card_dirty take relay as an argument; submit passes relay()), the merge under flights' writes without and with the reserve, the card side read back, the compare after the sends, and card_merge_relay for a fetch between them. QUEUE_ORDER goes up by one per send that takes ranges and not for one with nothing to send, and card_dirty notes the ranges with the send's number; a page of 602 runs leaves a settle due without patches (UNMERGED[2], 602 runs) and past a room's patches (UNMERGED[5]); with the reserve the runs go in and up as 600 dword patches and 3 copies; the card side then holds the title's bytes, the compare finds no piece changed since its hash (the hash runs held the pieces sent to), and the merge keeps the second send's title bytes and takes a shader's bytes beside them. Another test takes two copies through one room (Room::next_copy), another stale_under_flights with refreshes under flights. The planning after card_dirty is plan_send (split, buffer, patches, patched_at, hash runs), tested with a buffer that holds fewer patches than the ranges make, with none, and with one left empty; the room's binding to the reserve is put_in_under_flights. Probes at the seven places the review named (stale_under_flights, patch_reserve, patch_buffer, merge_under_writes, card_patches, card_merge_relay, card_before past its early return) are all reached now. These tests never free their title memory: the write watch's journal remembers pages for good, and watch's test that expects a fresh region to show nothing written failed now and then when it was given their address. Each send is waited for before anything is checked, so a failing check drops nothing the card still uses (a failing run hung the suite once).

CardNotes::over put every range not sent yet in order once more than 256 had been noted out of order since: 0.8, 3.9 and 12.2 ms a question with 80 thousand, 400 thousand and 1.4 million noted in order (rv_time_a_question_that_puts_the_notes_in_order at b63a342), under the notes' lock and the CPU side's, which the submitting thread's merges wait for. The notes are now a main part, a second part, and what came since: a long loose tail is sorted alone and goes, with what was noted in order before it, into the second part; what was noted in order after a send becomes the main part as it is when it follows it; the second part goes into the main one once it holds more than an eighth of it. Same bench: 18-21 microseconds a question, 46 the longest. A test checks that the main part is not touched until the second passes an eighth, and the random test against the old pass over all notes still passes.

The runs of pieces hashed again are made with the plan, before QUEUE_ORDER and CARD_WORK (card_hash_runs), joined as they come since the ranges are in order (no 28 MB of runs to sort for 1.4 million ranges): 10.3 ms under both locks at b63a342, 2.2 ms now outside them (rv_time_the_hash_runs_made_under_the_queue_order). A send of 1,398,101 short ranges to a copy with hashes kept a thread waiting at most 0.35 ms for QUEUE_ORDER and 0.39 ms for CARD_WORK; with the runs made under the locks as at b63a342, 44-185 ms (rv_time_the_locks_a_send_of_the_most_short_ranges_holds, with this machine at 97% CPU; this code under the same load: 0.6-3.9 and 0.4-0.7 ms).

The frame line said "now off" for VICTORY_CARD_REHASH_RUNS while the patch joined the runs anyway; it now says what joins them. The pool's documentation says four times the buffer one made for them would be (up to about eight times their bytes), and card_before's says why a plan's buffer may hold fewer patches than its short ranges make (short ranges of refreshes and merges past the merge's room, or no memory for a buffer past 16 MiB: those go by copies, past 512). A test's vec! (17394eb) is an array, so clippy -D warnings passes.

victory-gpu: 151 passed, 5 ignored with one thread, in release (every run) and in debug; at b63a342 with the review's five tests 139 passed, 2 failed, 4 ignored. In parallel (this branch has no warp_turn): of 22 whole runs of this code (16 of them a test short of it), 20 passed and 2 ended in the access violation the WARP tests have in d3d10warp.dll without it (0xC0000005 at offset 0xc7bb9; b63a342: 1 of 8 runs); of 6 runs before its tests waited for each send and kept their title memory, with the machine at 97% CPU, 2 failed frame's tick test (5 ms ticks) and one of them watch's view test too. Clippy -D warnings --all-targets, with and without --all-features: nothing. 15 mutations each fail a test, a no-op control passes: the five the review found passing (Room::new(true) without the reserve, no re-split for the buffer's room, no next_copy, UNMERGED's indices swapped, no QUEUE_ORDER update) and ten of this commit's lines (the reserve given back first, no reserve fallback, the room's join only where a run ends, busy ranges as declared, the notes always into the main part, no continuation, the second part not searched, hash runs not joined, no fallback for runs out of order, card_dirty without the relay).

(cherry picked from commit ec13e4a6823808cdecf69521ae3786a55ab9843f)
- XMemMapPhysicalPages failed for a range that crosses the placeholders
  earlier views left behind; they are joined before the range is mapped.
- A pending call (a dialog) wrote its late result into state that a
  cancel had already freed, and could complete a later call on the same
  block; the state is shared now and a result for a call that is gone
  is dropped.
- At an XMA loop's end the loop-start subframe skip cut the frame that
  ends the loop instead of the one the loop starts in.
- GetModuleFileNameA gave a title image's path in UTF-8 instead of the
  ANSI code page the title's narrow file calls are decoded with.
- The emulated clzero loop zeroed nothing for blocks of 2 GiB or more,
  nor the one line the loop zeroes when its end is not past its start.
- The census counted a function once per import hint.
- Relocation targets and a watched RVA were added without a check for
  overflow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Reported by Bennet0k in https://github.com/fxceless/victory-fork/issues/173
With VICTORY_WIDE_REFRESH the jobs added their own time to the frame
line's preparing counter and the flush then subtracted the excess; when
the frame line took the counter to 0 in between, the subtraction
wrapped it. The jobs now count bytes only and the flush adds the time
it took once. Also corrects the doc of VICTORY_ASK_ONCE, which is on
by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
The frame line's preparing was 105-115 ms a frame with only the copies
(about 50 ms) named. A line per frame now splits it into the write-watch
asking, the title bytes put in under flights, the lists' deferred steps,
their state preludes, the last refreshes, the snapshots and the copies
in the card's memory, settles left out. The copy step no longer counts
the refreshes its title write flushes, which already count their own
time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
VICTORY_WAVE_WIDE=<hash>,... allows the wave-wide form for the listed
shaders only, as VICTORY_WAVE_WIDE=1 allows it for all. On an RTX 4090
(32-lane waves) seven compute shaders of the prologue were translated
for 64-lane waves and refused at pipeline creation; offline, with the
form allowed, five of them (2cc4c197, 369cbe90, 5dc3b259, 6f225b64,
926c46ba, all one console wave per group) become 32-lane pipelines the
card takes. The global switch stays off because it once lost the card
with two particle programs; a list keeps those out.

The offline translate command honours the list too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
They wake the title's threads that wait for the card and land what it
ran, so they sit on the frame's path. At normal priority they competed
for cores with every other program: in a PIX capture with all 32 cores
busy (builds), the settling thread was ready but not running for 542 ms
of a 580 ms window while the card sat idle for 625 ms. The title's own
submitting thread already runs at 15; these two now run at 9.
VICTORY_HELPER_PRIORITY=0 keeps them at normal priority.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
# Conflicts:
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/pipeline.rs
#	crates/victory-shader/src/emit/mod.rs
Bug fixes from a repository-wide audit (GPU backend, shader translator, HLE, loader)
Adapta a proposta de Flyander em fxceless/victory-fork#305, usando uma cópia da página e verificando substituição e remoção no Direct3D 12.
Inclui as correções propostas em fxceless/victory-fork#706 e #709 e os testes da auditoria local.
- release_held looked at the events waiting for fences only before it
  ran what queues held; without late submissions a held list's
  bottom-of-pipe write into a fence then woke nobody until some later
  call. They are looked at again once something ran.
- A pending_with call's thread checked that its call was still the
  block's and then completed by the block's address: a cancel and a new
  call on the block in between got the old result. It now completes
  that call alone, its own done flag deciding.
- The heap pass was keyed once per list, so a list that binds a second
  view heap never ran that heap's pass nor kept its table; keyed per
  list and heap now.
- join_placeholders skips its two queries for a range inside one 64 KiB
  granule (the single-page maps of page-mapping copies).
- victory translate no longer drops a shader named in
  VICTORY_WAVE_WIDE_ONLY as a duplicate of the same code unnamed.
- SUBMISSION_US has its doc back (PREPARE_SPLIT's had been put between
  them), and the frame line no longer calls the copies a part of the
  deferred steps alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Fix review findings on #2: fence events after held runs, late async results
- in_place_let_go walked every loose window below the remapped range's
  end, under the lock the asks take, on every remap. It now starts as far
  below the range as the longest window the map has held, which no
  window reaching the range can exceed.
- a_cancelled_pending_call_drops_its_late_result waited 100 ms for the
  work thread to finish; on a loaded machine it could pass before the
  thread had completed anything. The thread now notes its block when it
  ends (in tests), and the test waits for that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
A console wave64 program that no form carries in 32 lanes was handed
over with WaveSize(64), and on an RTX 4090 (waves of 32)
CreateComputePipelineState refused it with E_INVALIDARG and no reason,
on every run, for 3 to 7 of the prologue's compute shaders. It is now
refused at translation with the reason ("a console wave64 program that
still needs 64-lane waves"), and gets the constant-edge retry that only
refused programs had. Its dispatches are dropped as before. Hosts with
64-lane waves are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
The title's tiled lighting writes each pixel's material class into the
twin of a depth plane, then draws each class with the depth test equal.
The pass that draws the twin into the plane ran only when the list
closed, after those draws, so every frame they tested the classes of the
frame before: the frame line's "times used before the pass" grew by one
a frame (962 to 2219 over 159 s in a release run).

The depth target's bind for a draw now records the pass first, when the
plane is behind (a copy due, or a use that saw it late), and the draw's
state is set again after it (State::replay). Copies, clears and shader
reads keep the late path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
- CardNotes::take built and allocated an empty Arc for every card copy
  with nothing noted, on every send (~600 copies, ~30 sends a frame, ~20
  copies with notes), only for card_dirty to drop it. It returns a
  shared empty one now, with the same sends and notes.
- Batch::flush gathered every pending refresh's range and ask_ahead
  sorted them before finding that the submission's one asking stands and
  returning. The flush skips both while it stands (watch::asking_stands);
  the journal is left as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Every 16th pass of BufferViews::begin_pass revisited all of a heap's
buffer slots (some 70,000): a release run's heap pass alternated between
11 ms and 1.9 ms frame averages a second, about 73 ms of one frame in
16 on the thread recording the title's list. Each pass now revisits the
next sixteenth in turn with the slots written since: the same mean and
the same coverage (each slot within about 16 passes), without the spike.
The first pass of a heap still takes all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
The heap pass looks again at every texture uploaded in part, asking the
kernel about each 64 KiB of it, although the runtime's notices already
make a slot due when memory is mapped, unmapped or written under it:
4.5 ms a frame on average in a release run (241 slots looked at, peaks
of 13-16 ms), with "looks that found no more mapped" growing by ~153 a
frame.

- The frame line now counts looks that found more of a texture mapped
  with no notice between ("arrived unannounced"), the cases the looks
  are for.
- VICTORY_TEXTURE_PARK_FRAMES=<n> (off by default) lets a texture
  uploaded in part and found no further along wait up to n frames before
  the next look. With it on, dropped notices make the slots waiting on
  looks due at once. To be tried where the new counter stays about 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
Depth plane before the class draws; steadier heap pass; less per-submission work; 64-lane-only refusals
Une os históricos a partir do snapshot equivalente e incorpora as melhorias de formatos, carregador, serviços, shaders, pré-compilação e diagnóstico de pipelines.

Mantém a ABI de memória e descritores do Vice-Tay nas sobreposições com os caminhos de marcas de escrita e de semântica numérica estrita do original.
Corrige o laço CLZERO testado pelo CI
Adapt the staging-path fix from VIctory #2716 while retaining Vice-Tay save recovery behavior.
The dumps write 8-bit colour as is and drop alpha; a line per dump now
gives each channel's range and how many texels hold zero there (the grass
trail map's alpha, for the missing ground).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 743398874f)
Diagnostics only. The trace of a listed frame named every command but not
the barriers between them, so whether the title orders two dependent
dispatches could not be read from it. Each barrier call now notes itself
in its list: the enhanced form as its groups' (kind, count) pairs (0
global, 1 texture, 2 buffer), the legacy form as its barriers' kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit eed1670036)
What was wrong: buffer and typed-buffer loads of normalized formats
(UNORM, SNORM) converted a code by dividing it on the host. The host's
division is not exact. On the RX 6700 XT, 125 of the 256 8-bit codes
loaded one ulp high, and 16-bit codes such as 257, 261, ..., 32896
loaded one ulp low; WARP was exact. The console's buffer unit gives the
float nearest the exact quotient, and titles rely on it in decisions:
Grand Theft Auto VI's mesh programs read a material index from a vertex
colour's alpha as `v_mul_legacy_f32 255.0` then `v_cvt_u32_f32`. A
quotient one ulp low truncates to the code below (the 16-bit codes above
did), so another material is picked.

What changed: for formats up to 16 bits per channel the quotient
a / (2^n - 1) is worked out from integers: Q = floor(a * 2^32 / d) as
a * K plus a correction (none when n divides 32), rounded to 24 bits up
exactly when its highest dropped bit is set (the quotient is never
exact, so never a tie), and that integer, at most 2^24 and so exact as a
float on any host, scaled by a power of two. The reference is the exact
quotient rounded to the nearest float, which removes the dependence on
how the host rounds a division or converts a large integer (WARP rounds
integers above 2^31 otherwise). Signed formats convert their magnitude
the same way; their two lowest codes stay -1.0. The 11- and 12-bit
widths, whose smallest codes need more bits, are rounded fully in
integers.

Cost: about 18-21 DXIL operations a channel where the division was 2 (a
division by a constant more where n does not divide 32), so a 4-channel
8-bit fetch is about 80 operations instead of about 12. The car body's
mesh program grows from 4,616 to 5,103 instructions (+487 for about 23
normalized channels). In the title it is not measurable: in a run of
the intro cutscene with this commit (cost2, on the previous main
4015a182), on world windows with no pipelines being made, the frame
median was 881 ms and the GPU 349 ms a frame (median 335), against
1,013 and 389 (365) for the same tree without it (s1a). Two runs of one
tree have differed by 132 ms of GPU a frame, so the difference is
within run-to-run noise.

Evidence: tests `normalized_buffer_formats_load_correctly_rounded_quotients`
(every 8- and 10-bit code and a 16-bit sample, unsigned and signed,
bit-exact on hardware and WARP; it failed on the RX 6700 XT before, at
8-bit code 3) and `normalized_codes_truncate_back_to_themselves` (the
title's truncation gives every code back; 16-bit code 257 came back as
256 before). Offline, the integer arithmetic as emitted matches the exact
quotient for every code of every width 2 to 16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit da82e444ec)
Adapt VIctory 5c4c685, a1a2077, and 67e8ae1 for the Vice-Tay loader and shader harness. Apply the Direct3D 12 self-copy guard from fxceless a253706.
Adapt the Windows regression and recovery behavior from VIctory PR #2716.
A wave64 program on a 32-lane host runs each console wave as two host
waves. In a group of several console waves, each console wave takes a
wave-wide branch on its own, so a group barrier inside the branch waits
for waves that never arrive. The two host waves of a console wave now
meet through an LDS counter of their own instead: the first to arrive
spins until the other does, with a spin limit so a missing partner
gives wrong values rather than a hung GPU.

Programs named in VICTORY_WAVE_WIDE_ONLY whose LDS already fills
32 KiB place these dwords over their last ones (6b82bc7d uses its LDS
as a bitset that is read from the start).

Offline on an RTX 4090, 8 of the 9 WaveSize 64 compute programs the
driver refused or translated approximately now translate, validate and
create pipelines; 02384a60, 6b82bc7d and f133e35e are new. 2da4beb3
still fails: it builds a sampler inside a region it can skip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6c79b662d5af028521e09b4e7d30c327b7cd1f0d)
docs/wave64-on-wave32.md: why the driver refuses WaveSize 64, how the
translator places a console wave on two host waves, the wave-wide form,
pair meetings for groups of several console waves and the LDS budget,
the switches, the first room's programs with their state, offline and
live results, known gaps and the test. The README's shader row links it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 5791d723b2ea8f5b6fe40196b5121592c61378be)
The raw descriptor sync reads each changed 64 KiB heap page and called
mirror_copied for each of its 2,048 records, locking the made and copied
tables per record, though most records of a written page are unchanged.
It now compares the page's records with the kept ones under one lock and
mirrors only those that changed.

In the first room the sync took 38 ms a frame on the submitting thread;
with this change 29 ms, and the frame rate went from 6.5 to 7.1 FPS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit ebc4fec22af3ce8bec4a0c6261bae6c56fee873d)
docs/descriptor-sync.md: what the sync does and why, its cost per frame
in the first room, the change in this branch with measurements on two
bases, VICTORY_HEAP_SYNC and its effect, the frame log line and the
tests that cover it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b880e4b49a14348a8b53908cc88e95cee1d0db15)
- The SCC of a lane-mask operation joined at a skip was refused with the
  same words as a mask read as a number, which the local forms take: the
  two need different fixes, and a log could not tell which stopped a
  shader (f133e35efed2a48a). It now says "an SCC of a lane mask
  exchanged where not every lane runs" (the suffix keeps the retries).
- With VICTORY_WAVE_WHY, the translator's WAVE64 lines carry no hash and
  came from translations on several threads; translations then run one
  at a time, each between two lines naming its shader.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
(cherry picked from commit ef9d37b12a7270c050e3f194bd9507c1582adeb2)
The frame line's "dropped N without a host pipeline" (~344 a frame in a
release run) counted every draw and dispatch dropped, whatever the
reason: pipelines with no host pipeline, stages of the ray-tracing
structure builder while it is off, binds refused, index buffers without
a host copy, rectangles not expanded, mesh dispatches switched off. A
line per period now gives them per frame by reason, so the next run
shows which one to fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
(cherry picked from commit dd12b04f6c803bce475697ce52f3ca9a9421e954)
The frame line's "buffer views left null as the host would refuse them"
grew by about four a frame in a release run, and only the first of each
call site was logged. An empty view loses nothing; a raw view that
starts off 16 bytes (one logged: 184 dwords from dword 2) or a view not
on an element of its copy hides data the title wrote, and views of
memory with no host copy were not counted at all. Each null view is now
counted by reason, the first of each reason logged with its fields, and
the frame line gives the split next to the old total.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
(cherry picked from commit 642b4724803d0991b8824ee622b2b7e529fca682)
The title calls device methods 0x1c8 and 0x218 thousands of times (over
16,384 and 2,048 in a release run) and goes without the pipelines they
fail to make, which may be details missing from the image. Only the
first 16 words of a few descriptions were logged, not what they point
at, and whether the title then makes the same pipelines through the
standard methods was not known.

- The doc of unknown_pipeline says what the logged descriptions held.
- The first calls of each slot and the first two of each layout log
  every blob a description points at (bytes and a hash), up to 48 calls a
  slot, and every 1024th call logs the count.
- Pipelines made through the standard methods (0x50, 0x58, 0x1f0, 0x2b0)
  are counted, and apart when the same thread's last unknown call came
  just before (under 20 us, 200 us, 2 ms, later): a fallback shows about
  one per failed call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WFqqAvbrdcaXe2SvGb2y64
(cherry picked from commit c5c4816fdbe2f44c7832abda44e1f7c103b2dc5d)
- The unknown pipeline dump reads only committed, readable memory with no
  guard page: its pointers are guessed, and the in-process copy took a
  guard page's one-shot exception, disarming the title's guard. Test:
  a_guessed_read_leaves_a_guard_page_armed.
- The dump looks at the first 256 calls of each slot, falls back to the
  slot's shortest description (12 words for 0x218), keys graphics layouts
  on the first two groups only, logs words up to the last present group
  and leaves groups out of compute lines.
- Standard pipeline methods are counted once they made a pipeline, timed
  from when the title called; the first ones, and the first that follow an
  unknown call, are logged.
- A dispatch with a graphics pipeline is counted as a pipeline of another
  kind; a host list without mesh dispatches has its own reason; indexed
  rectangles without a host pipeline count as no host pipeline. The drop
  line gives the counts beside the rates, and the frame line no longer
  calls every drop a missing pipeline.
- Buffer views: empty views are counted first, views of a format with no
  element size count as typed, and each reason is logged once for shader
  resource views and once for unordered ones.
- Docs: VICTORY_WAVE_WHY slows pipeline making; the unknown pipeline notes
  say what this build logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3151af7023d62fefbf476df9081526bb4e6bdfb5)
On the host, wave operations leave a pixel shader's helper lanes out: in a
waterfall loop they read no lane, took whatever descriptor that gave and ran
to the loop limit. Triangle edges on skin and car paint; time lost per draw.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit fe0506aeb484289987239f8280182d6b7bb59f61)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 2b3c339ef155d5798312d653db0d1a4fa0eee371)
Adapt the CPU fallback from Marvisak/VIctory@8ff7913 with its regression test. Keep the existing geometry shader.
Adapt VItoriaBr ed6e5af for the Vice-Tay descriptor path, using the existing staging size limit.
Port the synthetic pixel fixtures from Marvisak/VIctory@4015a18.
Comparing two settings by starting the game twice costs about three
minutes per run to load the same scene, and lands on a different moment
of it. Live switches change while the title runs.

- live.rs: a Live switch reads its environment variable once; with
  VICTORY_LIVE=<file> a thread reads NAME=VALUE lines from that file four
  times a second and overrides it. A check is one atomic load; each
  change is logged as "live switch NAME=VALUE".
- VICTORY_HEAP_SYNC and VICTORY_WIDE_REFRESH are live.
- VICTORY_METER_MS sets how often the frame line is logged (5 s by
  default); 1000 logs every second's numbers.
- docs/live-switches.md: use, method, which switches are live, results.

In one session on the first room, VICTORY_HEAP_SYNC on against off over
three 20-second cycles: 6.7 FPS (148.5 ms) against 8.2 FPS (121.8 ms),
49 one-second samples per state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit d0a7e237af28fc8c1713092b4b6971919c724368)
Upstream keeps clippy::all and undocumented_unsafe_blocks at warn and its
CI denies warnings; this fork let nine lints through. The workspace lint
table is upstream's again, and the code passes it without changing what
it does:

- 34 unsafe blocks get their own SAFETY comment (most repeat a group
  comment Clippy did not count; seven are new, written from the code).
- 19 complex types get names (ByteRanges, SharedRanges, Totals,
  HandleKey, LdsMeet, local aliases in tests).
- Equivalent rewrites: saturating_sub, as_chunks, iterator loops and
  fill, byte slicing of a string, a match arm that reads the same with
  and without diagnostics, a test value that was always 1.

CI also runs on pushes to main, as upstream's does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 4931ba125eaa0caed0d573ef0c966fa390236c00)
Two places the PR #6 diagnostics added that upstream's lints flag: the
LAYOUTS static's type gets a name, and a test's zeroed
MEMORY_BASIC_INFORMATION gets its SAFETY comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c8954d557fd5c77abbe2015e02e1908270e90e4f)
Links the notes on live switches, the raw descriptor sync and 64-lane
programs on 32-lane GPUs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 858dd6f0a2f95853e31e87a3762fc24c63a93f72)
Comments named eleven of the title's shader programs. Upstream's asset
policy keeps every piece of the game out of the repository, its text
included; the comments now say what each program does, with its hash
where they had one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 722c34df2f96fa6f939f8e52afb30df8643a46d8)
Integrate the upstream history at 13f91ca. Keep the fork interfaces for overlapping descriptor, GPU queue, texture, and shader changes.

Port DirectStorage page submission, scalar v_readlane EXEC handling and temporary storage for large texture reads with regression tests.
README.md is upstream's (13f91ca), title included, with two sections of
our own added after its status: the development PC and the local test
results. docs/ is upstream's: architecture.md takes its text back, and the
fork's notes (descriptor sync, live switches, wave64 on 32-lane hosts, ray
tracing) and CONTRIBUTING.md are removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI runs on pull requests and on pushes to main, as upstream's does; the
fork's extra branch and manual trigger are gone. victory.example.toml takes
upstream's text back. Outside the code, only the README's development PC
and local test results now differ from upstream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stabilize timing-sensitive Windows tests
Revisit placed texture slots once after dropping remap ranges, including completed uploads. Consume the overflow flag and queued ranges under the same lock.

Based-on: 56bb7c30

Co-authored-by: PastiiJay <[email protected]>
Reuse command-list scratch chunks for aligned texture uploads and retain each host pipeline and root-signature pair once per recording.

Based-on: https://github.com/Belobug/VIctory-Belobug-AMD/pull/30

Based-on: https://github.com/Belobug/VIctory-Belobug-AMD/pull/25

Co-authored-by: romainhedouin <[email protected]>
Comments in lower.rs, lower_tests.rs and wave64_tests.rs still named
three of the title's shader programs. The asset policy keeps all of the
title's text out of the repository; they are described instead, with
their hashes where they had one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With pair meetings (a group of several console waves on a 32-lane host),
`mask_dword` and `scc_some` move the halves' exchange to the current
block. `fill_phis` calls them after every block is lowered and closed, so
the exchange split the closed last block and failed the assertion in
`split_before` (a panic the shader cache took as a failed program, which
also skipped the other forms). Such a join is now refused with its own
reason, `PAIR_PHI`, and the other forms are tried. The redirect is also
skipped in local mode, where nothing meets.

Test: `an_scc_joined_after_a_wave_wide_skip_in_pairs_is_refused_not_a_panic`
(a wave64 SCC join after a wide skip in a group of 128); it panics at
`bitcode.rs:509` without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shortcut that puts the halves' counters over the last dwords of a
program whose own LDS fills the host's 32 KiB ran for every wave64
program under VICTORY_WAVE_WIDE=1, in every form, and for programs with
more LDS than the host has. It now needs the wave-wide form (pair
meetings), a program the caller named (`wave_wide_here`, not the global
switch), and the program's own LDS within 32 KiB, so its accesses stay
in bounds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A host wave whose partner left the program (at the loop limit, say) spun
the full 2^18 reads at every other meeting. A wait that runs out now sets
a bit in the console wave's counter, and later waits pass at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CPU rectangle expansion chose the right angle per vertex-buffer slot,
from that slot's own elements. A slot without a float position (colours
alone) fell back to corner 1, so its attributes went to the wrong corners
of the second triangle when the position's right angle was elsewhere.
The right angles now come from the slot that holds the position, for
every slot of the draw, and all slots are checked before any expansion
is recorded.

Test: `every_slot_takes_the_right_angle_of_the_position`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`current` fell back to the next older version on any I/O error. A
manifest held by another process then served a stale save, and the next
write dropped the newer version. Only a missing manifest, an unparsable
one or a missing blob count as damage now; other errors are returned, as
upstream does. When every version is damaged the container is refused
with InvalidData instead of the last error, so a missing manifest no
longer reports the container as absent.

Tests: `a_locked_newer_version_refuses_instead_of_serving_an_older_one`
(Windows; it fails with the old fallback) and
`only_damaged_versions_are_refused_not_absent`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A read of the VICTORY_LIVE file that failed (while it is rewritten) was
taken as an empty file, so every switch it named fell back to its
environment value for a quarter second and the flip was logged. The
values now stay. VICTORY_WIDE_REFRESH's comment says what turns it on:
any value but 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Recover texture remaps and reduce command-list allocation overhead
Rewrite the Vice-Tay README with current benchmarks
Document Vice-Tay on my PC and benchmark setup
VICTORY_KEYS_FILE=<file>: a script writes lines `<key> <seconds>` into the
file, and the next input poll (at most 50 ms later) holds each key that
long, focus or not, then removes the file. A measuring script can answer
the account screen's prompt or turn the camera while someone else uses the
desktop; the keyboard path needs the title's window in front. Unset,
nothing is read. Scripted keys (this file, and VICTORY_KEYS in diagnostics
builds) now reach the pad in every build.

Test: `a_keys_file_holds_each_key_for_its_seconds`. Live: three first-room
measurements passed the account screen with the desktop on another window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
386e885 ran 30 min 12 s in the world on the RTX 4090, from the cell into
the robbery, median 7.0 fps over 1,629 one-second samples. It was closed by
hand when the process reached 36 GB of private memory, which is now the
limit on session length. The cold-cache launch keeps its own heading so its
0.8 fps cinematic figure is not read as play speed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The key was the BLAKE3 of our executable, so every rebuild started with a
cold cache even when the translator had not changed: the 30-minute session
counted 0 hits and 3,249 translations. The key is now the translator's
sources (victory_shader::SOURCE_HASH), this file (which holds the entry
encoding) and the same translation settings as before (loop limit, group
sync, the wave64 switches, the clean-up passes). Upstream keys its cache the
same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A CPU profile of the 30-minute session put Mutex::lock_contended at the top
of all five threads that record the title's command lists. The largest
caller (2,762 samples in 60 s) was HostHeap::mirror_words, which took the
heap-wide lock of made records on every bind, even when the slot was
already made from the record the draw read, which is nearly always.

The made records and the kernel snapshot's records are now atomics. A bind
that finds its slot made from the same record, with the snapshot in
agreement, returns the view without a lock. Everything else (making,
nulling or letting go of a slot) still runs under one lock, `making`. A slot
reads 0 while it is being made, so a draw that reads it in that window
takes the lock and waits instead of using a half-written slot. The frame
line now counts the binds that took the fast path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XAsyncComplete held the call's `done` lock while the title's provider
ran OP_CLEANUP. A cleanup that waits for a worker thread which is itself
completing the same call (it took the call before the cleanup removed
it) deadlocked: the worker blocks on `done`. The first completion now
claims the call with an atomic flag and runs unlocked; the status is
still published after the cleanup, while the block is valid, and `done`
is set only for the waiters.

Co-authored-by: Claude Opus 5.5 <[email protected]>
XMemFreeDefault released 32-bit allocations with a bare VirtualFree, so the
write guards and tracked pages over them outlived the memory. When a later
allocation took the same address, the GPU side copied from stale tracking
or changed the protection of memory that was no longer the title's. The
free now reports the whole allocation (every region with its base, since
guarded pages split it) as remapped before releasing it, and the alloc
reports the new range.

Ported from Marvisak/VIctory#2824, adapted to our watch module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The in-process copy that replaced ReadProcessMemory catches a guard page
fault and fails the copy, as the kernel's read did. Raising that fault
clears PAGE_GUARD, though, so the title's own first touch of the page (a
stack growing into it, for one) later found no guard. The handler now sets
the flag again over the page's current protection; the direct copy test
checks it.

From the guard page part of PastiiJay/klbf-lab#34.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every texture the title sampled kept a staging buffer the size of the whole
texture for as long as it was sampled; only textures idle for 10 s gave it
back. A VirtualAlloc trace from launch to seven minutes into the world put
6.6 GB of the process in these buffers (4,616 of them), the largest share
the layer itself holds.

The buffer is now optional. Once a texture's upload ran, nothing changed it
for 2 s and 30 frames, and no list holds its staging, the buffer goes and
its record (hash, write-watch state, flags) stays, so an unchanged texture
is neither detiled nor uploaded again. The next detiling makes a new buffer.
Detiling holds the buffer's lock while it writes, and a list that records an
upload keeps the buffer alive until it is reset. VICTORY_STAGING_KEEP=1
keeps every buffer as before. The per-second texture line and the
diagnostics memory line count the buffers alive, let go and made again.

Ported from PastiiJay/klbf-lab#23, without its tile-residency condition
(we have no tiled levels).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`lookup` looked at the 64 buffers starting nearest below an address. With
more short buffers than that above the start of a long one that holds the
address, the long buffer went unfound and the ask fell to a loose window,
a second host copy of the same bytes that the long buffer's own copy never
sees. `in_place_let_go` had the same blind spot at 256.

The buffer map now keeps the long buffers (over 64 KiB) in a second index
by start, with their ends. A search checks the nearest buffer, then the
short ones that start within 64 KiB below, then the long index. Letting go
of in-place copies on a remap walks the same two ranges, so it stays
bounded while seeing every buffer that overlaps.

Ported from brunofgmag/victory-fork#1142.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the bind fast path, the next lock the list-recording threads met was
the view table's: view_at took it to clone the view a record names, and
every record of a view took it too, even when the view had its entry long
ago. It is a read-write lock now. Lookups (view_at, a view or a placed
shape that is already in the table, the memory line) share it; only a new
entry or shape and a released resource take it alone.

A correction to the previous commit's message: the buffer map fix came
from fxceless/victory-fork#1142.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A check of view memory copied every clean block number of the range into
a list before seeing whether all of them were clean, which they nearly
always are (some 150,000 blocks a frame). It counts them first now and
builds the list only when one is not. Asking which pages were written
no longer collects them into a list before noting them in the journal.

From the write-watch part of fablinoo/kelvaroq 0053.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each landing split the whole list of objects waiting for submissions into
two new vectors, tens of thousands of entries at a time. A VirtualAlloc
trace counted some 400 MB committed and freed that way in 36 seconds of
play. The finished ones now move into a list the landing thread keeps,
the waiting list keeps its room, and both are dropped or reused in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every merge of a card copy-back piece cleared its scratch list and zeroed
it again to the piece's length before reading title memory over all of
it. The read fills every byte it is given, so the list now only grows
when a piece is longer and keeps its bytes otherwise. The kernel read
used when direct copies are off counted a read that stopped short as a
success; it fails now, as a short direct copy does.

From LooperSalty/AnyXboxX 021c8309.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The present shows the whole resource of the first plane. The title's
plane record also carries a source rectangle; when it asks for part of
the resource, the rows past it are not part of the picture, which could
be the corrupted band at the bottom of some scenes. The present now logs
the plane count, the rectangle and the resource size whenever they
change, so the next run says whether that is the case.

The record layout is from fablinoo/kelvaroq 0049.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A texture refresh holds title memory still so that no page goes under its
read, and held it through the hash of the whole texture and the detiling.
The title's page remaps wait for every refresh under way. With the switch
the refresh copies the bytes out, lets go, then hashes and detiles the
copy. Off by default until it is measured here.

From edsuuu/VI-BR-PORT ac1d2945.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each page remap joined and split placeholders, mapped the view and
committed its pages: four calls that each hold the address space, some
850 times a frame while the title streams. With the switch the view is
mapped first and the placeholders are fitted only if that fails, and a
section page committed once is not committed again (one bit a page per
section). Off by default until it is measured here.

From edsuuu/VI-BR-PORT 80eb362e.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three test sessions ended a few minutes into the world with "window
closed" and no one meaning to close them. Windows does not say who sent a
message, but it does say whether it was sent from another thread (and
whether that thread waits) or posted, and which process owns the window
in front. The close handlers now log both, so the next such close points
at its sender.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:31 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:08 UTC · original

+59k/-32k across 117 files is a whole-fork diff, not a reviewable change - same shape as #2643. If this carries real fixes, please split them into focused PRs; as-is nobody can verify what it does.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2758#issuecomment-7173246739) +59k/-32k across 117 files is a whole-fork diff, not a reviewable change - same shape as #2643. If this carries real fixes, please split them into focused PRs; as-is nobody can verify what it does.
Author
Owner

@⁠NovNovikov on GitHub · 2026-11-25 21:00 UTC · original

Sadly ground braking changes like this will not be recognized. You should advertize your own fork instead of trying to improve the upstream

**@⁠NovNovikov** on GitHub · 2026-11-25 21:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2758#issuecomment-7174485106) Sadly ground braking changes like this will not be recognized. You should advertize your own fork instead of trying to improve the upstream
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 21:16 UTC · original

Thanks for taking a look, @⁠kotekompotek. That's fair. This PR is too broad to review as a single change. The XGameSave fix is available separately in #2716, with its own regression tests.

Thanks for the suggestion, @⁠NovNovikov. I posted a Vice-Tay update with my test setup, the results for each build, and the rendering issues I still see.

**@⁠TaynanGT** on GitHub · 2026-11-25 21:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2758#issuecomment-7174863283) Thanks for taking a look, @⁠kotekompotek. That's fair. This PR is too broad to review as a single change. The XGameSave fix is available separately in [#2716](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2716), with its own regression tests. Thanks for the suggestion, @⁠NovNovikov. I posted a [Vice-Tay update](https://github.com/TaynanGT/Vice-Tay/discussions/17) with my test setup, the results for each build, and the rendering issues I still see.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:14 UTC · original · edited 2026-11-26 01:14 UTC

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: 32 files, among them README.md, crates/victory-gpu/src/resource.rs and crates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2758#issuecomment-7177311821) · edited 2026-11-26 01:14 UTC <!-- victory-triage v1 head=79cc404d270aa898e0f827df25821a14087aee95 verdict=needs-rebase at=2026-11-26T01:14:34Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: 32 files, among them `README.md`, `crates/victory-gpu/src/resource.rs` and `crates/victory-shader/src/emit/lower.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot closed this pull request 2026-11-26 08:25:14 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2758
No description provided.