VRAM: ray tracing must fit a VRAM-scaled budget, below textures (8 GB cards starve) #164

Closed
opened 2026-09-29 06:00:00 +00:00 by sky_line · 3 comments
Owner

From an RX 7600 (8 GB) user's log (see #145): ray tracing used ~3 GB (AS 1,910 MB incl. 912 MB rigged, aux 1,080 MB) plus 1.9 GB staging. Texture residency was squeezed to 367 MB at mip bias 7, so avatars never loaded.

Problems

  • RenderVKRTBlasBudgetMB (768) only bounds static BLAS (mStaticBytes + mRigBytes > budget stops static builds, but rigged BLAS are always built). Rigged BLAS and all RT aux buffers (TLAS, scratch, rt_geom, rig positions) are unbounded.
  • The budget is a fixed number, not scaled to the card: 768 MB means little on 24 GB and a lot on 8 GB.
  • Texture residency is computed against a heap that non-texture consumers have already filled. Textures are what users see missing, so they should win, with RT and optional effects yielding first.
  • The texture bias oscillates under pressure (0->1->2->1->3 every few seconds): no hysteresis.

Fix

  1. One RT memory budget covering static + rigged BLAS + TLAS + scratch + aux, default scaled to VRAM (e.g. ~8% of the device-local budget, a small floor on 8 GB cards).
  2. Degrade in order when over budget: shrink the RT radius, then drop rigged RT (projector shadows from avatars fall back to the shadow map path), then disable RT for the session with a one-time notice. Never evict textures to make room for RT.
  3. Texture-first VRAM allocation: give the residency budget a guaranteed share (e.g. >= 50% of device-local on <= 8 GB), and make RT / probes / optional passes fit the remainder.
  4. Hysteresis on the texture bias: raise at >95% of budget, lower only below ~80% after a hold time, so it stops thrashing.
  5. Log the RT total vs its budget and the texture share in the VKMem line.

Test on an 8 GB card (or cap the budget via a debug setting) in a busy sim: textures stay at bias <= 1, RT degrades instead.

Refs #145, #157, #160, #161.

From an RX 7600 (8 GB) user's log (see #145): ray tracing used ~3 GB (AS 1,910 MB incl. 912 MB rigged, aux 1,080 MB) plus 1.9 GB staging. Texture residency was squeezed to 367 MB at mip bias 7, so avatars never loaded. ## Problems - `RenderVKRTBlasBudgetMB` (768) only bounds **static** BLAS (`mStaticBytes + mRigBytes > budget` stops static builds, but rigged BLAS are always built). Rigged BLAS and all RT aux buffers (TLAS, scratch, rt_geom, rig positions) are **unbounded**. - The budget is a fixed number, not scaled to the card: 768 MB means little on 24 GB and a lot on 8 GB. - Texture residency is computed against a heap that non-texture consumers have already filled. Textures are what users see missing, so they should win, with RT and optional effects yielding first. - The texture bias **oscillates** under pressure (0->1->2->1->3 every few seconds): no hysteresis. ## Fix 1. **One RT memory budget** covering static + rigged BLAS + TLAS + scratch + aux, default scaled to VRAM (e.g. ~8% of the device-local budget, a small floor on 8 GB cards). 2. **Degrade in order** when over budget: shrink the RT radius, then drop rigged RT (projector shadows from avatars fall back to the shadow map path), then disable RT for the session with a one-time notice. Never evict textures to make room for RT. 3. **Texture-first VRAM allocation**: give the residency budget a guaranteed share (e.g. >= 50% of device-local on <= 8 GB), and make RT / probes / optional passes fit the remainder. 4. **Hysteresis** on the texture bias: raise at >95% of budget, lower only below ~80% after a hold time, so it stops thrashing. 5. Log the RT total vs its budget and the texture share in the VKMem line. Test on an 8 GB card (or cap the budget via a debug setting) in a busy sim: textures stay at bias <= 1, RT degrades instead. Refs #145, #157, #160, #161.
Author
Owner

Root cause for the RX 7600 report: RT memory was never released after RT was turned off.

Timeline from their log:

  • 04:39–04:45: RT projector shadows on (probably while testing the greyed-out option, #155). AS grows to 1,910 MB and aux to 1,080 MB.
  • 04:45: the RT: blas static stats stop, so nothing consumes RT.
  • 04:45–05:51: AS 1,910 and aux 1,080 stay allocated for the rest of the session. Textures starve down to mip bias 7.

Why: LLCleanRTVK::idleFrame kept every static BLAS resident. Rigged BLAS never aged out, because mFrame pauses while idle. The TLAS, scratch and aux buffers were never freed.

Fix (local, pending test): after 15 s with no RT consumer, releaseAll() retires every BLAS, the TLAS and all RT buffers through the retire ring, and arena chunks are freed completely. The next active frame rebuilds lazily. Logged as RT: idle for 15 s -- released N MB ....

The rest of this ticket still stands: a single VRAM-scaled budget while RT is on, textures first, and hysteresis on the bias.

**Root cause for the RX 7600 report: RT memory was never released after RT was turned off.** Timeline from their log: - 04:39–04:45: RT projector shadows on (probably while testing the greyed-out option, #155). AS grows to 1,910 MB and aux to 1,080 MB. - 04:45: the `RT: blas static` stats stop, so nothing consumes RT. - 04:45–05:51: AS **1,910** and aux **1,080** stay allocated for the rest of the session. Textures starve down to mip bias 7. Why: `LLCleanRTVK::idleFrame` kept every static BLAS resident. Rigged BLAS never aged out, because `mFrame` pauses while idle. The TLAS, scratch and aux buffers were never freed. Fix (local, pending test): after **15 s** with no RT consumer, `releaseAll()` retires every BLAS, the TLAS and all RT buffers through the retire ring, and arena chunks are freed completely. The next active frame rebuilds lazily. Logged as `RT: idle for 15 s -- released N MB ...`. The rest of this ticket still stands: a single VRAM-scaled budget while RT *is* on, textures first, and hysteresis on the bias.
Author
Owner

Part of #405 (RAM/VRAM management epic).

Part of #405 (RAM/VRAM management epic).
sky_line added this to the Slipstream project 2026-10-06 15:04:15 +00:00
Author
Owner

Ticket audit 2026-10-07: done and shipped in 0.12.0 Beta 5. Idle RT release, one VRAM-scaled RT budget with a degrade ladder, and shadow-map fallback (16614b5d06, 5c0bda4d22, 8ea8cecde5, 71dd10e545). If you still see the problem on the current beta, please reopen or file a new report.

Ticket audit 2026-10-07: done and shipped in **0.12.0 Beta 5**. Idle RT release, one VRAM-scaled RT budget with a degrade ladder, and shadow-map fallback (16614b5d06, 5c0bda4d22, 8ea8cecde5, 71dd10e545). If you still see the problem on the current beta, please reopen or file a new report.
Sign in to join this conversation.
No milestone
No project
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
sky_line/Slipstream#164
No description provided.