Upstream: 31 conflicting fixes ported by hand (stacked on #653) #716

Open
github-bot wants to merge 149 commits from github-bot/gh-716 into main AGit
Owner

@⁠coderanonymus on GitHub · 2026-11-25 05:27 UTC · original
coderanonymus:upstream-ports → main · +12072 −1413 · 99 files · 149 commits · open

Stacked on #653, which brings over the 113 upstream fixes that apply cleanly. Please merge that one first; this PR's own commits are the 34 after it.

Rebased on main (a26859f)

Rebased with #653 onto a26859f. The port of 4ab20fc (indirect budget charged in record order) is dropped. a26859f rewrote the same clamp shader, and I won't merge two rewrites of it without a run. Everything else applied. Clippy passes with and without --all-features on a clean build, Linux tests (263) pass, and so does the asset policy.

Why

#653 left out the upstream commits that conflict with the fork. Most of those are fixes inside code the fork rewrote. This PR ports them by hand, so the fork has them without a full upstream merge.

What

  • 31 commits, one per upstream commit.
    • Each keeps its upstream author and names its upstream sha (cherry picked from or ported from).
    • Each has a Port notes paragraph saying what differed on the fork and how it was resolved.
    • By area: GPU 13, shaders 11, loader/app/input 7.
  • Already in the fork, so not ported: 705a2f6 (micro-tile runs), 12eba49 (whole-wave EXEC constants), f821cb9 (parallel library loads), f47ebd8 (cache invalidations as no-ops), 1e923ad (WAVE_OPS for lane_bit), 4e60ea3 (indirect drop before clamp), 42363ab and ccfb029 (shader tests skip without a GPU). The fork has each in its own form; the reviewers checked each claim.
  • Three commits of mine:
    • The asset policy check failed with all ports together. emit/lower.rs reached 525,703 bytes, past its 512 KiB limit, so repository_passes_policy failed. Its test module moves to emit/lower/tests.rs. The move is byte-for-byte, apart from one level of indentation (checked with diff). Upstream has started splitting emit/lower/ the same way.
    • Shaders, host waves of 32 that don't exchange. A console wave64 program can run there as two halves, and lane_bit then tests the low dword in both host waves. atom() now refuses an opaque mask there, and a constant one unless its two dwords are equal. The ported v_cndmask_b32 change refuses its own paths the same way. The atom() hole was already on main, for example a compare ANDed with a constant feeding a select. Test: a_constant_select_mask_on_host_halves_is_refused, with five cases, all of which translated (wrongly) or reached the wrong path before.
    • The ported mesh test now says why it skipped a device, as the other skip sites do.

How it was made and reviewed

Ultracode workflow:

  • One agent per upstream commit (or chain of dependent commits), each in its own worktree.
  • A skeptic reviewed every port, and one repair round followed where needed. 4 ports were approved after repair. 2 were rejected, and I fixed them by hand:
    • copy-no-region: a wrong comment.
    • the v_cndmask_b32 constant masks: the half-wave miscompile above.
  • The stacked branch then had a fresh review of the two fixed ports, plus three area reviewers looking for interactions between the ports.
  • That review found the atom() hole, fixed above, and two small slips, fixed in the last commit. It found no other interactions between ports.

Some of these ports may overlap open fork PRs, judged by title only: #165 (Staging::detile), #325 (frame waits), #97 (DirectStorage page 0; d09f3aa itself was left out for that reason).

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features, for x86_64-pc-windows-msvc (cross-checked from Linux): clean on the stacked branch.
  • Linux tests: victory-shader 194 pass, 3 ignored. xtask passes, including the asset policy. formats, core, pipeline and game pass.
  • Not run: the Windows and GPU tests, or the game. Several ports add Windows tests (crash log, title copies, DRED breadcrumbs, upload scratch, mesh primitives). Those were type-checked, and their reviewers reasoned through them against the fork's code. Their first real run will be CI on Windows.

No game data used; the game isn't named in the tree.

Ported (upstream sha, author)
  • f5cb5ff Capture startup breakpoint diagnostics (Peter Bonanni)
  • a3acc87 Check the required startup archive before executing Series 1.0.2.1 (Peter Bonanni)
  • e5b7159 Shaders: walk a lane-mask diagram once in vars and given (TG0000)
  • 810f442 GPU: a frame wait takes its tick before it sleeps (Manuel Pérez)
  • 882664e GPU: keep the frame wait's tick for the diagnostics log (Manuel Pérez)
  • 64484b4 Input: apply VICTORY_KEYS to a connected host pad too (Alpaca-exe)
  • 7f00a62 Crash reports: name the host's CPU and Windows build (Duff)
  • b58d198 GPU: copy into title memory without asking for its region first (jsthope)
  • 3f5eff5 input: with no device, previous and next readings walk every device in time order (b000m)
  • 691236d GPU: align appended input-element offsets like D3D12 (JFIREonFIRE)
  • 6526965 GPU: find a list in the DRED breadcrumbs by its name, not only its pointer (OpenBot)
  • 8a358e3 GPU: find the lists in the DRED breadcrumbs by position when the debug layer hides them (OpenBot)
  • 52d528b GPU: match a breadcrumb node's name followed by the debug layer's note; drop the position fallback (OpenBot)
  • c430b1d Shaders: tbuffer_load_format_d16 loads pack two 16-bit channels per VGPR (Duff)
  • 645391b Shaders: a normalized buffer format's ends load as exactly 1.0 and -1.0 (Duff)
  • f177aae Shaders: cap BDD memo table and bail out early on overflow (Yaekai)
  • 5d6889e Shaders: lower v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32 and v_msad_u8 (Rareuncommon)
  • 67c4f53 victory-shader: resolve Structured::other and constant masks in v_cndmask_b32 (bartikele)
  • 59035de GPU: grow per-list upload scratch on demand (Launch)
  • 100de0e Shader tests: a skipped device says why it was skipped (skl)
  • e52777a GPU list: bind initial pipeline state in create_list and create_list_x (给伊莉雅补魔)
  • f096774 GPU: throttle failed swap-chain creation and resize (Aws)
  • 4fc9d70 GPU: keep Staging::detile inside the staging buffer and harden committed() (HailLucifer666)
  • c0228d9 victory-shader: mask mesh primitive vertex indices to 9 bits (drop edge flags) (tjthebigbearcat-hub)
  • 13185f5 GPU: GetDeviceRemovedReason reports the host device's state instead of E_NOTIMPL (BastienRdz)
  • e29391f Shaders: honor op_sel, omod and clamp on v_interp_p2_f16 (Calvix2k)
  • 0601955 Shaders: a helper lane's v_readfirstlane reads its own value (Vax)
  • ed0dbfd GPU: copy title writes under ranges a submission's shaders write (Kevin Pratap Sidhu)
  • 146dfef gfx10: resolve the opcode name once, at decode time (pes7)
  • 0de9efc Loader: clzero loops in one exception; rdpru (Maledetto)
  • 514927d Loader: tests for the clzero loop edge cases (Maledetto)

🤖 Generated with Claude Code

**@⁠coderanonymus** on GitHub · 2026-11-25 05:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/716) `coderanonymus:upstream-ports` → `main` · +12072 −1413 · 99 files · 149 commits · open Stacked on #653, which brings over the 113 upstream fixes that apply cleanly. Please merge that one first; this PR's own commits are the 34 after it. ## Rebased on main (a26859f) Rebased with #653 onto a26859f. The port of 4ab20fc (indirect budget charged in record order) is dropped. a26859f rewrote the same clamp shader, and I won't merge two rewrites of it without a run. Everything else applied. Clippy passes with and without `--all-features` on a clean build, Linux tests (263) pass, and so does the asset policy. ## Why #653 left out the upstream commits that conflict with the fork. Most of those are fixes inside code the fork rewrote. This PR ports them by hand, so the fork has them without a full upstream merge. ## What - **31 commits, one per upstream commit.** - Each keeps its upstream author and names its upstream sha (`cherry picked from` or `ported from`). - Each has a *Port notes* paragraph saying what differed on the fork and how it was resolved. - By area: GPU 13, shaders 11, loader/app/input 7. - **Already in the fork, so not ported:** 705a2f6 (micro-tile runs), 12eba49 (whole-wave EXEC constants), f821cb9 (parallel library loads), f47ebd8 (cache invalidations as no-ops), 1e923ad (WAVE_OPS for `lane_bit`), 4e60ea3 (indirect drop before clamp), 42363ab and ccfb029 (shader tests skip without a GPU). The fork has each in its own form; the reviewers checked each claim. - **Three commits of mine:** - **The asset policy check failed with all ports together.** `emit/lower.rs` reached 525,703 bytes, past its 512 KiB limit, so `repository_passes_policy` failed. Its test module moves to `emit/lower/tests.rs`. The move is byte-for-byte, apart from one level of indentation (checked with diff). Upstream has started splitting `emit/lower/` the same way. - **Shaders, host waves of 32 that don't exchange.** A console wave64 program can run there as two halves, and `lane_bit` then tests the low dword in both host waves. `atom()` now refuses an opaque mask there, and a constant one unless its two dwords are equal. The ported `v_cndmask_b32` change refuses its own paths the same way. The `atom()` hole was already on `main`, for example a compare ANDed with a constant feeding a select. Test: `a_constant_select_mask_on_host_halves_is_refused`, with five cases, all of which translated (wrongly) or reached the wrong path before. - The ported mesh test now says why it skipped a device, as the other skip sites do. ## How it was made and reviewed Ultracode workflow: - One agent per upstream commit (or chain of dependent commits), each in its own worktree. - A skeptic reviewed every port, and one repair round followed where needed. 4 ports were approved after repair. 2 were rejected, and I fixed them by hand: - copy-no-region: a wrong comment. - the `v_cndmask_b32` constant masks: the half-wave miscompile above. - The stacked branch then had a fresh review of the two fixed ports, plus three area reviewers looking for interactions between the ports. - That review found the `atom()` hole, fixed above, and two small slips, fixed in the last commit. It found no other interactions between ports. Some of these ports may overlap open fork PRs, judged by title only: #165 (`Staging::detile`), #325 (frame waits), #97 (DirectStorage page 0; d09f3aa itself was left out for that reason). ## Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`, for `x86_64-pc-windows-msvc` (cross-checked from Linux): clean on the stacked branch. - Linux tests: victory-shader 194 pass, 3 ignored. xtask passes, including the asset policy. formats, core, pipeline and game pass. - **Not run:** the Windows and GPU tests, or the game. Several ports add Windows tests (crash log, title copies, DRED breadcrumbs, upload scratch, mesh primitives). Those were type-checked, and their reviewers reasoned through them against the fork's code. Their first real run will be CI on Windows. No game data used; the game isn't named in the tree. <details><summary>Ported (upstream sha, author)</summary> - f5cb5ff Capture startup breakpoint diagnostics (Peter Bonanni) - a3acc87 Check the required startup archive before executing Series 1.0.2.1 (Peter Bonanni) - e5b7159 Shaders: walk a lane-mask diagram once in vars and given (TG0000) - 810f442 GPU: a frame wait takes its tick before it sleeps (Manuel Pérez) - 882664e GPU: keep the frame wait's tick for the diagnostics log (Manuel Pérez) - 64484b4 Input: apply VICTORY_KEYS to a connected host pad too (Alpaca-exe) - 7f00a62 Crash reports: name the host's CPU and Windows build (Duff) - b58d198 GPU: copy into title memory without asking for its region first (jsthope) - 3f5eff5 input: with no device, previous and next readings walk every device in time order (b000m) - 691236d GPU: align appended input-element offsets like D3D12 (JFIREonFIRE) - 6526965 GPU: find a list in the DRED breadcrumbs by its name, not only its pointer (OpenBot) - 8a358e3 GPU: find the lists in the DRED breadcrumbs by position when the debug layer hides them (OpenBot) - 52d528b GPU: match a breadcrumb node's name followed by the debug layer's note; drop the position fallback (OpenBot) - c430b1d Shaders: tbuffer_load_format_d16 loads pack two 16-bit channels per VGPR (Duff) - 645391b Shaders: a normalized buffer format's ends load as exactly 1.0 and -1.0 (Duff) - f177aae Shaders: cap BDD memo table and bail out early on overflow (Yaekai) - 5d6889e Shaders: lower v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32 and v_msad_u8 (Rareuncommon) - 67c4f53 victory-shader: resolve Structured::other and constant masks in v_cndmask_b32 (bartikele) - 59035de GPU: grow per-list upload scratch on demand (Launch) - 100de0e Shader tests: a skipped device says why it was skipped (skl) - e52777a GPU list: bind initial pipeline state in create_list and create_list_x (给伊莉雅补魔) - f096774 GPU: throttle failed swap-chain creation and resize (Aws) - 4fc9d70 GPU: keep Staging::detile inside the staging buffer and harden committed() (HailLucifer666) - c0228d9 victory-shader: mask mesh primitive vertex indices to 9 bits (drop edge flags) (tjthebigbearcat-hub) - 13185f5 GPU: GetDeviceRemovedReason reports the host device's state instead of E_NOTIMPL (BastienRdz) - e29391f Shaders: honor op_sel, omod and clamp on v_interp_p2_f16 (Calvix2k) - 0601955 Shaders: a helper lane's v_readfirstlane reads its own value (Vax) - ed0dbfd GPU: copy title writes under ranges a submission's shaders write (Kevin Pratap Sidhu) - 146dfef gfx10: resolve the opcode name once, at decode time (pes7) - 0de9efc Loader: clzero loops in one exception; rdpru (Maledetto) - 514927d Loader: tests for the clzero loop edge cases (Maledetto) </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- indirect.rs: the timing rig kept the written depth view it never reads
  after setup; drop the field.
