Skip to content

Link over-budget mesh outputs to the paired pixel shader on macOS - #161

Merged
pragyaangaur merged 2 commits into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-paired-mesh-outputs
Nov 26, 2026
Merged

pragyaangaur merged 2 commits into
pragyaangaur:mainfrom
gdemontalivet:fix/macos-paired-mesh-outputs

Conversation

@gdemontalivet

Copy link
Copy Markdown
Contributor

This backports Texbirds’ paired mesh and pixel shader translation to the macOS runtime. Related to #132 and the footprint measurements in #153.

For over-budget shaders, the translator first caps the declared vertex and primitive counts at the number of exporting lanes. If the standalone shader still exceeds 32 KiB, setting VICTORY_LINK_MESH_OUTPUTS=1 enables a second translation using the actual pixel shader’s input reads. Both stages keep the system values they need. Results are cached by the full source hashes. Each translation inherits the runtime's Wine options. Pairing is opt-in. The standalone count tightening applies in both modes.

The native workspace passed 457 tests. The release Windows build completed, and the shader suite passed 280 tests under CrossOver Preview and D3DMetal on an M5 Max, with three ignored. The synthetic mesh/pixel test checks the rendered color by readback.

In a separate integration build with the same linking algorithm, I exercised all 66 distinct shader-pack pairs found for six affected character shader names. Forty-four standalone mesh shaders across these pairs failed DXIL validation. Both stages of all 66 linked pairs validated and created a hardware pipeline. Two over-budget pairs also linked during a live prologue run, each at 28,672 bytes. The scene remained overexposed. The capture interval from world frame +48 to +90 ran at 0.58 FPS with linking versus 0.71 FPS in an earlier baseline run. Those single runs had different shader-cache and background compilation conditions. This change addresses pipeline correctness. Its gameplay FPS benefit is unproven.

The repository tests use generated shaders.

…ipelines

Port Texbirds' Marvisak/VIctory#2398 to the macOS runtime. Preserve the runtime compiler options and limit container retention to the experimental path.

Co-authored-by: Tex <kwintjanleenders@gmail.com>
@pragyaangaur

Copy link
Copy Markdown
Owner

Thanks for the careful measurements. This overlaps #153 (same 32 KiB limit, same helper, different size formula) and conflicts with #180 and #164 in lower.rs and emit/mod.rs. Please settle one shared mesh output size helper with #153 (the 4 bytes per component times exact vertex count measured on D3DMetal, or justify the round up to 32), say whether the always-on count tightening should also be opt-in, run cargo fmt on the new code, and rebase.

The size now comes from the shared mesh_outputs helper (4 bytes per component times the exact vertex count) and Metal's limit, and the duplicate 32-rounded helper and limit are gone. The count tightening stays on for any shader over the limit, since each lane exports one vertex and one primitive.
@pragyaangaur
pragyaangaur merged commit 3b8d507 into pragyaangaur:main Nov 26, 2026
1 of 2 checks passed
@pragyaangaur

Copy link
Copy Markdown
Owner

I merged main into this branch and merged it. The paired mesh and pixel linking now uses the shared helper from #153 (mesh_outputs and METAL_MESH_OUTPUT_BYTES: 4 bytes per component times the exact vertex count), and the 32-rounded helper and its separate limit constant are gone. The count tightening to the lane count stays always on, since a lane exports one vertex and one primitive, and it only applies to shaders that are over the limit. Linking itself stays opt-in with VICTORY_LINK_MESH_OUTPUTS=1. The mesh output tests were updated for the exact formula and the tightened counts. CI passed on a rerun (one run failed in memory::tests::a_submission_that_missed_leaves_the_copies_at_once, which this change does not touch). Thank you for the measurements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Host GPU runtime: resources, copies, presenting area:shader Shader translator d3dmetal A difference in Apple's D3DMetal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants