Skip to content

GPU: snapshot only newly declared write ranges - #45

Open
gmankab wants to merge 1 commit into
spidercraft:linux-native-runtimefrom
gmankab:contrib/linux-native-sparse-write-snapshots
Open

gmankab wants to merge 1 commit into
spidercraft:linux-native-runtimefrom
gmankab:contrib/linux-native-sparse-write-snapshots

Conversation

@gmankab

@gmankab gmankab commented Nov 26, 2026

Copy link
Copy Markdown

Writable views of a large GPU shadow can overlap or extend the before-image many times in one submission. The current code recopies previously saved bytes as the range grows and copies the gap between distant views.

This Linux native adaptation of Marvisak/VIctory #3318 stores disjoint original ranges. An overlapping declaration captures only newly covered bytes. Copy-back still reads and merges title memory in the original 64 KiB pieces, including when a piece spans several saved ranges.

CPU snapshot fixture, median of nine warmed trials Copied before → after Time before → after
49 growing write ranges in a 174 MiB shadow 4,116 → 156 MiB 440.23 → 90.04 ms
Two distant 1 MiB ranges 175 → 2 MiB 19.18 → 0.16 ms

The independent contribution passed all 44 regular victory-gpu tests on each backend. The integration with the pending Linux native changes passed all 74 regular GPU tests on each backend. The regression checks first-write contents, gaps, page reconstruction, and reset between submissions. Lavapipe emitted the existing descriptor validation message VUID-VkWriteDescriptorSet-dstSet-04611. The fixture measures CPU snapshot preparation. In-game frame timing remains unmeasured for this patch.

Tested-on: RX 6800 and Lavapipe, Fedora Linux 45, Linux native
Assisted-by: gpt-6.2 sol xhigh

Overlapping writable views can grow the shadow buffer's before-image
many times in one submission. Each growth recopies bytes already saved.
Distant writes also snapshot the untouched gap between them. Large
heap views make this work expensive during command preparation.

Keep the first originals in sorted disjoint ranges and capture only
newly covered bytes. Borrow a contiguous original page directly or
reassemble it in reusable scratch when it spans several ranges. This
keeps the existing title read, writeback merge, and write-watch stamps
page-based. Return captured storage after the last pending range.

Verify overlaps, distant ranges, page reconstruction, and reuse across
submissions. A 174 MiB CPU fixture with 49 growing ranges reduced
bytes copied from 4,116 MiB to 156 MiB and median time from 440 to 90 ms.

Based-on: Marvisak#3318
Tested-on: RX 6800 and Lavapipe, Fedora Linux 45, Linux native
Assisted-by: gpt-6.2 sol xhigh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant