A pooled texture or buffer is handed out only once it holds the hook that gives its piece back #637

Open
deama wants to merge 1 commit from deama/Darner:c14/pool-shadow into Main
First-time contributor

Run in the game only inside a combined test build (official main c8258f9 + #594–#601 + this PR + the two other fix PRs from the same source), not on its own. Ported from uncommitted "Patch C14" work in a local VIctory-NVIDIA tree (before the rename). Error-path hardening found by reading the code.

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: read from the code. A texture or CPU-visible buffer placed in a block is handed out even when SetPrivateDataInterface refuses the object that gives its piece back (give_back_to). The piece then stays taken for good. A texture without the private data is treated as not pooled, so its first upload gets no aliasing barrier over what the card last did in that memory. It is also counted (HELD, the card ledger, the census, the park's counters) before the hook is attached.

One commit:

  • pool: a placed resource is handed out only once it holds the hook that gives its piece back

  • The hook comes first (Reclaim::register). If it can't be attached, the resource is let go first, and only then is its piece free again: at once and uncounted, since no list named it (Reclaim::registered tells release).

  • The caller falls back as when placement fails: texture gives Pooled::Unpooled, texture_moved and cpu_buffer give None. The counts (PARK_HOLE_USED among them) are taken only after success. A buffer that can't be mapped is let go before its piece is given back.

  • A test checks the order and the pool's figures on a heap of the software adapter, and fails if the immediate reclaim is replaced by a normal rest.

  • Not ported from the source: its serialized growth of 4 MiB card-buffer heaps and its tight-shadow root protection. Both act on card buffers and tight shadows that exist only in the source tree's uncommitted work, not in Darner.

How it was tested

  • Tested revision: b9f575ba84 (branch head; gates below). Game runs used a combined test build that contains it.
  • Commands and results: on b9f575ba84, Windows 10 22H2 with its built-in Direct3D 12 (no Shader Model 6.6), Rust 1.98.1:
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed
    • cargo --config 'profile.test.package.darner-shader.opt-level=3' test --workspace --locked --no-fail-fast (the opt-level only speeds up darner-shader's exhaustive float tests): 66 failed, all of which fail on unmodified main (c8258f9556) on this PC too (darner-shader tests that need Shader Model 6.6).
    • darner-gpu's test process aborts at the first test that needs Shader Model 6.6, on main too, so its tests were run in batches that survive the abort and compared one by one with main (main: 1658 pass, 8 fail, 139 need Shader Model 6.6, 81 ignored): no test that passes on main fails here, none removed; 1 new tests: 1 pass.
    • cargo xtask policy: ok (576 files).
  • Game, combined test build, RTX 4080 16 GB, Windows 10 22H2, 4K, DLSS Balanced, outdoor checkpoint (harness from #596): a strict debug-layer run loaded and drew at the outdoor pose. A refused hook is rare, so the new path almost certainly did not run there.
  • Changes a default: no. The normal path is unchanged.
  • A/B result: not applicable.
  • Gates run on that revision: see above.
  • Hardware dependence: none known.
  • Coverage gaps: the failure path is covered by the unit test only. The piece-return callback locks its pool, so callers must not hold a pool lock when calling give_back_to; the three current callers don't.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Only inside the combined build; the changed path is an error path.
  • 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: #512 (builder view pages and read-only arena eviction; other code in the same memory area).
  • Replaces or overlaps: none found
**Run in the game only inside a combined test build** (official `main` c8258f9 + #594–#601 + this PR + the two other fix PRs from the same source), not on its own. Ported from uncommitted "Patch C14" work in a local VIctory-NVIDIA tree (before the rename). Error-path hardening found by reading the code. ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: read from the code. A texture or CPU-visible buffer placed in a block is handed out even when `SetPrivateDataInterface` refuses the object that gives its piece back (`give_back_to`). The piece then stays taken for good. A texture without the private data is treated as not pooled, so its first upload gets no aliasing barrier over what the card last did in that memory. It is also counted (HELD, the card ledger, the census, the park's counters) before the hook is attached. One commit: - pool: a placed resource is handed out only once it holds the hook that gives its piece back - The hook comes first (`Reclaim::register`). If it can't be attached, the resource is let go first, and only then is its piece free again: at once and uncounted, since no list named it (`Reclaim::registered` tells `release`). - The caller falls back as when placement fails: `texture` gives `Pooled::Unpooled`, `texture_moved` and `cpu_buffer` give `None`. The counts (PARK_HOLE_USED among them) are taken only after success. A buffer that can't be mapped is let go before its piece is given back. - A test checks the order and the pool's figures on a heap of the software adapter, and fails if the immediate reclaim is replaced by a normal rest. - Not ported from the source: its serialized growth of 4 MiB card-buffer heaps and its tight-shadow root protection. Both act on card buffers and tight shadows that exist only in the source tree's uncommitted work, not in Darner. ## How it was tested - Tested revision: `b9f575ba84` (branch head; gates below). Game runs used a combined test build that contains it. - Commands and results: on `b9f575ba84`, Windows 10 22H2 with its built-in Direct3D 12 (no Shader Model 6.6), Rust 1.98.1: - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed - `cargo --config 'profile.test.package.darner-shader.opt-level=3' test --workspace --locked --no-fail-fast` (the opt-level only speeds up darner-shader's exhaustive float tests): 66 failed, all of which fail on unmodified `main` (c8258f9556) on this PC too (darner-shader tests that need Shader Model 6.6). - darner-gpu's test process aborts at the first test that needs Shader Model 6.6, on `main` too, so its tests were run in batches that survive the abort and compared one by one with `main` (`main`: 1658 pass, 8 fail, 139 need Shader Model 6.6, 81 ignored): no test that passes on `main` fails here, none removed; 1 new tests: 1 pass. - `cargo xtask policy`: ok (576 files). - Game, combined test build, RTX 4080 16 GB, Windows 10 22H2, 4K, DLSS Balanced, outdoor checkpoint (harness from #596): a strict debug-layer run loaded and drew at the outdoor pose. A refused hook is rare, so the new path almost certainly did not run there. - Changes a default: no. The normal path is unchanged. - A/B result: not applicable. - Gates run on that revision: see above. - Hardware dependence: none known. - Coverage gaps: the failure path is covered by the unit test only. The piece-return callback locks its pool, so callers must not hold a pool lock when calling `give_back_to`; the three current callers don't. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). Only inside the combined build; the changed path is an error path. - [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: #512 (builder view pages and read-only arena eviction; other code in the same memory area). - Replaces or overlaps: none found
A texture or CPU-visible buffer placed in a block was handed out even when
SetPrivateDataInterface refused the object that gives its piece back
(`give_back_to`). The piece then stayed taken for good, and a texture with
no private data was taken for an allocation of its own: `is_pooled` said
no, so its first upload had no aliasing barrier over what the card last did
in that memory. It was also counted (HELD, the card ledger, the census, the
park's counters) before the hook was attached.

The hook now comes first (`Reclaim::register`). If it cannot be attached,
the resource is let go, and only then is its piece free again: at once and
uncounted, since no list named it (`Reclaim::registered` tells `release`).
The caller falls back as when placement fails: `texture` gives
`Pooled::Unpooled`, `texture_moved` and `cpu_buffer` give `None`. The counts,
PARK_HOLE_USED among them, are taken only after it succeeds. A buffer that
cannot be mapped is let go before its piece is given back. A test checks the
order and the pool's figures on a heap of the software adapter.

Ported from VIctory-NVIDIA's uncommitted Patch C14 (track 3, registration
rollback). Not ported: its serialized growth of the 4 MiB card-buffer heaps
(`take_card_piece`) and its tight-shadow root CBV/SRV copies and root UAV
rejection in draw.rs. Both act on card buffers and tight shadows, which
exist only in that tree's uncommitted work, not in Darner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from [pr-fix][memory] A pooled texture or buffer is handed out only once it holds the hook that gives its piece back to A pooled texture or buffer is handed out only once it holds the hook that gives its piece back 2026-12-06 03:25:45 +00:00
Owner

Test needed — commit b9f575ba; what to check:

  • The problem on main: read from the code. A texture or CPU-visible buffer placed in a block is handed out even when SetPrivateDataInterface refuses the object that gives its piece back (give_back_to). The piece then stays taken for good. A texture without the private data is treated as not pooled, so its first upload gets no aliasing barrier over what the card last did in that memory. It is also counted (HELD, the card ledger, the census, the park's counters) before the hook is attached.

One commit:

  • pool: a placed resource is handed out only once it holds the hook that gives its piece back

  • The hook comes first (Reclaim::register). If it can't be attached, the resource is let go first, and only then is its piece free again: at once and uncounted, since no list named it (Reclaim::registered tells release).

  • The caller falls back as when placement fails: texture gives Pooled::Unpooled, texture_moved and cpu_buffer give None. The counts (PARK_HOLE_USED among them) are taken only after success. A buffer that can't be mapped is let go before its piece is given back.

  • A test checks the order and the pool's figures on a heap of the software adapter, and fails i

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `b9f575ba`; what to check: - The problem on main: read from the code. A texture or CPU-visible buffer placed in a block is handed out even when `SetPrivateDataInterface` refuses the object that gives its piece back (`give_back_to`). The piece then stays taken for good. A texture without the private data is treated as not pooled, so its first upload gets no aliasing barrier over what the card last did in that memory. It is also counted (HELD, the card ledger, the census, the park's counters) before the hook is attached. One commit: - pool: a placed resource is handed out only once it holds the hook that gives its piece back - The hook comes first (`Reclaim::register`). If it can't be attached, the resource is let go first, and only then is its piece free again: at once and uncounted, since no list named it (`Reclaim::registered` tells `release`). - The caller falls back as when placement fails: `texture` gives `Pooled::Unpooled`, `texture_moved` and `cpu_buffer` give `None`. The counts (PARK_HOLE_USED among them) are taken only after success. A buffer that can't be mapped is let go before its piece is given back. - A test checks the order and the pool's figures on a heap of the software adapter, and fails i Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
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 'c14/pool-shadow:deama-c14/pool-shadow'
git switch 'deama-c14/pool-shadow'

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 'deama-c14/pool-shadow'
git switch 'deama-c14/pool-shadow'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'deama-c14/pool-shadow'
git switch 'deama-c14/pool-shadow'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'deama-c14/pool-shadow'
git switch 'Main'
git merge --squash 'deama-c14/pool-shadow'
git switch 'Main'
git merge --ff-only 'deama-c14/pool-shadow'
git switch 'Main'
git merge 'deama-c14/pool-shadow'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!637
No description provided.