- draw.rs: the scissor census sorts by a reversed key.
- resource.rs: placed_filler_twins is read only by the diagnostics
  build's copystat; allow it to be dead without the feature, as
  shadow and pipeline do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A frame that ends in a packet where no frame begins (the tail of a frame that crossed packets, then padding) left the next frame pointing into that padding, which ended the stream early. Now the next frame is found by following each packet's skip to the next packet with frames.

(cherry picked from commit ba42db643c15c1b7fb17ba40464dddda36c1db60)
Our own completions looked their call up again by block address: after a
provider's DoWork returned, after a cancel, after a failed begin, and when
queued DoWork ran. A provider usually ends its call itself (XAsyncComplete
from DoWork or Cancel), and once it has, the title may begin a new call on
the same block, from its completion routine or from a thread that polls
the status. The lookup then found that new call:

- the old call's DoWork result (S_OK, size 0) or cancel (E_ABORT) ended
  the new call before it had done anything, ran its cleanup and fired the
  completion routine a second time;
- DoWork still queued for a canceled call ran the new call's DoWork.

Each queued DoWork now carries the call that scheduled it and runs only
while that call is still the block's, and DoWork, cancel and begin
complete that call. A call that is already over ignores a second
complete, so nothing reaches the next call. XAsyncComplete itself still
goes by block, as providers name their call by its block.

(cherry picked from commit d01b17070d)
Fail when a requested scan root cannot be opened. Report traversal errors below a readable root alongside the other skipped inputs.

(cherry picked from commit b1bdd8994a)
A callback submitted with a delay waited on a thread of its own and was
delivered when the delay ran out, whether or not the queue had been
terminated meanwhile. XTaskQueueTerminate only canceled what was already
in the ports, so a pending delayed callback was not canceled: it ran
later as live work (canceled = false), after the termination callback,
by which time a title may have freed what the callback uses.

The queue now keeps its delayed callbacks in a list until their delay
runs out. Terminate cancels them along with the queued ones, before it
calls the termination callback, and a delay that runs out after that
finds nothing to deliver. A submit racing Terminate checks `terminated`
under the list's lock, so the callback is either canceled or refused.

(cherry picked from commit b9ff219826)
`victory run GTA6.exe`, run from the game folder, gives an exe path with
an empty parent, and that empty folder was mounted as G:. An empty path
cannot be made absolute, so the root stayed empty and G:\x64\a.rpf
became \x64\a.rpf: the root of the current drive. The title then found
none of its files.

An empty root is now the current directory, which is what an empty
folder means everywhere else (`Path::new("").join("x")` is `x` in the
current directory). Passing a path with a folder in it is unaffected.

(cherry picked from commit 01ae55a3ba04c39a0e8851cc00da16af7a49adbd)
imdct_half worked out every pre- and post-rotation with sin_cos on each
call (n of them per subframe) and ran its FFT on two fresh Vecs. The
rotations, the bit-reversed order and the butterfly rotations now come
from a table built once for 128, 256 and 512 samples; the work buffers
live on the stack. Every value is computed with the same expression (the
butterflies with the same running product), so the output is bit for
bit what it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 4eb0898b3cbd6d0bbbffad540aca5d7e3531ac58)
Decoder::decode took the caller's bit count as the end of the frame. Past
the data the bit reader returns zeros, and a stereo tile header reading
only zeros gives the subframe to no channel, so it never moves on; with a
count beyond the data it never overreads either, and looped for good.
Clamp the end to the bits the data holds. A frame from read_frame always
holds its bits, so its decoding does not change.

Add deterministic noise tests (xorshift64, fixed seeds, as BCPack's):
buffers of noise packets, streams of noise frames with clean and damaged
headers, frames in mono and stereo at each sample rate, bit counts past the
data, and read_frame and packet at any offset. Every walk is bounded and
every decode must give one frame of samples. The bit-count test hangs
without the fix; the others pass on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit d4d1822049fed053c6188ea0b016b0976a71bf41)
GetModuleFileNameA/W on the host clears the thread's last error when
the name fits, and code tells a truncated name from a whole one by it
(grow the buffer while the last error is ERROR_INSUFFICIENT_BUFFER; or
fail if it is, also when the name filled the buffer exactly). Our
answer for a title image set the error when the name was cut and left
it alone otherwise, so after one call with too small a buffer, or
after any earlier call on the thread that left 122, a whole name still
read as truncated.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 3c7d845b3b)
When a frame ended a loop, decode cut it at the loop's end subframe, set
the loop's skip (the subframes of the loop's first frame that lie before
the loop) and then took that skip out of the frame in hand: the loop's
last. So the head of the last frame was dropped instead, and the first
frame played from its start, with the audio before the loop in it. The
number of samples came out the same; the seam did not.

The pending skip is still applied to the frame in hand, and the loop's
skip is set after it, for the frame decoded next.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 985d8d4b025384b5f13a3177ef906c8b6cce6840)
The source resolver's rule (local files only) knew a share as `\..`,
`//..` or `file://server/..`. The host knows more spellings: any two
leading separators (`/\server\share`), the object manager's prefix
(`\??\UNC\server\share`), and a `file:` URL with no host whose path
starts with two separators (`file:////server/share`,
`file:\server\share`, also percent-encoded). Those fell through as
relative paths or drive-less local files and went to the host's
resolver unchanged.

They are refused now, naming the server. Paths with one leading
separator, a drive after the slashes or the prefix, and the path of a
URL that names this machine pass as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 11ca3ce492)
(cherry picked from commit e57e76a7b4)
Stack dumps (VICTORY_STACKS, diagnostics builds) read another thread's
TEB right after NtQueryInformationThread and suspended it only later: a
thread exiting in between frees its TEB, and the read faults. The
thread is now suspended first and resumed on every way out.

The dump times went through Duration::from_secs_f64, which panics on
`inf` or `1e20`, killing the dump thread (the crash hook logs it as a
crash). They are parsed by `schedule` now, which leaves out NaN and
times no Duration holds. 1 new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit acdcc41687be2ecd2bf2efc43ab7449329483382)
Calls are filed by their block's address, and a call that succeeded with
a result stays filed until XAsyncGetResult takes it. XAsyncBegin refused
any block whose address had a call filed. So when a title never took a
result and freed the block, the next block it was given at that address
could not begin a call: E_INVALIDARG, every time, with the old call's
provider never cleaned up.

