Keep texture refresh notifications through streaming bursts #896

Open
github-bot wants to merge 3 commits from github-bot/gh-896 into main AGit
Owner

@⁠gomeaw on GitHub · 2026-11-25 12:08 UTC · original
gomeaw:fix/keep-texture-changes → main · +186 −41 · 2 files · 3 commits · open

Problem

A bindless texture that has finished uploading relies on mapping and storage-write notifications to become due again. When either notification buffer reached 32,768 entries, the next nonadjacent notification cleared every earlier entry. A texture could keep its old upload even after the layer had recorded a change to its memory.

Change

Merge touching and overlapping ranges before looking up affected slots. When the buffer fills, reclaim at least 4,096 entries before appending the next notification. If merging overlaps is insufficient, join just enough neighboring pairs to make room. This preserves coverage and avoids repeatedly sorting the full buffer under the producer lock when merging overlaps would free only one or two entries. The texture pass may check additional slots in those gaps. Diagnostics count the gaps joined at capacity.

Verification

  • The Windows D3D12 software-adapter comparison tested the patch applied to upstream 0b0074e. The original code loses the earliest notification. With the patch, the already-uploaded slot becomes due again through both the remap and completed-write paths. The tests also check coverage across 65,536 disjoint changes and verify that a nearly disjoint queue leaves room after compaction. All 22 descriptor tests passed. Windows comparison
  • An optimized synthetic CPU benchmark on Apple M4 used the production range and slot-lookup helpers. For 16,384 notifications covering 512 address ranges, remap collection and lookup went from 1.12 ms to 0.19 ms and completed-write collection and lookup went from 0.96 ms to 0.19 ms. Both selected the same slots. A 24-notification case added about 0.1 µs.
  • A separate stress case started with 32,767 disjoint ranges and one duplicate already queued, then alternated 256 notifications between two existing ranges. The median CPU time across 31 samples fell from 80.55 ms on the first PR revision to 0.33 ms with the compaction headroom. Both preserved coverage.
  • The asset-policy check passed. Cross-target Clippy completed for the GPU crate in both feature configurations with existing upstream warnings.

Issue #821 shows why a completed-write notification can matter to an already-uploaded texture. #606 handles a remap of a staged texture, and #221 and #733 optimize the later selection of due uploads. This PR covers the earlier loss of notifications at capacity. The frequency of that overflow in gameplay and the effect on frames remain unmeasured.

AI-assisted with Codex. All test and benchmark inputs were synthetic.

**@⁠gomeaw** on GitHub · 2026-11-25 12:08 UTC · [original](https://github.com/fxceless/victory-fork/pull/896) `gomeaw:fix/keep-texture-changes` → `main` · +186 −41 · 2 files · 3 commits · open ### Problem A bindless texture that has finished uploading relies on mapping and storage-write notifications to become due again. When either notification buffer reached 32,768 entries, the next nonadjacent notification cleared every earlier entry. A texture could keep its old upload even after the layer had recorded a change to its memory. ### Change Merge touching and overlapping ranges before looking up affected slots. When the buffer fills, reclaim at least 4,096 entries before appending the next notification. If merging overlaps is insufficient, join just enough neighboring pairs to make room. This preserves coverage and avoids repeatedly sorting the full buffer under the producer lock when merging overlaps would free only one or two entries. The texture pass may check additional slots in those gaps. Diagnostics count the gaps joined at capacity. ### Verification - The Windows D3D12 software-adapter comparison tested the patch applied to upstream `0b0074e`. The original code loses the earliest notification. With the patch, the already-uploaded slot becomes due again through both the remap and completed-write paths. The tests also check coverage across 65,536 disjoint changes and verify that a nearly disjoint queue leaves room after compaction. All 22 descriptor tests passed. [Windows comparison](https://github.com/gomeaw/victory-fork/actions/runs/45626359020/job/139247502828) - An optimized synthetic CPU benchmark on Apple M4 used the production range and slot-lookup helpers. For 16,384 notifications covering 512 address ranges, remap collection and lookup went from 1.12 ms to 0.19 ms and completed-write collection and lookup went from 0.96 ms to 0.19 ms. Both selected the same slots. A 24-notification case added about 0.1 µs. - A separate stress case started with 32,767 disjoint ranges and one duplicate already queued, then alternated 256 notifications between two existing ranges. The median CPU time across 31 samples fell from 80.55 ms on the first PR revision to 0.33 ms with the compaction headroom. Both preserved coverage. - The asset-policy check passed. Cross-target Clippy completed for the GPU crate in both feature configurations with existing upstream warnings. Issue #821 shows why a completed-write notification can matter to an already-uploaded texture. #606 handles a remap of a staged texture, and #221 and #733 optimize the later selection of due uploads. This PR covers the earlier loss of notifications at capacity. The frequency of that overflow in gameplay and the effect on frames remain unmeasured. AI-assisted with Codex. All test and benchmark inputs were synthetic.
Merge overlapping changes before looking up placed views. If the whole pending buffer is disjoint, fold neighboring intervals to preserve coverage within the existing cap.
Merging just one overlap at capacity meant a producer could sort the entire queue again for each following notification. Free one eighth of the queue when exact coalescing leaves less room, joining only enough pairs to reach that target.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:53:25 +00:00
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/896/head:github-bot/gh-896'
git switch 'github-bot/gh-896'

Merge

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