Interior walls missing: wall meshes are over the 32 KiB mesh output limit #528

Open
opened 2026-11-28 01:02:26 +00:00 by LakshanSivakumar · 11 comments
LakshanSivakumar commented 2026-11-28 01:02:26 +00:00 (Migrated from github.com)
Contributor

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


What you see

Pieces of the interior walls are missing. In one shot a small bright patch high on the wall shows the sky through a hole.

What I know

The wall meshes are refused because their mesh shader output is larger than 32 KiB. In a 420 s run, 13 mesh programs were refused for this, and about 7,000 mesh draws were dropped by frame 1984. One frame's trace shows 31 wall draws dropped for mesh 1c451759; a9184e59 is another wall.

  • The refused sizes are 33,792, 36,864 and 38,400 bytes.
  • The check runs per mesh program, before it is paired with a pixel shader, so trimming outputs to what the pixel shader reads never applies.
  • VICTORY_MESH_OVER_LIMIT=1 does not let them through. It skips one copy of the check, but make_render in shaders.rs has a second copy with no switch, and that one refuses the pipeline.
  • The converter lays mesh outputs out in signature order. With the best order, the walls are still 264 bytes per vertex, 33,792 bytes in all.
  • Each wall vertex carries its 4 clip distances twice: once for clipping, and once as a 16-byte copy for the pixel shader. Without the copy the walls would be 248 bytes per vertex and would fit.
  • I do not know Metal's real limit. Apple's only published figure is 16 KB per mesh (WWDC22), but 32 KB pipelines draw fine here. The report that a 34,816-byte layout hangs the GPU comes from the Wine route, not this port.

What would help

  • Someone to measure the real limit on Apple Silicon: a mesh pipeline just over 32 KiB with VICTORY_TRACE_GPU_FAILS=1, on a spare run. derz92 reported 300 s clean on an M5 Max with the first check off.
  • A fix that checks the size after trimming to what the pixel shader reads.
  • Or a fix that drops the second copy of the clip distances and clips in the pixel shader.

An untested first commit that reorders outputs to cut padding exists and I can push it if someone wants to build on it.

How to see it

Branch lit-world/base-3 (commit 9a0d811d). It is #437 with fixes on top: #518, the cross-page loads, texture fixes, the page table for described pipelines and the image null-view test. It is not main, and one upstream test fails on it by design (wave32_tests::a_branch_on_a_first_lane_read_is_not_uniform_across_the_halves).

VICTORY_CONSOLE_PIPELINES=0 VICTORY_METAL_RESIDENCY_SETS=1 VICTORY_TEXTURE_DROP_TOP_MIP=1 \
VICTORY_OUTPUT=1280x720 VICTORY_UPSCALER=6 VICTORY_STEP_OVER=pool VICTORY_PIPELINE_TIMEOUT_S=15 \
tools/macos/run-native.sh --console series-s <game folder>

Apple Silicon Mac with 48 GB, Series S profile. The world shows about 4.5 minutes after start on a cold shader cache.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6656990360 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T01:02:26Z. --- ### What you see Pieces of the interior walls are missing. In one shot a small bright patch high on the wall shows the sky through a hole. ### What I know The wall meshes are refused because their mesh shader output is larger than 32 KiB. In a 420 s run, 13 mesh programs were refused for this, and about 7,000 mesh draws were dropped by frame 1984. One frame's trace shows 31 wall draws dropped for mesh `1c451759`; `a9184e59` is another wall. - The refused sizes are 33,792, 36,864 and 38,400 bytes. - The check runs per mesh program, before it is paired with a pixel shader, so trimming outputs to what the pixel shader reads never applies. - `VICTORY_MESH_OVER_LIMIT=1` does not let them through. It skips one copy of the check, but `make_render` in `shaders.rs` has a second copy with no switch, and that one refuses the pipeline. - The converter lays mesh outputs out in signature order. With the best order, the walls are still 264 bytes per vertex, 33,792 bytes in all. - Each wall vertex carries its 4 clip distances twice: once for clipping, and once as a 16-byte copy for the pixel shader. Without the copy the walls would be 248 bytes per vertex and would fit. - I do not know Metal's real limit. Apple's only published figure is 16 KB per mesh (WWDC22), but 32 KB pipelines draw fine here. The report that a 34,816-byte layout hangs the GPU comes from the Wine route, not this port. ### What would help - Someone to measure the real limit on Apple Silicon: a mesh pipeline just over 32 KiB with `VICTORY_TRACE_GPU_FAILS=1`, on a spare run. derz92 reported 300 s clean on an M5 Max with the first check off. - A fix that checks the size after trimming to what the pixel shader reads. - Or a fix that drops the second copy of the clip distances and clips in the pixel shader. An untested first commit that reorders outputs to cut padding exists and I can push it if someone wants to build on it. ### How to see it Branch [`lit-world/base-3`](https://github.com/LakshanSivakumar/Native-Victory-macOS/tree/lit-world/base-3) (commit `9a0d811d`). It is #437 with fixes on top: #518, the cross-page loads, texture fixes, the page table for described pipelines and the image null-view test. It is not main, and one upstream test fails on it by design (`wave32_tests::a_branch_on_a_first_lane_read_is_not_uniform_across_the_halves`). ```bash VICTORY_CONSOLE_PIPELINES=0 VICTORY_METAL_RESIDENCY_SETS=1 VICTORY_TEXTURE_DROP_TOP_MIP=1 \ VICTORY_OUTPUT=1280x720 VICTORY_UPSCALER=6 VICTORY_STEP_OVER=pool VICTORY_PIPELINE_TIMEOUT_S=15 \ tools/macos/run-native.sh --console series-s <game folder> ``` Apple Silicon Mac with 48 GB, Series S profile. The world shows about 4.5 minutes after start on a cold shader cache.
derz92 commented 2026-11-28 01:11:15 +00:00 (Migrated from github.com)
Author
Contributor

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