A zeroed block is a new one: the block of a result left behind holds the
result's size, so it never reads zero. XAsyncBegin now ends a finished
call filed under the address of a zeroed block (its provider gets its
cleanup) and begins the new one. A call still in flight keeps its
address, and a block still holding a result is refused as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 5cff0007a5)
The decoder fills an XMA voice's output ring until the write block
(word 0, bits 27-31) comes round to the title's read block (word 9,
bits 0-4). The write block wraps modulo the ring size (word 0, bits
22-26), and so does a read block moved on by command 18, but a read block
the title set up at or past the ring's end was compared as it was: no
write block ever equalled it. With a stream that loops forever the pass
never ended, holding that voice's lock, so the title's next command on
the voice (advance, disable) waited for good, and releasing the context
arrays did too.

Take the read block modulo the ring size as well, as the write side
already does. A test sets up read block 6 on a ring of four with an
endless loop and requires the pass to end within seconds, with blocks 0
and 1 filled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1054fe87de08038e887d6f7c6f44e5b07ac7a9f9)
No graphics object's interface list holds IUnknown, so QueryInterface
for it (and every call that hands out an object by interface id) said
E_NOINTERFACE and returned null. COM code asks for it to compare two
pointers for identity, to keep an object as a plain reference, or to
pass it on to an API that takes any object.

object::is, which all of those go through, now also matches IUnknown.
The DXGI device answers with the D3D12 device, which it already stands
for: one pointer whichever of the object's interfaces is asked.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 92f2c60c8159e34a47570aa81f3d25624cc6db5c)
XStoreQueryPackageIdentifier documents E_INVALIDARG for a store id that
has no installed package. We returned XPackage's 0x89245208 instead.

(cherry picked from commit e3bef08985)
host::module held the module cache's lock while it called
LoadLibraryExA. Loading a DLL that is not loaded yet takes the OS
loader lock, and title code runs under that lock too (a title DLL's
thread attach, TLS callbacks run as threads start), where it can need
the cache: any first use of a host! function, or a late-bound title
DLL. One thread holding the cache and waiting for the loader lock,
another holding the loader lock and waiting for the cache: the process
hangs, and cannot even exit, as ExitProcess needs the loader lock too.

The cache is now looked up, then unlocked for the load, then locked
again to keep the handle; a thread that loaded the same DLL meanwhile
got the same module, which stays loaded.

(cherry picked from commit c6959acba3)
(cherry picked from commit 93a24b7cdaeb0e7f132f711e9cbd9ba405b0f639)
The MicrosoftGame.config reader ended a tag at its first '>', but XML
allows '>' unescaped inside an attribute value. A value with one
(DefaultDisplayName="A > B") cut the tag short: its '/>' was never
seen, so the element stayed open and every element after it was read
as its child. Game/TitleId and the storage quota were then not found,
and the title ran as id 00000000 with no storage quota, its saves and
temporary files in that folder, without a warning.

A tag now ends at the first '>' outside quotes.

(cherry picked from commit d549b6397e)
Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e6ebec9ccf)
XGameUiShowTextEntryAsync documents a 1024-character maximum on console,
1024 for a maxTextLength of 0, and 1024 for the Password scope whatever
the title asks. 0 meant no limit here, larger limits were kept and the
scope was ignored.

(cherry picked from commit 936e5e51c9)
A slice may not start at null, even an empty one, so asking for a title
image's name with (NULL, 0) was undefined behaviour; a debug build
aborted the process. A null buffer is now no buffer: nothing is written,
0 is returned and the last error is ERROR_INSUFFICIENT_BUFFER.

(cherry picked from commit c000581df2)
A literal is 32 bits; in a 64-bit operand the hardware sign-extends it
when the operand is signed (i64) and zero-extends it otherwise (LLVM's
AMDGPU operand rules). Every literal was zero-extended, so
v_cmp_lt_i64 v[1:2], -100 compared with 4294967196, and so did the
other i64 compares, v_ashrrev_i64 and s_ashr_i64.

Literals of operands of i64 instructions are now sign-extended, in the
vector and the scalar paths.

(cherry picked from commit 7d049431de9b12873d801de2b8a54ab4007fcde9)
(cherry picked from commit e6fe8ecbf8)
(cherry picked from commit 2c22e2b2d2)
(cherry picked from commit a3f89eda54)
(cherry picked from commit 75fe6c02b2)
(cherry picked from commit b956320125)
A refused XMemVirtualAlloc or XMemAllocDefault handed the title a null in
silence, and the title then writes at null plus an offset, which reads
like a title bug. In #289 the faulting write is at 0x217800, the
request's length 0x2173a0 rounded up to 2 KiB, so the base it built on
was most likely such a null.

At the commit limit, XMemVirtualAlloc now writes the same crashes.log
report the physical-page commit writes since #51 (the shared part is
`commit_refused`); other refusals, and a host heap out of memory, are
warnings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 65062e133c)
The write block (context word 0, bits 27-31) was used as it is for the first
block of a pass, so one at or past the ring size (bits 22-26) was written
past the ring's end, possibly into another APU allocation, before it wrapped
with (write + 1) % size. Take it modulo the ring first, as the read block is
taken, and as advance_read does.

(cherry picked from commit 7a5d85e6a2867081ed54515ce7f33bae3fcb643d)
(cherry picked from commit b796c8b8b80cfa4506f254474ab9fd7260bfd8e6)
An instruction guard depends on its EXEC and the reachability of its block. Keep the most recent result, including an elided guard, rather than repeating the same BDD queries for consecutive vector instructions. Scalar instructions still bypass guard selection.

Cover EXEC changes across and within a branch with a synthetic shader. Add a CPU-only guard_runs benchmark for unmasked, short, and long masked runs.

(cherry picked from commit 81b81df351)
The run check split on every byte that is not alphanumeric or +/=, so
b"\x4d\x5a..." broke into 3-character pieces and an xxd -i style
[0x4d, 0x5a, ...] array into 4-character pieces. Either form of up to
about 100 KB of copied bytes passed the check and the pre-commit hook.

Also count the hex digits of \x escapes and 0x literals that have only
commas, whitespace or backslashes between them, and flag the file when
that passes the same 512 limit. The largest such run in the tree is 36
digits. Decimal arrays are still not caught.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e950e81756)
Six diagnostic switches (VICTORY_D3D12_DEBUG, _GBV, _DRED, _WARP,
VICTORY_GPU_TIMING and VICTORY_DUMP_TARGETS) were on whenever their
variable existed, so VICTORY_D3D12_WARP=0 still selected the software
adapter. They now go through one helper that reads a value other than 0
as on and an unset variable or 0 as off; every other value keeps the
meaning it had. The README says so above its switch table.

(cherry picked from commit a4974e4c21)
The disassembly text showed operands that some instructions lack, and
dropped VOP3P negation that applies to one half only:

- s_memtime, s_memrealtime and s_get_waveid_in_workgroup printed the
  unused SMEM base and offset.
- A global or scratch access with no SGPR base printed `null`, not `off`.
- A MUBUF load with lds printed the unused vdata as a destination.
- VOP1 SDWA printed src1_sel, though VOP1 has no second source.
- VOP3P ops other than v_fma_mix with only neg_lo or only neg_hi set on
  a source printed as if the source were not negated. These now get
  LLVM's neg_lo:[..] and neg_hi:[..] suffixes; a source negated in both
  halves keeps `-src`.

Expected operands come from llvm-mc -mcpu=gfx1030 (gfx1010 for
s_get_waveid_in_workgroup). Only the text changes; translation reads
Fields and is unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 6325df752c5638365c3e5a2b2f827ba0f3f145cb)
translate writes emitted DXIL and validator reports to the
VICTORY_EMIT_DUMP directory. Both are derived from the game's shaders,
but the directory was never checked against the source tree. With
VICTORY_EMIT_DUMP=. run from the checkout, the .txt reports land in the
repo, and git and cargo xtask policy both let them through.

Check the directory once at the start of translate::run, as Config
already does for the cache and data directories.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 988fd9a647)
(cherry picked from commit 350f91c23a9402b2a556a84c208a80030910ae3f)
(cherry picked from commit 43e2ca9de2)
(cherry picked from commit e34cb5396a)
(cherry picked from commit efe102edac86f365a9951f3c92228413cbee8e46)
(cherry picked from commit 7216ab7113)
Preserve stale staging files left by interrupted writers and retry a bounded number of atomic create_new attempts. Propagate unrelated I/O errors immediately. Add deterministic CPU regressions. AI-assisted.

(cherry picked from commit a32eacdd5e)
(cherry picked from commit aaacc2dcfe)
Co-Authored-By: GPT 6.2 Sol <[email protected]>
(cherry picked from commit 64b80c3109)
(cherry picked from commit 121412bec21b0790d04d56399f49e2d140652864)
Co-Authored-By: GPT 6.2 Sol <[email protected]>
(cherry picked from commit 3e98bd7e0ce79762162ac958e3ab67cc85de00c9)
(cherry picked from commit 6d174aeeeb93669ab9f43ff01b24963933433af8)
(cherry picked from commit c1c32819e90155967ad03f076a94b62fbf44a403)
SDATA on s_atc_probe and s_atc_probe_buffer is a 7-bit immediate, the buffer resource is four dwords, and GLC/DLC are not operands of either.

(cherry picked from commit 3d71ad1a6547836ac1dbd19bfab2d759c965d307)
(cherry picked from commit 072fde01acd3d4f6b7d0aa3dd61b559154c1047b)
(cherry picked from commit 131944d02d)
(cherry picked from commit 0be58e62d2)
The PE-specific export table stores one name per address-table slot, so when two names alias one ordinal the earlier name is silently dropped from ImageInfo and from victory inspect --exports. Use the generic Object::exports iterator instead, which yields every named export and then ordinal-only entries, and map its target and flags back to our representation. Add a synthetic PE regression with two names for one ordinal plus a separate export.

