fix(shader): the water light's tile lists take a slot a lane #221

Closed
mutlusinan wants to merge 1 commit from upstream-pr/221 into main
mutlusinan commented 2026-11-27 19:53:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mutlusinan on 2026-11-27T19:53:36Z.


Problem

On a host of 32-lane waves, water_shading:CS_TransmissionVolumetrics_GenerateTiles (the title, build 1.0.2.1) runs as two host waves per console wave, and the two tile appends in it assume a 64-lane wave: the first lane adds the whole wave's count and every lane's slot is its rank on top of what the counter held. The second half's rank needs the first half's lane mask; without it the second wave's tiles overwrite slots of the first, those tiles get no light, and the sea shows dark blocks around boats, piers and lamp posts (blocks of 16x16 pixels). This is why this fork currently leaves the water light's two programs out by default (VICTORY_WATER_LIGHT, off).

Fix

emit/water_tile_slots.rs: before translation, the known program is rewritten so every lane takes its own list slot — one atomic add of 1 per lane, and the lane's slot is what the counter held. Slots are still each given once and the counters end the same; only the order within a list differs, which nothing reads. No lane mask, first lane or exchange between the halves is left in the two appends.

  • Byte-exact match only: container digest, code length and FNV-1a of the code; any other program is untouched.
  • VICTORY_WATER_TILE_SLOTS=0 restores the old form.
  • Applied in emit::translate and in victory translate (which drives emit itself), so the offline path sees the same form.

Verification

  • cargo check --workspace --target x86_64-pc-windows-msvc --locked — clean.
  • cargo run -p xtask -- policy — 286 files ok.
  • Not run in game here: no Windows PC or GPU in this environment. Please test on the RTX card, ideally the first boat ride with VICTORY_WATER_LIGHT=1, watching for the dark blocks around boats and piers.

Ported from fxceless/victory-fork cd93552, itself after xss3009's "Fix transmission tile allocation on wave32 hosts"; written again for this tree (GPL-3.0-or-later, GPL-compatible).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5532327042 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221). Originally posted by [mutlusinan](https://github.com/mutlusinan) on 2026-11-27T19:53:36Z. --- ### Problem On a host of 32-lane waves, `water_shading:CS_TransmissionVolumetrics_GenerateTiles` (the title, build 1.0.2.1) runs as two host waves per console wave, and the two tile appends in it assume a 64-lane wave: the first lane adds the whole wave's count and every lane's slot is its rank on top of what the counter held. The second half's rank needs the first half's lane mask; without it the second wave's tiles overwrite slots of the first, those tiles get no light, and the sea shows dark blocks around boats, piers and lamp posts (blocks of 16x16 pixels). This is why this fork currently leaves the water light's two programs out by default (`VICTORY_WATER_LIGHT`, off). ### Fix `emit/water_tile_slots.rs`: before translation, the known program is rewritten so every lane takes its own list slot — one atomic add of 1 per lane, and the lane's slot is what the counter held. Slots are still each given once and the counters end the same; only the order within a list differs, which nothing reads. No lane mask, first lane or exchange between the halves is left in the two appends. - Byte-exact match only: container digest, code length and FNV-1a of the code; any other program is untouched. - `VICTORY_WATER_TILE_SLOTS=0` restores the old form. - Applied in `emit::translate` and in `victory translate` (which drives `emit` itself), so the offline path sees the same form. ### Verification - `cargo check --workspace --target x86_64-pc-windows-msvc --locked` — clean. - `cargo run -p xtask -- policy` — 286 files ok. - Not run in game here: no Windows PC or GPU in this environment. **Please test on the RTX card**, ideally the first boat ride with `VICTORY_WATER_LIGHT=1`, watching for the dark blocks around boats and piers. Ported from fxceless/victory-fork `cd93552`, itself after xss3009's "Fix transmission tile allocation on wave32 hosts"; written again for this tree (GPL-3.0-or-later, GPL-compatible).
mutlusinan commented 2026-11-27 20:21:17 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mutlusinan on 2026-11-27T20:21:17Z.


