A loop limit for compute programs alone (hair strands no longer scatter with VICTORY_SHADER_LOOP_LIMIT=32) #683

Open
Danigamer05 wants to merge 1 commit from upstream-pr/683 into main
Danigamer05 commented 2026-11-25 04:24:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Danigamer05 on 2026-11-25T04:24:54Z.


Problem

With VICTORY_SHADER_LOOP_LIMIT=32, which NVIDIA Turing cards run with (#5: without it the device is lost), character hair renders as scattered strands around the head that change every frame.

A lane that reaches the translated loop limit leaves the program without its writes (count_iteration / abort_block in lower.rs). The hair simulation's per-vertex constraint pass (smh_sim_*:CS_SolvePerVertConstraint, 8 variants) has a uniform loop with one iteration per strand vertex, more than 32 of them. So its lanes never stored, and the strands drawn from the simulation buffers came from stale or never-written positions.

How it was narrowed down (RTX 2080 SUPER, 2119b0e):

  • all 30 smh_sim_* programs skipped → no scattered strands (posing and interpolation are fine)
  • only CS_WavePerSplineConstraint_32 skipped → still scattered
  • only the 8 CS_SolvePerVertConstraint variants skipped → scattered strands gone (hair hangs loose, since nothing constrains it)
  • the disassembly of that pass is lane-local (no LDS, no lane reads, no exchange between host waves), but it has a uniform loop (0xa20 → 0x1b4c, n-1 iterations)
  • general limit raised to 1024 → hair in place in 12 of 12 sampled world frames, 30 min, no device loss

Change

VICTORY_SHADER_LOOP_LIMIT_CS=<n> (diagnostics builds) sets the loop limit for compute programs only. If it is unset, compute follows VICTORY_SHADER_LOOP_LIMIT exactly as before. The shader cache keys on it. The README documents it, and there is a unit test for the parsing (the two limit parsers now share one helper).

Measurements (RTX 2080 SUPER, c96b4f2 + this change, prologue world, 25–30 min each, no device loss in any run)

Settings Hair fps GPU ms/frame
LOOP_LIMIT=32 only scattered (unchanged) 0.98 664
LOOP_LIMIT=32 + LOOP_LIMIT_CS=128 in place in every sampled world frame (one stray strand in two) 1.02 609
LOOP_LIMIT=32 + LOOP_LIMIT_CS=1024 in place 0.85 719

With 1024 a smeared copy of the character also appears along the bottom of the screen: some other compute loop now runs to its end. 128 does not show it, so the README recommends VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128.

Not tested on AMD or on cards that run without a loop limit; for them nothing changes unless the new variable is set.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:5485149900 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/683). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-25T04:24:54Z. --- ## Problem With `VICTORY_SHADER_LOOP_LIMIT=32`, which NVIDIA Turing cards run with (#5: without it the device is lost), character hair renders as scattered strands around the head that change every frame. A lane that reaches the translated loop limit leaves the program **without its writes** (`count_iteration` / `abort_block` in `lower.rs`). The hair simulation's per-vertex constraint pass (`smh_sim_*:CS_SolvePerVertConstraint`, 8 variants) has a uniform loop with one iteration per strand vertex, more than 32 of them. So its lanes never stored, and the strands drawn from the simulation buffers came from stale or never-written positions. How it was narrowed down (RTX 2080 SUPER, 2119b0e): - all 30 `smh_sim_*` programs skipped → no scattered strands (posing and interpolation are fine) - only `CS_WavePerSplineConstraint_32` skipped → still scattered - only the 8 `CS_SolvePerVertConstraint` variants skipped → scattered strands gone (hair hangs loose, since nothing constrains it) - the disassembly of that pass is lane-local (no LDS, no lane reads, no exchange between host waves), but it has a uniform loop (`0xa20` → `0x1b4c`, `n-1` iterations) - general limit raised to 1024 → hair in place in 12 of 12 sampled world frames, 30 min, no device loss ## Change `VICTORY_SHADER_LOOP_LIMIT_CS=<n>` (diagnostics builds) sets the loop limit for compute programs only. If it is unset, compute follows `VICTORY_SHADER_LOOP_LIMIT` exactly as before. The shader cache keys on it. The README documents it, and there is a unit test for the parsing (the two limit parsers now share one helper). ## Measurements (RTX 2080 SUPER, c96b4f2 + this change, prologue world, 25–30 min each, no device loss in any run) | Settings | Hair | fps | GPU ms/frame | |---|---|---|---| | `LOOP_LIMIT=32` only | scattered (unchanged) | 0.98 | 664 | | `LOOP_LIMIT=32` + `LOOP_LIMIT_CS=128` | in place in every sampled world frame (one stray strand in two) | 1.02 | 609 | | `LOOP_LIMIT=32` + `LOOP_LIMIT_CS=1024` | in place | 0.85 | 719 | With 1024 a smeared copy of the character also appears along the bottom of the screen: some other compute loop now runs to its end. 128 does not show it, so the README recommends `VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128`. Not tested on AMD or on cards that run without a loop limit; for them nothing changes unless the new variable is set. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Danigamer05 commented 2026-11-25 10:11:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Danigamer05 on 2026-11-25T09:12:30Z.


