GPU: walk only dirty gaps when refreshing guarded views #977

Open
gmankab wants to merge 1 commit from upstream-pr/979 into main
gmankab commented 2026-11-25 14:36:03 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by gmankab on 2026-11-25T14:36:03Z.


The texture refresh path checks guarded views repeatedly, including heaps whose 64 KiB blocks are all clean. The clean-block lookup currently allocates a vector of every clean block under the guard mutex before it can find the gaps.

Store those clean blocks as half-open runs and walk their gaps. A fully clean view needs one lookup. This keeps the existing guard lock, mapping checks, alias protection and write notifications. The tests compare the runs against the per-block representation and exercise real guarded and aliased mappings.

This takes the clean-run idea from #824 into a standalone change. It applies directly to current main and does not require the other changes in that PR.

Validation

  • 13 write-watch and mapping tests passed on this branch under Wine, including the interval regression test. The equivalent canonical test branch passed all 14 tests in its write-watch module.

  • A synthetic 174 MiB lookup benchmark measured 7.6 µs to about 12 ns for an entirely clean range and 11.7 µs to about 80 ns with four gaps. These measurements cover the lookup and gap walk only.

  • A local paired RX 6800 run used the same launch settings, starting saves and caches. Both builds rendered the same prologue shot. The interval build did not show a frame-time improvement in the first 75 seconds of heavy rendering. In the first full reporting window, at similar executed draw counts (1,337 vs 1,352), the control reported 12.0 seconds per frame and the interval build 17.8 seconds. The measured time inside GetWriteWatch also varied between runs. One run per variant is insufficient to attribute the timing difference to this patch.

Based-on: https://github.com/fxceless/victory-fork/pull/824
Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton
Assisted-by: gpt-6.2 sol xhigh

<!-- greyfinch-sync:fxceless/victory-fork:issue:6606933148 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/979). Originally posted by [gmankab](https://github.com/gmankab) on 2026-11-25T14:36:03Z. --- The texture refresh path checks guarded views repeatedly, including heaps whose 64 KiB blocks are all clean. The clean-block lookup currently allocates a vector of every clean block under the guard mutex before it can find the gaps. Store those clean blocks as half-open runs and walk their gaps. A fully clean view needs one lookup. This keeps the existing guard lock, mapping checks, alias protection and write notifications. The tests compare the runs against the per-block representation and exercise real guarded and aliased mappings. This takes the clean-run idea from #824 into a standalone change. It applies directly to current main and does not require the other changes in that PR. Validation - 13 write-watch and mapping tests passed on this branch under Wine, including the interval regression test. The equivalent canonical test branch passed all 14 tests in its write-watch module. - A synthetic 174 MiB lookup benchmark measured 7.6 µs to about 12 ns for an entirely clean range and 11.7 µs to about 80 ns with four gaps. These measurements cover the lookup and gap walk only. - A local paired RX 6800 run used the same launch settings, starting saves and caches. Both builds rendered the same prologue shot. The interval build did not show a frame-time improvement in the first 75 seconds of heavy rendering. In the first full reporting window, at similar executed draw counts (1,337 vs 1,352), the control reported 12.0 seconds per frame and the interval build 17.8 seconds. The measured time inside GetWriteWatch also varied between runs. One run per variant is insufficient to attribute the timing difference to this patch. Based-on: https://github.com/fxceless/victory-fork/pull/824 Tested-on: RX 6800, Fedora Linux 45, Wine/vkd3d-proton Assisted-by: gpt-6.2 sol xhigh
avt0m4t48 commented 2026-11-25 16:12:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-25T15:25:55Z.


I ran the same release fixture at 0b0074e and ac6e475 on native Windows. All 11 existing watch tests passed on the baseline and all 12 passed on this head, each in a fresh process. The added interval oracle was among the 12.

I also exercised the full guard() call on a real 174 MiB page-file mapping. I alternated baseline, candidate, candidate, baseline on the same runner and checked the page list on every call. The table gives the two process medians per build, with nine samples per process.

View state Baseline This PR
Completely clean 10.62–10.72 µs 0.020 µs
Four changed 64 KiB blocks 19.61–19.70 µs 3.61–3.72 µs

The four-block case includes reporting and restoring protections inside guard(). Reopening the four blocks and writing into them happen outside the timer. This is a synthetic guarded-view cost on the Windows runner. The RX 6800 frame-time observation in the PR is a separate measurement.

Fixture · Windows run

<!-- greyfinch-sync:fxceless/victory-fork:comment:7166831908 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/979#issuecomment-7166831908). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-25T15:25:55Z. --- I ran the same release fixture at `0b0074e` and `ac6e475` on native Windows. All 11 existing watch tests passed on the baseline and all 12 passed on this head, each in a fresh process. The added interval oracle was among the 12. I also exercised the full `guard()` call on a real 174 MiB page-file mapping. I alternated baseline, candidate, candidate, baseline on the same runner and checked the page list on every call. The table gives the two process medians per build, with nine samples per process. | View state | Baseline | This PR | | --- | ---: | ---: | | Completely clean | 10.62–10.72 µs | 0.020 µs | | Four changed 64 KiB blocks | 19.61–19.70 µs | 3.61–3.72 µs | The four-block case includes reporting and restoring protections inside `guard()`. Reopening the four blocks and writing into them happen outside the timer. This is a synthetic guarded-view cost on the Windows runner. The RX 6800 frame-time observation in the PR is a separate measurement. [Fixture](https://github.com/avt0m4t48/victory-fork/commit/b826e82a654bfd0c6748c77609b4795979649f53) · [Windows run](https://github.com/avt0m4t48/victory-fork/actions/runs/45644267212)
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/979:upstream-pr/979'
git switch 'upstream-pr/979'

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/979'
git switch 'upstream-pr/979'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/979'
git switch 'upstream-pr/979'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/979'
git switch 'main'
git merge --squash 'upstream-pr/979'
git switch 'main'
git merge --ff-only 'upstream-pr/979'
git switch 'main'
git merge 'upstream-pr/979'
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!977
No description provided.