metal: refuse a shader converter older than 3.0 (#295) #351

Merged
tiagonogueiraa-bit merged 1 commit from upstream-pr/351 into main 2026-11-27 16:14:20 +00:00
tiagonogueiraa-bit commented 2026-11-27 13:43:21 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T13:43:21Z.


Refs #295

Cause. Before 3.0, Apple's Metal Shader Converter takes every 1D and 2D texture as an array type. Its 2.1 manual says so under "Texture arrays", and the 3.0 changelog lists "Default support for non-array texture types". The host binds a 2D texture as a plain 2D view, which is what 3.0 and later expect. Through an older converter, a compute shader's writes to such a texture are dropped and the texture stays zero, with no refusal and no GPU error. That matches the loading screen in #295: panels drawn, no art. Unreal Engine 5.6's copy (D3DRendererMetal-30.2) is older than Apple's 2.1 (31.2), so it belongs to the generation before 3.0.

Measured with Apple's own releases (each .pkg expanded, loaded through VICTORY_MSC_DYLIB). M-series Mac, macOS 27.2, cargo test -p victory-gpu on main b639c17:

Converter D3DRendererMetal victory-gpu lib tests
1.1 20 346 passed, 1 failed
2.1 31.2 346 passed, 1 failed
3.0 32.47 347 passed
4.0 beta 3 (installed) 347 passed
  • The test that fails is a_texture_compute_writes_is_copied_back_into_title_memory. It failed 3 times in 3 runs on 2.1 and on 1.1, and passed 3 of 3 on 3.0 and 4.0 beta 3. On 2.1 the texture reads back all zero: 16,256 of 16,384 bytes differ, and 0 bytes are nonzero.
  • Swapping the view type flips it. With create_texture_view making 2D views as 2D arrays (an experiment, not in this PR), the same test passes on 2.1 and fails on 3.0.

Change.

  • Converter check. Msc::open refuses a converter that lacks IRCompilerSetFunctionConstantResourceSpace. 3.0 added that export: 3.0 and 4.0 beta 3 have it, and 1.0, 1.1 and 2.1 do not. The C API has no version call, and the Mach-O version is 0.0.0, so exports are the only reliable sign.
  • Message. The refusal names the path and says to install 3.0 or newer. try_open_default now logs once why no converter was loaded (metal: no shader converter: ...).
  • Setup script. native-setup.sh warns about an older converter (checked with nm -gU).
  • Docs. README asks for 3.0 or newer, and the "Which converter" note in docs/native-host.md gives the cause and these numbers.

What it does not change. A converter of 3.0 or newer loads exactly as before, so the 3.0 and 4.0 beta 3 runs above are unchanged. The path still decides only the existing warning about a non-default copy. Making array views for an older converter instead would also work. It is not done here, because every 2D view and directly bound texture would need the other type, for a converter Apple has replaced. Say if you prefer that route.

Checks.

  • cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 580 passed, 0 failed, 7 ignored.
  • cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings: clean.
  • cargo xtask policy: ok.
  • New test: msc::tests::a_converter_older_than_3_is_refused_by_its_exports.

No game data was used for any of this. I don't have Unreal's copy to run it directly. @Olima34, for the board.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5527647045 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/351). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-27T13:43:21Z. --- Refs #295 **Cause.** Before 3.0, Apple's Metal Shader Converter takes every 1D and 2D texture as an array type. Its 2.1 manual says so under "Texture arrays", and the 3.0 changelog lists "Default support for non-array texture types". The host binds a 2D texture as a plain 2D view, which is what 3.0 and later expect. Through an older converter, a compute shader's writes to such a texture are dropped and the texture stays zero, with no refusal and no GPU error. That matches the loading screen in #295: panels drawn, no art. Unreal Engine 5.6's copy (`D3DRendererMetal-30.2`) is older than Apple's 2.1 (`31.2`), so it belongs to the generation before 3.0. **Measured with Apple's own releases** (each `.pkg` expanded, loaded through `VICTORY_MSC_DYLIB`). M-series Mac, macOS 27.2, `cargo test -p victory-gpu` on main `b639c17`: | Converter | `D3DRendererMetal` | victory-gpu lib tests | |---|---|---| | 1.1 | 20 | 346 passed, **1 failed** | | 2.1 | 31.2 | 346 passed, **1 failed** | | 3.0 | 32.47 | 347 passed | | 4.0 beta 3 | (installed) | 347 passed | - **The test that fails** is `a_texture_compute_writes_is_copied_back_into_title_memory`. It failed 3 times in 3 runs on 2.1 and on 1.1, and passed 3 of 3 on 3.0 and 4.0 beta 3. On 2.1 the texture reads back all zero: 16,256 of 16,384 bytes differ, and 0 bytes are nonzero. - **Swapping the view type flips it.** With `create_texture_view` making 2D views as 2D arrays (an experiment, not in this PR), the same test passes on 2.1 and fails on 3.0. **Change.** - **Converter check.** `Msc::open` refuses a converter that lacks `IRCompilerSetFunctionConstantResourceSpace`. 3.0 added that export: 3.0 and 4.0 beta 3 have it, and 1.0, 1.1 and 2.1 do not. The C API has no version call, and the Mach-O version is 0.0.0, so exports are the only reliable sign. - **Message.** The refusal names the path and says to install 3.0 or newer. `try_open_default` now logs once why no converter was loaded (`metal: no shader converter: ...`). - **Setup script.** `native-setup.sh` warns about an older converter (checked with `nm -gU`). - **Docs.** README asks for 3.0 or newer, and the "Which converter" note in `docs/native-host.md` gives the cause and these numbers. **What it does not change.** A converter of 3.0 or newer loads exactly as before, so the 3.0 and 4.0 beta 3 runs above are unchanged. The path still decides only the existing warning about a non-default copy. Making array views for an older converter instead would also work. It is not done here, because every 2D view and directly bound texture would need the other type, for a converter Apple has replaced. Say if you prefer that route. **Checks.** - `cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask`: 580 passed, 0 failed, 7 ignored. - `cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings`: clean. - `cargo xtask policy`: ok. - New test: `msc::tests::a_converter_older_than_3_is_refused_by_its_exports`. No game data was used for any of this. I don't have Unreal's copy to run it directly. @Olima34, for the board.
LakshanSivakumar commented 2026-11-27 16:15:13 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:15:13Z.


Merged in 4cf84c83. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. The converter here is 3.0 or newer, so I did not see the refusal itself. Thanks.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7223039812 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/351#issuecomment-7223039812). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:15:13Z. --- Merged in 4cf84c83. Before pushing I ran the tests (native arm64), Windows clippy, the policy check, a release build, and one headless game run of the exact tree (170 s, Series S): menus at 30 fps, the world entered at about 81 s and kept presenting to the end at about 1 frame a second, 0 GPU errors, no crash. The converter here is 3.0 or newer, so I did not see the refusal itself. Thanks.
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
LakshanSivakumar/Native-Victory-macOS!351
No description provided.