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

Manually merged
github merged 1 commit from gh-pr/10/head into gh-pr/10/base 2026-11-26 03:46:19 +00:00
Owner

@⁠ismailchaka1 on GitHub · 2026-11-23 22:53 UTC · original
ismailchaka1:emulate-amd-only-instructions → main · +109 −1 · 1 files · 1 commits · merged 2026-11-23 23:08 UTC

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

**@⁠ismailchaka1** on GitHub · 2026-11-23 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/10) `ismailchaka1:emulate-amd-only-instructions` → `main` · +109 −1 · 1 files · 1 commits · merged 2026-11-23 23:08 UTC 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)
The title is built for Zen 2 and uses clzero, monitorx/mwaitx and SSE4a's
extrq/insertq, which Intel CPUs lack: it died at startup with an illegal
instruction on an i7-14700KF. The vectored handler now does their job and
resumes: clzero zeroes the 64-byte line at rax, monitorx is skipped, mwaitx
yields, extrq/insertq run on the saved XMM registers.

Tested: victory-loader crash tests (new one runs each instruction), and the
title now gets past startup on an i7-14700KF with an RTX 4070 SUPER.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:46:18 +00:00
github manually merged commit 934e67fbad into gh-pr/10/base 2026-11-26 03:46:19 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-23 23:04 UTC · original · edited 2026-11-23 23:10 UTC

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.

**@⁠jeremygold02** on GitHub · 2026-11-23 23:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/10#issuecomment-7116521022) · edited 2026-11-23 23:10 UTC 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.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

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