Risk assessment (porting review)

  • No effect in a default run, by the shape of this tree. pipeline::make::left_out leaves the water light's two programs out unless VICTORY_WATER_LIGHT=1 (crates/victory-gpu/src/pipeline/make.rs:88), so this program is never translated and host_form never sees it. The offline translator additionally needs VICTORY_HOST_MAX_WAVE=32: host_max_wave() defaults to 0 and host_form requires 32.
    → This PR is a no-op until that leave-out is removed; that should be its own change, after the fix is proven in play.
  • Blast radius if enabled: the rewrite requires the container digest, the code length and the FNV-1a of the whole program; any other program is left untouched, and a mismatched title build makes it a no-op rather than a mis-rewrite. A wrong offset inside that one program would break the water light only, not the translator.
  • Cache: translation_fingerprint covers the translator source hash, every VICTORY_* switch the source names (the build script scans for them, so VICTORY_WATER_TILE_SLOTS is included) and the host facts including host_max_wave — toggling either side does not reuse a stale translation.
  • Compatibility: merges cleanly and type-checks against main at e69e39c.
  • Not run: in-game water test (no Windows/GPU here).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7227420220 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7227420220). Originally posted by [mutlusinan](https://github.com/mutlusinan) on 2026-11-27T20:21:17Z. --- ### Risk assessment (porting review) - **No effect in a default run, by the shape of this tree.** `pipeline::make::left_out` leaves the water light's two programs out unless `VICTORY_WATER_LIGHT=1` (`crates/victory-gpu/src/pipeline/make.rs:88`), so this program is never translated and `host_form` never sees it. The offline translator additionally needs `VICTORY_HOST_MAX_WAVE=32`: `host_max_wave()` defaults to 0 and `host_form` requires 32. → This PR is a no-op until that leave-out is removed; that should be its own change, after the fix is proven in play. - **Blast radius if enabled:** the rewrite requires the container digest, the code length and the FNV-1a of the whole program; any other program is left untouched, and a mismatched title build makes it a no-op rather than a mis-rewrite. A wrong offset inside that one program would break the water light only, not the translator. - **Cache:** `translation_fingerprint` covers the translator source hash, every `VICTORY_*` switch the source names (the build script scans for them, so `VICTORY_WATER_TILE_SLOTS` is included) and the host facts including `host_max_wave` — toggling either side does not reuse a stale translation. - **Compatibility:** merges cleanly and type-checks against `main` at `e69e39c`. - **Not run:** in-game water test (no Windows/GPU here).
cloph-dsp commented 2026-11-28 02:35:15 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-11-28T02:35:15Z.


Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):

  • PR #221 at head a37e53267e5b096e452f9f53031bff91d8e9a857, merge base 0cef07e9d766df48f0e95f13ce3bbbe2290fe9d3.
  • Exact module-qualified tests, each 1 passed / 0 failed / 293 filtered, exit 0:
    • cargo test --locked -p victory-shader --lib -- emit::water_tile_slots::tests::an_append_becomes_one_add_a_lane_and_keeps_its_length --exact --test-threads=1 --quiet
    • cargo test --locked -p victory-shader --lib -- emit::water_tile_slots::tests::another_program_is_left_as_it_is --exact --test-threads=1 --quiet
  • git grep -F for these test names on the base returned no hits (tests are new on this PR); git diff --check 0cef07e9 HEAD clean (3 files, +185/-2).
  • Used a per-worktree CARGO_TARGET_DIR (never shared) with CARGO_BUILD_JOBS=2.
  • Only the named synthetic tests were replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain).
  • GPU/driver: N/A (CPU-only tests). No game data, assets, extracted shaders, DRM or decrypt involved.

