Metal: add native Apple Silicon GPU conformance harness #460

Closed
github-bot wants to merge 1 commit from gh-pr/460/head into gh-pr/460/base
Owner

@⁠pedrofort on GitHub · 2026-11-24 03:41 UTC · original
pedrofort:metal-conformance → main · +1194 −1 · 5 files · 1 commits · closed without merging

Overview

This PR introduces an experimental native Metal GPU conformance harness for Apple Silicon.

It demonstrates that synthetic Xbox GFX10 shaders translated by VIctory can be converted from DXIL to Metal libraries and executed on Apple GPU hardware, with their outputs verified against independent CPU references.

The complete test path is:

GFX10 → VIctory → DXIL → Metal Shader Converter → Metal GPU execution → readback verification

No Wine, Rosetta, Windows VM or game assets are required.

Hardware validation

  • Apple M5 with 16 GB unified memory

  • macOS 27.2.1

  • Native ARM64 executable

  • Rust 1.98.1

  • Xcode and macOS SDK 27.0

  • Metal Shader Converter 4.0.3

  • Metal API and GPU validation enabled

Results

Verification | Result -- | -- Automated checks with optional A/B comparison | 58/58 passed Translated shader pixel comparisons | 16,384/16,384 RGBA channel comparisons | 65,536 Maximum observed channel error in positive tests | 0 Compute buffer values | 64/64 Buffer guard values | 16/16 Failed checks | 0 Blocked checks | 0 Asset policy | 155 files passed Xtask unit tests | 5/5 passed Xtask Clippy | Passed

GPU coverage

  • Constant pixel colors

  • Position-dependent floating-point arithmetic

  • Integer and floating-point conversions

  • Bitwise operations

  • Conditional selection

  • Dynamic byte permutation covering all 256 selector values in each output byte, using two operand pairs

  • Translated vertex shaders

  • Combined translated vertex and pixel pipelines

  • Native versus translated vertex pipeline equivalence

  • Compute dispatch with writable raw buffers

  • GPU memory readback and trailing guard verification

A negative control deliberately compares a red output against a checkerboard reference. The harness correctly detects the mismatch and rejects the result.

Optional differential testing

The harness accepts a second VIctory executable for A/B testing.

During development, the dynamic v_perm_b32 changes from #423 were tested against the original lowering. Both operand sets produced byte-identical GPU outputs, while the candidate no longer declared the INT64 shader feature.

Reproduction

Install Apple's Metal Shader Converter and Xcode, then run:

python3 tests/metal/run.py --victory /path/to/victory

All generated artifacts remain in a temporary directory outside the repository.

The runner produces detailed logs, GPU readbacks and a JSON summary. Failed or blocked checks return a nonzero exit status.

Asset policy

Only the three specifically named Python and Swift test sources are newly permitted. All existing file-size, binary-content, magic-signature and encoded-data checks remain enforced.

No generated binaries, proprietary assets or Apple converter components are committed.

Relationship to other PRs

The harness is independent of the implementation changes in #235, #423 and #438.

A working macOS VIctory executable is required. Native build portability was validated using #235 by @⁠SkippySteve. The optional #423 comparison is not required for normal use.

Limitations

This is a GPU testing infrastructure, not a complete Metal backend or Xbox title runtime.

It does not establish game compatibility, general resource binding support, mesh shader compatibility or performance improvements.

Independent testing on other Apple Silicon generations is welcome.

AI-assisted implementation, reviewed and validated on physical Apple Silicon hardware.