(cherry picked from commit d0dd9fc5c0)
write_if_changed used a shared <hash>.tmp file, so two concurrent cold launches of the same image could truncate each other's staging bytes or fail the rename after the other had published. Move publication into a portable module that stages under a unique pid/sequence name and removes it on failure. Two hermetic tests cover concurrent publishers and a failed rename.

(cherry picked from commit 1aac20aa8fd97237053c985b942225d54c0194a7)
elements() took field text up to the next '<', so a generator comment before the value made TitleId, StoreId or SizeMB empty. Skip comments while gathering the text. Add a regression with comments inside all three fields.

(cherry picked from commit ca362a4247)
runtime stores an absolute image path while relaunch_args searched raw CLI arguments for exact text, so a relative launch argument made XLaunchNewGame silently rerun the old title. Normalize the argument the same way runtime does before replacing it. Also split the title's quoted config args into proper arguments instead of split_whitespace. Add a regression covering a relative startup path, a different target and quoted/empty args.

(cherry picked from commit 71e88665c4)
Windows command lines quote only with double quotes. split_args treated an apostrophe as a quote too, so -name=O'Brien swallowed the following argument. Only toggle on ", and add the apostrophe case to the relaunch test (review note on #455).

(cherry picked from commit eb8067f2ea)
`resolve` canonicalizes the longest existing prefix and re-appends the rest, but it walks up with
`Path::file_name()`, which is None for a trailing `..`. A path such as `<tmp>/a/../b` (nothing exists yet) hit the
`_` arm and returned PolicyError::Io, so a cache_dir or data_dir with a `..` in a directory that does not exist yet
was rejected, and `normalize`'s `..` handling for the missing tail was never reached.

A trailing `..` is now kept in `rest` so `normalize` resolves it lexically.

Test: resolves_dot_dot_in_a_path_that_does_not_exist_yet (fails before, passes after). cargo test -p victory-core,
cargo fmt --check and cargo clippy --tests are clean.

(cherry picked from commit 52f0a099ede8aa4d5bde61a0c46963a77a4378ba)
(cherry picked from commit fd44561ea1180aff5380285527fb8cac8195f4e8)
emulate_amd_only copies only the bytes left in the faulting page and
gated clwb_len on n >= 15 because clwb_len took a fixed [u8; 15]. A
4- to 10-byte clwb starting in the last 14 bytes of a page (or falling
back from a clwb_loop that straddles the page end) was therefore
skipped, leaving pre-Ice Lake Intel CPUs with an unhandled
STATUS_ILLEGAL_INSTRUCTION.

Change clwb_len to take &[u8], bounds-checking each byte read and
returning Some(len) only when len <= code.len(), and drop the n >= 15
guard in emulate_amd_only.

Fixes #924.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 60d2cf9cbcf5a2abc773d5de10c3c892e77d3340)
(cherry picked from commit 246ecea963)
(cherry picked from commit 45ed8e3242f49ac164943fce5f42cc2546f61239)
(cherry picked from commit 8d67fa5b00eb6714c5ac71e9d01172cc6cdbcf08)
(cherry picked from commit 534e1dd74c)
Read complete payload bytes directly inside an XMA2 packet. Keep the bit reader for packet headers, interleaved stream skips and the final partial byte. Add coverage for all eight alignments at packet boundaries and EOF. On Windows x86-64, 36,720 synthetic reads matched the previous implementation, including returned bytes and the next frame position. A release microbenchmark of read_frame measured 1009 to 168 ns for 128-byte frames and 7977 to 1062 ns for 1 KiB frames (median of nine runs).

(cherry picked from commit 03a6f22906b4372ec08d003e9103997659647b0f)
(cherry picked from commit 259ba31e28ca4ceb379682d6383c3b6f75bad014)
(cherry picked from commit 8610ffb85baedbc7b8c4c9de1222b0911e00e589)
(cherry picked from commit e3c9dd0d53)
(cherry picked from commit ef0c3e9449)
(cherry picked from commit 41b2472e134c8f402cacc011001dec1a8ca294e4)
With TdrLevel 0 Windows never resets a hung GPU: a slow or hung world
frame freezes the whole desktop, and the runtime never sees a device
removal it could report (#1054). With 1 the timeout is a blue screen.
Both are set by hand, often to keep slow frames from being reset, and
reports of "the PC froze" do not say so.

When the host device is made on a hardware adapter, read TdrLevel,
TdrDelay and TdrDdiDelay from HKLM\SYSTEM\CurrentControlSet\Control\
GraphicsDrivers, log them ("default" where a value is not set), and warn
for TdrLevel 0 or 1 with what to set instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 42961e8e57)
Closing the window never suspended Grand Theft Auto VI: its suspend
routine waits for a state that only its constrained-change routine
starts, and RegisterAppConstrainedChangeNotification bound to the host's
version, which never calls it. Every close ended in the one-second
deadline.

Register constrained-change routines here and run them (constrained)
before the suspend routines (quiesced), as the console does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a7847a5201)
Getting started names Rust (pinned in rust-toolchain.toml) without saying
how to get it. Add rustup through winget or rustup.rs, that the pinned
toolchain then comes on the first cargo command, and the MSVC C++ build
tools the Windows target needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 098a26aad5)
Microsoft's XAsyncCancel reference says: "If the XAsyncCancel function
is invoked for an asynchronous call that has already completed, nothing
happens."

A call that completed successfully with a nonempty result stays in
CALLS until the title reads the result via XAsyncGetResult, so
XAsyncCancel still found it and invoked the provider with OP_CANCEL
before XAsyncComplete returned early on call.done.

Check call.done under its lock in XAsyncCancel and return immediately
when the call is already complete, dropping the lock before invoking
the provider.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 44ce06784b)
(cherry picked from commit 47c00d5ea6ef8095adbe9681ea2f549ae4d7b8e6)
(cherry picked from commit 142ec8dd45)
The high dword of the 48-bit product whose low dword v_mul_u32_u24 and v_mul_i32_i24 already give: the low
24 bits of each operand, zero- or sign-extended, through the existing mul_hi.

The test module gets lowers_valu, a one-thread compute program with root constants in v1..v4 and a buffer
store of v0 (built with lower_with), so a vector instruction can be checked for lowering without a GPU.

AI-assisted (Claude Code).

(cherry picked from commit 344704e02850eb227fe61d4fd54e6657c17ea68d)
(cherry picked from commit 643fc6dfecffbd06de7313897b7d4bc4ffef6564)
(cherry picked from commit 64a33ec757)
(cherry picked from commit 4f54c47755)
(cherry picked from commit 1ed26e50d860f328cd42c640bc12486f65603995)
(cherry picked from commit 32eb934959)
(cherry picked from commit 5c44562868df4c33cce60488132d83cf5ff02f30)
DXGI's R8 typeless family is R8_UNORM/UINT/SNORM/SINT (formats 61..=64). The
family() table folded A8_UNORM (65) into R8_TYPELESS (60), so an R8 view of an
A8 host texture passed the family(view) != family(own) check in fits() and was
silently rewritten to A8's format. A8 cannot be cast to R8 in D3D12, so such a
view must be rejected instead. Drop 65 from the range; it now maps to itself.

(cherry picked from commit 97c8783f4a)
The opcode was registered but fell through to the integer path and failed
to lower. It converts the low four bits of src0 as a signed 4-bit integer
and divides by 16, ignoring the upper bits. Sign-extend the nibble, convert
to f32 and multiply by 1/16; all sixteen results are exact.

The test runs every nibble value plus values with junk in the upper bits
and compares the f32 bit patterns.

(cherry picked from commit 78c12677e54f3aa901c089059e170ccf6a57ae78)
(cherry picked from commit e45bacd12fd320077a5dfcd421361a51efcd8a3c)
(cherry picked from commit 4e155a36ad728e1a21e7253ff4097af06582a45f)
(cherry picked from commit 2b13ae4192)
Query OPTIONS19 in the shader host and retain the previous linear-mip approximation when anisotropic point-mip filtering is unavailable. Preserve comparison/min/max reduction and LOD bounds. Add tests for supported and unsupported capabilities, all reduction modes, and unrelated filters.

Validated with 4 sampler tests, 123 all-feature shader tests (1 benchmark ignored), shader/GPU all-target/all-feature Clippy with warnings denied, and asset policy. No in-game validation claimed.

(cherry picked from commit 23fc8a55e803b5721076f59f27c019441af1f2bd)
Apply the same OPTIONS19 capability check and filter fallback in the production GPU pipeline as in the shader host. Unsupported or older runtimes retain the prior linear-mip approximation instead of receiving an unsupported static-sampler filter.

Validated together with the shader-side changes: 123 all-feature shader tests passed (1 benchmark ignored), shader/GPU all-target/all-feature Clippy with warnings denied, and asset policy.

(cherry picked from commit 7dfa86fa39ec77ff12df9b44f4e0bd436442d236)
Reduce each group of four bits to one bit and preserve the scalar condition code.

(cherry picked from commit c3a04e2e4164523f38ffceec23509a0ba4316856)
Check both mask widths, the condition code and the zeroed upper destination.

(cherry picked from commit e3fe5bf94f848c2a6ca36900c2dfa70342083109)
(cherry picked from commit a7636dd7b1)
Handle scalar and two-channel UNORM inputs and signed normalized inputs.

(cherry picked from commit 6f36cdf982)
(cherry picked from commit be3202de393b71c9385f74b587256b01b48f7f63)
(cherry picked from commit 711d651ccab7673e5ab4365bd692294e954c845f)
(cherry picked from commit 2286e038cc606809869a7d7d577c470d059bc268)
(cherry picked from commit 9ccb83c00a9b0ee5121e4a9b2f6c0ee223630c84)
(cherry picked from commit 274f6988c9779b0612186c3448123e5e157d56e4)
The layouts follow AMD's addrlib, but the tests only checked them
against themselves (every element on its own address) and a few
hand-worked offsets. Two tests now pin them to addrlib itself
(Mesa src/amd/addrlib at ed09d38, Navi 21 settings):

