Shaders: read program constant tables from a root SRV instead of per-thread scratch #8

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

@⁠adib-cyber007 on GitHub · 2026-12-02 08:41 UTC · original
adib-cyber007:pr/5-shader-const-table-srv → main · +197 −8 · 18 files · 1 commits · open

Port of DoubleGhosty/cool_fox ea59cc01 (PR #176, GPL-3.0), using SLOT_CODE_TABLE = 249 so it does not collide with this fork's SLOT_VIEW_ADDRESSES = 250.

Why (high impact for 4 GB VRAM / 16 GB RAM)

When a shader keeps its program constant table as an internal constant array and indexes it dynamically, NVIDIA's driver puts it into per-thread scratch memory and reserves ~125 MB per KB of table across all GPU warp slots — never freed. The title's 17–21 KB hair-strand and fog-raymarch constant tables alone take up to ~4.3 GB on desktop cards, which on a 4 GB RTX 3050 overflows straight into shared system RAM (5.4–6.5 GB in bench/nightlog.md) and drives pagefile thrashing.

Moving constant tables into a single read-only raw root SRV (SLOT_CODE_TABLE) made once per pipeline eliminates that per-thread scratch allocation.

Toggle & Cache

  • VICTORY_CODE_TABLE_PRIVATE=1 keeps the old form for before/after comparison.
  • Shader cache keys on VICTORY_CODE_TABLE_PRIVATE and cleanly round-trips code_table (tested with non-empty tables). Run victory.exe shaders <game_folder> once after merging.

Verification

  • emit::lower::tests::the_code_table_starts_after_the_instructions, emit::tests::the_code_table_starts_after_the_instructions, shader_cache::tests::entries_round_trip_and_reject_damage (including non-empty code_table), and default + --features diagnostics builds passed with zero new warnings.
  • Live shared-VRAM & private-RAM savings need measurement on your RTX 3050 walk run.
**@⁠adib-cyber007** on GitHub · 2026-12-02 08:41 UTC · [original](https://github.com/ImTaneax/VIctory-RTX3050-4gb/pull/8) `adib-cyber007:pr/5-shader-const-table-srv` → `main` · +197 −8 · 18 files · 1 commits · open Port of `DoubleGhosty/cool_fox` `ea59cc01` (PR #176, GPL-3.0), using `SLOT_CODE_TABLE = 249` so it does not collide with this fork's `SLOT_VIEW_ADDRESSES = 250`. ### Why (high impact for 4 GB VRAM / 16 GB RAM) When a shader keeps its program constant table as an internal constant array and indexes it dynamically, NVIDIA's driver puts it into per-thread scratch memory and reserves ~125 MB per KB of table across all GPU warp slots — never freed. The title's 17–21 KB hair-strand and fog-raymarch constant tables alone take up to ~4.3 GB on desktop cards, which on a 4 GB RTX 3050 overflows straight into shared system RAM (`5.4–6.5 GB` in `bench/nightlog.md`) and drives pagefile thrashing. Moving constant tables into a single read-only raw root SRV (`SLOT_CODE_TABLE`) made once per pipeline eliminates that per-thread scratch allocation. ### Toggle & Cache - `VICTORY_CODE_TABLE_PRIVATE=1` keeps the old form for before/after comparison. - Shader cache keys on `VICTORY_CODE_TABLE_PRIVATE` and cleanly round-trips `code_table` (tested with non-empty tables). Run `victory.exe shaders <game_folder>` once after merging. ### Verification - `emit::lower::tests::the_code_table_starts_after_the_instructions`, `emit::tests::the_code_table_starts_after_the_instructions`, `shader_cache::tests::entries_round_trip_and_reject_damage` (including non-empty `code_table`), and default + `--features diagnostics` builds passed with zero new warnings. - Live shared-VRAM & private-RAM savings need measurement on your RTX 3050 walk run.
Port of DoubleGhosty/cool_fox ea59cc01 (PR #176, GPL-3.0), using SLOT_CODE_TABLE=249 to avoid colliding with SLOT_VIEW_ADDRESSES=250. Moves shader constant tables (such as hair strand and fog raymarch 17-21 KB tables) out of per-thread private arrays where NVIDIA's driver reserves ~125 MB/KB of never-freed scratch memory (~4.3 GB on desktop cards, overflowing 4 GB laptops into shared RAM/pagefile). VICTORY_CODE_TABLE_PRIVATE=1 keeps the old form for A/B comparison; shader cache keys on it and round-trips code_table cleanly.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:41:51 +00:00
github-bot changed title from shaders: read program constant tables from a root SRV instead of per-… to Shaders: read program constant tables from a root SRV instead of per-thread scratch 2026-12-02 10:22:07 +00:00
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/8/head:github-bot/gh-8'
git switch 'github-bot/gh-8'

Merge

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