Skip to content

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

Closed
TaynanGT wants to merge 467 commits into
Marvisak:mainfrom
TaynanGT:main
Closed

TaynanGT wants to merge 467 commits into
Marvisak:mainfrom
TaynanGT:main

Conversation

@TaynanGT

@TaynanGT TaynanGT commented Nov 25, 2026 •

Copy link
Copy Markdown

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

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

What it changes

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

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

Known differences from main

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

Tests

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

🤖 Generated with Claude Code

fxceless and others added 30 commits November 24, 2026 14:30
The update moved the particle light-atlas compute programs to a form that
puts group barriers inside branches and loops; a dispatch of them stood on
the card until the device was reset. That form is now off unless
VICTORY_WAVE_WIDE=1, and the shader cache key includes the wave switches.
Checked with a plain run of this tree on the test machine.
…apter

Hosted runners list a display stub first, so the default device there is the
software adapter; the tests that need a real card now skip it.
- Clean-up passes over each translated module (VICTORY_SHADER_OPT bits: dead
  code, folding, reuse, branch facts, loads within a block, wave64 first-lane
  exchange), part of the shader cache key. About 43 % fewer host instructions
  over the pack; about 20 ms less GPU time per frame on the test machine.
- translate: a census of the emitted code.
- Checked with plain game runs of this tree on the test machine.
…ative VGPR reads keep parked lanes (#11)

The console compiler parks a wave64 lane mask in two lanes of a spare VGPR
and may restore the halves with other instructions between the two
v_readlane_b32. The pair restore now looks ahead in the block (nothing between
may touch the second register, write the first, or save into the lanes), so
the mask comes back as a mask. This lets indirect_light_probes
CS_IrradianceCache_Shade / ShadeSecondary translate: they were dropped every
frame, leaving the irradiance cache unlit and everything in shadow black.

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

translate: VICTORY_TRANSLATE_ONLY=<hash prefixes> limits a run to those
containers; VICTORY_HOST_MAX_WAVE=32 translates as on a 32-lane host, so
--pipelines matches what the runtime creates on NVIDIA.
Comments, documents and descriptions now say "the title". No code changes.
…form

Fixes two gaps in lane_uniform that prevented wave-uniform VGPRs (such as the BVH builder's prefix-sum loop in #16) from lowering v_readfirstlane_b32 on 32-lane hosts without a cross-half exchange:

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

Part of #16.

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

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

Fixes #12.

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

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

Related to #53.

(cherry picked from commit 3ed5e8918d32c091d36edda94f825ba8f6e30a83)
…de opt

(cherry picked from commit 442d7c25ab1849a5e25fbf19313ead3c172cddae)
…s request

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

(cherry picked from commit 7e22f187dd7ec6f632a07857b1fe3718ec350638)
…s order

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

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

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

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

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

(cherry picked from commit 481569b)
TaynanGT and others added 5 commits November 25, 2026 17:43
Rewrite the Vice-Tay README with current benchmarks
Document Vice-Tay on my PC and benchmark setup
VICTORY_KEYS_FILE=<file>: a script writes lines `<key> <seconds>` into the
file, and the next input poll (at most 50 ms later) holds each key that
long, focus or not, then removes the file. A measuring script can answer
the account screen's prompt or turn the camera while someone else uses the
desktop; the keyboard path needs the title's window in front. Unset,
nothing is read. Scripted keys (this file, and VICTORY_KEYS in diagnostics
builds) now reach the pad in every build.

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

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

Copy link
Copy Markdown

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

@TaynanGT

Copy link
Copy Markdown
Author

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

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

This was referenced Nov 25, 2026
386e885 ran 30 min 12 s in the world on the RTX 4090, from the cell into
the robbery, median 7.0 fps over 1,629 one-second samples. It was closed by
hand when the process reached 36 GB of private memory, which is now the
limit on session length. The cold-cache launch keeps its own heading so its
0.8 fps cinematic figure is not read as play speed.

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

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

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

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

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

Ported from #2824, adapted to our watch module.

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

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

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

Every texture the title sampled kept a staging buffer the size of the whole
texture for as long as it was sampled; only textures idle for 10 s gave it
back. A VirtualAlloc trace from launch to seven minutes into the world put
6.6 GB of the process in these buffers (4,616 of them), the largest share
the layer itself holds.

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

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

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

`lookup` looked at the 64 buffers starting nearest below an address. With
more short buffers than that above the start of a long one that holds the
address, the long buffer went unfound and the ask fell to a loose window,
a second host copy of the same bytes that the long buffer's own copy never
sees. `in_place_let_go` had the same blind spot at 256.

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

Ported from brunofgmag/victory-fork#1142.

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

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

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

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

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

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

From LooperSalty/AnyXboxX 021c8309.

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

The record layout is from fablinoo/kelvaroq 0049.

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

A texture refresh holds title memory still so that no page goes under its
read, and held it through the hash of the whole texture and the detiling.
The title's page remaps wait for every refresh under way. With the switch
the refresh copies the bytes out, lets go, then hashes and detiles the
copy. Off by default until it is measured here.

From edsuuu/VI-BR-PORT ac1d2945.

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

From edsuuu/VI-BR-PORT 80eb362e.

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

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

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


Generated by Claude Code

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.