- layouts_match_addrlib: 21 descriptions over every mode Layout::offset
  addresses (linear, 256 B, 4 KiB and 64 KiB S and D; 1-16 byte
  elements, block compression, arrays, mip tails, 2D and 3D), each
  with addrlib's surface size, first tail mip and a hash of the
  address of every element.
- deep_volumes_keep_their_chain_in_each_slabs_tail: a 16x16x64 volume
  whose chain is all in the tail (addrlib's mipChainInTail), with
  explicit addresses: each 16-slice slab has its own tail block, and
  mip 1's 32 slices span two of them.

Over a wider sweep (about 20,000 descriptions, every mip count for
volumes up to 256 deep) main matches addrlib exactly in size, tail and
every address compared. A tail-entry rule that also requires a mip's depth to
fit one slab changes 5,456 of 14,780 volume layouts (5,087 grow, by
up to 5x) and moves their addresses; both tests fail with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f078008b112343b6e68c8ca72b884073064320c1)
fence.rs already implements ID3D12Fence1::GetCreationFlags at slot 11
(0x58), but FENCE_IIDS only listed ID3D12Fence and PAGEABLE_IIDS, so
CreateFence and QueryInterface rejected ID3D12Fence1 with E_NOINTERFACE.

Add ID3D12Fence1 (433685fe-e22b-4ca0-a8db-b5b4f4dd0e4a) to FENCE_IIDS
and add a unit test covering creation, QueryInterface, and
GetCreationFlags.

Co-Authored-By: Gemini 4 Neon <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit bbdc3ca7249948b7624ba65f4282615caef895b8)
(cherry picked from commit 3f6910ac3201f8c5a59e65e55420f5e74f2e494e)
A package copied without the DLLs that ship beside the executable leaves
every import from them unbound, and the title stops at its first call into
one: Grand Theft Auto VI 1.0.2.1 at +0x2237178 during System Init (#930,
#1553, #8), with nothing saying why.

After mapping the title DLLs, name the main image's static imports that
must come from the title's folder (neither the host nor our runtime serves
them) but were not mapped from it. Print them; when executing with the
default trap policy, stop before running title code. With
`--unimplemented zero` the title still runs (stubs were asked for).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e9cb14ad3e)
save() releases LAST and library locks before calling write_atomically(), which always wrote to the same fixed host-pipelines.tmp path. Concurrent worker saves and shutdown save(true) can truncate or unlink each other's temp file on Windows.

- Serialize write_atomically() with a mutex and unique per-call temp filename (.tmp-<pid>-<n>), cleaning up the temp file on rename failure.
- Add a 4-thread concurrent write_atomically stress test.

(cherry picked from commit be824d9d218320c71f2623ed4b14045210785db5)
(cherry picked from commit eb7cc2d43711e806bbd8578d4ef75bde30326c20)
A title makes its window on one of its own threads and reads its messages
only when that thread reaches its PeekMessage loop. In slow frames and
loads that is seconds apart, so the system shows the busy cursor over the
window and a click turns it into a "Not responding" ghost.

A top-level title window is now made message-only (it can never be shown),
and a stand-in window with the title's text, style, icon and fitted size is
made on a thread of ours that does nothing but pump its messages. The
title's ShowWindow shows the stand-in, its window text follows, closing the
stand-in suspends and ends the title as before, the keyboard window menu is
still refused, and the stand-in goes when the title's window does. Frames
are presented to the process's visible window, now the stand-in; input is
unaffected, since titles read it through GameInput, not window messages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 9145d9d3da)
(cherry picked from commit 6493dd93100cd8a8f1e20138a4b3f85b477f9c9b)
(cherry picked from commit 8d3a025df199e6e26ccb404d4cf0f172fdde8b1c)
(cherry picked from commit 40f30be0b52ff0866fbdafb7944bb595ceae4e98)
A title that ends itself when its main loop has not ticked for a while
runs on through slower frames.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 532cb7cdfe)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 224e7869f0)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 70564ae08c)
Recovery took any name `v<digits>` as a version, so a leftover `v01`
next to a committed `v1` parsed as version 1, and the cleanup rebuilt
the name as `v1` and deleted the committed save (#870). A correctly
named but unreadable newer entry (an empty `v2`, a file, a broken
manifest) did the same: `v1` was pruned as older, the read failed, and
the next update committed a fresh `v1` holding only the changed blobs,
which the following read pruned again.

Now only `v<N>` exactly as `commit` writes it is a version. `current`
takes the newest version whose manifest reads, removes only versions
below it, and leaves unreadable newer entries alone. An update goes
above the highest version name present, so a stray entry neither hides
the save nor blocks writes. With no readable version at all, reads and
updates still fail and nothing is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b8dbcba260)
- descriptor/host.rs: the fork's cap on the dynamic-slot search was the
  ring's length, which cut off the n - 1 slots upstream's wraparound fix
  adds; the cap is lifted (the 'enough' gate stays), so a free run across
  the cursor is found, as upstream's new test expects.
- host.rs: late_stage() reads VICTORY_GPU_TIMING the way timing() now
  does, so VICTORY_GPU_TIMING=0 no longer turns off late waits and the
  relay while timing itself is off.
- The title is not named in the tree: four comments from the picks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f5cb5fff65)

Port notes: the fork's vectored handler first emulates console-only
instructions (console_insn, clzero/monitorx/mwaitx, clwb, SSE4a) and
returns early when it does; the breakpoint opt-in check now follows that
emulation, reading the exception code once. The README no longer names
rpcrt4.dll as an expected refusal: the fork serves rpcrt4's GUID calls
as a pseudo module, so loading it is not refused here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a3acc87c96)

Port notes: applied without conflicts on top of the previous port. The
fork's run() also checks the CPU's AVX2 first and returns the title's
exit code; the archive check sits between the two as upstream placed it
(before mapping, with --execute only), and title_dir moves up the same
way. Upstream adds no test and none is added here: the check lives in
the Windows-only app crate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bools::vars kept the nodes and variables it had seen in lists and scanned
them for every node, quadratic in the diagram's size; it now uses a set
that scans a short list while it is small and hashes once it grows.
Bools::given cofactored the diagram once per decided atom, each walk with
a fresh table; cofactors of different variables commute, so it now
replaces every decided atom in one walk. Equal functions are equal nodes,
so the results are the same nodes as before.

(cherry picked from commit e5b715983242c8c31296d3195dce74a22792d72d)

Port notes: the Bools code (vars, restrict, given) was unchanged on the
fork and took upstream's change as is; the fork's extra given() callers
(the SCC lane mask) keep their signature. Only the tests conflicted:
upstream's new tests and the fork's mask-phi tests were both appended at
the end of the tests module; both are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
frame::wait marked the tick it waited for as taken (LAST) only after
the sleep, outside the clock's lock, so two threads waiting for one
event kind at once both got the same tick and both returned on it,
against the module's once-per-tick rule (an origin wait then begins two
frames in one interval). next_tick now takes the tick under the clock's
lock when the wait comes within its time-out; a time-out takes none, as
before.

Port notes: the fork's wait() also ends a blocking wait at once on a
tick that passed untaken (a frame longer than a tick; VICTORY_LATE_WAITS=1
opts out), reading LAST after next_tick. Once next_tick takes the tick,
that read would always see the tick just taken, so the late-wait step
moved into next_tick, before the take and under the same lock; it takes
the earlier tick with a zero wait, as before. wait() keeps its
diagnostics counters. Like upstream, this commit alone does not build
with --features diagnostics (the debug log names tick); the next port
fixes it.

(cherry picked from commit 810f4422c763fe2904495919eed248d972b3f9cb)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit dropped the tick next_tick returns, but the
diagnostics build's tracing::debug! still names it (E0425). Bind it
again; it is unused without the feature, so that lint is allowed there.
Reported by Sunkiller-qc and r4tedx. cargo check -p victory-gpu passes
with and without --features diagnostics.

Port notes: applied cleanly on the previous port. The fork's
diagnostics counters in wait() use only wait and limit, so tick stays
used by the debug log alone, as upstream.

(cherry picked from commit 882664e13cfa557fb46d41e182c3267b01097485)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 64484b426ba8e5f9571c6398ab33ea573997d4d7)

Port notes: the fork already pressed the first pad's buttons from the
scripted keys, inside Host::pad, for slot 0 only and buttons only.
Upstream's merge in Hub::poll covers that (same FALLBACK_BUTTONS table
via fallback(), on the first connected slot, plus triggers and sticks),
so the fork's slot-0 block is replaced by it instead of kept twice. The
key_state comment keeps the fork's wording (the title).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Whether a crash is a missing instruction depends on the CPU (Intel CPUs
lack some of the console's AMD-only instructions), and which D3D12
runtime there is depends on the Windows build, yet a report carries
neither, so every report has needed a follow-up question.

Unhandled exceptions, panics and host GPU failures now end with a
"host:" line naming the CPU's brand string and the real Windows
version (RtlGetVersion), read once when the crash log is set up.

(cherry picked from commit 7f00a62a4b861f0a051cc600470ce0570ab43c6f)

Port notes: only Cargo.toml conflicted, because the fork added the
Win32_System_Performance feature next to upstream's new
Win32_System_SystemInformation; both are kept. crash.rs applied as is:
every crash path the fork has (panics, log_crash for host GPU failures,
the commit-limit message and thunk failures, unhandled exceptions)
already went through title_output(), so all now end with the host line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream stopped asking VirtualQuery about a title destination before
each copy (copy_mapped asks only once the kernel copy has failed) and
moved the copy-back (write_mapped) off WriteProcessMemory, which asks for
the destination's region before every piece. Two tests run both copies
against reserved memory with a committed block on each side of a hole.

Port notes: the fork already had the fix itself. copy_mapped asks a title
destination only after its kernel copy failed (VICTORY_COPY_ASK=1 asks
first), and write_mapped writes through NtWriteVirtualMemory rather than
WriteProcessMemory (VICTORY_DIRECT_WRITES=0 goes back), so the code paths
are kept as they are. This ports upstream's two tests unchanged and its
doc comments on copy_mapped and read. Those, and the comment in
copy_mapped's body, still said a title destination not all mapped is left
alone (it now takes nothing from its first unmapped page on; with
VICTORY_COPY_ASK=1, nothing at all) and that read's destination is always
mapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3f5eff57603270823920e15b93479dc168b08eb9)

