Make the water corrections in the runtime, on by default, instead of loading replacement modules from a folder.

The coordinate pair and the absorption guard needed modules made on each PC by tools/projective_recipe.py and a folder named in NX2NAVI_SPV_OVERRIDE, so no player had them. runtime/spirv_water.c makes the recipe's edits on the translation in memory, in the recipe's order: on the NVIDIA profile its three modules are byte for byte the recipe's (RTX 5090, game 1.1.1). vk_pipeline.c keeps the edited modules in a small table, made at first use, and builds a pair from them only when both of its stages were made; a module of another shape is built as it is, with a log line. NX2NAVI_WATER_PROJECTIVE=0 turns the corrections off. tests/water_projective_check.py compares the runtime's edits with the recipe's on made-up modules.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-12 07:55:57 -05:00
parent 56e142169c
commit d31c3a1036
8 changed files with 575 additions and 137 deletions

View File

@@ -18,7 +18,7 @@ for the launcher; a GPU with Vulkan 1.3 and `VK_EXT_external_memory_host` (curre
## Faster
- **A new install no longer builds its pipelines while you play.** A release now carries a list of the graphics
pipelines the game is known to draw, 8,605 of them in this one. The install builds all of them while it prepares the
pipelines the game is known to draw, 8,715 of them in this one. The install builds all of them while it prepares the
shaders, and every start builds them before play, as it already did for the pipelines your own install had drawn.
Before, a new install met each pipeline in play first: in Hyrule Field one ten-second stretch of a first visit had
1,769 draws wait for their pipelines, 461 ms in all, the longest frame 88 ms. In a first walk through Kakariko
@@ -55,16 +55,17 @@ for the launcher; a GPU with Vulkan 1.3 and `VK_EXT_external_memory_host` (curre
5 to 180 m in one frame; such a frame now starts a new history, and frame generation is told of every new start, so
it no longer makes frames between two unrelated pictures. `dlaa_cut = 0` turns the camera test off. By bct8925
(pull request #651).
- **Water drawn as a rectangle over solid ground at the Hyrule Castle moat and the Castle Town canal, and a red beam
there** (issue #398). The water's shader worked out each corner's place on the screen and blended that across the
surface, which goes wrong as soon as a corner of the surface is behind the camera; its place is now worked out per
pixel. The distance through the water that dims what lies under it can no longer be negative, which had turned the
dimming into a gain. Found and corrected by ChurchOfIlias (pull request #666); the game applies the correction to
those two shaders itself. `water_projective = 0` in nx2navi.ini leaves them as they are. The correction was compared
byte for byte on an NVIDIA card; on AMD it runs the same steps on AMD's translation of the shaders and was not run by
us. Why the distance comes out negative is not known yet.
- **The launcher run from the source with an older Python** stopped at *Gather Build Tools* with nothing but "No
module named 'zstandard'". It now says so on its first screen, with the command that installs what is missing.
## For testers
- **Water drawn as a rectangle over solid ground at the Hyrule Castle moat and the Castle Town canal, and a red beam
there** (issue #398): the source has an opt-in correction by ChurchOfIlias (pull request #666). It takes replacement
shaders made on your own PC from your own shader cache (`tools/projective_recipe.py`, `docs/water-projective.md`)
and is off unless `spv_override` names their folder. The release does not turn it on.
## Known issues
- A rare one-frame flicker of shadows or lighting, on grass and objects, may remain; the fix for the black part of the

View File

@@ -48,14 +48,31 @@ original, paired-coordinate and absorption-guard pipelines.
The vertex replacement stands for the translation itself: the outputs an install's
vertex output union adds are added to the replacement as to any other module, so the
pair holds whatever other fragment shaders that install has met with the vertex
shader. A pair blended with dual-source factors keeps its original modules. The log
names each replacement the first time it is built ("water projective: ... module").
shader. A pair blended with dual-source factors keeps its original modules.
The translations of game 1.1.1 are the same under the 0.9.0 translator as under
0.8.0's on NVIDIA (RTX 5090), so the profiles above still apply there.
## Private local preparation
## In the runtime, on by default
Use locally held inputs from the same supported translator profile:
The runtime makes both corrections itself (`runtime/spirv_water.c`, called from
`runtime/vk_pipeline.c` `water_projective_pair`): when a pipeline's shaders are one of
the translations above, it edits their SPIR-V in memory, with the steps of
`tools/projective_recipe.py` in the same order, and builds the pipeline from the
result. No file is read or written and nothing derived from the game is shipped.
`water_projective = 0` in `nx2navi.ini` builds the translations as they are. The log
names each corrected module the first time it is built ("vk_pipeline: water: ...");
a module that is not of the shape an edit expects is built as it is, with a line
that says so. A coordinate pair is corrected in both stages or in neither.
On the NVIDIA profile the runtime's three modules are byte for byte the ones the
recipe writes (RTX 5090, game 1.1.1, 0.9.0's translator). The AMD profile runs the
same code on AMD's translations, which were not at hand to compare.
`python tests/water_projective_check.py` compares the two on made-up modules.
## The recipe as a tool
`tools/projective_recipe.py` makes the same modules as files from locally held
inputs, for comparing or inspecting them:
```sh
python tools/projective_recipe.py --vertex <local-vertex.spv> --fragment <local-fragment.spv> --material <local-material.spv> --output build/water-projective
@@ -64,14 +81,8 @@ python tools/projective_recipe.py --vertex <local-vertex.spv> --fragment <local-
The material argument is optional for a coordinate-only comparison. The recipe
rejects unknown inputs, mixed profiles and existing output files. It writes
replacement modules named by the original vertex or set-1 fragment identities,
plus a manifest. Validate every generated module with
`spirv-val --target-env vulkan1.2 <module.spv>` before integration.
Rebuild using the documented UCRT64 workflow. Set `NX2NAVI_SPV_OVERRIDE` to the
absolute output directory in the test process, then restart. Default runtime
behavior is unchanged. Use separate pipeline caches for comparisons and disable
pipeline-binary reuse and boot prebuilding during the experiment. Unset the
override and restart to disable it. Do not change the directory during a run.
plus a manifest. Validate a generated module with
`spirv-val --target-env vulkan1.2 <module.spv>`. The runtime does not read them.
## Validation and limits