Evidence that Metal accepts these. On #437's tree (b998bb65 + #437), where there was only the one copy of the check, VICTORY_MESH_OVER_LIMIT=1 let all four oversized mesh programs through on an M5 Max, macOS 26.5. The declared outputs were 33,792, 36,864 and 38,400 bytes, the same sizes as here. They went through the converter and Metal's pipeline creation with no error, and a 300 s world run had 0 failed command buffers. Visibly, the hair came back (the dark spikes on the player's head were skipped hair/head meshes) and more of the yard drew. Details on #437.

So at least on M5 with macOS 26.5, the 32,768-byte figure isn't a hard limit for these pipelines. Ketan is testing synthetic sizes on an M4 Pro.

/claim

Plan for a first, small PR: make the second check in make_render honour the same VICTORY_MESH_OVER_LIMIT switch, with a test. Then report what a run on lit-world/base-3 shows with it on (walls, errors). Whether the guard should go entirely, or become a pipeline-creation check that only refuses if Metal actually fails, can follow once Ketan's M4 Pro results are in.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231483787 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231483787). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:11:15Z. --- Evidence that Metal accepts these. On #437's tree (b998bb65 + #437), where there was only the one copy of the check, `VICTORY_MESH_OVER_LIMIT=1` let all four oversized mesh programs through on an M5 Max, macOS 26.5. The declared outputs were 33,792, 36,864 and 38,400 bytes, the same sizes as here. They went through the converter and Metal's pipeline creation with no error, and a 300 s world run had **0 failed command buffers**. Visibly, the hair came back (the dark spikes on the player's head were skipped hair/head meshes) and more of the yard drew. Details on #437. So at least on M5 with macOS 26.5, the 32,768-byte figure isn't a hard limit for these pipelines. Ketan is testing synthetic sizes on an M4 Pro. /claim Plan for a first, small PR: make the second check in `make_render` honour the same `VICTORY_MESH_OVER_LIMIT` switch, with a test. Then report what a run on `lit-world/base-3` shows with it on (walls, errors). Whether the guard should go entirely, or become a pipeline-creation check that only refuses if Metal actually fails, can follow once Ketan's M4 Pro results are in.
derz92 commented 2026-11-28 01:11:28 +00:00 (Migrated from github.com)
Author
Contributor

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


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231486458 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231486458). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:11:28Z. --- /claim
github-actions[bot] commented 2026-11-28 01:11:40 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T01:11:40Z.


Claimed by @derz92. Open a draft pull request with Refs #528 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231488918 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231488918). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T01:11:40Z. --- Claimed by @derz92. Open a draft pull request with `Refs #528` in its description within 24 hours, or the claim expires.
Olima34 commented 2026-11-28 01:29:04 +00:00 (Migrated from github.com)
Author
Contributor

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


@derz92 a question so we don't overlap. #536 makes VICTORY_MESH_OVER_LIMIT=1 pass both checks, which is great for testing. Are you also planning the default fix the issue asks for, a size check after trimming outputs to what the pixel shader reads, or dropping the duplicate clip-distance copy? If not, we'd like to take that part as a separate PR on top of yours, with a unit test and no over-limit pipelines run by default. If you're already on it, we'll stay off.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231697355 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231697355). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:29:04Z. --- @derz92 a question so we don't overlap. #536 makes `VICTORY_MESH_OVER_LIMIT=1` pass both checks, which is great for testing. Are you also planning the default fix the issue asks for, a size check after trimming outputs to what the pixel shader reads, or dropping the duplicate clip-distance copy? If not, we'd like to take that part as a separate PR on top of yours, with a unit test and no over-limit pipelines run by default. If you're already on it, we'll stay off.
derz92 commented 2026-11-28 01:35:08 +00:00 (Migrated from github.com)
Author
Contributor

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


Correction to my comment above: I was wrong. On #437's tree, VICTORY_MESH_OVER_LIMIT=1 did not get these programs through. That tree's second check (make_render) still refused them: the run's counters show mesh_refused_over_limit=10753, and its log has "mesh outputs exceed Metal's limit; pipeline refused" for 1c451759, a9184e59 and b6837618. I'd searched for the first check's wording, saw none, and wrongly concluded they compiled. The visual differences I credited to it (hair, the yard) must have come from something else in that run.