AI-assisted (Hy4 flash).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7232463274 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7232463274). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-28T02:35:15Z. --- Independent local verification (Windows, Rust 1.100.0/MSVC, no game data): - PR #221 at head `a37e53267e5b096e452f9f53031bff91d8e9a857`, merge base `0cef07e9d766df48f0e95f13ce3bbbe2290fe9d3`. - Exact module-qualified tests, each 1 passed / 0 failed / 293 filtered, exit 0: - `cargo test --locked -p victory-shader --lib -- emit::water_tile_slots::tests::an_append_becomes_one_add_a_lane_and_keeps_its_length --exact --test-threads=1 --quiet` - `cargo test --locked -p victory-shader --lib -- emit::water_tile_slots::tests::another_program_is_left_as_it_is --exact --test-threads=1 --quiet` - `git grep -F` for these test names on the base returned no hits (tests are new on this PR); `git diff --check 0cef07e9 HEAD` clean (3 files, +185/-2). - Used a per-worktree `CARGO_TARGET_DIR` (never shared) with `CARGO_BUILD_JOBS=2`. - Only the named synthetic tests were replayed; full workspace suite and clippy were not run locally (no clippy component on this toolchain). - GPU/driver: N/A (CPU-only tests). No game data, assets, extracted shaders, DRM or decrypt involved. AI-assisted (Hy4 flash).
dsh38 commented 2026-11-28 03:58:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dsh38 on 2026-11-28T03:58:54Z.


Independent in-game check on main 8fc2254 (v2026.11.27.10), Windows 11 25H2 build 26200.9974, RTX 4080 SUPER 16 GB, driver 617.14. I used Series X, DLSS Performance (1280×720 to 2560×1440), a 1920×1080 window and a local 4× FG configuration. Each run started with a copy of the same save and an empty engine cache.

With the water lighting enabled, the boat mission showed a dark, screen-aligned rectangle at the waterline of a passing yacht. I instrumented the successful rewrite and confirmed that this PR’s per-lane allocation actually ran for 1aa247ed3653b616. The rectangle was still visible in that run.

I then removed the per-lane rewrite and tried the water subset of Vice-Tay #208 at fe7c6e5. The generator and both tiled lighting consumers translated with paired Wave64 and created D3D12 pipelines. On the same route the water stayed lit, and the player confirmed that the rectangles under boats and the marked pickup were gone. The submerged shader was outside this surface test. This comparison changes the three surface shaders together, so it does not establish which individual shader is sufficient.

Successful run, play log excerpts:

INFO victory_gpu::host: host wave lanes min=32 max=32
INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 1aa247ed3653b616]
INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 5dc3b25986622949]
INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 6f225b641c5b0708]

