gpu: a value test on Metal for computed compute buffers (#421) #422

Merged
tiagonogueiraa-bit merged 1 commit from upstream-pr/422 into main 2026-11-28 01:34:35 +00:00
tiagonogueiraa-bit commented 2026-11-27 17:36:36 +00:00 (Migrated from github.com)

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


Refs #421

docs/native-host.md ("Computed compute buffers") said that path was only translation-tested: "no value test runs it on a GPU". This PR adds that test. It is test and docs only, with no translator or host change.

Test. addr_tests::a_compute_buffer_descriptor_around_a_computed_address_loads_title_memory (victory-gpu, on Metal with MSC 4.0 beta 3).

  • Path. It goes through the host's own path: shaders::translate of an FSPX container (pipeline::test_compute_container) whose root-constant record (root type 0, user data 0) reaches four user SGPRs. So constants_to_the_end and zero_copy_memory are exercised as in a run.
  • Program. Each lane builds a raw descriptor over s[0:1] + 16 (stride 0, control word 0x31014fac, bounds mode 3 with a byte count in dword 2), loads its dword by byte offset (buffer_load_dword ... offen) and stores it to dst[lane] with global_store_dword.
  • Address. The source address is above 4 GiB (VA_A), so the high bits go through the page table.
  • Results.
    • With 128 bytes, every lane reads its source dword.
    • With 64 bytes, lanes 16 and up read 0.

Learned while writing it. I first used control word 0x00014fac (bounds mode 0). With stride 0 every lane read 0, because mode 0 checks each offset against the stride. The docs now say so, next to the test's name.

Checks.

  • cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 1054 passed, 0 failed, 11 ignored.
  • Windows clippy -D warnings: clean.
  • cargo xtask policy: ok.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5530763465 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/422). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-27T17:36:36Z. --- Refs #421 `docs/native-host.md` ("Computed compute buffers") said that path was only translation-tested: "no value test runs it on a GPU". This PR adds that test. It is test and docs only, with no translator or host change. **Test.** `addr_tests::a_compute_buffer_descriptor_around_a_computed_address_loads_title_memory` (`victory-gpu`, on Metal with MSC 4.0 beta 3). - **Path.** It goes through the host's own path: `shaders::translate` of an FSPX container (`pipeline::test_compute_container`) whose root-constant record (root type 0, user data 0) reaches four user SGPRs. So `constants_to_the_end` and `zero_copy_memory` are exercised as in a run. - **Program.** Each lane builds a raw descriptor over `s[0:1] + 16` (stride 0, control word `0x31014fac`, bounds mode 3 with a byte count in dword 2), loads its dword by byte offset (`buffer_load_dword ... offen`) and stores it to `dst[lane]` with `global_store_dword`. - **Address.** The source address is above 4 GiB (`VA_A`), so the high bits go through the page table. - **Results.** - With 128 bytes, every lane reads its source dword. - With 64 bytes, lanes 16 and up read 0. **Learned while writing it.** I first used control word `0x00014fac` (bounds mode 0). With stride 0 every lane read 0, because mode 0 checks each offset against the stride. The docs now say so, next to the test's name. **Checks.** - `cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask`: 1054 passed, 0 failed, 11 ignored. - Windows clippy `-D warnings`: clean. - `cargo xtask policy`: ok.
Olima34 commented 2026-11-28 01:34:31 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T01:34:31Z.

Review: APPROVED


Check report (helping the maintainer clear the queue):

  • CI: check and macos-scripts green on the current head.
  • Read: the whole diff (test and docs only). It's a Metal value test of a compute buffer descriptor built around a root-constant address above 4 GiB, through the host's own translation, with a byte count that cuts lanes off. The docs now name it instead of saying no value test exists. The program is synthetic.
  • Local check: current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#397 #399 #422 #467 #471 #475 #479 #481 #486 #489 #494 #498 #505 #511). On it, the victory-gpu (arm64), victory-shader, victory-backend, victory-metal and victory tests pass, as do the macOS script tests (rustup-path.sh, run-summary-compare.sh, run-summary.sh --self-test), Windows clippy (-D warnings) and cargo xtask policy. One victory-gpu run in four failed main's own multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately. That test also flakes on main alone, so it isn't from this batch.
  • Not checked: no game run (the maintainer asked us to work on GitHub only).

Thanks @tiagonogueiraa-bit!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6094918916 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/422#pullrequestreview-6094918916). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:34:31Z. **Review:** APPROVED --- Check report (helping the maintainer clear the queue): - **CI:** `check` and `macos-scripts` green on the current head. - **Read:** the whole diff (test and docs only). It's a Metal value test of a compute buffer descriptor built around a root-constant address above 4 GiB, through the host's own translation, with a byte count that cuts lanes off. The docs now name it instead of saying no value test exists. The program is synthetic. - **Local check:** current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#397 #399 #422 #467 #471 #475 #479 #481 #486 #489 #494 #498 #505 #511). On it, the `victory-gpu` (arm64), `victory-shader`, `victory-backend`, `victory-metal` and `victory` tests pass, as do the macOS script tests (`rustup-path.sh`, `run-summary-compare.sh`, `run-summary.sh --self-test`), Windows clippy (`-D warnings`) and `cargo xtask policy`. One `victory-gpu` run in four failed main's own `multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately`. That test also flakes on main alone, so it isn't from this batch. - **Not checked:** no game run (the maintainer asked us to work on GitHub only). Thanks @tiagonogueiraa-bit!
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!422
No description provided.