gpu(native), metal: VICTORY_MESH_OVER_LIMIT lets an over-32-KiB mesh program through all three size checks (#528) #536

Closed
derz92 wants to merge 3 commits from upstream-pr/536 into lit-world/base-3
derz92 commented 2026-11-28 01:15:28 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-28T01:15:28Z.


Refs #528

Base: lit-world/base-3, not main. The mesh path and both size checks exist only on that branch (from #437).

What this changes

VICTORY_MESH_OVER_LIMIT=1 now lets a mesh program with more than 32 KiB of declared outputs through all three size checks:

  • refuse_mesh, before conversion, already honoured the switch;
  • make_render, when the pipeline is made, refused on size whatever the switch said, as #528 found;
  • the Metal backend's mesh_pipeline (victory-metal) had a third copy, also with no switch. A first run with only the second check fixed still refused 1c451759 and a9184e59 there.

All three now ask one rule in the shader crate, mesh_over_limit(bytes, mesh_guard_on()). The default is unchanged: the guard stays on. That matters because the limit's own note records a 34,816-byte layout that hung the GPU queue on the Wine route, and Ketan saw a hang the same way. Turning it off is an experiment that can hang the GPU.

Why

On #437's tree, which had only the first check, the switch let all four oversized programs through on an M5 Max with macOS 26.5. Their declared outputs were 33,792, 36,864 and 38,400 bytes, the same sizes #528 reports. They compiled through the converter and Metal with no error, and a 300 s world run had 0 failed command buffers. The player's hair came back (the dark spikes were the skipped hair and head meshes). Details on #437 and #528.

How it was tested

  • cargo test -p victory-gpu --lib (native arm64): 506 passed; victory-shader mesh tests 18 passed; victory-metal --lib 61 passed. New tests: mesh_tests::the_mesh_size_guard_refuses_over_32_kib_only_while_it_is_on, emit::mesh::tests::the_mesh_output_guard_refuses_over_32_kib_only_while_on.
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: passes.
  • cargo xtask policy: ok.
  • Game run on this branch with the switch on (walls drawn, GPU errors). I'll add it here once it has run.

Not in this PR

Whether the guard should be dropped, or turned into a pipeline-creation check that refuses only when Metal actually fails, waits for Ketan's synthetic tests on the M4 Pro (#437).

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • New diagnostics are behind a VICTORY_* variable and documented
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5535274503 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/536). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:15:28Z. --- Refs #528 **Base:** `lit-world/base-3`, not `main`. The mesh path and both size checks exist only on that branch (from #437). ## What this changes `VICTORY_MESH_OVER_LIMIT=1` now lets a mesh program with more than 32 KiB of declared outputs through **all three** size checks: - `refuse_mesh`, before conversion, already honoured the switch; - `make_render`, when the pipeline is made, refused on size whatever the switch said, as #528 found; - the Metal backend's `mesh_pipeline` (`victory-metal`) had a third copy, also with no switch. A first run with only the second check fixed still refused `1c451759` and `a9184e59` there. All three now ask one rule in the shader crate, `mesh_over_limit(bytes, mesh_guard_on())`. **The default is unchanged: the guard stays on.** That matters because the limit's own note records a 34,816-byte layout that hung the GPU queue on the Wine route, and Ketan saw a hang the same way. Turning it off is an experiment that can hang the GPU. ## Why On #437's tree, which had only the first check, the switch let all four oversized programs through on an M5 Max with macOS 26.5. Their declared outputs were 33,792, 36,864 and 38,400 bytes, the same sizes #528 reports. They compiled through the converter and Metal with no error, and a 300 s world run had 0 failed command buffers. The player's hair came back (the dark spikes were the skipped hair and head meshes). Details on #437 and #528. ## How it was tested - [x] `cargo test -p victory-gpu --lib` (native arm64): 506 passed; `victory-shader` mesh tests 18 passed; `victory-metal --lib` 61 passed. New tests: `mesh_tests::the_mesh_size_guard_refuses_over_32_kib_only_while_it_is_on`, `emit::mesh::tests::the_mesh_output_guard_refuses_over_32_kib_only_while_on`. - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: passes. - [x] `cargo xtask policy`: ok. - [ ] Game run on this branch with the switch on (walls drawn, GPU errors). I'll add it here once it has run. ## Not in this PR Whether the guard should be dropped, or turned into a pipeline-creation check that refuses only when Metal actually fails, waits for Ketan's synthetic tests on the M4 Pro (#437). ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] New diagnostics are behind a `VICTORY_*` variable and documented
derz92 commented 2026-11-28 01:35:11 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by derz92 on 2026-11-28T01:35:11Z.


Closing: with all three checks bypassed, Metal itself refuses these pipelines ("Total mesh size (36864) exceeds the maximum mesh size allowed (32768)"), so the switch can't draw the walls. The fix is trimming outputs (Ketan, #437). Details and my correction on #528.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231772024 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/536#issuecomment-7231772024). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:35:11Z. --- Closing: with all three checks bypassed, Metal itself refuses these pipelines ("Total mesh size (36864) exceeds the maximum mesh size allowed (32768)"), so the switch can't draw the walls. The fix is trimming outputs (Ketan, #437). Details and my correction on #528.

Pull request closed

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