**@⁠pedrofort** on GitHub · 2026-11-24 03:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/460) `pedrofort:metal-conformance` → `main` · +1194 −1 · 5 files · 1 commits · closed without merging <h2><span>Overview</span></h2><p><span>This PR introduces an experimental native Metal GPU conformance harness for Apple Silicon.</span></p><p><span>It demonstrates that synthetic Xbox GFX10 shaders translated by VIctory can be converted from DXIL to Metal libraries and executed on Apple GPU hardware, with their outputs verified against independent CPU references.</span></p><p><span>The complete test path is:</span></p><p><code><span>GFX10 → VIctory → DXIL → Metal Shader Converter → Metal GPU execution → readback verification</span></code></p><p><span>No Wine, Rosetta, Windows VM or game assets are required.</span></p><h2><span>Hardware validation</span></h2><ul><li><p><span>Apple M5 with 16 GB unified memory</span></p></li><li><p><span>macOS 27.2.1</span></p></li><li><p><span>Native ARM64 executable</span></p></li><li><p><span>Rust 1.98.1</span></p></li><li><p><span>Xcode and macOS SDK 27.0</span></p></li><li><p><span>Metal Shader Converter 4.0.3</span></p></li><li><p><span>Metal API and GPU validation enabled</span></p></li></ul><h2><span>Results</span></h2> Verification | Result -- | -- Automated checks with optional A/B comparison | 58/58 passed Translated shader pixel comparisons | 16,384/16,384 RGBA channel comparisons | 65,536 Maximum observed channel error in positive tests | 0 Compute buffer values | 64/64 Buffer guard values | 16/16 Failed checks | 0 Blocked checks | 0 Asset policy | 155 files passed Xtask unit tests | 5/5 passed Xtask Clippy | Passed <h2><span>GPU coverage</span></h2><ul><li><p><span>Constant pixel colors</span></p></li><li><p><span>Position-dependent floating-point arithmetic</span></p></li><li><p><span>Integer and floating-point conversions</span></p></li><li><p><span>Bitwise operations</span></p></li><li><p><span>Conditional selection</span></p></li><li><p><span>Dynamic byte permutation covering all 256 selector values in each output byte, using two operand pairs</span></p></li><li><p><span>Translated vertex shaders</span></p></li><li><p><span>Combined translated vertex and pixel pipelines</span></p></li><li><p><span>Native versus translated vertex pipeline equivalence</span></p></li><li><p><span>Compute dispatch with writable raw buffers</span></p></li><li><p><span>GPU memory readback and trailing guard verification</span></p></li></ul><p><span>A negative control deliberately compares a red output against a checkerboard reference. The harness correctly detects the mismatch and rejects the result.</span></p><h2><span>Optional differential testing</span></h2><p><span>The harness accepts a second VIctory executable for A/B testing.</span></p><p><span>During development, the dynamic </span><code><span>v_perm_b32</span></code><span> changes from #423 were tested against the original lowering. Both operand sets produced byte-identical GPU outputs, while the candidate no longer declared the INT64 shader feature.</span></p><h2><span>Reproduction</span></h2><p><span>Install Apple's Metal Shader Converter and Xcode, then run:</span></p><pre><code><span>python3 tests/metal/run.py --victory /path/to/victory</span></code></pre><p><span>All generated artifacts remain in a temporary directory outside the repository.</span></p><p><span>The runner produces detailed logs, GPU readbacks and a JSON summary. Failed or blocked checks return a nonzero exit status.</span></p><h2><span>Asset policy</span></h2><p><span>Only the three specifically named Python and Swift test sources are newly permitted. All existing file-size, binary-content, magic-signature and encoded-data checks remain enforced.</span></p><p><span>No generated binaries, proprietary assets or Apple converter components are committed.</span></p><h2><span>Relationship to other PRs</span></h2><p><span>The harness is independent of the implementation changes in #235, #423 and #438.</span></p><p><span>A working macOS VIctory executable is required. Native build portability was validated using #235 by @⁠SkippySteve. The optional #423 comparison is not required for normal use.</span></p><h2><span>Limitations</span></h2><p><span>This is a GPU testing infrastructure, not a complete Metal backend or Xbox title runtime.</span></p><p><span>It does not establish game compatibility, general resource binding support, mesh shader compatibility or performance improvements.</span></p><p><span>Independent testing on other Apple Silicon generations is welcome.</span></p><p><span>AI-assisted implementation, reviewed and validated on physical Apple Silicon hardware.</span></p>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:04:51 +00:00
github-bot closed this pull request 2026-11-26 04:04:52 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 17:38 UTC · original

Windows-side verification at head 8ce597b2beea8aa5073391010f012755c7a7fc76:

  • cargo test --locked -p xtask metal_test_sources_are_still_checked -- --test-threads=1: 1 passed, 0 failed, 4 filtered. This checks that only the three named Metal harness sources are allowlisted, while other Python/Swift files, an executable-style MZ signature, and an oversized source remain rejected.
  • cargo run --locked -p xtask -- policy: asset policy passed for 155 files.
  • python -m py_compile tests/metal/generate.py tests/metal/run.py: both Python files compiled successfully.

I reviewed the Metal runner and Swift probe. The runner requires native Apple Silicon macOS and exits before creating its temporary lab or invoking Swift, the converter, or GPU commands on other platforms. Therefore the Metal conversion, shader execution, pixel readback and compute-buffer checks were not reproduced here; those hardware results remain unverified by this Windows run.

This verification was AI-assisted.

**@⁠jeremygold02** on GitHub · 2026-11-24 17:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/460#issuecomment-7139485549) Windows-side verification at head `8ce597b2beea8aa5073391010f012755c7a7fc76`: - `cargo test --locked -p xtask metal_test_sources_are_still_checked -- --test-threads=1`: 1 passed, 0 failed, 4 filtered. This checks that only the three named Metal harness sources are allowlisted, while other Python/Swift files, an executable-style `MZ` signature, and an oversized source remain rejected. - `cargo run --locked -p xtask -- policy`: asset policy passed for 155 files. - `python -m py_compile tests/metal/generate.py tests/metal/run.py`: both Python files compiled successfully. I reviewed the [Metal runner](https://github.com/Marvisak/VIctory/blob/8ce597b2beea8aa5073391010f012755c7a7fc76/tests/metal/run.py) and [Swift probe](https://github.com/Marvisak/VIctory/blob/8ce597b2beea8aa5073391010f012755c7a7fc76/tests/metal/probe.swift). The runner requires native Apple Silicon macOS and exits before creating its temporary lab or invoking Swift, the converter, or GPU commands on other platforms. Therefore the Metal conversion, shader execution, pixel readback and compute-buffer checks were not reproduced here; those hardware results remain unverified by this Windows run. This verification was AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:03 UTC · original

Automated triage for the maintainers. Closing because it is outside the project's scope (VIctory targets Windows hosts; ports, launchers and tooling for other platforms are not being taken).

Out of scope: a macOS/Apple Silicon Metal harness (Python and Swift, needs Apple's Metal Shader Converter and the conflicting Linux-build PR #235), and it adds three path exceptions for .py/.swift files to the asset-policy allowlist in xtask/src/policy.rs.

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/460#issuecomment-7148082800) Automated triage for the maintainers. Closing because it is outside the project's scope (VIctory targets Windows hosts; ports, launchers and tooling for other platforms are not being taken). Out of scope: a macOS/Apple Silicon Metal harness (Python and Swift, needs Apple's Metal Shader Converter and the conflicting Linux-build PR #235), and it adds three path exceptions for .py/.swift files to the asset-policy allowlist in xtask/src/policy.rs. 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

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!460
No description provided.