Port notes: the only conflict was the shortcut comment upstream deletes,
which the fork had reworded to not name the title; it is deleted here too.
The walk and its test are upstream's unchanged; the fork's other edits to
this file (comment wording, the diagnostics-only scripted keys on the real
host's first pad) are kept and do not touch the fake host the test uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GraphicsState::elements()` placed an element with
`D3D12_APPEND_ALIGNED_ELEMENT` right after the previous one. D3D12 (and
vkd3d) start it at the next multiple of min(4, its size), so after a 1- or
2-byte element (R8, R16, R8G8...) the offset was too small. The host
pipeline gets the title's descriptions unchanged, so only the offsets
read here were wrong: the rectangle-list expansion read the fourth
vertex's attributes from the wrong bytes.

An explicit offset near 4 GiB also overflowed the next appended offset
(a panic in debug builds); it now saturates.

Tests: `appended_elements_are_aligned` and
`a_huge_explicit_offset_does_not_overflow` fail without the change.

Port notes: the `elements()` change applied unchanged (the fork's
function was identical to upstream's). The fork's host.rs already has a
`#[cfg(test)] mod tests` (pipeline-library and depth-bounds tests), so
upstream's new tests module was merged into it instead of being added as
a second module.

(cherry picked from commit 691236d606)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The device-removed report matched a breadcrumb node to a submitted list by
comparing `as_raw()` of the list with the node's `pCommandList`. On an
RTX 4070 no node ever matched, even without the debug layer: every list
was reported as `None`.

With device-removed data on, each host list is now named ("victory host
list <n>") when it is made, and a node is also matched by the name the
runtime copied (`pCommandListDebugNameW`). The pointer is still compared
first, against every interface pointer our live list answers with (its
own, IUnknown, ID3D12Object, ID3D12DeviceChild, ID3D12CommandList). The
node's pointer is only compared, never dereferenced: a node may name a list
that is long released.

With the debug layer on (`VICTORY_D3D12_DEBUG=1`) the nodes still do not
match; that case is left open.

Port notes: the fork's make_list keeps its lazy prelude (the list's
prelude is made on first need), so only the id and the name are added
after it; the new helpers sit after the fork's Chunk type, next to its
Scratch, and the tests join the fork's host tests. The report's two
pointer comparisons are the same code on the fork and are replaced as
upstream does.

(cherry picked from commit 65269650fca8b6c93e089374f3e4db677446ce5d)

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream: with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_DRED=1 every
breadcrumb node still came out as `None`. Upstream opened every
submission with a sentinel list of 17 markers and, when no node matched
a list by pointer or name, took the nodes after the last sentinel as the
submission's lists in order (`positional`). It also named each list with
the private data keys for a node's ANSI and wide name, compared both name
fields of a node, and logged the last node's pointer and names when no
node matched.

Port notes: only the parts that upstream keeps are ported. Upstream's
next commit (52d528b) removes the sentinel list, the matching by
position, the "matched by position" note in the report and the private
data keys again (lists are named with SetName only), so they are left
out here: on the fork they would have had to reach every path that
reports device-removed data (`submit`, `relay_land` and `settle`), only
to be deleted. Ported: the report collects the nodes once and matches
each to a run once (used for the progress line and for the stopped
lists), `HostList::is_node` compares the ANSI name field as well as the
wide one, and the warning with the last node's pointer and names when no
node names one of our lists. Upstream's tests for this commit cover only
the removed sentinel and position code, so none are added; the ANSI name
test comes with 52d528b.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A run on an RTX 4070 with the debug layer on showed why a list's name did
not match a node: the runtime appends its own note to the name we gave,
as in "victory host list 158 (debug layer indirect)". The name now matches
exactly or followed by " (", and never as the start of another number
("victory host list 1580"). Both name fields of the node are read, as before.

That makes the sentinel list and the matching by position of the previous
commit unnecessary, so they are removed, together with the extra private
data keys it set: lists are named with SetName again. The warning that
logs the last node's pointer and names when no node matches a list stays.

Tests: the name with the note matches in the wide and the ANSI field, a
longer number and a name without the " (" do not; with the match for the
exact name disabled or loosened to a prefix, the tests fail.

Port notes: the sentinel list, the matching by position and the
private data keys this commit removes upstream were never ported to
the fork (see the port of 8a358e3), so only the match of the name
followed by " (" and its tests are added. One assert of the new test
is wrapped as rustfmt would. The fork's code now has the same
additions and removals as upstream's three commits together.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The d16 forms of the typed buffer loads return each channel as 16 bits,
two per VGPR, low half first; the decoder already sizes their data that
way. The lowering only treated `buffer_` names as d16, so a
tbuffer_load_format_d16_* went through the 32-bit path: the first VGPR
got channel x as a 32-bit value (the f32 bits of 1.0 instead of the f16
pair (1.0, 2.0)) and the other channels were dropped.

The format path now packs its channels for d16: integer formats keep
their low 16 bits, the other formats become f16 (as the MUBUF d16 path
converts them).

Port notes: the fork's buffer lowering has the byte and 16-bit
(`narrow`) accesses right before the d16 test, which conflicted; both
are kept, with upstream's d16 test for buffer and tbuffer names. The
fork's format_load is upstream's, so d16_channels and the test apply
as they are.

(cherry picked from commit c430b1de2ad4292ab05623b972d89d751978f0c9)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Buffer format loads divide a UNORM or SNORM field by its largest value.
A host may divide through a reciprocal and land just below 1.0: on an
RX 9070 (RDNA 4), 16_16_UNORM's 65535 loaded through the d16 path as the
half 0x3BFF instead of 0x3C00. The largest value now selects 1.0, and an
SNORM field's two lowest values select -1.0, as the formats define them.

Port notes: applied without conflicts on top of the d16 port; the
fork's format_load is upstream's.

(cherry picked from commit 645391bcce957054e39f2d3df52177062769283e)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f177aaeade9f658ee6f48b1927c7e2a23a1d83f9)

Port notes: the only conflict was the constants block, where the fork
added MAX_MEETS and the Meets struct for its memoised meet search;
MAX_MEMO now sits after MAX_MEETS. The ite and forget changes applied
unchanged: the fork's ite, mk and forget match upstream, and every
fork caller that reads `overflow` (structure_wide, the lane-condition
fixpoint, the exit lowering) still fails with TOO_LARGE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
src2 plus the sum of the unsigned differences |a - b| of the operands' bytes (v_sad_u8), halves (v_sad_u16)
or whole dwords (v_sad_u32), wrapping at 32 bits. v_sad_hi_u8 adds the byte sum shifted to the high half;
v_msad_u8 leaves out a byte whose mask byte (src1) is 0.

AI-assisted (Claude Code).

(cherry picked from commit 5d6889e8be76f630445a4057f81221b723898583)

Port notes: the lowering applied unchanged (same place, before the
min3/max3/med3 arm). Only the test conflicted: the fork has its own
buffer_cache_invalidations_lower_as_no_ops test at the spot upstream
added sums_of_absolute_differences_lower, so both are kept, the fork's
first. The fork's lowers_valu helper is the same, so the test needs no
change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Structurisation now exports the lane masks not derived from EXEC or VALU
results (`Structured::other`: uniform selects, constants, opaque values),
and `v_cndmask_b32` resolves its mask there and takes inline constant
masks: 0 is no lane, -1 every lane, another constant this lane's bit of
it where host lanes are the console's.

Port notes: the fork's v_cndmask_b32 already lowers a mask held as a
number in compute programs by reading the register pair at the use
(exact for wave64 halves written apart, refused in a half-wave); that
path is kept for masks in `other` that reach an opaque atom, directly or
through lane-mask joins (the walk `lane_constant_masks` does, now shared
as `mask_reaches`). Uniform and constant masks from `other` go through
`boolean` as upstream does, so they also work outside compute, and a
constant one without console lanes stops with "a constant lane mask"
instead of tripping `cross_lane`'s debug assertion. `other` is exported
without the split wave64 low dwords, as the fork does for `masks`.
Inline constant masks are taken only as integers (128..=208, as
structurisation reads them; a float constant's 64-bit form differs), and
another constant is refused in a half-wave as the fork's number path
does. Upstream's test selected on a mask from an unsupported s0 input
into a dead v1; it now enables TGID_X (s0 an input), makes the second
select read v1, and also checks that a constant naming lanes, inline or
in a register, is refused without console lanes. The shortcut note in
`lane_constant_masks` now says what an opaque mask only a select reads
still does in compute.

On host waves of 32 that do not exchange (a console wave64 run as two
halves), `lane_bit` takes the host lane, so both waves would pick a
constant's bits from the low dword. On the paths this change opens or
touches (an inline constant, a constant in `other`, and the fork's own
path for a mask held as a number, which checked only `local`), a
constant mask is refused there: "a constant lane mask in a half-wave".
The test a_constant_select_mask_on_host_halves_is_refused covers the
inline and held forms. The held form translated wrongly before this
change; the inline one was refused as an untracked mask. A mask in
Structured::masks reaches `lane_bit` through atom() too; the commit
"a constant or opaque lane mask on host halves is refused" closes that.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A list's scratch chunks now grow: each new chunk is twice the last, at
least what is asked, at most SCRATCH_CHUNK, instead of every chunk after
the first being 4 MiB. A length whose 256-byte rounding overflows gets
None instead of a debug-build panic or a wrapped, empty allocation.
Diagnostics builds log each chunk taken (target victory_gpu::scratch),
and a new chunk's buffer name carries its size, now that chunks come in
several sizes.

Port notes: reimplemented by hand; the fork's scratch is a different
design (chunks shared between lists through the Spare pool and given back
on reset, a 256 KiB first chunk, VICTORY_SCRATCH_POOL=0 for 4 MiB chunks
kept by their list). The growth applies to the shared chunks only and
starts from the fork's SCRATCH_FIRST rather than upstream's 64 KiB; sizes
are powers of two (upstream: multiples of 64 KiB) so that the pool, which
matches sizes exactly, keeps few size classes. VICTORY_SCRATCH_POOL=0
keeps 4 MiB chunks as before. The fork already skipped chunks that do
not fit with a while loop, so upstream's if-to-while change was present.
Upstream's test is adapted: chunk sizes follow the fork's policy, and
after a reset it checks that shared chunks went back (their addresses can
be taken by other lists in between) or, without the pool, that the
list's own first chunk is used again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The GPU shader tests dropped Host::new's error, so a machine without a
usable device printed only "no SM 6.6 hardware device; skipped". On
Windows 10 without the Agility SDK (#84) the hardware adapter reports
SM 6.5 and WARP SM 6.2; the 15 VALU and waterfall tests then fail with
"neither hardware nor WARP SM 6.6 device available" and nothing says
the runtime is the cause. The seven skip sites now print the error:

    no SM 6.6 hardware device (the device supports SM 0x65 only); skipped
    no SM 6.6 warp device (the device supports SM 0x62 only); skipped

Checked on Windows 10 22H2, RTX 3060 + RTX 3090: both clippy runs of CI
pass; the victory-shader tests give the same 105 passed / 15 failed as
before, now with the reason.

(cherry picked from commit 100de0e97a231f07abba5a9d20efb8490ee5a010)

Port notes: the fork's valu_tests run_cases_on loops over a `devices`
slice instead of upstream's fixed hardware/WARP pair; the conflict was
resolved by keeping the fork's loop and taking upstream's match. The
fork has six more skip sites with the same `let Ok(host) = ... else`
shape (intersect_tests, rect.rs, four in wave64_tests, the latter
saying "not run"); they print the error the same way. The two sites
that skip silently (valu_tests' wave-size f64 case, mod.rs' optional
run after validation) are left as they were.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e52777af5b771e291616e5d3d462620ee696f357)

Port notes: the fork already passed the initial pipeline into new_list
and set it in the list's draw state (with its own doc comment and the
fork's `earlier`/`gate` list fields); what was missing is the
`pipeline::bound` call after a successful hand-out, so a pipeline first
bound at list creation now logs its "first bind" like set_pipeline and
reset do. The fork's `#[cfg(not(windows))] let _ = pipeline;` is gone
since `pipeline` is now used on every target. Upstream's test is kept
as is; the fork's create_compute, ComputeHead and pipeline::bound match
upstream's for it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit f0967745efcae4daf979b75e10576346e3a93ea6)

Port notes: the fork's Host also carries the adapter (for the video
memory budget) next to the presenter, and its resize path first settles
presents sent ahead and logs the new buffers and video memory. Kept all
of that; the settle_now(WHY_SYNC) wait moved inside the throttled
closure, so a frame skipped by the retry wait does not stall on the GPU.
The fork's video-memory logging around swap-chain creation stays as is.
Upstream's test was added next to the fork's existing host tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetCopyableFootprints does not pad the final row of the final subresource to RowPitch, so pitch * rows * depth in Staging::detile can exceed the mapped upload buffer size (UB in from_raw_parts_mut). committed() also used unchecked p + len (wrapping to end < p in release) and ignored PAGE_NOACCESS / PAGE_GUARD.

- Keep Staging.size unconditionally and clamp subresource slice length to size - footprint.Offset via subresource_len().
- Check overflow with checked_add / saturating_add and reject PAGE_NOACCESS / PAGE_GUARD in committed().
- Add regression tests for both.

(cherry picked from commit 4fc9d70fee4cc067106447e20be9930f9c49282c)

Port notes: the fork's Staging already keeps the buffer's size
unconditionally in `bytes` (the same `total` from GetCopyableFootprints
that sizes the upload buffer), so detile clamps against `self.bytes` and
the diagnostics-only `size` field stays as it was. The fork's committed()
asks QueryWorkingSetEx page by page by default (saturating, no wrap) and
only uses the VirtualQuery walk (committed_by_query()) under
VICTORY_COMMITTED_QUERY=1; upstream's overflow and PAGE_NOACCESS / PAGE_GUARD
hardening goes there. The regression test runs against both committed()
and committed_by_query(), next to the fork's title_memory_tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c0228d939ec1c206313f7e8cb44c922081b6f538)

Port notes: the fork's emit_indices also culls a primitive whose corner
names a vertex past the written count (min of max_vertices and the lane
count), so on the fork the 10-bit mask did not read out of range but made
every edge-flagged triangle (index 512 or more) vanish. The conflict was
only that rewrite: the fork's loop is kept and its mask is now 0x1FF, so
the bounds cull sees the real index. Upstream's tests are taken as they
are (the fork's host helpers match); the translation test's comment says
the old mask culled the primitive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ID3D12Device::GetDeviceRemovedReason "gets the reason that the device
was removed, or S_OK if the device isn't removed" (Microsoft D3D12
reference). Slot 37 (0x128) in the device function table was left on
the default handler, returning E_NOTIMPL (0x80004001) on a healthy
device, which a title checking FAILED(GetDeviceRemovedReason()) takes
as a lost device.

Wire slot 37 to removed_reason, which queries the host device's
GetDeviceRemovedReason() and returns S_OK on Ok (or when there is no
host device) and the error's HRESULT otherwise. Add a unit test
verifying slot 0x128 returns S_OK on a healthy device.

Co-Authored-By: Gemini 4 Neon <[email protected]>

(cherry picked from commit 13185f50ac0940a6a6bf21997d53f757ff269a44)

Port notes: the conflict was only positional. The fork has its own
unknown_pipeline handler where upstream's removed_reason lands, and the
test module's tail differs: upstream's context carried
shader_model_and_wave_options_are_the_consoles from an earlier upstream
commit the fork does not have, which is left out. removed_reason, the
slot 37 entry and the new test are upstream's unchanged; slot 0x128 was
unset on the fork as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The f16 interpolation always wrote the low destination half via
low_half() and dropped the VOP3 output modifiers. Write through
write_half() (op_sel[3], SDWA) and apply omod then clamp to the f16
result in f32 so the conversion rounds once, matching write_f()'s order.

Addresses VIC-BT-029 from audit #1242.

Validation:
- cargo test -p victory-shader --locked -- --test-threads=1
  --skip emit::valu_tests --skip emit::waterfall_tests
- cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings
- cargo xtask policy

(cherry picked from commit e29391f56c49047ec4046ef347ad3cc8063ac522)

Port notes: the fork's interp() evaluates a packed half as an f32 and
narrows it once (to_f16) instead of upstream's narrow16 per half, and it
lowers v_interp_p1ll_f16 (an f32 result) separately. So half_modifiers()
here takes that f32 and applies omod then clamp before the single
legacyF32ToF16, rather than round-tripping f16 bits through
legacyF16ToF32 as upstream does; the fork's p1ll and flat-dword paths are
unchanged. The mod.rs conflict was upstream test context the fork lacks
(emit_pixel, rows, texcoord and the tests using them); only the new
dump_dxil helper and test were taken, with the test's p2 comment fixed to
the encoding's real operands (v2, v1, attr0.x, v2). The test is
Windows-only (dxc -dumpbin). Its "low write keeps the high half"
check (-65536) cannot hold on the fork: bitcode::opt folds the merge
away because the old v2 is the constant 0. It checks instead that the
low write is masked to 65535 and not shifted. The emitted, optimized
module (disassembled on Linux) holds that (low), a shl by 16, the 2.0
multiply and dx.op.unary opcode 7 (high), and no saturate in the low
variant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On the console, whole-quad mode puts a pixel shader's helper lanes in
EXEC, so a waterfall loop (read the first lane's value, run the lanes
with that value, take them out of EXEC) serves them too. On the host,
wave operations leave helper lanes out: once only helper lanes are left in such
a loop, WaveReadLaneFirst reads no lane, no lane matches, and the
loop runs to the iteration limit in each of them. In a retail title's
world, draws took 0.3 to 1.3 s each until a submission passed the host's
2 s limit: DEVICE_HUNG about 200 s into the world.

A helper lane now takes its own value, so it matches in the first pass
and leaves. What it computes only feeds derivatives; its stores are
dropped already. Waterfall reads the proof already turns into per-lane
reads are unchanged.

(cherry picked from commit 0601955361c77fd8e306631784ed084a31e5ad8f)

Port notes: the fork's generic v_readfirstlane_b32 arm reads through
first_lane (a ballot of the guard where the instruction is guarded)
and, for compute programs split into two exchanging host waves, through
the halves exchange; the helper select is applied to that arm's result,
after the fork's logic. The fork's own_bits and waterfall-read arms
already give each lane its own value and are unchanged; the exchange
paths are compute-only, where the helper never applies. Upstream's
helpers_read context next to read_lane is not on the fork and was not
taken. The doc comment notes that the fork's pixel loop limit is its
own (128 by default) rather than LOOP_LIMIT; upstream adds no tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shadow::update skipped the ranges an earlier list of the same submission declared as written by shaders, so the title's writes there (constants, sizes) stayed stale in the copy for the whole submission; on an RTX 4050 Laptop a dispatch read its sizes as zeros and looped until the device was removed. None of the submission's own shaders has run when it refreshes: update_busy copies the pages the title wrote there since they were taken, and puts the same bytes into the snapshot, so copy-back neither takes them for the GPU's nor puts them back over a later title write.

Test: title_writes_under_a_busy_range_are_copied fails without this and should pass with it.

Port notes: reimplemented by hand, the fork's Shadow differs too much for the cherry-pick (no Tracked::take, a whole-copy snapshot instead of segments, copies in the card's memory). The fork also sends submissions ahead (late/relay, on by default), so `pending` can hold ranges of flights still on the card, and upstream's premise (the previous submission is done) does not hold for those. So the port records, per copy, the parts the submission being prepared declared that no earlier declared range held (`own`, in `writing`), refreshes only those through the fork's write-watch path (update_free/copy_stale, with the copied runs also written into the snapshot), and clears them when the submission goes to the card (`writes_sent`, called in Host::submit after take_snapshots). Ranges a flight holds keep the fork's handling (stale_under_flights/merge_under_writes). For copies in the card's memory the refreshed runs go up with the dirty upload before the lists and are hashed after it, as other refreshes. With wide_back (the default) the snapshot is taken after the refreshes anyway; the sync keeps the other snapshot modes right. The test is adapted: a write-watched VirtualAlloc instead of upstream's watch::tests::pool, read_host/write_host test helpers added, take_snapshots/writes_sent/copy_back_done called as Host::submit does, and one more assertion that a sent range is left alone. It is Windows-only and needs a host GPU (it returns early otherwise).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Instruction::name()` binary-searches the opcode table, and the pipeline
asks about every instruction eight times per translation: `ir::build`,
`structure`, `resource` (which has the most call sites), `io` and
`lower`. The answer cannot change - the encoding and opcode are decoded
from the words and never rewritten - so resolve it once when the
instruction is built and read the field after that.

