GPU: a declared write range's new parts are found in one pass over the ranges already declared #1156

Open
fffluffy-dev wants to merge 1 commit from upstream-pr/1159 into main
fffluffy-dev commented 2026-11-25 22:04:19 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fffluffy-dev on 2026-11-25T22:04:19Z.


Shadow::writing finds the parts of a newly declared write range that no earlier declared range holds (their bytes go into the snapshot). It cut each pending range out in turn, allocating a new list per pending range for every new declaration: for N distinct ranges in a submission that is N(N+1)/2 lists (461,280 for 960 ranges), on the preparing side of every submission that declares shader writes.

It now calls the existing outside(from, to, skip) once with the pending ranges mapped through inside: one sorted pass, two lists per declaration. The non-empty parts are the same, in the same order; the empty parts the old loop could leave were skipped by every consumer already (from >= to / from < to checks).

Validation (cargo-xwin, x86_64-pc-windows-msvc, tests under Wine): new test a_new_range_s_parts_are_those_one_cut_at_a_time_gave compares both on 960 pseudo-random overlapping, repeated, touching and empty ranges (identical parts; 461,280 → 1,920 lists). cargo test -p victory-gpu: 184 passed, 1 failed, 5 ignored; the failure (drvwatch::tests::the_system_takes_the_subscription) and 11 clippy -D warnings errors in resource.rs, fpsbox.rs and draw.rs are the same on main 9c184b3 without this change under Wine; this change adds none. cargo xtask policy ok. Not measured on a real frame: look at SnapshotUs / "preparing" on submissions with many declared ranges.

AI use: written with Claude Code (Claude Opus 5.5); reviewed and posted with my approval. No game files were used.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6614684105 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1159). Originally posted by [fffluffy-dev](https://github.com/fffluffy-dev) on 2026-11-25T22:04:19Z. --- `Shadow::writing` finds the parts of a newly declared write range that no earlier declared range holds (their bytes go into the snapshot). It cut each pending range out in turn, allocating a new list per pending range for every new declaration: for N distinct ranges in a submission that is N(N+1)/2 lists (461,280 for 960 ranges), on the preparing side of every submission that declares shader writes. It now calls the existing `outside(from, to, skip)` once with the pending ranges mapped through `inside`: one sorted pass, two lists per declaration. The non-empty parts are the same, in the same order; the empty parts the old loop could leave were skipped by every consumer already (`from >= to` / `from < to` checks). Validation (cargo-xwin, x86_64-pc-windows-msvc, tests under Wine): new test `a_new_range_s_parts_are_those_one_cut_at_a_time_gave` compares both on 960 pseudo-random overlapping, repeated, touching and empty ranges (identical parts; 461,280 → 1,920 lists). `cargo test -p victory-gpu`: 184 passed, 1 failed, 5 ignored; the failure (`drvwatch::tests::the_system_takes_the_subscription`) and 11 clippy `-D warnings` errors in `resource.rs`, `fpsbox.rs` and `draw.rs` are the same on main 9c184b3 without this change under Wine; this change adds none. `cargo xtask policy` ok. Not measured on a real frame: look at `SnapshotUs` / "preparing" on submissions with many declared ranges. **AI use:** written with Claude Code (Claude Opus 5.5); reviewed and posted with my approval. No game files were used.
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/1159:upstream-pr/1159'
git switch 'upstream-pr/1159'

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