Fix transmission tile allocation on wave32 hosts #45

Merged
xss3009 merged 1 commit from upstream-pr/45 into main 2026-11-28 19:01:28 +00:00
xss3009 commented 2026-11-27 13:44:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by xss3009 on 2026-11-27T13:44:21Z.


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.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5527660863 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45). Originally posted by [xss3009](https://github.com/xss3009) on 2026-11-27T13:44:21Z. --- ## 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.
jptorres96 commented 2026-11-27 16:16:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by jptorres96 on 2026-11-27T16:16:02Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7223056512 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45#issuecomment-7223056512). Originally posted by [jptorres96](https://github.com/jptorres96) on 2026-11-27T16:16:02Z. --- 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.
Younisl commented 2026-11-27 18:06:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Younisl on 2026-11-27T18:06:06Z.


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(),
             })
         })
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7225125148 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/45#issuecomment-7225125148). Originally posted by [Younisl](https://github.com/Younisl) on 2026-11-27T18:06:06Z. --- 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>
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!45
No description provided.