descriptor: advance RemapQueue::published when HostHeap::new takes its cursor #563

Open
groster17800 wants to merge 0 commits from groster17800/Darner:pr/remap-published-on-new-heap into Main
First-time contributor

Refs #389

Contributor role (optional)

  • Fluxer ID: VectorSoay#2100

What it changes

  • The problem on main: watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue fails intermittently in parallel cargo test -p darner-gpu --lib --locked runs and deterministically in cargo test -p darner-gpu --lib --locked -- --test-threads=1 on official/main (c8258f9) whenever test_view_heap allocates at virtual addresses recently unmapped and freed by earlier watch::tests (drop_views).

    assertion `left == right` failed
      left: [(8194, Some(2), 0, 8194), (8194, Some(1), 1024, 8193)]
     right: [(8193, Some(0), 1024, 8192), (8193, Some(1), 1024, 8192)]
    

HostHeap::new initialized remap_cursor to REMAPPED.latest without advancing REMAPPED.published. Even if refresh_remapped runs before any new entry arrives, it returns early on if remapped.latest == *cursor, leaving REMAPPED.published behind remap_cursor. When a subsequent RemapQueue::record overlaps the tail unpublished entry (or triggers full-queue unpublished compaction), RemapQueue::record merges the new write into that pre-heap range and overwrites its sequence with self.latest (> remap_cursor). RemapQueue::snapshot(cursor) then returns a span that existed before the heap was created, causing HostHeap::refresh_remapped to mark unrelated placed texture slots due (causing redundant texture re-reads, not missed updates).

This adds RemapQueue::cursor(&mut self) -> u64, which sets self.published = self.latest when HostHeap::new takes its initial cursor, plus a unit test (new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing) covering both back-entry coalescing and full-queue compaction without VirtualAlloc or a D3D12 device. Advancing published preserves snapshots for older heaps because RemapQueue::snapshot partitions solely by *sequence <= cursor.

How it was tested

  • Tested revision: 149c5f4 on pr/remap-published-on-new-heap (based on official/main c8258f9).
  • Commands and results:
    • cargo test -p darner-gpu --lib --locked descriptor::host::tests::new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing -- --nocapture: ok. 1 passed; 0 failed; 0 ignored; 1886 filtered out (0.00s)
    • cargo test -p darner-gpu --lib --locked descriptor::host::tests::remap_history: ok. 5 passed; 0 failed; 0 ignored; 1882 filtered out (0.11s)
    • cargo test -p darner-gpu --lib --locked watch::tests:: -- --test-threads=1: ok. 55 passed; 0 failed; 0 ignored; 1832 filtered out (1.33s; includes streamed_texture_written_through_an_alias_reaches_a_full_queue)
  • Changes a default: no (does not change any switch; affects heap cursor initialization for all HostHeap instances).
  • A/B result: not run in the game; no performance claim is made.
  • Gates run on that revision (149c5f4):
    • Gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings): passed (exit 0, 74.2s)
    • Gate 2 (cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): passed (exit 0, 57.3s)
    • Asset policy (cargo xtask policy): asset policy: 576 files ok (exit 0)
    • Gate 3 (cargo test --workspace --locked): not run standalone on 149c5f4; see the targeted darner-gpu runs above (full darner-gpu --lib 10x parallel + serial and --workspace -- --skip oracle64::legacy_mul_forms_are_exact were run with PR 2 cherry-picked onto 149c5f4 at c52c07a).
  • Gameplay, when relevant: not run in game (bug only causes spurious due marks / redundant texture re-reads; no in-game performance claim).
  • Shader wave sizes tested, when relevant: n/a.
  • Hardware dependence: Windows D3D12 host used for watch::tests::; RemapQueue::cursor unit test is hardware-independent.
  • Coverage gaps: no in-game measurement performed; full workspace cargo test was not run standalone on 149c5f4 without pr/gate3-watch-locks.

Checklist

  • I ran this change in the game, or say below why it can't be (unit and D3D12 host descriptor/watch tests only; no game performance claim made).
  • 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 found
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

