#44
Fix sky domes cut by the depth test
Some skies were cut by the depth test, differently in every run: coral shards in the Sky-High Sundae sky, and dark wedges with straight edges in the Wii Rainbow Road stars.
These skies are drawn on the far plane (pos.z == pos.w) after a depth pre-pass, then tested EQUAL or LEQUAL with depth writes off. On a Switch every such mesh lands on exactly 1.0. On Metal two sky meshes can differ by a few ulps, so whole triangles fail the test, and the sky behind shows through.
- The shader translator marks vertex shaders that set
pos.zandpos.wfrom the same register. In the 4.0.1 shader cache, 135 of about 16,000 vertex shader variants are marked. - The shader cache stores the mark in the
writes_depthcolumn (bit 1), so older caches still load. They have no marks, so the fix needs a Prepare. - Only marked draws with an
EQUALorLEQUALtest and depth writes off testLEQUALwith a depth bias of 4 ulps toward the camera. All other geometry keeps its exact depth test. - A bias of 0 does not fix the sky domes. A bias of 64 drew the Mute City sky over its most distant skyscrapers, which flickered as brown blotches during the course intro.
Tests
cargo test --workspacepasses, with new tests for the far-plane check.- Tested on macOS (M1) with update 4.0.1: Sky-High Sundae and Wii Rainbow Road were clean in every run (3 to 5 runs each), and the Mute City intro keeps its skyline. Other tracks looked unchanged.