Fix transmission tile allocation on wave32 hosts #45

Open
github-bot wants to merge 1 commit from github-bot/gh-45 into main AGit
Owner

@⁠xss3009 on GitHub · 2026-11-27 13:44 UTC · original
xss3009:pr-wave32-water-tile-append → main · +69 −1 · 2 files · 1 commits · open

Summary

Fix the transmission tile allocator for the identified compute program when the host supports only 32-lane waves. Each admitted lane reserves one slot in its existing front or back list. This keeps the classification, atomic counters, list layout, index reversal and downstream dispatch contract.

The rewrite checks the container and native program identities. It moves the relevant atomic, address and wait instructions from the locally supplied program at runtime. The pull request contains no shader binaries or captures. The existing default for experimental tiled water lighting stays in place.

Verification

  • Built the victory-shader release library and validated translated DXIL with the Windows SDK validator. The wave32 output is byte-identical to the correction tested on an RTX 5070 Ti. The wave64 output is byte-identical to the original.
  • The earlier wave32 instrumented run saw 305 missing entries and 8 duplicates in a sample with 2,306 eligible tiles. With the correction, 80 paired worklists and dispatches had zero missing, duplicate or extra entries.
  • Replayed the same first-chapter speedboat checkpoint on the installed NVIDIA fork. Bridge approach, bridge passage and open-water samples did not show the large dark rectangles seen in the baseline. This was sampled footage, with experimental tiled water lighting disabled on the current fork.
**@⁠xss3009** on GitHub · 2026-11-27 13:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45) `xss3009:pr-wave32-water-tile-append` → `main` · +69 −1 · 2 files · 1 commits · open ## Summary Fix the transmission tile allocator for the identified compute program when the host supports only 32-lane waves. Each admitted lane reserves one slot in its existing front or back list. This keeps the classification, atomic counters, list layout, index reversal and downstream dispatch contract. The rewrite checks the container and native program identities. It moves the relevant atomic, address and wait instructions from the locally supplied program at runtime. The pull request contains no shader binaries or captures. The existing default for experimental tiled water lighting stays in place. ## Verification - Built the `victory-shader` release library and validated translated DXIL with the Windows SDK validator. The wave32 output is byte-identical to the correction tested on an RTX 5070 Ti. The wave64 output is byte-identical to the original. - The earlier wave32 instrumented run saw 305 missing entries and 8 duplicates in a sample with 2,306 eligible tiles. With the correction, 80 paired worklists and dispatches had zero missing, duplicate or extra entries. - Replayed the same first-chapter speedboat checkpoint on the installed NVIDIA fork. Bridge approach, bridge passage and open-water samples did not show the large dark rectangles seen in the baseline. This was sampled footage, with experimental tiled water lighting disabled on the current fork.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:49:42 +00:00
Author
Owner

@⁠jptorres96 on GitHub · 2026-11-27 16:16 UTC · original

Independent run on RTX 4080 SUPER 16 GB (Ada, 32-lane waves), driver 621.01, Ryzen 5 5600X, Windows build 26300, toolchain 1.98.1, DXIL validator from DXC 1.9.2609.5, VICTORY_REQUIRE_HW_GPU=1. Head 69e7e00.

The PR adds no tests (the rewrite matches a program of the title), so this only checks it breaks nothing else:

  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean
  • cargo test -p victory-shader --lib -- --test-threads=1: 287 passed, 0 failed, 4 ignored

No game dump here, so the water itself is not checked.

**@⁠jptorres96** on GitHub · 2026-11-27 16:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45#issuecomment-7223056512) Independent run on RTX 4080 SUPER 16 GB (Ada, 32-lane waves), driver 621.01, Ryzen 5 5600X, Windows build 26300, toolchain 1.98.1, DXIL validator from DXC 1.9.2609.5, `VICTORY_REQUIRE_HW_GPU=1`. Head `69e7e00`. The PR adds no tests (the rewrite matches a program of the title), so this only checks it breaks nothing else: - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean - `cargo test -p victory-shader --lib -- --test-threads=1`: 287 passed, 0 failed, 4 ignored No game dump here, so the water itself is not checked.
Author
Owner