Refs #389 ## Contributor role (optional) - Fluxer ID: VectorSoay#2100 ## What it changes - The problem on main: `watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue` fails intermittently in parallel `cargo test -p darner-gpu --lib --locked` runs and deterministically in `cargo test -p darner-gpu --lib --locked -- --test-threads=1` on `official/main` (`c8258f9`) whenever `test_view_heap` allocates at virtual addresses recently unmapped and freed by earlier `watch::tests` (`drop_views`). ```text assertion `left == right` failed left: [(8194, Some(2), 0, 8194), (8194, Some(1), 1024, 8193)] right: [(8193, Some(0), 1024, 8192), (8193, Some(1), 1024, 8192)] ``` `HostHeap::new` initialized `remap_cursor` to `REMAPPED.latest` without advancing `REMAPPED.published`. Even if `refresh_remapped` runs before any new entry arrives, it returns early on `if remapped.latest == *cursor`, leaving `REMAPPED.published` behind `remap_cursor`. When a subsequent `RemapQueue::record` overlaps the tail unpublished entry (or triggers full-queue unpublished compaction), `RemapQueue::record` merges the new write into that pre-heap range and overwrites its `sequence` with `self.latest` (`> remap_cursor`). `RemapQueue::snapshot(cursor)` then returns a span that existed before the heap was created, causing `HostHeap::refresh_remapped` to mark unrelated placed texture slots due (causing redundant texture re-reads, not missed updates). This adds `RemapQueue::cursor(&mut self) -> u64`, which sets `self.published = self.latest` when `HostHeap::new` takes its initial cursor, plus a unit test (`new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing`) covering both back-entry coalescing and full-queue compaction without `VirtualAlloc` or a D3D12 device. Advancing `published` preserves snapshots for older heaps because `RemapQueue::snapshot` partitions solely by `*sequence <= cursor`. ## How it was tested - Tested revision: `149c5f4` on `pr/remap-published-on-new-heap` (based on `official/main` `c8258f9`). - Commands and results: - `cargo test -p darner-gpu --lib --locked descriptor::host::tests::new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing -- --nocapture`: `ok. 1 passed; 0 failed; 0 ignored; 1886 filtered out` (`0.00s`) - `cargo test -p darner-gpu --lib --locked descriptor::host::tests::remap_history`: `ok. 5 passed; 0 failed; 0 ignored; 1882 filtered out` (`0.11s`) - `cargo test -p darner-gpu --lib --locked watch::tests:: -- --test-threads=1`: `ok. 55 passed; 0 failed; 0 ignored; 1832 filtered out` (`1.33s`; includes `streamed_texture_written_through_an_alias_reaches_a_full_queue`) - Changes a default: no (does not change any switch; affects heap cursor initialization for all `HostHeap` instances). - A/B result: not run in the game; no performance claim is made. - Gates run on that revision (`149c5f4`): - Gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`): passed (`exit 0`, `74.2s`) - Gate 2 (`cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`): passed (`exit 0`, `57.3s`) - Asset policy (`cargo xtask policy`): `asset policy: 576 files ok` (`exit 0`) - Gate 3 (`cargo test --workspace --locked`): not run standalone on `149c5f4`; see the targeted `darner-gpu` runs above (full `darner-gpu --lib` 10x parallel + serial and `--workspace -- --skip oracle64::legacy_mul_forms_are_exact` were run with PR 2 cherry-picked onto `149c5f4` at `c52c07a`). - Gameplay, when relevant: not run in game (bug only causes spurious due marks / redundant texture re-reads; no in-game performance claim). - Shader wave sizes tested, when relevant: n/a. - Hardware dependence: Windows D3D12 host used for `watch::tests::`; `RemapQueue::cursor` unit test is hardware-independent. - Coverage gaps: no in-game measurement performed; full workspace `cargo test` was not run standalone on `149c5f4` without `pr/gate3-watch-locks`. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (unit and D3D12 host descriptor/watch tests only; no game performance claim made). - [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 found - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HostHeap::new initialized remap_cursor from REMAPPED.latest without advancing REMAPPED.published, and refresh_remapped returns early when latest == cursor. Later overlapping writes or full-queue compaction in RemapQueue::record then coalesced into unpublished pre-heap ranges and overwrote their sequence numbers with self.latest (> remap_cursor), causing the new heap's snapshot to observe spans that existed before the heap was created and mark unrelated texture slots due (causing extra texture re-reads rather than missed updates). This also broke watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue whenever a view reused a recently unmapped virtual address.

