[pr-performance][memory] Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default) #62

Open
Sobo wants to merge 1 commit from Sobo/Darner:windows-sparse into main
Contributor

With DARNER_WINDOWS_SPARSE=1 (and tiled resources tier 2 or more), the
card side of a window of title memory is a reserved buffer: its 64 KiB
tiles get memory from a pool of 64 MiB heaps only when a send first
brings them bytes that are not zero, or when shaders may write them, and
give it back when a send brings a whole tile as zeros. Empty heaps go
back to the card 5 s later. The mappings are made on the queue before
the list that sends. Unset or 0: windows as before.

A window made tile by tile is counted in WINDOW_SPARSE_BYTES, not in
WINDOW_CARD_BYTES, so its drop leaves WINDOW_CARD_BYTES alone: taking its
size off there ran the count below zero a few minutes into a city, and
from then on window_admission refused every new window the card. The
windows line says that count too.

Ported from fxceless/blackbebec b715714 (GPL-3.0), without its
DIRECT/Sources parts.

Co-Authored-By: Claude Opus 5.5 [email protected]
Fluxer-ID: 1577742832095989771

Contributor role (optional)

  • Fluxer ID: 1577742832095989771

What it changes

Switch: DARNER_WINDOWS_SPARSE=1 (off by default).

A window of title memory (memory outside the title's buffers) gets as its card side a reserved buffer (CreateReservedResource) that is given memory in 64 KiB tiles, from a pool of heaps, only where the GPU or the CPU actually touches it. Empty heaps are released after 5 s, not at once (releasing them at once lost the device). Page buffers stay out of tiled windows (buffer_sides(..., direct = !tiled)).

A tiled window is counted in WINDOW_SPARSE_BYTES, not in WINDOW_CARD_BYTES, so its drop leaves WINDOW_CARD_BYTES alone. (Taking its size off there ran that count below zero a few minutes into a city; from then on window_admission refused every new window the card (Fallback::Cap) and placed it in the PC's memory.) The windows line also says that count now.

Ported from fxceless/blackbebec b715714 (GPL-3.0), without its DIRECT/Sources parts.

How it was tested

  • Tested revision: Darner main 4a92569fb (git.gtahub.st) with this patch applied. Build check: cargo clippy -p darner-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings: clean. cargo test was not run (no Windows machine for the checks). The gameplay numbers below come from my own builds, which carried this change together with other local changes (same scene, settings and hardware before and after).
  • Hardware and setup: i7-10700K (8 cores, 16 threads), RTX 3090 24 GB, 32 GB RAM, Windows 11; page file 128 GB; NVIDIA shader cache 100 GB; shaders prepared with the preload, then darner warm --used --again with DARNER_WARM_SHARED=1.
  • Gameplay: Series X profile (and Series S where said), DLSS quality, FSR 3 frame generation 2x, ray tracing off.
  • Before and after (heavy city scenes): memory shared with the card up to 15.6 GB (it overflowed and the driver crashed, with large card windows) -> about 7.3 GB; the title's GPU work 45.8 -> 36.4 ms a frame.
  • The counter fix: in three runs without it, the windows' card count went below zero after 5 to 6 minutes, each time where the city's stutter and late textures began (seen as buffer mirror span of about 17,592,186,040,000 MB in the compile-memory line). In three runs with it (Series S profile, 1440p output, FSR 3 frame generation 2x, 5 to 6 minutes of city each), the count stayed at 0 MB, the span stayed positive (4.3 to 4.9 GB), and at the end 1,126 windows (6.9 GB) were on the card, none in the PC's memory, none turned away.
  • Coverage gaps: one PC only. DARNER_PAGE_BUFFERS=3 (now on by default) solves a similar problem; the two have not been compared side by side.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none for the same problem. Open PRs that share files only: #37 (shadow.rs) and many that touch host.rs or lib.rs.
With DARNER_WINDOWS_SPARSE=1 (and tiled resources tier 2 or more), the card side of a window of title memory is a reserved buffer: its 64 KiB tiles get memory from a pool of 64 MiB heaps only when a send first brings them bytes that are not zero, or when shaders may write them, and give it back when a send brings a whole tile as zeros. Empty heaps go back to the card 5 s later. The mappings are made on the queue before the list that sends. Unset or 0: windows as before. A window made tile by tile is counted in WINDOW_SPARSE_BYTES, not in WINDOW_CARD_BYTES, so its drop leaves WINDOW_CARD_BYTES alone: taking its size off there ran the count below zero a few minutes into a city, and from then on window_admission refused every new window the card. The windows line says that count too. Ported from fxceless/blackbebec b715714 (GPL-3.0), without its DIRECT/Sources parts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Fluxer-ID: 1577742832095989771 <!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> <!-- Use Fixes #N for a complete fix or Refs #N for a partial change. --> ## Contributor role (optional) - Fluxer ID: 1577742832095989771 ## What it changes Switch: `DARNER_WINDOWS_SPARSE=1` (off by default). A window of title memory (memory outside the title's buffers) gets as its card side a reserved buffer (CreateReservedResource) that is given memory in 64 KiB tiles, from a pool of heaps, only where the GPU or the CPU actually touches it. Empty heaps are released after 5 s, not at once (releasing them at once lost the device). Page buffers stay out of tiled windows (`buffer_sides(..., direct = !tiled)`). A tiled window is counted in `WINDOW_SPARSE_BYTES`, not in `WINDOW_CARD_BYTES`, so its drop leaves `WINDOW_CARD_BYTES` alone. (Taking its size off there ran that count below zero a few minutes into a city; from then on `window_admission` refused every new window the card (`Fallback::Cap`) and placed it in the PC's memory.) The windows line also says that count now. Ported from fxceless/blackbebec b715714 (GPL-3.0), without its DIRECT/Sources parts. ## How it was tested - Tested revision: Darner `main` 4a92569fb (git.gtahub.st) with this patch applied. Build check: `cargo clippy -p darner-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings`: clean. `cargo test` was not run (no Windows machine for the checks). The gameplay numbers below come from my own builds, which carried this change together with other local changes (same scene, settings and hardware before and after). - Hardware and setup: i7-10700K (8 cores, 16 threads), RTX 3090 24 GB, 32 GB RAM, Windows 11; page file 128 GB; NVIDIA shader cache 100 GB; shaders prepared with the preload, then `darner warm --used --again` with `DARNER_WARM_SHARED=1`. - Gameplay: Series X profile (and Series S where said), DLSS quality, FSR 3 frame generation 2x, ray tracing off. - Before and after (heavy city scenes): memory shared with the card up to 15.6 GB (it overflowed and the driver crashed, with large card windows) -> about 7.3 GB; the title's GPU work 45.8 -> 36.4 ms a frame. - The counter fix: in three runs without it, the windows' card count went below zero after 5 to 6 minutes, each time where the city's stutter and late textures began (seen as `buffer mirror span` of about 17,592,186,040,000 MB in the compile-memory line). In three runs with it (Series S profile, 1440p output, FSR 3 frame generation 2x, 5 to 6 minutes of city each), the count stayed at 0 MB, the span stayed positive (4.3 to 4.9 GB), and at the end 1,126 windows (6.9 GB) were on the card, none in the PC's memory, none turned away. - Coverage gaps: one PC only. `DARNER_PAGE_BUFFERS=3` (now on by default) solves a similar problem; the two have not been compared side by side. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none for the same problem. Open PRs that share files only: #37 (shadow.rs) and many that touch host.rs or lib.rs.
With DARNER_WINDOWS_SPARSE=1 (and tiled resources tier 2 or more), the
card side of a window of title memory is a reserved buffer: its 64 KiB
tiles get memory from a pool of 64 MiB heaps only when a send first
brings them bytes that are not zero, or when shaders may write them, and
give it back when a send brings a whole tile as zeros. Empty heaps go
back to the card 5 s later. The mappings are made on the queue before
the list that sends. Unset or 0: windows as before.

A window made tile by tile is counted in WINDOW_SPARSE_BYTES, not in
WINDOW_CARD_BYTES, so its drop leaves WINDOW_CARD_BYTES alone: taking its
size off there ran the count below zero a few minutes into a city, and
from then on window_admission refused every new window the card. The
windows line says that count too.

Ported from fxceless/blackbebec b715714 (GPL-3.0), without its
DIRECT/Sources parts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fluxer-ID: 1577742832095989771
Sobo changed title from WIP: Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default) to [pr-performance][memory] Windows of title memory on the card tile by tile (DARNER_WINDOWS_SPARSE; off by default) 2026-12-03 18:34:22 +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 'windows-sparse:Sobo-windows-sparse'
git switch 'Sobo-windows-sparse'

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 'Sobo-windows-sparse'
git switch 'Sobo-windows-sparse'
git rebase 'main'
git switch 'main'
git merge --ff-only 'Sobo-windows-sparse'
git switch 'Sobo-windows-sparse'
git rebase 'main'
git switch 'main'
git merge --no-ff 'Sobo-windows-sparse'
git switch 'main'
git merge --squash 'Sobo-windows-sparse'
git switch 'main'
git merge --ff-only 'Sobo-windows-sparse'
git switch 'main'
git merge 'Sobo-windows-sparse'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!62
No description provided.