Faces with only eyes and teeth: the face programs are exempt from VICTORY_LDS_BOUNDS #938

Merged
Victorywillbeours222 merged 1 commit from upstream-pr/938 into main 2026-11-28 19:39:38 +00:00
Victorywillbeours222 commented 2026-11-28 09:27:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Victorywillbeours222 on 2026-11-28T09:27:31Z.


Fixes the faces drawn as floating eyes and teeth (#100, #586).

Cause

VICTORY_LDS_BOUNDS has been on by default since 64d4931b. With it, a shared-memory access past LDS_SIZE in the program's header reads 0, and a write there is dropped. The game's face network does not stay inside that size:

  • its compute_graph_ops programs (the matrix products, dot products and reductions);
  • the two programs that rebuild face normals from the blend shapes (ped_morphable_model_cs, ped_standard_head_cs).

Both use shared memory past the size in their headers. Held to that size, their results are zeros, so the skin of the head is not drawn and only the eyes and teeth are left.

slot=0x218 does not decide it: that warning is logged in runs with the faces drawn too. The default VICTORY_LEAVE_OUT (02384a60fda6f2d0,731a39171b568298) does not decide it here either. All the runs below had it, and only the bounds changed between them.

Change

  • Every other program keeps the bounds.
  • 25 programs are exempt by default: 23 compute_graph_ops programs and the two normal programs. They are named by the first 16 hex digits of the container's BLAKE3, as run logs name shaders.
  • VICTORY_LDS_BOUNDS_EXEMPT=<hash>[,<hash>..] replaces the list. VICTORY_LDS_BOUNDS_EXEMPT=0 exempts none, which is the bounds as they are now.
  • The setting is in the shader cache's key, so translations cached before the change are not reused.
  • host_shader passes the container's hash to the translator through emit::with_program, a thread-local. That is the only place it is needed.

Tested

RTX 5080 with a Ryzen 7 5800X, Series X profile, 1440p with DLSS Quality. Each run is a scripted 10-minute walk through the opening: the interview, the store flashback and the street. The shaders were translated again and the used pipelines warmed before each run.

build faces submitting thread waiting for the card, per frame (median / p90) fps (median, second half) frames over 100 ms
bounds on (64d4931b merged into Kemerd's main) eyes and teeth only 0.1 / 3.5 ms 16.6 60/min
same, VICTORY_LDS_BOUNDS=0 drawn 70.9 / 118.2 ms 7.2 317/min
this change (on Kemerd's main 2f0bc2d9) drawn, both scenes 1.0 / 10.0 ms 18.1 74/min

VICTORY_LDS_BOUNDS=0 brings the faces back too, but switching the bounds off everywhere costs the card a lot of time. Exempting only the programs that need it keeps the speed.

Clippy (both CI steps, toolchain 1.98.1) finds nothing in the lines this changes. On this main it already stops on three lints elsewhere: descriptor.rs:1234 and shadow.rs:1708 (is_multiple_of), and emit/mod.rs:2768 (let_and_return, test build).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5538723951 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/938). Originally posted by [Victorywillbeours222](https://github.com/Victorywillbeours222) on 2026-11-28T09:27:31Z. --- Fixes the faces drawn as floating eyes and teeth (#100, #586). ## Cause `VICTORY_LDS_BOUNDS` has been on by default since 64d4931b. With it, a shared-memory access past `LDS_SIZE` in the program's header reads 0, and a write there is dropped. The game's face network does not stay inside that size: - its `compute_graph_ops` programs (the matrix products, dot products and reductions); - the two programs that rebuild face normals from the blend shapes (`ped_morphable_model_cs`, `ped_standard_head_cs`). Both use shared memory past the size in their headers. Held to that size, their results are zeros, so the skin of the head is not drawn and only the eyes and teeth are left. `slot=0x218` does not decide it: that warning is logged in runs with the faces drawn too. The default `VICTORY_LEAVE_OUT` (`02384a60fda6f2d0,731a39171b568298`) does not decide it here either. All the runs below had it, and only the bounds changed between them. ## Change - Every other program keeps the bounds. - 25 programs are exempt by default: 23 `compute_graph_ops` programs and the two normal programs. They are named by the first 16 hex digits of the container's BLAKE3, as run logs name shaders. - `VICTORY_LDS_BOUNDS_EXEMPT=<hash>[,<hash>..]` replaces the list. `VICTORY_LDS_BOUNDS_EXEMPT=0` exempts none, which is the bounds as they are now. - The setting is in the shader cache's key, so translations cached before the change are not reused. - `host_shader` passes the container's hash to the translator through `emit::with_program`, a thread-local. That is the only place it is needed. ## Tested RTX 5080 with a Ryzen 7 5800X, Series X profile, 1440p with DLSS Quality. Each run is a scripted 10-minute walk through the opening: the interview, the store flashback and the street. The shaders were translated again and the used pipelines warmed before each run. | build | faces | submitting thread waiting for the card, per frame (median / p90) | fps (median, second half) | frames over 100 ms | |---|---|---|---|---| | bounds on (64d4931b merged into Kemerd's main) | eyes and teeth only | 0.1 / 3.5 ms | 16.6 | 60/min | | same, `VICTORY_LDS_BOUNDS=0` | drawn | 70.9 / 118.2 ms | 7.2 | 317/min | | this change (on Kemerd's main 2f0bc2d9) | drawn, both scenes | 1.0 / 10.0 ms | 18.1 | 74/min | `VICTORY_LDS_BOUNDS=0` brings the faces back too, but switching the bounds off everywhere costs the card a lot of time. Exempting only the programs that need it keeps the speed. Clippy (both CI steps, toolchain 1.98.1) finds nothing in the lines this changes. On this main it already stops on three lints elsewhere: `descriptor.rs:1234` and `shadow.rs:1708` (`is_multiple_of`), and `emit/mod.rs:2768` (`let_and_return`, test build).
Yuanzer commented 2026-11-28 15:34:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Yuanzer on 2026-11-28T15:34:13Z.


I reviewed the exemption path and found two concrete isolation issues worth fixing before merge. The default 25-hash list itself is not affected, so these concern the override API and panic behavior.

  1. The documented 16-digit key is matched as an arbitrary prefix. lds_bounds_exempt() uses p.starts_with(h.as_str()), while the comment says the setting is <16 hex digits>. A value such as VICTORY_LDS_BOUNDS_EXEMPT=a therefore exempts every program whose hash starts with a, even though it is not a valid program name. That can silently remove the bounds from many more shaders and reintroduce the very LDS/performance problem this PR avoids. Please validate each entry as exactly 16 ASCII hex digits and compare with p == h (after normalizing case), then add tests that an exact hash matches while a shorter prefix does not.

  2. with_program does not restore state if f unwinds, and it breaks if calls are nested. It clones the new hash, calls f(), and only then clears the thread-local. If translation panics or with_program is used recursively, the outer value is lost and the stale value can remain on a reused worker. A small RAII guard that saves the previous value and restores it on Drop, or an equivalent try/finally structure, would preserve the current API without allocation beyond the saved state. A nested-call test and a catch_unwind restoration test would pin that down.

These are both small changes and do not alter the measured face fix.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7241567881 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/938#issuecomment-7241567881). Originally posted by [Yuanzer](https://github.com/Yuanzer) on 2026-11-28T15:34:13Z. --- I reviewed the exemption path and found two concrete isolation issues worth fixing before merge. The default 25-hash list itself is not affected, so these concern the override API and panic behavior. 1. **The documented 16-digit key is matched as an arbitrary prefix.** `lds_bounds_exempt()` uses `p.starts_with(h.as_str())`, while the comment says the setting is `<16 hex digits>`. A value such as `VICTORY_LDS_BOUNDS_EXEMPT=a` therefore exempts every program whose hash starts with `a`, even though it is not a valid program name. That can silently remove the bounds from many more shaders and reintroduce the very LDS/performance problem this PR avoids. Please validate each entry as exactly 16 ASCII hex digits and compare with `p == h` (after normalizing case), then add tests that an exact hash matches while a shorter prefix does not. 2. **`with_program` does not restore state if `f` unwinds, and it breaks if calls are nested.** It clones the new hash, calls `f()`, and only then clears the thread-local. If translation panics or `with_program` is used recursively, the outer value is lost and the stale value can remain on a reused worker. A small RAII guard that saves the previous value and restores it on `Drop`, or an equivalent `try/finally` structure, would preserve the current API without allocation beyond the saved state. A nested-call test and a `catch_unwind` restoration test would pin that down. These are both small changes and do not alter the measured face fix.
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!938
No description provided.