Rebased onto main at 9376fd6 (it was conflicting after the shader cache key change). The only real change from the old version: compute_loop_limit() now goes into translation_fingerprint() next to the loop limit, so cached translations are redone when VICTORY_SHADER_LOOP_LIMIT_CS changes. Unit tests and clippy for victory-shader pass; the in-game check on 9376fd6 (RTX 2080 SUPER) is running now.

AI-assisted (Claude Code).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7158019453 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/683#issuecomment-7158019453). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-25T09:12:30Z. --- Rebased onto `main` at 9376fd6 (it was conflicting after the shader cache key change). The only real change from the old version: `compute_loop_limit()` now goes into `translation_fingerprint()` next to the loop limit, so cached translations are redone when `VICTORY_SHADER_LOOP_LIMIT_CS` changes. Unit tests and clippy for `victory-shader` pass; the in-game check on 9376fd6 (RTX 2080 SUPER) is running now. AI-assisted (Claude Code).
Danigamer05 commented 2026-11-25 10:11:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Danigamer05 on 2026-11-25T09:16:46Z.


In-game check on 9376fd6 + this PR, RTX 2080 SUPER, VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128, no programs skipped: hair is drawn as whole strands in the first gameplay scene, about 3 fps.

AI-assisted (Claude Code).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7158115676 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/683#issuecomment-7158115676). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-25T09:16:46Z. --- In-game check on 9376fd6 + this PR, RTX 2080 SUPER, `VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_SHADER_LOOP_LIMIT_CS=128`, no programs skipped: hair is drawn as whole strands in the first gameplay scene, about 3 fps. AI-assisted (Claude Code).
Filip722 commented 2026-11-26 19:30:14 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-26T19:30:14Z.


I tested this compute-only loop limit on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton 3.2.0. Both Series S runs used the same executable, checkpoint, initial caches and 40% render scale. The general loop limit was 32 in both arms.

Compute loop limit Unique Presents in 54 s FPS Median / p95 interval Min. free VRAM
32 294 5.45 152 / 285 ms 1236 MiB
128 319 5.90 154 / 253 ms 1944 MiB

Hair scattered around the head with 32. With 128 it held its shape in the same view and throughout a camera turn. Both runs accepted camera input and ended cleanly. These are single-run timing observations. The focused Windows loop-option test passed in the isolated Proton prefix.

Assisted by Codex (GPT-6.2-Sol High).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7201660702 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/683#issuecomment-7201660702). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-26T19:30:14Z. --- I tested this compute-only loop limit on Bazzite 44, RTX 5060 Laptop 8 GB, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton 3.2.0. Both Series S runs used the same executable, checkpoint, initial caches and 40% render scale. The general loop limit was 32 in both arms. | Compute loop limit | Unique Presents in 54 s | FPS | Median / p95 interval | Min. free VRAM | | --- | ---: | ---: | ---: | ---: | | 32 | 294 | 5.45 | 152 / 285 ms | 1236 MiB | | 128 | 319 | 5.90 | 154 / 253 ms | 1944 MiB | Hair scattered around the head with 32. With 128 it held its shape in the same view and throughout a camera turn. Both runs accepted camera input and ended cleanly. These are single-run timing observations. The focused Windows loop-option test passed in the isolated Proton prefix. Assisted by Codex (GPT-6.2-Sol High).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/683:upstream-pr/683'
git switch 'upstream-pr/683'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/683'
git switch 'upstream-pr/683'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/683'
git switch 'upstream-pr/683'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/683'
git switch 'main'
git merge --squash 'upstream-pr/683'
git switch 'main'
git merge --ff-only 'upstream-pr/683'
git switch 'main'
git merge 'upstream-pr/683'
git push origin 'main'
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
fxceless/victory-fork!683
No description provided.