@⁠Younisl on GitHub · 2026-11-27 18:06 UTC · original

Thanks for the Wave32 tile append fix. I tested it on an RTX 4070 SUPER with experimental water lighting enabled. The local build was based on d12eb1b and also used paired Wave32 lowering for the two water-volume shaders, round-to-nearest-even conversion for packed depth, and the dispatch-order change below.

In the sampled Series X boat scene (1440p, DLSS Performance, frame generation and ray tracing off), the large dark rectangles disappeared and the brighter water lighting remained. All four water-related compute shaders passed the Windows SDK DXIL validator. This was a test of the combined changes. The dispatch-order change was not isolated in a separate visual run and no FPS gain was measured.

The diff ends the indirect-argument batch after the transmission clear and tile-generation passes. Later indirect dispatches then use the updated tile counts. The diff applies to the tested base with git apply.

Dispatch-order patch against d12eb1b
diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs
--- a/crates/victory-gpu/src/draw.rs
+++ b/crates/victory-gpu/src/draw.rs
@@ -3753,7 +3832,7 @@ impl State {
         }
         // SAFETY: an open list with everything set.
         unsafe { list.list.Dispatch(x, y, z) };
-        self.buffers_written();
+        self.buffers_written(p);
         DISPATCHED.fetch_add(1, Ordering::Relaxed);
         if let Some(role) = p.stages.first().and_then(|s| s.shader.ambient)
             && crate::ambient::on()
@@ -4983,11 +5062,12 @@ impl State {
 }
 
 impl State {
-    /// Shaders that can write buffers were recorded: arguments may be others
-    /// from here on.
-    fn buffers_written(&mut self) {
+    /// The water tile counts are read by later indirect dispatches. End the
+    /// batch when those counts change so the next clamp reads the new values.
+    fn buffers_written(&mut self, p: &HostPipeline) {
+        let writes_water_tile_args = p.stages.first().is_some_and(|s| s.shader.writes_water_tile_args);
         match &mut self.batch {
-            Some(batch) if batches() == 2 => batch.wrote = true,
+            Some(batch) if batches() == 2 && !writes_water_tile_args => batch.wrote = true,
             batch => *batch = None,
         }
     }
@@ -5338,7 +5418,7 @@ impl State {
         #[cfg(feature = "diagnostics")]
         list.ran_indirect(p.pso.as_raw() as usize, &p.name, kind, max, &self.user);
         if kind == DISPATCH {
-            self.buffers_written();
+            self.buffers_written(p);
         } else {
             self.drew(Some(p));
         }
diff --git a/crates/victory-gpu/src/pipeline.rs b/crates/victory-gpu/src/pipeline.rs
index c462b0e..8ba0e48 100644
--- a/crates/victory-gpu/src/pipeline.rs
+++ b/crates/victory-gpu/src/pipeline.rs
@@ -64,6 +64,9 @@ pub(crate) struct Shader {
     /// Its part in the stand-in for the indirect light.
     #[cfg(windows)]
     pub(crate) ambient: Option<crate::ambient::Role>,
+    /// Clears or generates the indirect arguments for the water lighting tiles.
+    #[cfg(windows)]
+    pub(crate) writes_water_tile_args: bool,
     #[cfg(windows)]
     translated: OnceLock<Option<Translated>>,
 }
@@ -117,6 +120,14 @@ fn shader(stage: &'static str, bytes: &[u8]) -> Arc<Shader> {
                 #[cfg(windows)]
                 ambient: (stage == "compute").then(|| crate::ambient::role(bytes)).flatten(),
                 #[cfg(windows)]
+                writes_water_tile_args: stage == "compute"
+                    && [
+                        &b"CS_TransmissionVolumetrics_ClearTiles"[..],
+                        &b"CS_TransmissionVolumetrics_GenerateTiles"[..],
+                    ]
+                    .into_iter()
+                    .any(|name| bytes.windows(name.len()).any(|word| word == name)),
+                #[cfg(windows)]
                 translated: OnceLock::new(),
             })
         })