Add RemapQueue::cursor() to advance published to latest when HostHeap::new takes its initial cursor (older heaps still see all entries since their cursor because snapshot partitions on *sequence <= cursor), plus a deterministic RemapQueue unit test covering both back-entry coalescing and compaction.

Co-Authored-By: Gemini <[email protected]>
First-time contributor

Code review & local test verification on 149c5f4 (Windows 11, Rust --locked):

  • Verified RemapQueue::cursor() updates self.published = self.latest when HostHeap::new initializes remap_cursor, sealing prior unpublished remap entries so later overlapping writes or REMAP_LIMIT compaction cannot advance their sequence numbers past the new heap's starting cursor.
  • cargo test --locked -p darner-gpu descriptor::host::tests -- --skip oracle64: 94 passed, 0 failed (1 ignored), including new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing.
  • cargo clippy --locked --all-targets -- -D warnings: 0 warnings.
Code review & local test verification on `149c5f4` (Windows 11, Rust `--locked`): - Verified `RemapQueue::cursor()` updates `self.published = self.latest` when `HostHeap::new` initializes `remap_cursor`, sealing prior unpublished remap entries so later overlapping writes or `REMAP_LIMIT` compaction cannot advance their sequence numbers past the new heap's starting cursor. - `cargo test --locked -p darner-gpu descriptor::host::tests -- --skip oracle64`: **94 passed, 0 failed** (`1` ignored), including `new_heap_cursor_seals_prior_unpublished_ranges_against_coalescing`. - `cargo clippy --locked --all-targets -- -D warnings`: **0 warnings**.
First-time contributor

Tested merged onto c8258f95 (release), head 149c5f4b. RTX 3090 24 GB, driver 621.24, i5-10600K, 32 GB, Windows 11.

One unattended run, 60 s in the world: exit code 0, no device removed, no new kind of WARN or ERROR line compared with main.

Note: #547 and #563 seem to make the same fix (the remap cursor is published when HostHeap::new sets it up). I tested both and saw no difference between them in this run. Only one of them is probably needed.

AI-assisted testing (Claude Code, Claude Opus 5.5); results and text reviewed by me.

Tested merged onto `c8258f95` (release), head `149c5f4b`. RTX 3090 24 GB, driver 621.24, i5-10600K, 32 GB, Windows 11. One unattended run, 60 s in the world: exit code 0, no device removed, no new kind of WARN or ERROR line compared with `main`. Note: #547 and #563 seem to make the same fix (the remap cursor is published when `HostHeap::new` sets it up). I tested both and saw no difference between them in this run. Only one of them is probably needed. _AI-assisted testing (Claude Code, Claude Opus 5.5); results and text reviewed by me._
TrustNo1 changed title from [pr-fix][memory] descriptor: advance RemapQueue::published when HostHeap::new takes its cursor to descriptor: advance RemapQueue::published when HostHeap::new takes its cursor 2026-12-06 03:27:02 +00:00
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/remap-published-on-new-heap:groster17800-pr/remap-published-on-new-heap'
git switch 'groster17800-pr/remap-published-on-new-heap'

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 'groster17800-pr/remap-published-on-new-heap'
git switch 'groster17800-pr/remap-published-on-new-heap'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'groster17800-pr/remap-published-on-new-heap'
git switch 'groster17800-pr/remap-published-on-new-heap'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'groster17800-pr/remap-published-on-new-heap'
git switch 'Main'
git merge --squash 'groster17800-pr/remap-published-on-new-heap'
git switch 'Main'
git merge --ff-only 'groster17800-pr/remap-published-on-new-heap'
git switch 'Main'
git merge 'groster17800-pr/remap-published-on-new-heap'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!563
No description provided.