No crash log was produced during these rendering comparisons. AI-assisted testing on physical hardware.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233568784 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7233568784). Originally posted by [dsh38](https://github.com/dsh38) on 2026-11-28T03:58:54Z. --- Independent in-game check on main `8fc2254` (v2026.11.27.10), Windows 11 25H2 build 26200.9974, RTX 4080 SUPER 16 GB, driver 617.14. I used Series X, DLSS Performance (1280×720 to 2560×1440), a 1920×1080 window and a local 4× FG configuration. Each run started with a copy of the same save and an empty engine cache. With the water lighting enabled, the boat mission showed a dark, screen-aligned rectangle at the waterline of a passing yacht. I instrumented the successful rewrite and confirmed that this PR’s per-lane allocation actually ran for `1aa247ed3653b616`. The rectangle was still visible in that run. I then removed the per-lane rewrite and tried the water subset of [Vice-Tay #208](https://github.com/TaynanGT/Vice-Tay/pull/208) at `fe7c6e5`. The generator and both tiled lighting consumers translated with paired Wave64 and created D3D12 pipelines. On the same route the water stayed lit, and the player confirmed that the rectangles under boats and the marked pickup were gone. The submerged shader was outside this surface test. This comparison changes the three surface shaders together, so it does not establish which individual shader is sufficient. Successful run, play log excerpts: ~~~text INFO victory_gpu::host: host wave lanes min=32 max=32 INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 1aa247ed3653b616] INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 5dc3b25986622949] INFO victory_gpu::pipeline::host: host pipeline shaders=[compute 6f225b641c5b0708] ~~~ No crash log was produced during these rendering comparisons. AI-assisted testing on physical hardware.
xss3009 commented 2026-11-28 04:07:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xss3009 on 2026-11-28T04:07:33Z.


I tested PR head a37e53267e5b096e452f9f53031bff91d8e9a857 on a physical RTX 5070 Ti (16 GB, driver 621.24, Windows 11 build 22631). This was the upstream diagnostics build of the unmodified PR head. I used a private copy of the first-chapter boat checkpoint, Series X, a 1920×1080 scene with 2560×1440 output, and DLSS, frame generation and the BVH builder off.

Both VICTORY_WATER_LIGHT=1 and VICTORY_WATER_TILE_SLOTS=1 were set. The runtime logged 32-lane waves and successfully created the D3D12 compute pipelines for 1aa247ed3653b616, 5dc3b25986622949 and 6f225b641c5b0708.

Observed during the first boat ride: the previous large dark rectangles were not seen in this stretch. Small black blocks still flickered around another vessel's waterline on the bridge approach. The still frame locates the vessel, and the flicker was observed during live play. This run does not include a matched switch-off comparison or a per-pass capture of the small blocks, so it does not identify which pass causes the remaining artifact. The location is similar to the residual described in the RTX 4080 SUPER report above.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7233718564 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7233718564). Originally posted by [xss3009](https://github.com/xss3009) on 2026-11-28T04:07:33Z. --- I tested PR head `a37e53267e5b096e452f9f53031bff91d8e9a857` on a physical RTX 5070 Ti (16 GB, driver 621.24, Windows 11 build 22631). This was the upstream diagnostics build of the unmodified PR head. I used a private copy of the first-chapter boat checkpoint, Series X, a 1920×1080 scene with 2560×1440 output, and DLSS, frame generation and the BVH builder off. Both `VICTORY_WATER_LIGHT=1` and `VICTORY_WATER_TILE_SLOTS=1` were set. The runtime logged 32-lane waves and successfully created the D3D12 compute pipelines for `1aa247ed3653b616`, `5dc3b25986622949` and `6f225b641c5b0708`. **Observed during the first boat ride:** the previous large dark rectangles were not seen in this stretch. Small black blocks still flickered around another vessel's waterline on the bridge approach. The still frame locates the vessel, and the flicker was observed during live play. This run does not include a matched switch-off comparison or a per-pass capture of the small blocks, so it does not identify which pass causes the remaining artifact. The location is similar to the residual described in the [RTX 4080 SUPER report above](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7233568784).
xss3009 commented 2026-11-28 04:29:18 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xss3009 on 2026-11-28T04:29:18Z.


Follow-up on the RTX 5070 Ti waterline reproduction.

I kept VICTORY_WATER_LIGHT=1 and the PR's per-lane allocator enabled in both runs. On the unmodified PR shader path (with diagnostics for capture), the player captured several rectangular dark patches at the shore/water boundary before the first bridge and observed intermittent smaller patches on the water. In a local build based on this PR, I ported the paired Wave64 lowering from Vice-Tay #208 and selected only the two surface lighting consumers, 5dc3b25986622949 and 6f225b641c5b0708. GenerateTiles (1aa247ed3653b616) still used the PR's per-lane allocator. Its emitted DXIL hash matched the PR baseline in the offline control.

Both paired consumer shaders validated with Microsoft's DXIL validator, and the run log confirmed both used the paired route and created D3D12 compute pipelines. Both runs used the same first-boat checkpoint, 1080p scene with 1440p output, and no DLSS, frame generation or BVH builder. The player saw the bridge-approach view clean up. Three bursts of 24 presented frames from the local build at the rear-camera bridge approach supported the visual result. We matched the bridge direction and camera framing approximately, without matching a passing yacht's exact position or the exact mission tick.

This narrows that reproduction to the two consumer passes as a group. I have not isolated which consumer is necessary in game. The clean result is from the local paired-consumer change on top of a37e532. Please consider the two consumer paths alongside the allocator before using the result to enable experimental water lighting by default.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7234070314 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7234070314). Originally posted by [xss3009](https://github.com/xss3009) on 2026-11-28T04:29:18Z. --- Follow-up on the RTX 5070 Ti waterline reproduction. I kept `VICTORY_WATER_LIGHT=1` and the PR's per-lane allocator enabled in both runs. On the **unmodified PR shader path** (with diagnostics for capture), the player captured several rectangular dark patches at the shore/water boundary before the first bridge and observed intermittent smaller patches on the water. In a local build based on this PR, I ported the paired Wave64 lowering from [Vice-Tay #208](https://github.com/TaynanGT/Vice-Tay/pull/208) and selected **only** the two surface lighting consumers, `5dc3b25986622949` and `6f225b641c5b0708`. `GenerateTiles` (`1aa247ed3653b616`) still used the PR's per-lane allocator. Its emitted DXIL hash matched the PR baseline in the offline control. Both paired consumer shaders validated with Microsoft's DXIL validator, and the run log confirmed both used the paired route and created D3D12 compute pipelines. Both runs used the same first-boat checkpoint, 1080p scene with 1440p output, and no DLSS, frame generation or BVH builder. The player saw the bridge-approach view clean up. Three bursts of 24 presented frames from the local build at the rear-camera bridge approach supported the visual result. We matched the bridge direction and camera framing approximately, without matching a passing yacht's exact position or the exact mission tick. This narrows that reproduction to the two consumer passes as a group. I have not isolated which consumer is necessary in game. The clean result is from the local paired-consumer change on top of `a37e532`. Please consider the two consumer paths alongside the allocator before using the result to enable experimental water lighting by default.
mutlusinan commented 2026-11-28 12:01:29 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mutlusinan on 2026-11-28T12:01:29Z.


Rebased onto current main; the earlier "inert" note is superseded

Rebased onto 63b902f (force-with-lease) and re-verified: cargo check --workspace --target x86_64-pc-windows-msvc --locked is clean.

Correction to the risk note above: since 64d4931 ("Water light on…") the water light's two programs are translated by default (VICTORY_WATER_LIGHT=0 turns them off), so host_form is no longer inert — this rewrite would run in ordinary play on a 32-lane host. The rest of the note still holds: the rewrite is gated on the container digest, the code length and the FNV-1a of the whole program, so a different build makes it a no-op, and a wrong offset would affect that one program only. An in-game check of the water now matters before merging.

Also note main fixed a different cause of the same symptom in the meantime (VICTORY_LOOPS_WAVE, CS_TransmissionVolumetrics_Tiled loops in ir.rs); this change addresses the GenerateTiles list slots and the two are independent.

GitHub reports the CI run as action_required (a fork contributor's run waits for maintainer approval), so nothing has been executed yet.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7238939611 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7238939611). Originally posted by [mutlusinan](https://github.com/mutlusinan) on 2026-11-28T12:01:29Z. --- ### Rebased onto current `main`; the earlier "inert" note is superseded Rebased onto `63b902f` (force-with-lease) and re-verified: `cargo check --workspace --target x86_64-pc-windows-msvc --locked` is clean. **Correction to the risk note above:** since `64d4931` ("Water light on…") the water light's two programs are translated **by default** (`VICTORY_WATER_LIGHT=0` turns them off), so `host_form` is no longer inert — this rewrite would run in ordinary play on a 32-lane host. The rest of the note still holds: the rewrite is gated on the container digest, the code length and the FNV-1a of the whole program, so a different build makes it a no-op, and a wrong offset would affect that one program only. An in-game check of the water now matters before merging. Also note `main` fixed a *different* cause of the same symptom in the meantime (`VICTORY_LOOPS_WAVE`, `CS_TransmissionVolumetrics_Tiled` loops in `ir.rs`); this change addresses the `GenerateTiles` list slots and the two are independent. GitHub reports the CI run as `action_required` (a fork contributor's run waits for maintainer approval), so nothing has been executed yet.
trustno1-coder commented 2026-11-28 19:23:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:23:56Z.


Thanks for this. I'm closing it without merging: main already rewrites the same water light program on 32-lane hosts (#45's water_tile_append), and the two conflict. If yours fixes something #45 doesn't, please rebase on the current main and open a new pull request with a comparison.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244514234 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/221#issuecomment-7244514234). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:23:56Z. --- Thanks for this. I'm closing it without merging: main already rewrites the same water light program on 32-lane hosts (#45's water_tile_append), and the two conflict. If yours fixes something #45 doesn't, please rebase on the current main and open a new pull request with a comparison.

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
trustno1-coder/VIctory-NVIDIA!221
No description provided.