Measured with the synthetic bench from #1002 (no game data), sixteen
interleaved rounds per arm, best of each, nanoseconds per instruction, at
256/1k/4k/16k instructions:

  resource     17 -> 9, 15 -> 7, 24 -> 16, 23 -> 15    (0.47-0.67)
  lower       511 -> 479, 428 -> 411, 440 -> 401, 477 -> 428  (0.90-0.96)
  io           27 -> 23, 26 -> 21, 26 -> 22, 30 -> 22   (0.73-0.85)
  whole       926 -> 881, 920 -> 874, 958 -> 921, 1019 -> 939 (0.92-0.96)

`decode` pays the one search it used to be spared (112 -> 115 at 16k,
inside the run-to-run spread); every stage after it reads a field. The
emitted DXIL is byte-identical at all four sizes.

cargo test --workspace --locked: 342 passed, 0 failed, 7 ignored.
Both clippy configurations clean; cargo xtask policy ok.

(cherry picked from commit 146dfef67a3ecd2c4fd8f9cff8de149c65dfe6f0)

Port notes: the fork rewrites decoded instructions in ir::unspill (a
scalar parked in a VGPR lane becomes s_mov_b32/s_mov_b64 or s_nop), which
built the struct by hand in another module. With the name cached in a
private field, that rewrite now goes through a new crate-internal
Instruction::new that resolves the name, and decode uses it too, so a
rewritten save or restore is not left named v_writelane_b32 /
v_readlane_b32. Added ir test parked_scalars_become_moves_with_their_names
for that path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Based on #34 by ka1qux (commit faa0a9a), rebased over #45, which added the
same flag and register helpers for clwb loops; the duplicates are merged
into gpr/cmp_flags/CMP_FLAGS.