On lit-world/base-3 with all three checks bypassed (#536), Metal itself refuses them at pipeline creation: "Total mesh size (36864) exceeds the maximum mesh size allowed (32768)", and the same for 38400 and 33792 (M5 Max, macOS 26.5). So 32 KiB is a real Metal limit for these pipelines, and bypassing the guards can't draw the walls. Trimming outputs to what the paired pixel shader reads, as Ketan is doing on #437, is the fix.

I'm closing #536 and releasing this.

/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231771597 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231771597). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:35:08Z. --- **Correction to my comment above: I was wrong.** On #437's tree, `VICTORY_MESH_OVER_LIMIT=1` did **not** get these programs through. That tree's second check (`make_render`) still refused them: the run's counters show `mesh_refused_over_limit=10753`, and its log has "mesh outputs exceed Metal's limit; pipeline refused" for `1c451759`, `a9184e59` and `b6837618`. I'd searched for the first check's wording, saw none, and wrongly concluded they compiled. The visual differences I credited to it (hair, the yard) must have come from something else in that run. On `lit-world/base-3` with all three checks bypassed (#536), **Metal itself refuses them** at pipeline creation: "Total mesh size (36864) exceeds the maximum mesh size allowed (32768)", and the same for 38400 and 33792 (M5 Max, macOS 26.5). So 32 KiB is a real Metal limit for these pipelines, and bypassing the guards can't draw the walls. Trimming outputs to what the paired pixel shader reads, as Ketan is doing on #437, is the fix. I'm closing #536 and releasing this. /release
derz92 commented 2026-11-28 01:41:00 +00:00 (Migrated from github.com)
Author
Contributor

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


@Olima34 no. Please see my correction above: with every check bypassed, Metal itself refuses these pipelines ("Total mesh size (36864) exceeds the maximum mesh size allowed (32768)"), so #536 couldn't help and I closed it. The real fix is the one you name, a size check after trimming outputs to what the pixel shader reads (Ketan is doing the trimming on #437). I'm releasing this so whoever takes that has it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231843855 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231843855). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:41:00Z. --- @Olima34 no. Please see my correction above: with every check bypassed, Metal itself refuses these pipelines ("Total mesh size (36864) exceeds the maximum mesh size allowed (32768)"), so #536 couldn't help and I closed it. The real fix is the one you name, a size check after trimming outputs to what the pixel shader reads (Ketan is doing the trimming on #437). I'm releasing this so whoever takes that has it.
derz92 commented 2026-11-28 01:41:01 +00:00 (Migrated from github.com)
Author
Contributor

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


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231844076 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231844076). Originally posted by [derz92](https://github.com/derz92) on 2026-11-28T01:41:01Z. --- /release
github-actions[bot] commented 2026-11-28 01:41:17 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T01:41:17Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231847326 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231847326). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T01:41:17Z. --- Released. This issue is free to claim.
Olima34 commented 2026-11-28 01:52:40 +00:00 (Migrated from github.com)
Author
Contributor

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


Thanks @derz92, that's a useful result: 32 KiB is Metal's own hard limit for these pipelines ("Total mesh size … exceeds the maximum mesh size allowed (32768)"), so the only way to draw the walls is to make their outputs fit. Closing #536 was the right call.

@Ketan-Kapse since the output trimming lives on #437: do you plan to send it as its own PR? If you'd rather not, we can take that part: trim each mesh program's outputs to what its paired pixel shader reads, check the size after trimming, and if still needed drop the duplicate 16-byte clip-distance copy (248 bytes a vertex would fit). It would come with unit tests and no over-limit pipeline ever created. We'll wait for your answer before claiming, so we don't duplicate your work.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231977191 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7231977191). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-28T01:52:40Z. --- Thanks @derz92, that's a useful result: 32 KiB is Metal's own hard limit for these pipelines ("Total mesh size … exceeds the maximum mesh size allowed (32768)"), so the only way to draw the walls is to make their outputs fit. Closing #536 was the right call. @Ketan-Kapse since the output trimming lives on #437: do you plan to send it as its own PR? If you'd rather not, we can take that part: trim each mesh program's outputs to what its paired pixel shader reads, check the size after trimming, and if still needed drop the duplicate 16-byte clip-distance copy (248 bytes a vertex would fit). It would come with unit tests and no over-limit pipeline ever created. We'll wait for your answer before claiming, so we don't duplicate your work.
tarcisioads commented 2026-11-28 05:22:38 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by tarcisioads on 2026-11-28T05:22:38Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7234630702 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7234630702). Originally posted by [tarcisioads](https://github.com/tarcisioads) on 2026-11-28T05:22:38Z. --- /claim
github-actions[bot] commented 2026-11-28 05:22:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T05:22:47Z.


Claimed by @tarcisioads. Open a draft pull request with Refs #528 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7234632345 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/528#issuecomment-7234632345). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T05:22:47Z. --- Claimed by @tarcisioads. Open a draft pull request with `Refs #528` in its description within 24 hours, or the claim expires.
Sign in to join this conversation.
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#528
No description provided.