Windows playability, shader translation, D3D12 stability, and HLE improvements #1330

Closed
sahajiscoding wants to merge 50 commits from upstream-pr/1330 into main
sahajiscoding commented 2026-11-24 17:29:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sahajiscoding on 2026-11-24T17:29:43Z.


Summary

A set of clean-room improvements across the shader compiler, D3D12 runtime, HLE platform modules, formats/loader, and Windows launcher experience, focused on Windows playability and stability. All changes strictly follow docs/asset-policy.md (zero copyrighted assets; Cargo.lock, .github/workflows/ci.yml, and .gitignore unchanged).

Note for maintainers: This branch combines several subsystem improvements (76 files). If you prefer reviewing smaller, targeted PRs by subsystem (shader compiler / D3D12 / HLE / Windows launcher), I'm happy to split them out.


1. Shader Translation & DXIL (victory-shader)

  • Additional RDNA2 VALU lowering: Added v_mul_hi_{u,i}32_{u,i}24, v_mad_{u,i}32_{u,i}16, v_lerp_u8, v_sad_u{8,16,32}, v_cvt_pk_{u,i}16_{u,i}32, and v_dot{2,4}_{i,u}32_{i,u}{16,8} (wrapping 32-bit path, plus INT64-flagged saturating clamp path), validated with dxil.dll.
  • Contiguous low-channel image_store dmasks: Supports 0x0, 0x1, 0x3, 0x7, 0xF (both 32-bit and d16), while still rejecting sparse masks.
  • 64-bit atomics, structured root buffers, and pixel helper-lane guards: Added SFI0 feature bit reporting (Int64Ops, AtomicInt64OnTypedResource, AtomicInt64OnHeapResource, ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer), helper-lane protection for pixel v_readfirstlane_b32, and additional VALU / f16 / wave-size handling.
  • Scalar/mask control flow (#878): Includes s_bcnt1_i32_b32/b64 lane-mask tracking and dead-edge undef handling in fill_phis. (Flagging for review: please note the open discussion on #878 regarding Wave32 uniform s_bcnt1 branches — happy to revert or adjust that hunk separately if preferred.)

2. D3D12 Runtime & GPU Host (victory-gpu)

  • High-performance discrete GPU selection (#208 / #1132): Uses IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) with optional VICTORY_ADAPTER=<index | name substring> override and startup GPU/VRAM logging so hybrid Windows laptops don't default to an iGPU.
  • Sampler heap 2,048 cap fallback (#100 / #86): Caps shader-visible sampler heaps at D3D12's architectural 2,048 limit instead of failing heap creation.
  • Shader cache write-failure fallback (#358): Returns the in-memory translated shader if persisting the entry to disk fails.
  • Pipeline, descriptor & resource hardening: Dynamic descriptor reclamation, integer render-target blend guards, depth bounds (OMSetDepthBounds), monotonic fence updates, clamped sampler descriptors, saturating COM refcounts, dirty-page texture detiling (Layout::extents), and wave-lane count reporting (wave_lane_count_max).
  • Fallback window polish: Added F11 / Alt+Enter borderless fullscreen toggling and clean WM_CLOSE handling.

3. HLE, Input, Audio & Platform (victory-hle, victory-formats, victory-loader, victory-pipeline, victory-game)

  • Input (gameinput.rs):
    • Windows.Gaming.Input 4-motor impulse trigger rumble with XInput fallback.
    • Enhanced keyboard+mouse fallback gamepad (preserves all documented bindings, adds Space=A, Left Ctrl=B, R=X, Left Shift=L3, mouse LMB=RT/RMB=LT/MMB=R3, and RMB / F9 mouse camera look).
    • Null-device previous_reading / next_reading now walks readings across all devices in chronological order (#361).
  • Windowing & display:
    • lifecycle.rs: F11 / Alt+Enter borderless fullscreen toggle on hooked title windows and >= 1 dimension clamp in fit_into() (#451).
    • display.rs: No-op deferral fallback when PowerSetRequest returns ERROR_NOT_SUPPORTED.
  • Async, files, networking & services:
    • xasync.rs: XTaskQueueRegisterWaiter / XTaskQueueUnregisterWaiter (#888) and immediate wake/cancel of delayed callbacks on XTaskQueueTerminate (#132).
    • files.rs: Clamps .. traversal at the virtual drive root on short paths as well (#182).
    • dstorage.rs: Added CancelRequestsWithTag and Query (#889).
    • speech.rs, xgame.rs, xgameui.rs, xsystem.rs, net.rs: XAccessibility slots (#865), QueryInterface on all xgame vtables (#901), password input style (#881), sandbox ID buffer check (#862), and zero-address connect/WSAConnect handling (#891).
  • Formats, cache & loader:
    • xma.rs: Cached IMDCT pre/post sin_cos tables across subframes (#172) and bit-reader width guards (#907).
    • cache.rs: Atomic Windows NTFS cache publication using hard_link + remove_file to prevent ERROR_ACCESS_DENIED races (#890).
    • sgd5.rs, crash.rs, tls.rs, stacks.rs: Checked arithmetic, slice-based clwb_len, and TLS/stack bounds guards (#905, #924, #938).

4. Windows Launcher & Packaging (apps/victory, victory-core, scripts/)

  • victory doctor & interactive launcher (#910): Double-clicking victory.exe opens an interactive PC readiness & title launcher menu with GPU/SM 6.6/Mesh Shader diagnostics, [S] game-folder setup wizard (victory.toml), [K] controls guide, Series X/S toggle, and Explorer drag-and-drop .exe launching.
  • Portable config lookup: Falls back to victory.toml next to victory.exe when not present in the working directory.
  • Release packaging script: Added scripts/build-windows.ps1 to build and assemble a portable Windows folder under target\victory-windows\.

Testing & Verification

  • Passed GitHub Actions Windows CI (windows-latest):
    • cargo clippy --workspace --all-targets --locked -- -D warnings
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
    • cargo test --workspace --locked (all 11 crates, including WARP/DXIL validation tests, NTFS cache concurrency tests, new unit tests, and xtask asset-policy check)
  • Not yet tested on live game data: All verification was performed against the test suite and WARP/DXIL validator without a live Xbox title dump.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6587637738 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1330). Originally posted by [sahajiscoding](https://github.com/sahajiscoding) on 2026-11-24T17:29:43Z. --- ## Summary A set of clean-room improvements across the shader compiler, D3D12 runtime, HLE platform modules, formats/loader, and Windows launcher experience, focused on Windows playability and stability. All changes strictly follow `docs/asset-policy.md` (zero copyrighted assets; `Cargo.lock`, `.github/workflows/ci.yml`, and `.gitignore` unchanged). > **Note for maintainers:** This branch combines several subsystem improvements (76 files). If you prefer reviewing smaller, targeted PRs by subsystem (shader compiler / D3D12 / HLE / Windows launcher), I'm happy to split them out. --- ### 1. Shader Translation & DXIL (`victory-shader`) - **Additional RDNA2 VALU lowering**: Added `v_mul_hi_{u,i}32_{u,i}24`, `v_mad_{u,i}32_{u,i}16`, `v_lerp_u8`, `v_sad_u{8,16,32}`, `v_cvt_pk_{u,i}16_{u,i}32`, and `v_dot{2,4}_{i,u}32_{i,u}{16,8}` (wrapping 32-bit path, plus `INT64`-flagged saturating `clamp` path), validated with `dxil.dll`. - **Contiguous low-channel `image_store` dmasks**: Supports `0x0`, `0x1`, `0x3`, `0x7`, `0xF` (both 32-bit and `d16`), while still rejecting sparse masks. - **64-bit atomics, structured root buffers, and pixel helper-lane guards**: Added `SFI0` feature bit reporting (`Int64Ops`, `AtomicInt64OnTypedResource`, `AtomicInt64OnHeapResource`, `ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer`), helper-lane protection for pixel `v_readfirstlane_b32`, and additional VALU / f16 / wave-size handling. - **Scalar/mask control flow (`#878`)**: Includes `s_bcnt1_i32_b32/b64` lane-mask tracking and dead-edge `undef` handling in `fill_phis`. *(Flagging for review: please note the open discussion on `#878` regarding Wave32 uniform `s_bcnt1` branches — happy to revert or adjust that hunk separately if preferred.)* ### 2. D3D12 Runtime & GPU Host (`victory-gpu`) - **High-performance discrete GPU selection (`#208` / `#1132`)**: Uses `IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)` with optional `VICTORY_ADAPTER=<index | name substring>` override and startup GPU/VRAM logging so hybrid Windows laptops don't default to an iGPU. - **Sampler heap 2,048 cap fallback (`#100` / `#86`)**: Caps shader-visible sampler heaps at D3D12's architectural 2,048 limit instead of failing heap creation. - **Shader cache write-failure fallback (`#358`)**: Returns the in-memory translated shader if persisting the entry to disk fails. - **Pipeline, descriptor & resource hardening**: Dynamic descriptor reclamation, integer render-target blend guards, depth bounds (`OMSetDepthBounds`), monotonic fence updates, clamped sampler descriptors, saturating COM refcounts, dirty-page texture detiling (`Layout::extents`), and wave-lane count reporting (`wave_lane_count_max`). - **Fallback window polish**: Added `F11` / `Alt+Enter` borderless fullscreen toggling and clean `WM_CLOSE` handling. ### 3. HLE, Input, Audio & Platform (`victory-hle`, `victory-formats`, `victory-loader`, `victory-pipeline`, `victory-game`) - **Input (`gameinput.rs`)**: - Windows.Gaming.Input 4-motor impulse trigger rumble with XInput fallback. - Enhanced keyboard+mouse fallback gamepad (preserves all documented bindings, adds `Space=A`, `Left Ctrl=B`, `R=X`, `Left Shift=L3`, mouse `LMB=RT`/`RMB=LT`/`MMB=R3`, and `RMB` / `F9` mouse camera look). - Null-device `previous_reading` / `next_reading` now walks readings across all devices in chronological order (`#361`). - **Windowing & display**: - `lifecycle.rs`: `F11` / `Alt+Enter` borderless fullscreen toggle on hooked title windows and `>= 1` dimension clamp in `fit_into()` (`#451`). - `display.rs`: No-op deferral fallback when `PowerSetRequest` returns `ERROR_NOT_SUPPORTED`. - **Async, files, networking & services**: - `xasync.rs`: `XTaskQueueRegisterWaiter` / `XTaskQueueUnregisterWaiter` (`#888`) and immediate wake/cancel of delayed callbacks on `XTaskQueueTerminate` (`#132`). - `files.rs`: Clamps `..` traversal at the virtual drive root on short paths as well (`#182`). - `dstorage.rs`: Added `CancelRequestsWithTag` and `Query` (`#889`). - `speech.rs`, `xgame.rs`, `xgameui.rs`, `xsystem.rs`, `net.rs`: `XAccessibility` slots (`#865`), `QueryInterface` on all `xgame` vtables (`#901`), password input style (`#881`), sandbox ID buffer check (`#862`), and zero-address `connect`/`WSAConnect` handling (`#891`). - **Formats, cache & loader**: - `xma.rs`: Cached IMDCT pre/post `sin_cos` tables across subframes (`#172`) and bit-reader width guards (`#907`). - `cache.rs`: Atomic Windows NTFS cache publication using `hard_link` + `remove_file` to prevent `ERROR_ACCESS_DENIED` races (`#890`). - `sgd5.rs`, `crash.rs`, `tls.rs`, `stacks.rs`: Checked arithmetic, slice-based `clwb_len`, and TLS/stack bounds guards (`#905`, `#924`, `#938`). ### 4. Windows Launcher & Packaging (`apps/victory`, `victory-core`, `scripts/`) - **`victory doctor` & interactive launcher (`#910`)**: Double-clicking `victory.exe` opens an interactive PC readiness & title launcher menu with GPU/SM 6.6/Mesh Shader diagnostics, `[S]` game-folder setup wizard (`victory.toml`), `[K]` controls guide, Series X/S toggle, and Explorer drag-and-drop `.exe` launching. - **Portable config lookup**: Falls back to `victory.toml` next to `victory.exe` when not present in the working directory. - **Release packaging script**: Added `scripts/build-windows.ps1` to build and assemble a portable Windows folder under `target\victory-windows\`. --- ## Testing & Verification - Passed GitHub Actions Windows CI (`windows-latest`): - `cargo clippy --workspace --all-targets --locked -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo test --workspace --locked` (all 11 crates, including WARP/DXIL validation tests, NTFS cache concurrency tests, new unit tests, and `xtask` asset-policy check) - **Not yet tested on live game data:** All verification was performed against the test suite and WARP/DXIL validator without a live Xbox title dump.
EduBertozzi commented 2026-11-24 18:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by EduBertozzi on 2026-11-24T17:30:50Z.


A heads-up on part 4 (the launcher), from the author of #910's menu: #959 implements the same double-click menu and adds the same apps/victory/src/menu.rs and menu::wanted() hook in main.rs. So whichever of the two lands first, the other conflicts.

They overlap but aren't the same, so they could be combined instead of choosing one:

  • #959 runs the game in a child victory run, so a crash leaves the window up and shows how the run ended. It also:
    • remembers the last game;
    • wraps hints to the console width;
    • names the GPU and driver through DXGI;
    • copies the check as a plain report for GitHub, with the profile folder redacted;
    • has 9 unit tests. It has been tested natively on Windows 10, under Wine (#910), and by @Zipettte on an RX 7700 XT.
  • This PR's launcher adds things #959 doesn't have: the [S] game-folder setup that writes victory.toml, the [K] controls guide, and the [M] Series X/S toggle. Those are good additions.

If you split the launcher out as you offered, I'd be glad to bring [S], [K] and [M] into #959, credited to you, or the other way round, whichever the maintainers prefer. That way the menu is reviewed once.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139306882 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1330#issuecomment-7139306882). Originally posted by [EduBertozzi](https://github.com/EduBertozzi) on 2026-11-24T17:30:50Z. --- A heads-up on part 4 (the launcher), from the author of #910's menu: #959 implements the same double-click menu and adds the same `apps/victory/src/menu.rs` and `menu::wanted()` hook in `main.rs`. So whichever of the two lands first, the other conflicts. They overlap but aren't the same, so they could be combined instead of choosing one: - #959 runs the game in a child `victory run`, so a crash leaves the window up and shows how the run ended. It also: - remembers the last game; - wraps hints to the console width; - names the GPU and driver through DXGI; - copies the check as a plain report for GitHub, with the profile folder redacted; - has 9 unit tests. It has been tested natively on Windows 10, under Wine (#910), and by @Zipettte on an RX 7700 XT. - This PR's launcher adds things #959 doesn't have: the `[S]` game-folder setup that writes `victory.toml`, the `[K]` controls guide, and the `[M]` Series X/S toggle. Those are good additions. If you split the launcher out as you offered, I'd be glad to bring `[S]`, `[K]` and `[M]` into #959, credited to you, or the other way round, whichever the maintainers prefer. That way the menu is reviewed once. AI-assisted (Claude Code).
EduBertozzi commented 2026-11-24 19:04:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by EduBertozzi on 2026-11-24T18:14:38Z.


@sahajiscoding I brought your three launcher ideas into #959 (6614cc2), credited to this PR:

  • S sets the game folder. It edits only the game_dir line of victory.toml, so the file's comments stay. A dropped .exe stands for its folder, and a folder inside the repo is refused.
  • K shows the keyboard's stand-in pad as main maps it.
  • M switches Series X / S for runs.

So if the maintainers would rather review the launcher once, #959 now covers what part 4 of this PR adds. Your fullscreen and mouse-look keys aren't in it, since main doesn't have those features.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140365100 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1330#issuecomment-7140365100). Originally posted by [EduBertozzi](https://github.com/EduBertozzi) on 2026-11-24T18:14:38Z. --- @sahajiscoding I brought your three launcher ideas into #959 ([`6614cc2`](https://github.com/EduBertozzi/VIctory/commit/6614cc2)), credited to this PR: - **S** sets the game folder. It edits only the `game_dir` line of `victory.toml`, so the file's comments stay. A dropped `.exe` stands for its folder, and a folder inside the repo is refused. - **K** shows the keyboard's stand-in pad as `main` maps it. - **M** switches Series X / S for runs. So if the maintainers would rather review the launcher once, #959 now covers what part 4 of this PR adds. Your fullscreen and mouse-look keys aren't in it, since `main` doesn't have those features. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:06:15 +00:00
Marvisak commented 2026-11-25 01:08:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:37:34Z.


Automated triage for the maintainers. Closing because it breaks a repository rule (see docs/asset-policy.md and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148708383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1330#issuecomment-7148708383). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:37:34Z. --- Automated triage for the maintainers. Closing because it breaks a repository rule (see `docs/asset-policy.md` and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1330
No description provided.