clzero: the two loops compilers build around it are done whole in one
exception, leaving registers and flags as the last pass would. Anything else
around it is one line and the next instruction.

rdpru: returns the time-stamp counter for MPERF and APERF, 0 for other
counters, and leaves the flags as they are: a Ryzen 7 5800X3D running it
natively in user mode changes none, for known counters or not.

Added over #34:
- loop 1 rejects cmp rax, rax (it fell into the loop and left wrong flags);
- tests that go through the emulation on any CPU (both loop shapes, the
  rax-rax and wrong-neighbour fallbacks, rdpru with both flag states), since
  on an AMD host the native tests never enter the handler.

Port notes: crash.rs took the change as it is, but on the fork the
vectored handler first gives every illegal instruction to
console_insn::emulate (the emulator ported from XCL), which decodes
clzero, the `clzero; add rax, 0x40; cmp rax, b; jb` loop and rdpru
itself; emulate_amd_only only sees what it declines (a line that is not
writable, such as a block the GPU write watch guards). Its loop arm left
rax at the limit and the flags as they were, and zeroed nothing for a
loop that ends after one pass (cmp rax, rax), so upstream's native test
would fail on an Intel host. It now zeroes the lines the passes zero
(still region by region, as Windows reports them writable) and steps
over the clzero alone with rax at the last pass: the CPU runs that
pass's add, cmp and jb, and leaves rax and the flags as the real loop
does. Spans of 2 GiB or more keep the fork's old shortcut. A plain
clzero whose line is writable now goes to crash::clzero (pub(crate)),
so the `mov rax, a; add a, 0x40; clzero; cmp a, b; jb` loop runs whole
on the live path too; its lines after the first are not checked (one
that is not writable faults inside the handler, as the fallback's
unchecked writes already did). rdpru on the live path stays
console_insn's (QueryPerformanceCounter for MPERF and APERF, 0 for
other counters, flags kept); upstream's TSC version is the fallback.
Added a console_insn test of the live path.

(cherry picked from commit 0de9efced179dfb523748f21cf4bdbe0d3aa7533)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Port notes: applied as it is. These tests call emulate_amd_only
directly, so they cover crash::clzero, which on the fork also does the
second loop shape for console_insn's live path.

(cherry picked from commit 514927d2842de485c4359516b08fc42daa2895a6)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the ported fixes, crates/victory-shader/src/emit/lower.rs reached
525,703 bytes. That is past the asset policy's 512 KiB limit for one
file, so xtask's repository_passes_policy failed. Its test module moves,
unchanged apart from one level of indentation, to emit/lower/tests.rs,
which leaves lower.rs at 497,625 bytes. Upstream has also begun moving
parts of lower.rs into emit/lower/ (bvh.rs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A console wave64 program can run on host waves of 32 that do not
exchange (halves set, exchange None). There lane_bit takes the host
lane, so both host waves test the low dword of a mask held as a number:
console lanes 32-63 get the bits of lanes 0-31. The ported v_cndmask_b32
change refuses this for its own paths. A review of the stack found that
a mask in Structured::masks still reaches lane_bit through atom(), for
example a compare ANDed with a constant (s_and_b64 s[0:1], vcc, 1) or
with a pair written apart. That hole was already on main.

atom() now refuses an opaque mask there, and a constant one unless its
two dwords are equal (the host lane's bit is then exact). The test
a_constant_select_mask_on_host_halves_is_refused gains three cases: a
compare with a constant, a compare with a pair, and a constant pair in
Structured::other. Without this change, they translated.

Also corrects helper_reads_own's doc: on the fork a pixel loop stops
after 128 passes, not at LOOP_LIMIT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ported mesh primitive test (c0228d9) dropped Host::new's error. The
other skip sites print it since 0dde6f9.

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

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 05:27 UTC · original

Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T05:27:05.268972Z
We couldn’t complete this review. Comment @codex review to try again.
ef4e8a9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 05:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/716#issuecomment-7153787820) <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ef4e8a90d55b487ef30da4ff61ca9be9c238b8ac","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ❌ Failed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ❌ **Failed** <relative-time datetime="2026-11-25T05:27:05.268972Z">2026-11-25T05:27:05.268972Z</relative-time><br/>We couldn’t complete this review. Comment `@codex review` to try again. | `ef4e8a9` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 05:27 UTC · original

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 05:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/716#issuecomment-7153788352) You have reached your Codex usage limits for code reviews. You can see your limits in the [Codex usage dashboard](https://chatgpt.com/codex/cloud/settings/usage).
Author
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 06:28 UTC · original

Offline check on the retail shader pack: no program gained or lost, but 17,346 programs' DXIL changes. So this changes code in most of the title's shaders, and needs an in-game look before it lands.

Setup: RTX 5090, Windows 11. victory translate --validate --list over the title's full shader pack (26,084 programs), main 310c6eb against this head (with #653 under it), with a local DXIL hash on each validated line.

main this PR
validated 25,382 25,382 (none new, none lost)
DXIL changed among those 17,346

A sample of 3 changed programs, dxc -dumpbin with SSA numbers normalized:

  • 4, 36 and 70 lines differ.
  • Mostly extra and / select / icmp, and in one, 20 dx.op.isHelperLane calls.
  • So these are real code changes, not only encoding (unlike the 59 in #215). They look like the helper-lane handling ported from upstream.
  • Since #653 alone changes nothing on this pack, these come from the 32 hand-ported fixes here.

I have not checked what the changes do in game.

AI use: Claude Code with Claude Opus 5.5 ran the pack, compared the dumps and wrote this. Nothing from the title is in it.

**@⁠JRamos1993** on GitHub · 2026-11-25 06:28 UTC · [original](https://github.com/fxceless/victory-fork/pull/716#issuecomment-7154829891) **Offline check on the retail shader pack: no program gained or lost, but 17,346 programs' DXIL changes. So this changes code in most of the title's shaders, and needs an in-game look before it lands.** **Setup:** RTX 5090, Windows 11. `victory translate --validate --list` over the title's full shader pack (26,084 programs), `main` `310c6eb` against this head (with #653 under it), with a local DXIL hash on each validated line. | | `main` | this PR | |---|---|---| | validated | 25,382 | 25,382 (none new, none lost) | | DXIL changed among those | | **17,346** | **A sample of 3 changed programs**, `dxc -dumpbin` with SSA numbers normalized: - 4, 36 and 70 lines differ. - Mostly extra `and` / `select` / `icmp`, and in one, 20 `dx.op.isHelperLane` calls. - So these are real code changes, not only encoding (unlike the 59 in #215). They look like the helper-lane handling ported from upstream. - Since #653 alone changes nothing on this pack, these come from the 32 hand-ported fixes here. I have not checked what the changes do in game. AI use: Claude Code with Claude Opus 5.5 ran the pack, compared the dumps and wrote this. Nothing from the title is in it.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/Cargo.toml
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/device.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-hle/src/modules/xgamesave.rs
  • crates/victory-loader/src/console_insn.rs
  • crates/victory-pipeline/src/cache.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/wave64_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/716/head:github-bot/gh-716'
git switch 'github-bot/gh-716'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-716'
git switch 'github-bot/gh-716'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-716'
git switch 'github-bot/gh-716'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-716'
git switch 'main'
git merge --squash 'github-bot/gh-716'
git switch 'main'
git merge --ff-only 'github-bot/gh-716'
git switch 'main'
git merge 'github-bot/gh-716'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.