Keep texture refresh notifications through streaming bursts #895

Open
gomeaw wants to merge 3 commits from upstream-pr/896 into main
gomeaw commented 2026-11-25 12:08:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by gomeaw on 2026-11-25T12:08:21Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5491027087 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/896). Originally posted by [gomeaw](https://github.com/gomeaw) on 2026-11-25T12:08:21Z. --- ### 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.
Filip722 commented 2026-11-26 22:59:40 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-26T22:59:40Z.


I re-ran the burst case on current main 52ac4ec. The unpatched test lost the earliest change. With this PR applied on the same Bazzite 44 and GE-Proton11-14 setup, the physical RTX 5060 Laptop test kept the earlier range and made the already-uploaded view due again through both remaps and completed writes. The disjoint-coverage and compaction-headroom tests also passed.

Updated source-only review branch at f918253a348dea41af2214689a91ee36687e290f. It includes #1357's existing test-file split for the inherited asset-policy size failures and preserves the newer completed-write diagnostics. Windows-target GPU Clippy with warnings denied and the full asset policy passed. Review branch

Assisted by Codex (GPT-6.2-Sol High).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7205161578 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/896#issuecomment-7205161578). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-26T22:59:40Z. --- I re-ran the burst case on current main `52ac4ec`. The unpatched test lost the earliest change. With this PR applied on the same Bazzite 44 and GE-Proton11-14 setup, the physical RTX 5060 Laptop test kept the earlier range and made the already-uploaded view due again through both remaps and completed writes. The disjoint-coverage and compaction-headroom tests also passed. Updated source-only review branch at `f918253a348dea41af2214689a91ee36687e290f`. It includes #1357's existing test-file split for the inherited asset-policy size failures and preserves the newer completed-write diagnostics. Windows-target GPU Clippy with warnings denied and the full asset policy passed. [Review branch](https://github.com/Filip722/victory-fork/tree/gpu-keep-texture-notifications-main) Assisted by Codex (GPT-6.2-Sol High).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/896:upstream-pr/896'
git switch 'upstream-pr/896'

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 'upstream-pr/896'
git switch 'upstream-pr/896'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/896'
git switch 'upstream-pr/896'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/896'
git switch 'main'
git merge --squash 'upstream-pr/896'
git switch 'main'
git merge --ff-only 'upstream-pr/896'
git switch 'main'
git merge 'upstream-pr/896'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
fxceless/victory-fork!895
No description provided.