**@⁠Younisl** on GitHub · 2026-11-27 18:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45#issuecomment-7225125148) Thanks for the Wave32 tile append fix. I tested it on an RTX 4070 SUPER with experimental water lighting enabled. The local build was based on `d12eb1b` and also used paired Wave32 lowering for the two water-volume shaders, round-to-nearest-even conversion for packed depth, and the dispatch-order change below. In the sampled Series X boat scene (1440p, DLSS Performance, frame generation and ray tracing off), the large dark rectangles disappeared and the brighter water lighting remained. All four water-related compute shaders passed the Windows SDK DXIL validator. This was a test of the combined changes. The dispatch-order change was not isolated in a separate visual run and no FPS gain was measured. The diff ends the indirect-argument batch after the transmission clear and tile-generation passes. Later indirect dispatches then use the updated tile counts. The diff applies to the tested base with `git apply`. <details> <summary>Dispatch-order patch against d12eb1b</summary> ```diff diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -3753,7 +3832,7 @@ impl State { } // SAFETY: an open list with everything set. unsafe { list.list.Dispatch(x, y, z) }; - self.buffers_written(); + self.buffers_written(p); DISPATCHED.fetch_add(1, Ordering::Relaxed); if let Some(role) = p.stages.first().and_then(|s| s.shader.ambient) && crate::ambient::on() @@ -4983,11 +5062,12 @@ impl State { } impl State { - /// Shaders that can write buffers were recorded: arguments may be others - /// from here on. - fn buffers_written(&mut self) { + /// The water tile counts are read by later indirect dispatches. End the + /// batch when those counts change so the next clamp reads the new values. + fn buffers_written(&mut self, p: &HostPipeline) { + let writes_water_tile_args = p.stages.first().is_some_and(|s| s.shader.writes_water_tile_args); match &mut self.batch { - Some(batch) if batches() == 2 => batch.wrote = true, + Some(batch) if batches() == 2 && !writes_water_tile_args => batch.wrote = true, batch => *batch = None, } } @@ -5338,7 +5418,7 @@ impl State { #[cfg(feature = "diagnostics")] list.ran_indirect(p.pso.as_raw() as usize, &p.name, kind, max, &self.user); if kind == DISPATCH { - self.buffers_written(); + self.buffers_written(p); } else { self.drew(Some(p)); } diff --git a/crates/victory-gpu/src/pipeline.rs b/crates/victory-gpu/src/pipeline.rs index c462b0e..8ba0e48 100644 --- a/crates/victory-gpu/src/pipeline.rs +++ b/crates/victory-gpu/src/pipeline.rs @@ -64,6 +64,9 @@ pub(crate) struct Shader { /// Its part in the stand-in for the indirect light. #[cfg(windows)] pub(crate) ambient: Option<crate::ambient::Role>, + /// Clears or generates the indirect arguments for the water lighting tiles. + #[cfg(windows)] + pub(crate) writes_water_tile_args: bool, #[cfg(windows)] translated: OnceLock<Option<Translated>>, } @@ -117,6 +120,14 @@ fn shader(stage: &'static str, bytes: &[u8]) -> Arc<Shader> { #[cfg(windows)] ambient: (stage == "compute").then(|| crate::ambient::role(bytes)).flatten(), #[cfg(windows)] + writes_water_tile_args: stage == "compute" + && [ + &b"CS_TransmissionVolumetrics_ClearTiles"[..], + &b"CS_TransmissionVolumetrics_GenerateTiles"[..], + ] + .into_iter() + .any(|name| bytes.windows(name.len()).any(|word| word == name)), + #[cfg(windows)] translated: OnceLock::new(), }) }) ``` </details>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/45/head:github-bot/gh-45'
git switch 'github-bot/gh-45'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-45'
git switch 'github-bot/gh-45'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-45'
git switch 'github-bot/gh-45'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-45'
git switch 'main'
git merge --squash 'github-bot/gh-45'
git switch 'main'
git merge --ff-only 'github-bot/gh-45'
git switch 'main'
git merge 'github-bot/gh-45'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.