loader: emulate AMD-only instructions on Intel CPUs #10

Merged
ismailchaka1 merged 1 commit from upstream-pr/10 into main 2026-11-23 23:08:20 +00:00
ismailchaka1 commented 2026-11-23 22:53:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ismailchaka1 on 2026-11-23T22:53:17Z.


The title is built for Zen 2 and uses AMD-only instructions that Intel CPUs lack. On an i7-14700KF it died at startup with an illegal instruction (0xc000001d). It hit them one after another: clzero, then monitorx, then SSE4a's insertq.

The vectored handler in crates/victory-loader/src/crash.rs now does their job and resumes:

  • clzero (0f 01 fc) zeroes the 64-byte line at rax.
  • monitorx (0f 01 fa) is skipped and mwaitx (0f 01 fb) yields. Both are only wait hints.
  • extrq / insertq (register forms, with an optional REX prefix) run on the saved XMM registers.

Anything else still reaches the crash report as before. Each emulated instruction costs an exception, so a hot loop would be slow; the title got through startup without noticeable delay.

Testing

  • cargo test -p victory-loader --lib crash: a new test runs each instruction and checks the result. It passes whether the CPU runs the instruction natively or the handler emulates it.
  • With the title on an i7-14700KF and an RTX 4070 SUPER (driver 610.88), Windows 11: it now gets past startup and runs about a minute before the host device is removed. That later failure is separate. With VICTORY_D3D12_DEBUG=1 on WARP, the debug layer reports compute shaders that want 64-lane waves, which the README already lists as a requirement.

This change was written with AI assistance (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6570496183 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/10). Originally posted by [ismailchaka1](https://github.com/ismailchaka1) on 2026-11-23T22:53:17Z. --- The title is built for Zen 2 and uses AMD-only instructions that Intel CPUs lack. On an i7-14700KF it died at startup with an illegal instruction (`0xc000001d`). It hit them one after another: `clzero`, then `monitorx`, then SSE4a's `insertq`. The vectored handler in `crates/victory-loader/src/crash.rs` now does their job and resumes: - `clzero` (`0f 01 fc`) zeroes the 64-byte line at `rax`. - `monitorx` (`0f 01 fa`) is skipped and `mwaitx` (`0f 01 fb`) yields. Both are only wait hints. - `extrq` / `insertq` (register forms, with an optional REX prefix) run on the saved XMM registers. Anything else still reaches the crash report as before. Each emulated instruction costs an exception, so a hot loop would be slow; the title got through startup without noticeable delay. ## Testing - `cargo test -p victory-loader --lib crash`: a new test runs each instruction and checks the result. It passes whether the CPU runs the instruction natively or the handler emulates it. - With the title on an i7-14700KF and an RTX 4070 SUPER (driver 610.88), Windows 11: it now gets past startup and runs about a minute before the host device is removed. That later failure is separate. With `VICTORY_D3D12_DEBUG=1` on WARP, the debug layer reports compute shaders that want 64-lane waves, which the README already lists as a requirement. This change was written with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:50:54 +00:00
jeremygold02 commented 2026-11-24 06:54:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-23T23:04:30Z.


Verified on a second Intel system with a direct parent/head comparison. Windows 11, Core Ultra 7 265K, GeForce RTX 5070, NVIDIA 621.01. Both launchers were built locally with --locked --profile diag --features diagnostics and ran on the hardware adapter with no game memory cap.

Revision Startup result
015d45b (parent) Exited after 5.4 s with 0xc000001d, before the first present. The instruction at the fault was CLZERO in both the input image and the prepared copy. This CPU reports the CLZERO feature bit clear.
934e67f (PR head) The clzero_zeroes_its_line_on_any_cpu regression passed. With the same input, the title reached at least 128 PresentX calls; the host recorded 382 draws and 76 dispatches through that checkpoint. I ended the run at the capture checkpoint.

The eight 1920×1080 present-source readbacks at frames 1, 2, 4, 8, 16, 32, 64 and 128 were uniformly black.

A follow-up run used the combined source tree now on main at d348b9a (identical Git tree 365099f). Frame 256 showed the legible first-boot screen-narration/account menu on this RTX 5070. Both captured RGBA render targets matched the present-source image pixel for pixel. The menu ran at about 30 fps; the early black transitions at frames 357, 573, 789 and 1005 matched the cadence in #11. The 40-second observation ended at the time limit. Gameplay and longer-term GPU stability were outside this check.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7116521022 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/10#issuecomment-7116521022). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-23T23:04:30Z. --- Verified on a second Intel system with a direct parent/head comparison. Windows 11, Core Ultra 7 265K, GeForce RTX 5070, NVIDIA 621.01. Both launchers were built locally with `--locked --profile diag --features diagnostics` and ran on the hardware adapter with no game memory cap. | Revision | Startup result | | --- | --- | | `015d45b` (parent) | Exited after 5.4 s with `0xc000001d`, before the first present. The instruction at the fault was `CLZERO` in both the input image and the prepared copy. This CPU reports the CLZERO feature bit clear. | | `934e67f` (PR head) | The `clzero_zeroes_its_line_on_any_cpu` regression passed. With the same input, the title reached at least 128 `PresentX` calls; the host recorded 382 draws and 76 dispatches through that checkpoint. I ended the run at the capture checkpoint. | The eight 1920×1080 present-source readbacks at frames 1, 2, 4, 8, 16, 32, 64 and 128 were uniformly black. A follow-up run used the combined source tree now on `main` at `d348b9a` (identical Git tree `365099f`). Frame 256 showed the legible first-boot screen-narration/account menu on this RTX 5070. Both captured RGBA render targets matched the present-source image pixel for pixel. The menu ran at about 30 fps; the early black transitions at frames 357, 573, 789 and 1005 matched the cadence in #11. The 40-second observation ended at the time limit. Gameplay and longer-term GPU stability were outside this check.
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!10
No description provided.