Copy-back by memory class (#3838) cannot be made correct: the class is a caching statement, not a reader set (warm-launch face stretch, measurements) #4426

Open
opened 2026-11-30 20:18:52 +00:00 by github-bot · 35 comments
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:16 UTC · original

Filed so nobody spends more time on this lead. Note: drafted with Claude from my own runs and code reading; the fork build is a hand port of #3838, card RTX 5080, Series S profile.

Summary

Skipping the copy-back of shader writes by declared memory class (#3838: VICTORY_UNIFIED_BACK with WC_PIECES, WC_NO_BACK_PC, the byte floor and the shared-range rule) cannot be made correct by tuning classes, floors or the alias size. play.rs already leaves it off after #4028 #4055 #4012 #4024 #4038 #4058. This issue gives the reason from the console contract and four measurements, so the class masks do not get retried one by one.

What the console contract says, and what it does not

All in my own words, from the GDK documentation (graphics memory overview; physical page mapping reference; GPU synchronization on Scarlett).

  1. The protection a title passes describes how each processor's cache treats the range (write-combined, coherent, non-coherent, no GPU cache). It is a statement about caching and coherency. It is not a statement about who reads the bytes later.
  2. The same physical pages may be mapped several times in the address space; the mappings only have to agree on the CPU caching attribute. So bytes a shader writes through one mapping are, on the console, the same bytes every other mapping and every GPU view of those pages reads. No class marks a page as "written here, never read elsewhere".
  3. For CPU-cached non-coherent memory the documentation asks the title to think in whole 64-byte lines and to keep one writer at a time. That constrains writers. It gives the layer no licence to drop a write.
  4. The CPU is promised a GPU write once the work has finished and the GPU cache has written it back. After that point every reader sees it, CPU or GPU, through any mapping.

So the invariant a layer with separate host copies has to keep is: bytes a shader wrote reach every host copy of the same physical pages before the next reader of any of them. The class tells you which CPU reads are cheap. It says nothing about GPU readers through other copies, and those are what break.

Measured (fork port, RTX 5080)

Config, set at launch Cache Result
256 lists in flight, UNIFIED_BACK=1 (default classes, WC_PIECES=2, WC_NO_BACK_PC=1, floor 1024, shared-range rule on) cold faces and people stretched
same warm (library loaded, no pipelines being made) a spike of the face mesh from the brow in a close-up cutscene; stays for the session
same, then unified_back 0 and lists 32 switched live warm does not heal: once stale, the data stays stale
32 lists, copy-back of everything cold and warm clean in every run so far (a few minutes each, by eye)

The warm row matters: an earlier reading here, and mine on #3838, was that the stretch needs draws dropped during pipeline builds. It does not.

The shared-range rule in docs/unified-memory-classes.md is the right idea (copy back when another copy holds the bytes) but it is decided when the piece lands, for copies under 1 MiB that exist at that moment. A copy made later over the same pages, a larger window, or a texture view of them, takes the bytes from title memory, which never got the write. That is the same fault the doc describes for the face skinning data, through a reader the rule did not see.

What the copy-back actually costs (same card, same scene)

With copy-back of everything and 32 lists: 39.4 ms a frame, of which 17.0 ms is copying back 38.8 MB on the relay, 10.0 ms copies up (73.9 MB), 5.8 ms GPU. So the prize is real; the class filter is just not a safe way to take it.

Where I am putting the time instead: no copy at all

Heaps opened on title memory in place (OpenExistingHeapFromAddress1 on our own view of the section), a compute pass that compares the card side with a reference twin on the card and stores only changed dwords into title memory before the fence. Numbers that may save others a day, RTX 5080, driver 616.56, PCIe 5 x16, tests only, no game:

  • Race: plain 32-bit stores of whole changed dwords into title memory, with three CPU threads storing into neighbouring dwords of the same 64-byte lines: 0 CPU stores undone, 0 pass dwords missing, 6 runs of 5,000 landings, 2.8 to 4.0 billion CPU stores per run. (A compare-and-swap pass in the same harness lost about 100,000 per run: do not use atomics on that memory.)
  • Speed depends on the pattern inside a 64-byte line, not on bytes: every dword 43-45 GB/s (1.4 ns a line); one run of bytes per line about 2.5 ns a line whatever its length (1 dword in 16 = 1.5 GB/s); gaps between stored dwords in a line: about 330 ns a line (every other dword = 0.1 GB/s). This reconciles the "about 50 GB/s" and "about 2 GB/s" figures going around (#4211): both are right, for different patterns.
  • Reading title memory from the card: 45 GB/s, pattern-free.
  • In a game count run (no stores yet), per frame: of 885 changed 64 KiB pieces only 57 had no partly changed dword, so any in-place landing has to work per dword, not per piece; changed dwords were 78 % whole, 7 % half, 15 % single bytes.

Ask

  • Keep the class switches off, and say so in docs/unified-memory-classes.md, with the warm-launch result.
  • If someone wants to retry it, the test that decides is: a close-up cutscene on a warm launch with the switch on from launch, several minutes, then the same with it off from launch. A live flip proves nothing in either direction.
  • If anyone has a long session with the full set on and no stretch, post the config and card; I will run that exact set.
**@⁠Marsietiss** on GitHub · 2026-11-30 20:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425) Filed so nobody spends more time on this lead. Note: drafted with Claude from my own runs and code reading; the fork build is a hand port of #3838, card RTX 5080, Series S profile. ## Summary Skipping the copy-back of shader writes by declared memory class (#3838: `VICTORY_UNIFIED_BACK` with `WC_PIECES`, `WC_NO_BACK_PC`, the byte floor and the shared-range rule) cannot be made correct by tuning classes, floors or the alias size. `play.rs` already leaves it off after #4028 #4055 #4012 #4024 #4038 #4058. This issue gives the reason from the console contract and four measurements, so the class masks do not get retried one by one. ## What the console contract says, and what it does not All in my own words, from the GDK documentation (graphics memory overview; physical page mapping reference; GPU synchronization on Scarlett). 1. The protection a title passes describes **how each processor's cache treats the range** (write-combined, coherent, non-coherent, no GPU cache). It is a statement about caching and coherency. It is not a statement about who reads the bytes later. 2. The same physical pages may be mapped several times in the address space; the mappings only have to agree on the CPU caching attribute. So bytes a shader writes through one mapping are, on the console, the same bytes every other mapping and every GPU view of those pages reads. No class marks a page as "written here, never read elsewhere". 3. For CPU-cached non-coherent memory the documentation asks the title to think in whole 64-byte lines and to keep one writer at a time. That constrains writers. It gives the layer no licence to drop a write. 4. The CPU is promised a GPU write once the work has finished and the GPU cache has written it back. After that point every reader sees it, CPU or GPU, through any mapping. So the invariant a layer with separate host copies has to keep is: **bytes a shader wrote reach every host copy of the same physical pages before the next reader of any of them**. The class tells you which CPU reads are cheap. It says nothing about GPU readers through other copies, and those are what break. ## Measured (fork port, RTX 5080) | Config, set at launch | Cache | Result | |---|---|---| | 256 lists in flight, `UNIFIED_BACK=1` (default classes, `WC_PIECES=2`, `WC_NO_BACK_PC=1`, floor 1024, shared-range rule on) | cold | faces and people stretched | | same | warm (library loaded, no pipelines being made) | a spike of the face mesh from the brow in a close-up cutscene; stays for the session | | same, then `unified_back` 0 and lists 32 switched live | warm | does not heal: once stale, the data stays stale | | 32 lists, copy-back of everything | cold and warm | clean in every run so far (a few minutes each, by eye) | The warm row matters: an earlier reading here, and mine on #3838, was that the stretch needs draws dropped during pipeline builds. It does not. The shared-range rule in `docs/unified-memory-classes.md` is the right idea (copy back when another copy holds the bytes) but it is decided when the piece lands, for copies under 1 MiB that exist at that moment. A copy made later over the same pages, a larger window, or a texture view of them, takes the bytes from title memory, which never got the write. That is the same fault the doc describes for the face skinning data, through a reader the rule did not see. ## What the copy-back actually costs (same card, same scene) With copy-back of everything and 32 lists: 39.4 ms a frame, of which **17.0 ms is copying back 38.8 MB** on the relay, 10.0 ms copies up (73.9 MB), 5.8 ms GPU. So the prize is real; the class filter is just not a safe way to take it. ## Where I am putting the time instead: no copy at all Heaps opened on title memory in place (`OpenExistingHeapFromAddress1` on our own view of the section), a compute pass that compares the card side with a reference twin on the card and stores only changed dwords into title memory before the fence. Numbers that may save others a day, RTX 5080, driver 616.56, PCIe 5 x16, tests only, no game: - **Race:** plain 32-bit stores of whole changed dwords into title memory, with three CPU threads storing into neighbouring dwords of the same 64-byte lines: 0 CPU stores undone, 0 pass dwords missing, 6 runs of 5,000 landings, 2.8 to 4.0 billion CPU stores per run. (A compare-and-swap pass in the same harness lost about 100,000 per run: do not use atomics on that memory.) - **Speed depends on the pattern inside a 64-byte line, not on bytes:** every dword 43-45 GB/s (1.4 ns a line); one run of bytes per line about 2.5 ns a line whatever its length (1 dword in 16 = 1.5 GB/s); **gaps between stored dwords in a line: about 330 ns a line** (every other dword = 0.1 GB/s). This reconciles the "about 50 GB/s" and "about 2 GB/s" figures going around (#4211): both are right, for different patterns. - Reading title memory from the card: 45 GB/s, pattern-free. - In a game count run (no stores yet), per frame: of 885 changed 64 KiB pieces only 57 had no partly changed dword, so any in-place landing has to work per dword, not per piece; changed dwords were 78 % whole, 7 % half, 15 % single bytes. ## Ask - Keep the class switches off, and say so in `docs/unified-memory-classes.md`, with the warm-launch result. - If someone wants to retry it, the test that decides is: a close-up cutscene on a **warm** launch with the switch on from launch, several minutes, then the same with it off from launch. A live flip proves nothing in either direction. - If anyone has a long session with the full set on and no stretch, post the config and card; I will run that exact set.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:18:52 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-30 20:16 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-30 20:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7290674535) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:17 UTC · original

One open problem on the in-place route, stated plainly: it does not work yet, and it needs a trick I do not have a measured answer for.

The landing pass may only store dwords a shader changed (storing the unchanged ones in between would undo title CPU writes, which the race test guards). Real changed data is not dense, so many 64-byte lines get stores with gaps between them, and those cost about 330 ns a line on this card against 2.5 ns for a line with one run. About 5 ms per MB of such lines, in front of the fence. That can eat the whole 17 ms prize.

What I am measuring now, same harness:

  • several passes, where pass j stores only the j-th run of each line, so every pass looks like the fast case;
  • one thread per line storing in address order; storing column by column;
  • copying the runs instead of storing them from compute;
  • where the slow path starts (2, 3, 4 runs per line);
  • as a reference only: reading the title's line and writing it back whole, with the count of CPU stores it loses.

If anyone knows why a gapped line is 130 times slower (my guess: the write to system memory can carry byte enables only on its first and last dword, so a gapped line is split and serialised), or knows a store pattern, a heap flag or a driver path that avoids it on NVIDIA or AMD, that is the missing piece. Numbers from other cards with the same three patterns (every dword, 1 dword in 16, every other dword) would also tell whether this is one vendor's behaviour.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7290680266) One open problem on the in-place route, stated plainly: it does not work yet, and it needs a trick I do not have a measured answer for. The landing pass may only store dwords a shader changed (storing the unchanged ones in between would undo title CPU writes, which the race test guards). Real changed data is not dense, so many 64-byte lines get stores with gaps between them, and those cost about 330 ns a line on this card against 2.5 ns for a line with one run. About 5 ms per MB of such lines, in front of the fence. That can eat the whole 17 ms prize. What I am measuring now, same harness: - several passes, where pass j stores only the j-th run of each line, so every pass looks like the fast case; - one thread per line storing in address order; storing column by column; - copying the runs instead of storing them from compute; - where the slow path starts (2, 3, 4 runs per line); - as a reference only: reading the title's line and writing it back whole, with the count of CPU stores it loses. If anyone knows why a gapped line is 130 times slower (my guess: the write to system memory can carry byte enables only on its first and last dword, so a gapped line is split and serialised), or knows a store pattern, a heap flag or a driver path that avoids it on NVIDIA or AMD, that is the missing piece. Numbers from other cards with the same three patterns (every dword, 1 dword in 16, every other dword) would also tell whether this is one vendor's behaviour.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:22 UTC · original

Pinging the people whose work this touches, in case it saves you time:

  • @⁠x86 (#3838): the table above is the warm-launch result for the default class set; the reasoning section is why I think no class mask fixes it. If you have a set you believe is safe, name it and I will run it from launch.
  • @⁠banaanpapa (#4211, #3641): the per-line store numbers in the comment above extend your 5080 answers: one run per 64-byte line is fast, gaps inside a line are about 130 times slower. That decides whether an in-place landing can pay. Your shader page marks (#3641) would give the write set without the compare; do you have anything finer than 64 KiB in mind? Per-line marks would let the landing skip the gapped lines question entirely.
  • @⁠gabrielecabrini, @⁠superuser404notfound: you measured on #4211. If you can run the three patterns (every dword, 1 in 16, every other dword) on another card, I would like to know whether the gap cost is one vendor's.
**@⁠Marsietiss** on GitHub · 2026-11-30 20:22 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7290815178) Pinging the people whose work this touches, in case it saves you time: - @⁠x86 (#3838): the table above is the warm-launch result for the default class set; the reasoning section is why I think no class mask fixes it. If you have a set you believe is safe, name it and I will run it from launch. - @⁠banaanpapa (#4211, #3641): the per-line store numbers in the comment above extend your 5080 answers: one run per 64-byte line is fast, gaps inside a line are about 130 times slower. That decides whether an in-place landing can pay. Your shader page marks (#3641) would give the write set without the compare; do you have anything finer than 64 KiB in mind? Per-line marks would let the landing skip the gapped lines question entirely. - @⁠gabrielecabrini, @⁠superuser404notfound: you measured on #4211. If you can run the three patterns (every dword, 1 in 16, every other dword) on another card, I would like to know whether the gap cost is one vendor's.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 20:31 UTC · original

I only have an RTX 4070 SUPER (Linux, Proton, PCIe 4.0), so it's still NVIDIA. It won't answer the vendor question, but it can show whether the gap cost is specific to Blackwell, PCIe 5 or the Windows driver. I don't see the test on main: can you push the branch or tell me the test name? I'll run the three patterns.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 20:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291064127) I only have an RTX 4070 SUPER (Linux, Proton, PCIe 4.0), so it's still NVIDIA. It won't answer the vendor question, but it can show whether the gap cost is specific to Blackwell, PCIe 5 or the Windows driver. I don't see the test on main: can you push the branch or tell me the test name? I'll run the three patterns.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:33 UTC · original

@⁠gabrielecabrini thanks, a 4070 SUPER on Linux answers exactly those three (Blackwell, PCIe 5, Windows driver). The test is on a fork branch that is not public yet; I am asking whether I can push it. Until then it is small enough to rebuild from this, on top of the in-place card tests from #4211:

  • 64 MiB of title-side memory opened in place (OpenExistingHeapFromAddress1 on a view of a section, as the layer does), a placed buffer over it as a raw UAV; a second 64 MiB buffer in card memory holding the data to store.
  • One compute pass, 64 threads a group, one thread per dword: d = group * 64 + thread; if (mask(d)) title.Store(d * 4, card.Load(d * 4));
  • Three masks: every dword; (d & 15) == 0 (1 dword in 16, one run a line); (d & 1) == 0 (every other dword, 8 gaps a line).
  • Time from ExecuteCommandLists to the fence, best of 5 after one warm-up, pages touched on the CPU first so no first-touch faults are in it. Report GB/s of stored bytes and ns per 64-byte line (1,048,576 lines per 64 MiB).

Here: 43-45 GB/s (1.4 ns a line), 1.5-1.6 GB/s (2.5 ns a line), 0.1 GB/s (about 330 ns a line). A fourth mask worth having: two runs a line ((d & 15) == 0 || (d & 15) == 8), which tells where the slow path starts; I am measuring that now.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291121030) @⁠gabrielecabrini thanks, a 4070 SUPER on Linux answers exactly those three (Blackwell, PCIe 5, Windows driver). The test is on a fork branch that is not public yet; I am asking whether I can push it. Until then it is small enough to rebuild from this, on top of the in-place card tests from #4211: - 64 MiB of title-side memory opened in place (`OpenExistingHeapFromAddress1` on a view of a section, as the layer does), a placed buffer over it as a raw UAV; a second 64 MiB buffer in card memory holding the data to store. - One compute pass, 64 threads a group, one thread per dword: `d = group * 64 + thread`; `if (mask(d)) title.Store(d * 4, card.Load(d * 4));` - Three masks: every dword; `(d & 15) == 0` (1 dword in 16, one run a line); `(d & 1) == 0` (every other dword, 8 gaps a line). - Time from `ExecuteCommandLists` to the fence, best of 5 after one warm-up, pages touched on the CPU first so no first-touch faults are in it. Report GB/s of stored bytes and ns per 64-byte line (1,048,576 lines per 64 MiB). Here: 43-45 GB/s (1.4 ns a line), 1.5-1.6 GB/s (2.5 ns a line), 0.1 GB/s (about 330 ns a line). A fourth mask worth having: two runs a line (`(d & 15) == 0 || (d & 15) == 8`), which tells where the slow path starts; I am measuring that now.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:36 UTC · original

@⁠gabrielecabrini pushed: branch rtx5080/zerocopy-gate on Marsietiss/Mangrove (one commit, a320781c6). No game needed, nothing else should be using the card:

cargo test -p victory-gpu --lib host::inplace_land::gate::card_bus -- --ignored --nocapture --test-threads=1
cargo test -p victory-gpu --lib host::inplace_land::gate::card_race -- --ignored --nocapture --test-threads=1

card_bus prints GB/s and ns per 64-byte line for each pattern; card_race is the lost-store check (takes a few minutes). It was only ever run on Windows; if opening the heap on a view fails under Proton, the HRESULT it prints is a result too.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291187020) @⁠gabrielecabrini pushed: branch `rtx5080/zerocopy-gate` on Marsietiss/Mangrove (one commit, a320781c6). No game needed, nothing else should be using the card: ``` cargo test -p victory-gpu --lib host::inplace_land::gate::card_bus -- --ignored --nocapture --test-threads=1 cargo test -p victory-gpu --lib host::inplace_land::gate::card_race -- --ignored --nocapture --test-threads=1 ``` `card_bus` prints GB/s and ns per 64-byte line for each pattern; `card_race` is the lost-store check (takes a few minutes). It was only ever run on Windows; if opening the heap on a view fails under Proton, the HRESULT it prints is a result too.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:42 UTC · original

Correction to my own table, from re-reading the warm run's log. I wrote that the warm launch had no pipelines being made and concluded the stretch does not need dropped draws. The first half holds (library loaded, 0 being made on every frame line). The second does not follow: that run still dropped draws without a host pipeline, about 250 a frame in the world and 2,400 to 2,950 a frame through the cutscene where the stretch showed.

What keeps the conclusion standing is the comparison: the two runs with 32 lists and copy-back of everything, which looked clean, drop the same amounts (median about 300 a frame, peaks 2,500 to 2,800). So dropped draws are present in both and do not separate stretched from clean; the class switch and the list count do. But "no drops on a warm launch" was wrong, and why draws are dropped with nothing being made is a separate question I am now reading.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291360039) Correction to my own table, from re-reading the warm run's log. I wrote that the warm launch had no pipelines being made and concluded the stretch does not need dropped draws. The first half holds (library loaded, 0 being made on every frame line). The second does not follow: that run still dropped draws without a host pipeline, about 250 a frame in the world and 2,400 to 2,950 a frame through the cutscene where the stretch showed. What keeps the conclusion standing is the comparison: the two runs with 32 lists and copy-back of everything, which looked clean, drop the same amounts (median about 300 a frame, peaks 2,500 to 2,800). So dropped draws are present in both and do not separate stretched from clean; the class switch and the list count do. But "no drops on a warm launch" was wrong, and why draws are dropped with nothing being made is a separate question I am now reading.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:44 UTC · original

Result on the gapped-line problem (RTX 5080, test rig only, 64 MiB of title-side memory opened in place, GPU time by timestamps, median of 20):

Stores per 64-byte line one pass split into one dispatch per run
1 run 2.7 ms (2.6 ns a line) 3.0 ms
2 runs 24-28 ms (9-10x) 5.6 ms (2.1x)
3 runs 122 ms (45x) not timed
4 runs 198 ms (73x) not timed
8 runs (every other dword) 355 ms (131x) 20.4 ms (7.6x)

So the slow path starts at the second run in a line, wherever the gap sits and whatever the run lengths. What fixes it is a dispatch boundary: dispatch j stores only the j-th run of every line, the k store dispatches are recorded back to back with no barrier between them, then one barrier and the dispatch that updates the reference copy. Cost is about 2.6 ns per (line, run). It raced clean against CPU threads storing into the neighbouring dwords (0 CPU stores undone, 0 owned dwords missing, one run of 2,000 landings, 8 runs a line only).

What did not help: reordering stores inside one dispatch (one thread per line in address order: 11-15x at 2 runs; one thread per 4 KiB page: 6-16x), 16 dispatches by column (3x even at 1 run), a copy command per run (36x at 2 runs, plus CPU time to record), and running the runs in turn inside one dispatch. Reading the title's line and writing it back whole is fast (6x, pattern-free) but undid 1.6 % of concurrent CPU stores, so it is not usable.

My reading, not proven: the cost comes from several writes reaching the same 64-byte line close together in time; only a dispatch boundary separates them enough. Whether the card or the root complex serialises them, the test cannot tell.

Not shown yet, and it matters: the rig has all 64 MiB behind one buffer and one indirect call; the real layout is many 2 MiB parts, each its own heap, with records written by a compaction pass. The per-dispatch overhead there is unmeasured, and so is the real mix of runs per line in a game frame (counting that next).

**@⁠Marsietiss** on GitHub · 2026-11-30 20:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291391109) Result on the gapped-line problem (RTX 5080, test rig only, 64 MiB of title-side memory opened in place, GPU time by timestamps, median of 20): | Stores per 64-byte line | one pass | split into one dispatch per run | |---|---|---| | 1 run | 2.7 ms (2.6 ns a line) | 3.0 ms | | 2 runs | 24-28 ms (9-10x) | 5.6 ms (2.1x) | | 3 runs | 122 ms (45x) | not timed | | 4 runs | 198 ms (73x) | not timed | | 8 runs (every other dword) | 355 ms (131x) | 20.4 ms (7.6x) | So the slow path starts at the second run in a line, wherever the gap sits and whatever the run lengths. What fixes it is a **dispatch boundary**: dispatch j stores only the j-th run of every line, the k store dispatches are recorded back to back with no barrier between them, then one barrier and the dispatch that updates the reference copy. Cost is about 2.6 ns per (line, run). It raced clean against CPU threads storing into the neighbouring dwords (0 CPU stores undone, 0 owned dwords missing, one run of 2,000 landings, 8 runs a line only). What did not help: reordering stores inside one dispatch (one thread per line in address order: 11-15x at 2 runs; one thread per 4 KiB page: 6-16x), 16 dispatches by column (3x even at 1 run), a copy command per run (36x at 2 runs, plus CPU time to record), and running the runs in turn inside one dispatch. Reading the title's line and writing it back whole is fast (6x, pattern-free) but undid 1.6 % of concurrent CPU stores, so it is not usable. My reading, not proven: the cost comes from several writes reaching the same 64-byte line close together in time; only a dispatch boundary separates them enough. Whether the card or the root complex serialises them, the test cannot tell. Not shown yet, and it matters: the rig has all 64 MiB behind one buffer and one indirect call; the real layout is many 2 MiB parts, each its own heap, with records written by a compaction pass. The per-dispatch overhead there is unmeasured, and so is the real mix of runs per line in a game frame (counting that next).
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 20:47 UTC · original

Ran both on the RTX 4070 SUPER (Linux, Proton Experimental, vkd3d-proton, NVIDIA 620.73.04, PCIe 4.0). Both pass. Under Wine, FXC fails the store pass, and the fill's FXC blob gets its root signature refused (0x80004005), so I compiled all passes with DXC (cs_6_0) locally.

card_bus, 64 MiB, store into title memory:

pattern GB/s ns per 64 B line
every dword 26.1 2.4
1 dword in 16 2.3 1.7
first 32 B of each line 17.7 1.8
every other dword 0.16 194

So the gap cost is there on Ada, PCIe 4 and the Linux driver too: about 80x a dense line here, about 235x on your 5080. Not Blackwell, PCIe 5 or the Windows driver. The two-runs-a-line mask isn't in this test, so I don't have that one.

card_race: 3 runs of 5,000 landings, ~21 billion CPU stores a run, 0 CPU stores undone, 0 pass dwords missing.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 20:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291477348) Ran both on the RTX 4070 SUPER (Linux, Proton Experimental, vkd3d-proton, NVIDIA 620.73.04, PCIe 4.0). Both pass. Under Wine, FXC fails the store pass, and the fill's FXC blob gets its root signature refused (`0x80004005`), so I compiled all passes with DXC (`cs_6_0`) locally. `card_bus`, 64 MiB, store into title memory: | pattern | GB/s | ns per 64 B line | |---|---|---| | every dword | 26.1 | 2.4 | | 1 dword in 16 | 2.3 | 1.7 | | first 32 B of each line | 17.7 | 1.8 | | every other dword | 0.16 | **194** | So the gap cost is there on Ada, PCIe 4 and the Linux driver too: about 80x a dense line here, about 235x on your 5080. Not Blackwell, PCIe 5 or the Windows driver. The two-runs-a-line mask isn't in this test, so I don't have that one. `card_race`: 3 runs of 5,000 landings, ~21 billion CPU stores a run, 0 CPU stores undone, 0 pass dwords missing.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:51 UTC · original

@⁠gabrielecabrini thank you, that is exactly the answer: 194 ns a gapped line on Ada / PCIe 4 / Linux against 330 here, so it is not Blackwell, not PCIe 5 and not the Windows driver, and the race result holds on a second card and driver stack (21 billion CPU stores a run, 0 undone). Good to know about FXC under Wine and that cs_6_0 from DXC works.

The two-runs mask and the split-dispatch variants from my last comment are now on the same branch (rtx5080/zerocopy-gate, cce039ead, tests only):

cargo test -p victory-gpu --lib host::inplace_land::gap::card_gap_bus_store_variants_into_title_memory -- --ignored --nocapture --test-threads=1
cargo test -p victory-gpu --lib host::inplace_land::gap::card_gap_race_of_the_variants -- --ignored --nocapture --test-threads=1

The row that matters most on your card: 2 runs and 8 runs a line, one pass against the split with no barrier between store dispatches (G2 in the output). If the split brings 8 runs down to about 8 times the one-run price there too, the trick is not specific to this card either.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291564273) @⁠gabrielecabrini thank you, that is exactly the answer: 194 ns a gapped line on Ada / PCIe 4 / Linux against 330 here, so it is not Blackwell, not PCIe 5 and not the Windows driver, and the race result holds on a second card and driver stack (21 billion CPU stores a run, 0 undone). Good to know about FXC under Wine and that `cs_6_0` from DXC works. The two-runs mask and the split-dispatch variants from my last comment are now on the same branch (`rtx5080/zerocopy-gate`, cce039ead, tests only): ``` cargo test -p victory-gpu --lib host::inplace_land::gap::card_gap_bus_store_variants_into_title_memory -- --ignored --nocapture --test-threads=1 cargo test -p victory-gpu --lib host::inplace_land::gap::card_gap_race_of_the_variants -- --ignored --nocapture --test-threads=1 ``` The row that matters most on your card: 2 runs and 8 runs a line, one pass against the split with no barrier between store dispatches (G2 in the output). If the split brings 8 runs down to about 8 times the one-run price there too, the trick is not specific to this card either.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 20:55 UTC · original

Ran both on the 4070 SUPER (same setup, DXC). 64 MiB, ns per line (x vs one run):

runs a line A one pass G2 split, no barrier
1 1.7 2.3 (1.3x)
2 28.8 (16.8x) 3.9–4.7 (2.3–2.8x)
8 195.5 (114x) 14.6 (8.5x)

So the split works here too, about 8x at 8 runs. One difference: G1 (one dispatch, runs in turn with a device barrier and group sync) is as fast as the split on this card: 4.0 ns at 2 runs, 14.3 at 8. Without the barrier (G1b) it stays slow. G1 isn't in the race test.

Race, 2,000 landings each: B1, G2, C1, C2 and D all clean (0 undone, 0 missing). F (load + whole-line store) undid 0.73 % of CPU stores.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 20:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291662201) Ran both on the 4070 SUPER (same setup, DXC). 64 MiB, ns per line (x vs one run): | runs a line | A one pass | G2 split, no barrier | |---|---|---| | 1 | 1.7 | 2.3 (1.3x) | | 2 | 28.8 (16.8x) | 3.9–4.7 (2.3–2.8x) | | 8 | 195.5 (114x) | 14.6 (8.5x) | So the split works here too, about 8x at 8 runs. One difference: G1 (one dispatch, runs in turn with a device barrier and group sync) is as fast as the split on this card: 4.0 ns at 2 runs, 14.3 at 8. Without the barrier (G1b) it stays slow. G1 isn't in the race test. Race, 2,000 landings each: B1, G2, C1, C2 and D all clean (0 undone, 0 missing). F (load + whole-line store) undid 0.73 % of CPU stores.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 20:55 UTC · original

@⁠gabrielecabrini that settles it for NVIDIA: the split brings 8 runs to 8.5x there and 7.6x here, and it raced clean on both. Thank you.

The G1 difference is interesting: here the runs-in-turn dispatch with a barrier stays slow (30 ns at 2 runs, 120 at 8), on your card it matches the split. So a barrier inside one dispatch separates the writes enough on Ada / vkd3d-proton and not on this card and driver. I will keep the dispatch boundary as the rule, since it is the one that works on both.

Next from my side: the same test with the real layout (many 2 MiB parts, each its own heap, records written on the card) and the run mix counted in a game frame. I will post both here.

**@⁠Marsietiss** on GitHub · 2026-11-30 20:55 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291666943) @⁠gabrielecabrini that settles it for NVIDIA: the split brings 8 runs to 8.5x there and 7.6x here, and it raced clean on both. Thank you. The G1 difference is interesting: here the runs-in-turn dispatch with a barrier stays slow (30 ns at 2 runs, 120 at 8), on your card it matches the split. So a barrier inside one dispatch separates the writes enough on Ada / vkd3d-proton and not on this card and driver. I will keep the dispatch boundary as the rule, since it is the one that works on both. Next from my side: the same test with the real layout (many 2 MiB parts, each its own heap, records written on the card) and the run mix counted in a game frame. I will post both here.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:01 UTC · original

The run mix from a game frame, as promised. Count only: the layer still copies everything back as before; a compute pass compares the card side with a reference copy on the card and counts what an in-place landing would store. RTX 5080, 256 lists in flight, copy-back of everything, in play after the first cutscene, per frame.

per frame
64 KiB pieces the card flags, in scope about 770 (of about 4,350 declared)
64-byte lines with a changed dword about 245,000
one run of changed dwords about 241,000 (98.4 %)
two runs about 1,500
three or more about 2,500
changed dwords fully changed 67 % (the rest change 1 to 3 bytes)
pieces with no partly changed dword about 40 of 770
count pass on the card 0.49 ms
copy-back today, same frames 20 to 27 ms for 26 to 34 MB

So the gapped-line problem touches under 2 % of lines. At the measured rates (2.6 ns per line and run with split dispatches) the stores for all of it come to under 1 ms a frame. That is an estimate from two measurements, not a measured frame.

Three checks that could have stopped this, and did not:

  • Is the reference copy exact? About a third of the flagged pieces turn out equal to it (flagged, nothing changed). For 35,387 of those the landing's own CPU compare was run against the card's bytes: changes found in 0.
  • Partly changed dwords: the unchanged bytes of the card's dword equal title memory's in 100.0 % (407 of 3.04 million differ), so merging at dword level is sound; partly changed dwords on pages the title wrote since the plan was made: 46 of 1.24 million.
  • Parts at scale: 2,821 parts of 64 KiB opened in place in 0.18 ms each, none refused, all bound in one table and read correctly in one dispatch.

What it does not cover: only about 47 % of the flagged pieces are in scope. The rest is title memory that is not opened as a view of a section (private allocations), plus classes and lazily landed copies left out for now. All in-scope memory here is write-combined, and every in-scope block sits on a page that is mapped at more than one title address, so ownership has to be tracked per physical page, not per address. Nothing has stored into title memory in a game run yet; that is the next step.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291804138) The run mix from a game frame, as promised. Count only: the layer still copies everything back as before; a compute pass compares the card side with a reference copy on the card and counts what an in-place landing would store. RTX 5080, 256 lists in flight, copy-back of everything, in play after the first cutscene, per frame. | | per frame | |---|---| | 64 KiB pieces the card flags, in scope | about 770 (of about 4,350 declared) | | 64-byte lines with a changed dword | about 245,000 | | one run of changed dwords | about 241,000 (98.4 %) | | two runs | about 1,500 | | three or more | about 2,500 | | changed dwords fully changed | 67 % (the rest change 1 to 3 bytes) | | pieces with no partly changed dword | about 40 of 770 | | count pass on the card | 0.49 ms | | copy-back today, same frames | 20 to 27 ms for 26 to 34 MB | So the gapped-line problem touches under 2 % of lines. At the measured rates (2.6 ns per line and run with split dispatches) the stores for all of it come to under 1 ms a frame. That is an estimate from two measurements, not a measured frame. Three checks that could have stopped this, and did not: - **Is the reference copy exact?** About a third of the flagged pieces turn out equal to it (flagged, nothing changed). For 35,387 of those the landing's own CPU compare was run against the card's bytes: changes found in 0. - **Partly changed dwords:** the unchanged bytes of the card's dword equal title memory's in 100.0 % (407 of 3.04 million differ), so merging at dword level is sound; partly changed dwords on pages the title wrote since the plan was made: 46 of 1.24 million. - **Parts at scale:** 2,821 parts of 64 KiB opened in place in 0.18 ms each, none refused, all bound in one table and read correctly in one dispatch. What it does not cover: only about 47 % of the flagged pieces are in scope. The rest is title memory that is not opened as a view of a section (private allocations), plus classes and lazily landed copies left out for now. All in-scope memory here is write-combined, and every in-scope block sits on a page that is mapped at more than one title address, so ownership has to be tracked per physical page, not per address. Nothing has stored into title memory in a game run yet; that is the next step.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:03 UTC · original

What I expect from this, what to be careful about, and where a second pair of hands would help. This is too big for one fork, and several of you are already close to it.

Expected gain (estimate, not measured)

  • Copy-back is 20 to 27 ms of a 34 to 55 ms frame here at 256 lists (17 ms of 39 at 32 lists). The stores that replace it should cost about 1 ms on the card plus the 0.5 ms compare.
  • The first version covers about 47 % of the flagged pieces (section views only). If cost follows piece count, that is roughly 8 to 13 ms a frame back, something like 25 fps to the low or mid 30s in the scene I measure in. It is CPU time on the relay and the submitting side, so it only shows as fps where those are the limit.
  • With private title memory in scope as well, most of the rest. That part is not designed.
  • It also removes the reason for the class filter: nothing is left on the card, so nothing can go stale.

Things that will bite (each one cost me a design round)

  1. Store only dwords the pass owns, with plain 32-bit stores. Compare-and-swap on that memory lost about 100,000 stores a run. Reading the title's line and writing it back whole is fast and undoes 0.7 to 1.6 % of concurrent CPU stores. Neither is usable.
  2. One run per line per dispatch. A second run in the same 64-byte line in the same dispatch costs 9 to 17 times; a dispatch boundary fixes it, a barrier inside one dispatch does so only on some cards.
  3. Ownership is per physical page, not per title address. Every in-scope block here is mapped at more than one address. A copy over the second address brings back stale reads.
  4. One writer at a time. While the card owns a block, the layer's CPU copy of it is frozen and no CPU path may merge, compare against or refresh from it. In my tree that is 29 places that read the CPU copy, not only the ones that write it.
  5. Title CPU writes into a card-owned block must reach the card in order. Reading title memory when the pass runs is wrong: with 100 or more lists in flight a later title write overtakes the flight that should have seen the earlier bytes. It needs a snapshot taken when the flight is prepared.
  6. Partly changed dwords (a third of changed dwords here) need the title's other bytes: one load, merge, one 32-bit store. The window between load and store is where a CPU write to the same dword can be lost; count how often the title writes those pages (46 in 1.24 million here) and make that a gate.
  7. The reference copy must be exact, or everything downstream is wrong silently. Check it by CPU compare before trusting it; do not assume.
  8. Unmap, remap and free while a pass is queued: settle before taking the mapping lock. Waiting under the view table lock deadlocks against the CPU landings that would let the wait finish.
  9. Flight numbering with holes (a flight numbered and then dropped) stalls "everything up to N has landed". The ownership table needs its own numbers.
  10. A 2 MiB part over a page that is not committed is refused (E_INVALIDARG); fall back to 64 KiB parts. 2,800 of those open and bind fine.
  11. Judge the picture on a close-up cutscene, on a warm launch, with the switch set from launch. A live flip proves nothing in either direction, and the open world hides this class of fault for minutes.
  12. FXC fails for these passes under Wine; DXC cs_6_0 works (thanks @⁠gabrielecabrini).

Where parallel work would help most

  • Private title memory (the other half). Can memory that is not a section view be opened in place, or re-backed by a section without the title noticing? This decides whether the gain is half or nearly all. Nobody here has measured it.
  • Shader page marks (@⁠banaanpapa, #3641). They would replace the compare pass and give the write set directly. Finer than 64 KiB would be worth a lot: per 4 KiB, or per line for the hot buffers.
  • AMD and Intel numbers for the card tests on rtx5080/zerocopy-gate (bus patterns, split dispatches, race). All results so far are NVIDIA.
  • Why a second run in a line is slow. A driver or bus explanation would say whether the split is the right fix or only the one I found.
  • An independent attempt to break the ownership model (points 3 to 5 and 8). I have an ownership table with a randomised model test and a slot table with a card probe, both tests only; say the word and they go on the same branch for review.
  • A reference scene everyone uses. I propose the first close-up cutscene after a warm launch, 5 minutes, with a recording.

I will keep posting numbers here as each step is measured, including the ones that go wrong.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291847404) What I expect from this, what to be careful about, and where a second pair of hands would help. This is too big for one fork, and several of you are already close to it. ## Expected gain (estimate, not measured) - Copy-back is 20 to 27 ms of a 34 to 55 ms frame here at 256 lists (17 ms of 39 at 32 lists). The stores that replace it should cost about 1 ms on the card plus the 0.5 ms compare. - The first version covers about 47 % of the flagged pieces (section views only). If cost follows piece count, that is roughly 8 to 13 ms a frame back, something like 25 fps to the low or mid 30s in the scene I measure in. It is CPU time on the relay and the submitting side, so it only shows as fps where those are the limit. - With private title memory in scope as well, most of the rest. That part is not designed. - It also removes the reason for the class filter: nothing is left on the card, so nothing can go stale. ## Things that will bite (each one cost me a design round) 1. **Store only dwords the pass owns, with plain 32-bit stores.** Compare-and-swap on that memory lost about 100,000 stores a run. Reading the title's line and writing it back whole is fast and undoes 0.7 to 1.6 % of concurrent CPU stores. Neither is usable. 2. **One run per line per dispatch.** A second run in the same 64-byte line in the same dispatch costs 9 to 17 times; a dispatch boundary fixes it, a barrier inside one dispatch does so only on some cards. 3. **Ownership is per physical page, not per title address.** Every in-scope block here is mapped at more than one address. A copy over the second address brings back stale reads. 4. **One writer at a time.** While the card owns a block, the layer's CPU copy of it is frozen and no CPU path may merge, compare against or refresh from it. In my tree that is 29 places that read the CPU copy, not only the ones that write it. 5. **Title CPU writes into a card-owned block** must reach the card in order. Reading title memory when the pass runs is wrong: with 100 or more lists in flight a later title write overtakes the flight that should have seen the earlier bytes. It needs a snapshot taken when the flight is prepared. 6. **Partly changed dwords** (a third of changed dwords here) need the title's other bytes: one load, merge, one 32-bit store. The window between load and store is where a CPU write to the same dword can be lost; count how often the title writes those pages (46 in 1.24 million here) and make that a gate. 7. **The reference copy must be exact,** or everything downstream is wrong silently. Check it by CPU compare before trusting it; do not assume. 8. **Unmap, remap and free while a pass is queued:** settle before taking the mapping lock. Waiting under the view table lock deadlocks against the CPU landings that would let the wait finish. 9. **Flight numbering with holes** (a flight numbered and then dropped) stalls "everything up to N has landed". The ownership table needs its own numbers. 10. **A 2 MiB part over a page that is not committed is refused** (E_INVALIDARG); fall back to 64 KiB parts. 2,800 of those open and bind fine. 11. **Judge the picture on a close-up cutscene, on a warm launch, with the switch set from launch.** A live flip proves nothing in either direction, and the open world hides this class of fault for minutes. 12. FXC fails for these passes under Wine; DXC `cs_6_0` works (thanks @⁠gabrielecabrini). ## Where parallel work would help most - **Private title memory (the other half).** Can memory that is not a section view be opened in place, or re-backed by a section without the title noticing? This decides whether the gain is half or nearly all. Nobody here has measured it. - **Shader page marks (@⁠banaanpapa, #3641).** They would replace the compare pass and give the write set directly. Finer than 64 KiB would be worth a lot: per 4 KiB, or per line for the hot buffers. - **AMD and Intel numbers** for the card tests on `rtx5080/zerocopy-gate` (bus patterns, split dispatches, race). All results so far are NVIDIA. - **Why a second run in a line is slow.** A driver or bus explanation would say whether the split is the right fix or only the one I found. - **An independent attempt to break the ownership model** (points 3 to 5 and 8). I have an ownership table with a randomised model test and a slot table with a card probe, both tests only; say the word and they go on the same branch for review. - **A reference scene everyone uses.** I propose the first close-up cutscene after a warm launch, 5 minutes, with a recording. I will keep posting numbers here as each step is measured, including the ones that go wrong.
Author
Owner

@⁠banaanpapa on GitHub · 2026-11-30 21:03 UTC · original

@⁠Marsietiss thanks for the ping and the numbers. Short answers, from what #3641 and #4174 do and from what I measured in play on an RTX 5080 today.

Granularity. Nothing finer than 64 KiB is built. A copy's bits are allocated per copy (view_marks::Bits), a view's entry is (base bit, phase), and a store sets bit base + ((phase + offset) >> 16). The shift is the only place the 64 KiB is fixed, plus VIEW_WRITE_BITS (2^22). Because bits are per copy and not per address, per line (>> 6) would be affordable: today's 3.4 GB of card copies need about 53 M bits, 6.6 MB in VRAM. The atomics stay one per marked store, with fewer collisions on a word if anything.

What marks can and can't give an in-place landing:

  • A mark says a shader stored somewhere in the line, not which dwords. Storing a marked line whole would undo the title's CPU stores to its other dwords, which is exactly what your race test guards against. So per-line marks don't remove the gapped-line question. They only narrow where your compare runs, from the ~770 flagged pieces to the lines actually written. Your count pass is 0.49 ms, so that's the most marks can save there.
  • Per-dword marks would be the exact write set: no reference twin and no compare, which also saves the twin's VRAM (that matters for 8 GB cards). The cost moves to one bit per dword of in-scope memory (1/32 of it) and an atomic per stored dword. The translator would have to merge those per wave (WaveActiveBitOr over 32 consecutive dwords, then one atomic). Sub-dword stores, your 15 % of 1 to 3 byte changes, would still need byte masks or a compare for those dwords.
  • Coverage. Only stores through heap/table UAV buffer views mark. Root-UAV stores, by-address stores (memory.rs) and our own copies don't. #4174 falls back to the full compare for any copy that has an unmarked writer in the submission, and an in-place landing driven by marks would need the same fallback.

Where the cost sits on this card. In play today (e1251c31, about 4,800 draws a frame), our compare lists took 0.2 to 0.3 ms of card time a frame, so finding what changed is already cheap here. The copy-back on the CPU isn't: the relay's landing took 6 to 13 ms a frame in the user's runs (newest build and an older one). That agrees with your 17 to 27 ms. The prize is in landing the bytes, not in finding them, which is where your in-place route aims.

If a shift switch for the marks helps your count (say VICTORY_VIEW_MARK_SHIFT=12 for 4 KiB pieces), I can add it to #4174.

**@⁠banaanpapa** on GitHub · 2026-11-30 21:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291861407) @⁠Marsietiss thanks for the ping and the numbers. Short answers, from what #3641 and #4174 do and from what I measured in play on an RTX 5080 today. **Granularity.** Nothing finer than 64 KiB is built. A copy's bits are allocated per copy (`view_marks::Bits`), a view's entry is (base bit, phase), and a store sets bit `base + ((phase + offset) >> 16)`. The shift is the only place the 64 KiB is fixed, plus `VIEW_WRITE_BITS` (2^22). Because bits are per copy and not per address, per line (`>> 6`) would be affordable: today's 3.4 GB of card copies need about 53 M bits, 6.6 MB in VRAM. The atomics stay one per marked store, with fewer collisions on a word if anything. **What marks can and can't give an in-place landing:** - **A mark says a shader stored somewhere in the line, not which dwords.** Storing a marked line whole would undo the title's CPU stores to its other dwords, which is exactly what your race test guards against. So per-line marks don't remove the gapped-line question. They only narrow where your compare runs, from the ~770 flagged pieces to the lines actually written. Your count pass is 0.49 ms, so that's the most marks can save there. - **Per-dword marks would be the exact write set:** no reference twin and no compare, which also saves the twin's VRAM (that matters for 8 GB cards). The cost moves to one bit per dword of in-scope memory (1/32 of it) and an atomic per stored dword. The translator would have to merge those per wave (`WaveActiveBitOr` over 32 consecutive dwords, then one atomic). Sub-dword stores, your 15 % of 1 to 3 byte changes, would still need byte masks or a compare for those dwords. - **Coverage.** Only stores through heap/table UAV buffer views mark. Root-UAV stores, by-address stores (`memory.rs`) and our own copies don't. #4174 falls back to the full compare for any copy that has an unmarked writer in the submission, and an in-place landing driven by marks would need the same fallback. **Where the cost sits on this card.** In play today (`e1251c31`, about 4,800 draws a frame), our compare lists took 0.2 to 0.3 ms of card time a frame, so finding what changed is already cheap here. The copy-back on the CPU isn't: the relay's landing took 6 to 13 ms a frame in the user's runs (newest build and an older one). That agrees with your 17 to 27 ms. The prize is in landing the bytes, not in finding them, which is where your in-place route aims. If a shift switch for the marks helps your count (say `VICTORY_VIEW_MARK_SHIFT=12` for 4 KiB pieces), I can add it to #4174.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:06 UTC · original

@⁠banaanpapa thanks, that is the clearest statement of what marks can and cannot do, and I agree with all three points. Your landing figure (6 to 13 ms on the relay) next to a 0.2 to 0.3 ms compare says the same thing from the other side.

Yes to the shift switch, and here is what I would use it for:

  • VICTORY_VIEW_MARK_SHIFT=12 (4 KiB). A third of my flagged 64 KiB pieces turn out equal to the reference copy (285 of 770 a frame): flagged at 64 KiB, nothing changed in the part I look at. At 4 KiB I expect most of those to drop out, and the compare to read a fraction of the 50 MB it reads now. It also matches the unit the write journal has for title CPU writes, which makes "did the title write this page since the flight was prepared" a like-for-like test.
  • Per line (>> 6) I would use as a filter in the store pass, not as a write set: skip lines with no mark before loading card and reference. At 6.6 MB of VRAM that is cheap. It does not remove the reference copy.
  • Per dword is the one that changes the design: no reference copy means about 470 MB of VRAM back here (twins for 108 copies), which is what makes this affordable on 8 GB cards. Two things I would need before leaning on it: the byte mask for sub-dword stores (a third of changed dwords here change 1 to 3 bytes; a mark per dword plus "compare only marked dwords against the title" may be enough, since for 100.0 % of partly changed dwords the unchanged bytes equalled title memory), and the fallback you describe for root-UAV and by-address writers. How large is that unmarked share in play on your side? If it is a few copies, a small set of reference copies only for those would do.

One number that may help you size it: in scope here are about 5,500 blocks of 64 KiB a frame (350 MB of title memory behind 108 copies), all write-combined. Per-dword bits for that are about 11 MB.

If you add the shift, I will run the count with 16, 12 and 6 and post flagged pieces, equal-to-reference share and compare time for each.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:06 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291931693) @⁠banaanpapa thanks, that is the clearest statement of what marks can and cannot do, and I agree with all three points. Your landing figure (6 to 13 ms on the relay) next to a 0.2 to 0.3 ms compare says the same thing from the other side. Yes to the shift switch, and here is what I would use it for: - **`VICTORY_VIEW_MARK_SHIFT=12` (4 KiB).** A third of my flagged 64 KiB pieces turn out equal to the reference copy (285 of 770 a frame): flagged at 64 KiB, nothing changed in the part I look at. At 4 KiB I expect most of those to drop out, and the compare to read a fraction of the 50 MB it reads now. It also matches the unit the write journal has for title CPU writes, which makes "did the title write this page since the flight was prepared" a like-for-like test. - **Per line (`>> 6`)** I would use as a filter in the store pass, not as a write set: skip lines with no mark before loading card and reference. At 6.6 MB of VRAM that is cheap. It does not remove the reference copy. - **Per dword** is the one that changes the design: no reference copy means about 470 MB of VRAM back here (twins for 108 copies), which is what makes this affordable on 8 GB cards. Two things I would need before leaning on it: the byte mask for sub-dword stores (a third of changed dwords here change 1 to 3 bytes; a mark per dword plus "compare only marked dwords against the title" may be enough, since for 100.0 % of partly changed dwords the unchanged bytes equalled title memory), and the fallback you describe for root-UAV and by-address writers. How large is that unmarked share in play on your side? If it is a few copies, a small set of reference copies only for those would do. One number that may help you size it: in scope here are about 5,500 blocks of 64 KiB a frame (350 MB of title memory behind 108 copies), all write-combined. Per-dword bits for that are about 11 MB. If you add the shift, I will run the count with 16, 12 and 6 and post flagged pieces, equal-to-reference share and compare time for each.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:07 UTC · original

On private title memory, from what I measured on #4211 (4070 SUPER, Proton, vkd3d-proton):

  • OpenExistingHeapFromAddress1 takes private, write-watched memory. It costs about 0.15–0.19 ms a MiB to open (like Windows) and the pages enter the working set.
  • In game at 150 s, private memory committed whole was 3,725 buffers but only 264 of 787 MB. Outside buffers there were 2,854 MB of private memory not committed whole or guarded, which can't be opened as it is.
  • The risk on Proton: opening doesn't pin the pages. The title's VirtualProtect and VirtualFree inside an open part succeed here (on Windows they fail with error 87), so nothing stops the title freeing or guarding memory a pass is still writing. I haven't tested what the card does then.
**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291958893) On private title memory, from what I measured on #4211 (4070 SUPER, Proton, vkd3d-proton): - `OpenExistingHeapFromAddress1` takes private, write-watched memory. It costs about 0.15–0.19 ms a MiB to open (like Windows) and the pages enter the working set. - In game at 150 s, private memory committed whole was 3,725 buffers but only 264 of 787 MB. Outside buffers there were 2,854 MB of private memory not committed whole or guarded, which can't be opened as it is. - The risk on Proton: opening doesn't pin the pages. The title's `VirtualProtect` and `VirtualFree` inside an open part succeed here (on Windows they fail with error 87), so nothing stops the title freeing or guarding memory a pass is still writing. I haven't tested what the card does then.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:09 UTC · original

@⁠gabrielecabrini that is the missing half, thank you. How I read it against my counts:

  • It can be opened, at the same cost as section views (I measure 0.18 ms per 64 KiB part, you 0.15 to 0.19 ms a MiB, so larger parts are much cheaper per byte). Here about 690 of the roughly 1,630 pieces the card flags a frame sit in memory that is not a section view, so this is the other half of the copy-back.
  • Only what is committed whole. Your 264 of 787 MB in buffers says a third of buffer bytes qualify as they are. Do you know how the written pieces split, not the bytes? If the shader-written buffers are mostly the whole-committed ones the share is better than a third. I can count that on my side: flagged pieces in private memory, by whether their 64 KiB block is committed whole and unguarded.
  • The Windows / Proton difference cuts both ways. On Windows a protect or free inside an open part fails with error 87, so the layer must close the part before it forwards the title's call, or the title's own call breaks. That is the hook I have at the top of every memory call: settle the flights that write the range, close the part, then let the call through. On Proton the call succeeds and the same hook is the only thing between a queued pass and freed memory. So the rule is the same on both, the failure is just loud on one and silent on the other. Worth a test on your side: free a part's range with a store pass queued and see whether the card faults, writes to a recycled page or is refused.
  • Guarded pages are the write watch's own doing in most layers; for a block the card owns the watch can be dropped (nobody merges it on the CPU), which may turn part of your 2,854 MB into memory that can be opened. I have not measured that.

The ownership table that this hook drives is on rtx5080/zerocopy-gate now (lease.rs, tests only, with a randomised model test), next to a slot table for the parts (slots.rs, with a 2,800-part card probe). If you want to try to break the model, the unmap and free cases are where I trust it least.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7291999792) @⁠gabrielecabrini that is the missing half, thank you. How I read it against my counts: - **It can be opened**, at the same cost as section views (I measure 0.18 ms per 64 KiB part, you 0.15 to 0.19 ms a MiB, so larger parts are much cheaper per byte). Here about 690 of the roughly 1,630 pieces the card flags a frame sit in memory that is not a section view, so this is the other half of the copy-back. - **Only what is committed whole.** Your 264 of 787 MB in buffers says a third of buffer bytes qualify as they are. Do you know how the *written* pieces split, not the bytes? If the shader-written buffers are mostly the whole-committed ones the share is better than a third. I can count that on my side: flagged pieces in private memory, by whether their 64 KiB block is committed whole and unguarded. - **The Windows / Proton difference cuts both ways.** On Windows a protect or free inside an open part fails with error 87, so the layer must close the part before it forwards the title's call, or the title's own call breaks. That is the hook I have at the top of every memory call: settle the flights that write the range, close the part, then let the call through. On Proton the call succeeds and the same hook is the only thing between a queued pass and freed memory. So the rule is the same on both, the failure is just loud on one and silent on the other. Worth a test on your side: free a part's range with a store pass queued and see whether the card faults, writes to a recycled page or is refused. - Guarded pages are the write watch's own doing in most layers; for a block the card owns the watch can be dropped (nobody merges it on the CPU), which may turn part of your 2,854 MB into memory that can be opened. I have not measured that. The ownership table that this hook drives is on `rtx5080/zerocopy-gate` now (`lease.rs`, tests only, with a randomised model test), next to a slot table for the parts (`slots.rs`, with a 2,800-part card probe). If you want to try to break the model, the unmap and free cases are where I trust it least.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:19 UTC · original

Ran the free-under-a-running-pass test on the 4070 SUPER (Proton, vkd3d-proton). It's a local test, not on your branch. Same layout as the #4211 probe: private write-watched memory, a part opened with OpenExistingHeapFromAddress1, a 256 KiB buffer in it. A store pass runs for about 500 ms, and 30 ms in (pass confirmed running, fence not reached) the title's call hits one 64 KiB page of the buffer. One case a process:

title's call during the pass call pass what the CPU reads after
none – ends, 498 ms all pattern
VirtualProtect read-only succeeds ends all pattern: the card ignores the protection
MEM_DECOMMIT of the page succeeds ends that page recommitted: all zero; the rest pattern
MEM_RELEASE + new allocation at the same address succeeds ends new memory: all marker, 0 pattern

No device removal and no NVRM/Xid lines in the kernel log in any case. So on Proton it's the silent failure: no fault and no stores into recycled pages, the pass's stores just vanish (my guess: the driver keeps the old pages pinned). Your hook (settle the flights, close the part, then let the call through) is the only protection here.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292233235) Ran the free-under-a-running-pass test on the 4070 SUPER (Proton, vkd3d-proton). It's a local test, not on your branch. Same layout as the #4211 probe: private write-watched memory, a part opened with `OpenExistingHeapFromAddress1`, a 256 KiB buffer in it. A store pass runs for about 500 ms, and 30 ms in (pass confirmed running, fence not reached) the title's call hits one 64 KiB page of the buffer. One case a process: | title's call during the pass | call | pass | what the CPU reads after | |---|---|---|---| | none | – | ends, 498 ms | all pattern | | `VirtualProtect` read-only | succeeds | ends | all pattern: the card ignores the protection | | `MEM_DECOMMIT` of the page | succeeds | ends | that page recommitted: all zero; the rest pattern | | `MEM_RELEASE` + new allocation at the same address | succeeds | ends | new memory: all marker, 0 pattern | No device removal and no NVRM/Xid lines in the kernel log in any case. So on Proton it's the silent failure: no fault and no stores into recycled pages, the pass's stores just vanish (my guess: the driver keeps the old pages pinned). Your hook (settle the flights, close the part, then let the call through) is the only protection here.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:21 UTC · original

@⁠gabrielecabrini that is a clean result and the worse of the two outcomes to design for: no fault, no stray stores, the landing just disappears. So on Proton a missed settle shows up as stale title memory minutes later with nothing in any log, exactly the kind of fault the class filter produced. Two things I take from it:

  • The hook has to be at the top of every title memory call that can change a mapping (protect, decommit, release, unmap, remap), before any lock, and it has to settle and close the part even when the call would be harmless on Windows.
  • It needs a check that does not depend on the platform failing: after the hook, the ownership table must show no block of the range on the card. I will count violations of that in the count build, so a missed path shows as a number before any store is wired.

The read-only case is useful too: protection does not stop the card, so the write watch says nothing about card-owned blocks on either platform.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292299102) @⁠gabrielecabrini that is a clean result and the worse of the two outcomes to design for: no fault, no stray stores, the landing just disappears. So on Proton a missed settle shows up as stale title memory minutes later with nothing in any log, exactly the kind of fault the class filter produced. Two things I take from it: - The hook has to be at the top of every title memory call that can change a mapping (protect, decommit, release, unmap, remap), before any lock, and it has to settle and close the part even when the call would be harmless on Windows. - It needs a check that does not depend on the platform failing: after the hook, the ownership table must show no block of the range on the card. I will count violations of that in the count build, so a missed path shows as a number before any store is wired. The read-only case is useful too: protection does not stop the card, so the write watch says nothing about card-owned blocks on either platform.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:23 UTC · original

More from the 4070 SUPER on Proton, on 8cdbeece:

  • Slots card probe: on Proton a 2 MiB part opens even with its last page reserved (your point 10 says Windows refuses it). So the probe opened 91 parts of 2 MiB instead of 2,821 of 64 KiB: 8.3 ms in all, 0.087 ms a part, and 2,821 of 2,821 reads right. It only fails its count assertion, which expects one part per page.
  • So I checked that page (local test): before the commit, the card reads it as zero, with no fault. After the title commits it, the card sees the CPU's writes and the CPU sees the card's. On Proton the 2 MiB part over a later-committed page is coherent, and the 64 KiB fallback isn't needed there.
  • Lease: random_interleavings_match_the_reference passes, all 8 seeds. Two harness notes: a_plan_let_go_without_close_is_caught fails under --release (it relies on a debug_assert), and the_probe_pass_compiles_with_the_tables_size fails because FXC under Wine can't compile the probe.
**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292341004) More from the 4070 SUPER on Proton, on `8cdbeece`: - **Slots card probe:** on Proton a 2 MiB part opens even with its last page reserved (your point 10 says Windows refuses it). So the probe opened 91 parts of 2 MiB instead of 2,821 of 64 KiB: 8.3 ms in all, 0.087 ms a part, and 2,821 of 2,821 reads right. It only fails its count assertion, which expects one part per page. - **So I checked that page (local test):** before the commit, the card reads it as zero, with no fault. After the title commits it, the card sees the CPU's writes and the CPU sees the card's. On Proton the 2 MiB part over a later-committed page is coherent, and the 64 KiB fallback isn't needed there. - **Lease:** `random_interleavings_match_the_reference` passes, all 8 seeds. Two harness notes: `a_plan_let_go_without_close_is_caught` fails under `--release` (it relies on a `debug_assert`), and `the_probe_pass_compiles_with_the_tables_size` fails because FXC under Wine can't compile the probe.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:25 UTC · original

One more, and it goes with your first point: settling isn't enough on Proton, the part has to be closed.

Private memory, part open as in the #4211 probe, no pass running. The title decommits a 64 KiB page of the buffer and commits it again (both succeed; the CPU reads zero). After that the card and the CPU see different pages: the card reads the old contents, not what the CPU wrote, and what the card stores never reaches the CPU. Only closing and reopening the part makes them see the same page again. No error anywhere.

The reserved page in my last comment was a section page committed after the part opened, and that one stayed coherent. A private page decommitted and committed again under an open part does not.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292387178) One more, and it goes with your first point: settling isn't enough on Proton, the part has to be closed. Private memory, part open as in the #4211 probe, **no pass running**. The title decommits a 64 KiB page of the buffer and commits it again (both succeed; the CPU reads zero). After that the card and the CPU see different pages: the card reads the old contents, not what the CPU wrote, and what the card stores never reaches the CPU. Only closing and reopening the part makes them see the same page again. No error anywhere. The reserved page in my last comment was a section page committed after the part opened, and that one stayed coherent. A private page decommitted and committed again under an open part does not.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:25 UTC · original

@⁠gabrielecabrini both go straight into the rules, thank you.

  • Decommit and commit again under an open part splits the page in two (card keeps the old one, CPU gets a new one, no error). So the rule is not "settle, then let the call through" but "settle, close the part, let the call through, reopen on next use", for every call that can change what backs a page, whether or not a pass is queued. I had the close in the design only for unmap and free; decommit and protect are now in the same list. I will also add a test for it on Windows, where I expect the decommit to be refused while the part is open (error 87), which is the loud version of the same thing.
  • A section page committed after the part opened stays coherent on Proton, and the 2 MiB part opens there over a reserved page. Good: fewer, larger parts on Proton. I will make the probe's count assertion accept either outcome and print which one it got.
  • Harness: the dropped-ticket test will be gated on debug assertions, and the probe's shader test skipped where FXC cannot compile it (with a line saying so), until the passes also build with DXC.

If you have time for one more: the same decommit-and-commit case on a section view page instead of private memory. If that one stays coherent, the split is a property of private pages only, and section views (all of my in-scope memory today) are safe from it even without the close.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292395167) @⁠gabrielecabrini both go straight into the rules, thank you. - **Decommit and commit again under an open part splits the page in two** (card keeps the old one, CPU gets a new one, no error). So the rule is not "settle, then let the call through" but "settle, **close the part**, let the call through, reopen on next use", for every call that can change what backs a page, whether or not a pass is queued. I had the close in the design only for unmap and free; decommit and protect are now in the same list. I will also add a test for it on Windows, where I expect the decommit to be refused while the part is open (error 87), which is the loud version of the same thing. - **A section page committed after the part opened stays coherent on Proton**, and the 2 MiB part opens there over a reserved page. Good: fewer, larger parts on Proton. I will make the probe's count assertion accept either outcome and print which one it got. - Harness: the dropped-ticket test will be gated on debug assertions, and the probe's shader test skipped where FXC cannot compile it (with a line saying so), until the passes also build with DXC. If you have time for one more: the same decommit-and-commit case on a **section view** page instead of private memory. If that one stays coherent, the split is a property of private pages only, and section views (all of my in-scope memory today) are safe from it even without the close.
Author
Owner

@⁠banaanpapa on GitHub · 2026-11-30 21:29 UTC · original

@⁠Marsietiss before you plan around per-dword marks, I measured the marks in play, and the cost side changes my answer.

One session in the world, RTX 5080, e1251c31 with #3641 and #4174, VICTORY_VIEW_MARKS=1 (64 KiB marks), 9 minutes, same scene as my runs without marks (about 4,800 draws a frame, the card 99 % busy):

without marks with marks
card time of the title's lists 25.0 ms 31.8 ms
frame median 27.1 ms 33.8 ms
our compare lists 0.2 ms 0.2 ms

The extra card time holds through the run: 31-32 ms in each quarter, with no pipelines being made. Every marked store pays for a load of its view's entry, a wave election and a read of the bitmap word, and on a card-bound PC that's about 27 % more card time. All of it to save a compare that costs 0.2 ms here. Per-dword marks would add bitmap traffic on top of that, not take it away.

Coverage, for the record: per frame, 300 compared copies (692 pieces of 64 KiB) were left to their marks, 18 (18 pieces) were compared whole because a writer didn't mark, and none were without bits. So the marks see nearly everything here, but they're too expensive to keep on.

So I'd drop marks as the write-set source. Your compare against a reference copy on the card, a 0.49 ms count pass, is the better design on this card. I won't send the shift switch; at this cost it would only answer a question we no longer need answered.

On why gapped lines are slow (your open question), the specs back your guess, at two levels:

  • On the link: PCIe lets a write's byte enables have gaps only in a single-dword write, or a two-dword write aligned to 8 bytes (AMD PG346, Efinix). A 64-byte line with two runs can't go as one write and is split into separate ones.
  • At the host: a write of less than a whole line makes the root complex or memory controller read the line, merge and write it back. Whole, aligned lines avoid that (US9535850, US6353877).

That fits your table: the slow path starts at the second run in a line, wherever the gap is. Your split into one dispatch per run gives each run its own contiguous write. It also says that wherever a pass can safely write whole lines, those are the cheapest of all.

**@⁠banaanpapa** on GitHub · 2026-11-30 21:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292485464) @⁠Marsietiss before you plan around per-dword marks, I measured the marks in play, and the cost side changes my answer. **One session in the world, RTX 5080, `e1251c31` with #3641 and #4174, `VICTORY_VIEW_MARKS=1` (64 KiB marks), 9 minutes, same scene as my runs without marks (about 4,800 draws a frame, the card 99 % busy):** | | without marks | with marks | |---|---|---| | card time of the title's lists | 25.0 ms | **31.8 ms** | | frame median | 27.1 ms | 33.8 ms | | our compare lists | 0.2 ms | 0.2 ms | The extra card time holds through the run: 31-32 ms in each quarter, with no pipelines being made. Every marked store pays for a load of its view's entry, a wave election and a read of the bitmap word, and on a card-bound PC that's about 27 % more card time. All of it to save a compare that costs 0.2 ms here. Per-dword marks would add bitmap traffic on top of that, not take it away. **Coverage, for the record:** per frame, 300 compared copies (692 pieces of 64 KiB) were left to their marks, 18 (18 pieces) were compared whole because a writer didn't mark, and none were without bits. So the marks see nearly everything here, but they're too expensive to keep on. So I'd drop marks as the write-set source. Your compare against a reference copy on the card, a 0.49 ms count pass, is the better design on this card. I won't send the shift switch; at this cost it would only answer a question we no longer need answered. **On why gapped lines are slow** (your open question), the specs back your guess, at two levels: - **On the link:** PCIe lets a write's byte enables have gaps only in a single-dword write, or a two-dword write aligned to 8 bytes ([AMD PG346](https://docs.amd.com/r/en-US/pg346-cpm-pcie/Completer-Memory-Write-Operation), [Efinix](https://www.efinixinc.com/docs-html/xcvr-pcie-controller-ug/topics/pcie/non-contiguous_writes.html)). A 64-byte line with two runs can't go as one write and is split into separate ones. - **At the host:** a write of less than a whole line makes the root complex or memory controller read the line, merge and write it back. Whole, aligned lines avoid that ([US9535850](https://patents.google.com/patent/US9535850), [US6353877](https://image-ppubs.uspto.gov/dirsearch-public/print/downloadPdf/6353877)). That fits your table: the slow path starts at the second run in a line, wherever the gap is. Your split into one dispatch per run gives each run its own contiguous write. It also says that wherever a pass can safely write whole lines, those are the cheapest of all.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:29 UTC · original

@⁠banaanpapa measured beats planned: 27 % more card time to save a 0.2 to 0.5 ms compare is a clear no. I drop per-dword marks from my plan and stay with the compare against a reference copy; the cost of that is VRAM (about 470 MB here), which I will try to cut by keeping reference copies only for blocks the card actually owns instead of for every candidate copy. Thanks for running it rather than leaving it as an idea, and for the coverage numbers (18 of 318 copies with an unmarked writer).

The link-level reading matches everything measured on both cards: gaps in byte enables only inside one dword, so a second run in a line is a second write, and the partial line costs a read-merge-write at the host. It also explains why a whole line (1.4 ns) is cheaper than a one-run line (2.5 ns) here. I cannot write whole lines in general, because the title's CPU may be writing the other dwords, but there is one case where it is safe and common: lines where every dword changed. They already go out dense today; I will make sure the pass never splits them.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292493740) @⁠banaanpapa measured beats planned: 27 % more card time to save a 0.2 to 0.5 ms compare is a clear no. I drop per-dword marks from my plan and stay with the compare against a reference copy; the cost of that is VRAM (about 470 MB here), which I will try to cut by keeping reference copies only for blocks the card actually owns instead of for every candidate copy. Thanks for running it rather than leaving it as an idea, and for the coverage numbers (18 of 318 copies with an unmarked writer). The link-level reading matches everything measured on both cards: gaps in byte enables only inside one dword, so a second run in a line is a second write, and the partial line costs a read-merge-write at the host. It also explains why a whole line (1.4 ns) is cheaper than a one-run line (2.5 ns) here. I cannot write whole lines in general, because the title's CPU may be writing the other dwords, but there is one case where it is safe and common: lines where every dword changed. They already go out dense today; I will make sure the pass never splits them.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:30 UTC · original

The section view case, as asked: the decommit is refused with error 87 while the part is open (the commit after it is a no-op). Card, view A and a second view B all keep seeing one page both ways. So on Proton too the split is a property of private pages; section views are safe from it.

One more on private memory that matters for "the other half": on Proton a part over private memory opens with S_OK even when one of its pages is read-only, PAGE_GUARD, or reserved, but then the whole part is detached from title memory. The card reads zero on every page, including plain ones, and CPU and card never see each other's writes, even after the page is made plain or committed. No error at open or later. Controls with every page plain (committed page by page, or at once) are coherent.

So on Proton a successful open of private memory doesn't prove the heap is on it. The part has to be fully committed and plain at open, or checked with a read-back after opening. My guess is that vkd3d-proton's host-memory import fails and it quietly falls back to its own memory, but I haven't checked that. Sections don't do this: a 2 MiB part over a reserved section page stays coherent.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292510650) The section view case, as asked: **the decommit is refused with error 87** while the part is open (the commit after it is a no-op). Card, view A and a second view B all keep seeing one page both ways. So on Proton too the split is a property of private pages; section views are safe from it. One more on private memory that matters for "the other half": on Proton a part over private memory **opens with S_OK even when one of its pages is read-only, `PAGE_GUARD`, or reserved, but then the whole part is detached from title memory**. The card reads zero on every page, including plain ones, and CPU and card never see each other's writes, even after the page is made plain or committed. No error at open or later. Controls with every page plain (committed page by page, or at once) are coherent. So on Proton a successful open of private memory doesn't prove the heap is on it. The part has to be fully committed and plain at open, or checked with a read-back after opening. My guess is that vkd3d-proton's host-memory import fails and it quietly falls back to its own memory, but I haven't checked that. Sections don't do this: a 2 MiB part over a reserved section page stays coherent.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:33 UTC · original

Checked the detached private part with vkd3d-proton's log on. When one page is read-only or reserved, vkd3d-proton logs vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e and OpenExistingHeapFromAddress1 still returns S_OK, so it falls back to memory of its own. With every page plain there's no such line and the part is coherent. On Proton the only sign is that warning (off by default), so the layer needs its own check after opening a private part, e.g. a sentinel the CPU writes and the card reads back.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292569715) Checked the detached private part with vkd3d-proton's log on. When one page is read-only or reserved, vkd3d-proton logs `vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e` and `OpenExistingHeapFromAddress1` still returns S_OK, so it falls back to memory of its own. With every page plain there's no such line and the part is coherent. On Proton the only sign is that warning (off by default), so the layer needs its own check after opening a private part, e.g. a sentinel the CPU writes and the card reads back.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:34 UTC · original

@⁠gabrielecabrini that closes the section side and opens a clear rule for the private side:

  • Section views: decommit under an open part is refused (error 87) on Proton as on Windows, and all views plus the card keep one page. So the memory I have in scope today cannot split; the hook still closes the part first, because otherwise the title's own call fails.
  • Private memory on Proton: a successful open proves nothing. One read-only, guarded or reserved page and the whole part is silently the driver's own memory. Rules I take: open only ranges that are fully committed and plain at that moment; after every open of a private part write a sentinel from the CPU and read it back on the card (and the other way) before the block may go to the card; and a write watch that guards pages has to be lifted for the range before opening, not after.

That sentinel check is cheap enough to do on Windows as well, so I will make it unconditional rather than per platform. It also gives a number for the log: parts opened, parts that failed the read-back.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292586804) @⁠gabrielecabrini that closes the section side and opens a clear rule for the private side: - **Section views:** decommit under an open part is refused (error 87) on Proton as on Windows, and all views plus the card keep one page. So the memory I have in scope today cannot split; the hook still closes the part first, because otherwise the title's own call fails. - **Private memory on Proton:** a successful open proves nothing. One read-only, guarded or reserved page and the whole part is silently the driver's own memory. Rules I take: open only ranges that are fully committed and plain at that moment; after every open of a private part write a sentinel from the CPU and read it back on the card (and the other way) before the block may go to the card; and a write watch that guards pages has to be lifted for the range before opening, not after. That sentinel check is cheap enough to do on Windows as well, so I will make it unconditional rather than per platform. It also gives a number for the log: parts opened, parts that failed the read-back.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:35 UTC · original

One addition to the section side: it's safe because you open on your own view. I checked the write guard's case on Proton (it leaves 64 KiB blocks of the title's views read-only, on by default):

part opened on opens coherent
a view with one read-only block S_OK no: card reads zero everywhere, its stores never reach the title's view
our own plain view; the read-only block is in the title's view only S_OK yes, both ways

So the same silent fallback hits section parts if the opened view isn't plain. Worth having the sentinel check on section parts too, not only private ones. On the private side the layer only uses the write watch; VICTORY_LAZY_LAND and the reader probes protect pages, but both are off by default.

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292627366) One addition to the section side: it's safe because you open on your own view. I checked the write guard's case on Proton (it leaves 64 KiB blocks of the title's views read-only, on by default): | part opened on | opens | coherent | |---|---|---| | a view with one read-only block | S_OK | **no**: card reads zero everywhere, its stores never reach the title's view | | our own plain view; the read-only block is in the title's view only | S_OK | yes, both ways | So the same silent fallback hits section parts if the opened view isn't plain. Worth having the sentinel check on section parts too, not only private ones. On the private side the layer only uses the write watch; `VICTORY_LAZY_LAND` and the reader probes protect pages, but both are off by default.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:38 UTC · original

@⁠gabrielecabrini good catch, and it changes one line of my rule set: the sentinel round trip goes on every part at open, section or private, and the part is opened only on a view of our own that nothing ever protects (which is what the count build does today, but by habit, not by rule). A guard that leaves blocks read-only in the title's view is then harmless, as your second row shows. I will also add a start-up line saying how many parts failed the round trip, so a platform that falls back silently shows up in the first log.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292679071) @⁠gabrielecabrini good catch, and it changes one line of my rule set: the sentinel round trip goes on **every** part at open, section or private, and the part is opened only on a view of our own that nothing ever protects (which is what the count build does today, but by habit, not by rule). A guard that leaves blocks read-only in the title's view is then harmless, as your second row shows. I will also add a start-up line saying how many parts failed the round trip, so a platform that falls back silently shows up in the first log.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:40 UTC · original

A housekeeping proposal: this has stopped being an issue. It is a running design thread with measurements from three people on two platforms, and it will keep growing while the store pass, the hooks and the private-memory half are built.

I suggest moving it to a Discussion (Ideas or a design category), where replies can be threaded per topic: one thread each for the card tests, the open-in-place rules per platform, the ownership and hook rules, and results from game runs. A maintainer can convert this issue in place ("Convert to discussion" in the sidebar), which keeps every comment and link. If that is not wanted, I can open a discussion myself, link it here and post a summary of the rules agreed so far as its first comment.

@⁠gabrielecabrini @⁠banaanpapa any preference? Until it moves I keep answering here.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292723991) A housekeeping proposal: this has stopped being an issue. It is a running design thread with measurements from three people on two platforms, and it will keep growing while the store pass, the hooks and the private-memory half are built. I suggest moving it to a **Discussion** (Ideas or a design category), where replies can be threaded per topic: one thread each for the card tests, the open-in-place rules per platform, the ownership and hook rules, and results from game runs. A maintainer can convert this issue in place ("Convert to discussion" in the sidebar), which keeps every comment and link. If that is not wanted, I can open a discussion myself, link it here and post a summary of the rules agreed so far as its first comment. @⁠gabrielecabrini @⁠banaanpapa any preference? Until it moves I keep answering here.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-30 21:42 UTC · original

we can go to design and post a summary with the measurements

**@⁠gabrielecabrini** on GitHub · 2026-11-30 21:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292770375) we can go to design and post a summary with the measurements
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 21:44 UTC · original

@⁠gabrielecabrini done: the design thread is now discussion #4516, with a summary of the measurements from both cards and the rules agreed so far as its first post. Corrections to that summary are welcome there. I will keep this issue for the original report only and answer design points in the discussion from now on.

**@⁠Marsietiss** on GitHub · 2026-11-30 21:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7292818555) @⁠gabrielecabrini done: the design thread is now discussion #4516, with a summary of the measurements from both cards and the rules agreed so far as its first post. Corrections to that summary are welcome there. I will keep this issue for the original report only and answer design points in the discussion from now on.
Author
Owner

@⁠d0dev on GitHub · 2026-11-30 22:16 UTC · original

Another data point for the in-place landing tests: RTX 4070 Ti SUPER (Ada), Windows 11, driver 616.92, PCIe 4.0 x16, so Ada on Windows next to the 5080 (Windows) and the 4070 SUPER (Proton). Branch rtx5080/zerocopy-gate at 8cdbeece3, debug test build, nothing else on the card.

card_gap_bus_store_variants_into_title_memory, 64 MiB, ns per 64-byte line (x vs one run):

runs a line A one pass B1 split + UAV barrier B2 ECL per run G2 split, no barrier C1 thread per line C2 thread per page
1 3.3 (1 dword in 16); 2.6 every dword 3.4 3.3 3.8 3.3 4.6
2 17.4 (5.2x) 6.7-6.8 (2.0x) 6.6-7.0 7.5 (2.3x) 20.7-26.1 11.0-52.0
3 104.2 (31x)
4 119-120 (36x)
8 266.1 (80x) 28.4 (8.6x) 28.1 27.1 (8.2x) 213.9 107.3

The gapped-line cost is here too (266 ns, between the 4070 SUPER's 194 and the 5080's 330). Two runs a line cost less than on either of your cards (about 5x against 9-17x). The dispatch boundary brings 8 runs to about 8x, same as on both.

card_race_plain_stores_into_title_memory_undo_no_cpu_store: 3 runs of 5,000 landings, about 1.9 billion CPU stores each: 0 undone, 0 shader dwords missing, counts as expected.

card_gap_race_of_the_variants, 2,000 landings each: B1, G2, C1, C2 and D all 0 undone and 0 missing. F (load + whole-line store) undid 1.93 M beside and 2.05 M partial-dword bytes, about 10,300 per million CPU stores, so the test catches it.

card_bus_speed_of_the_store_pass_card_and_title_memory at 64 KiB: about 0.075 ms submit to fence in every case. Only the race layout stood out storing into title memory: 0.229 ms (0.161 ms GPU) against 0.074 into card memory.

Full output available if useful.

**@⁠d0dev** on GitHub · 2026-11-30 22:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7293609507) Another data point for the in-place landing tests: **RTX 4070 Ti SUPER (Ada), Windows 11, driver 616.92, PCIe 4.0 x16**, so Ada on Windows next to the 5080 (Windows) and the 4070 SUPER (Proton). Branch `rtx5080/zerocopy-gate` at `8cdbeece3`, debug test build, nothing else on the card. **`card_gap_bus_store_variants_into_title_memory`**, 64 MiB, ns per 64-byte line (x vs one run): | runs a line | A one pass | B1 split + UAV barrier | B2 ECL per run | G2 split, no barrier | C1 thread per line | C2 thread per page | |---|---|---|---|---|---|---| | 1 | 3.3 (1 dword in 16); 2.6 every dword | 3.4 | 3.3 | 3.8 | 3.3 | 4.6 | | 2 | 17.4 (5.2x) | 6.7-6.8 (2.0x) | 6.6-7.0 | 7.5 (2.3x) | 20.7-26.1 | 11.0-52.0 | | 3 | 104.2 (31x) | | | | | | | 4 | 119-120 (36x) | | | | | | | 8 | 266.1 (80x) | 28.4 (8.6x) | 28.1 | 27.1 (8.2x) | 213.9 | 107.3 | The gapped-line cost is here too (266 ns, between the 4070 SUPER's 194 and the 5080's 330). Two runs a line cost less than on either of your cards (about 5x against 9-17x). The dispatch boundary brings 8 runs to about 8x, same as on both. **`card_race_plain_stores_into_title_memory_undo_no_cpu_store`**: 3 runs of 5,000 landings, about 1.9 billion CPU stores each: 0 undone, 0 shader dwords missing, counts as expected. **`card_gap_race_of_the_variants`**, 2,000 landings each: B1, G2, C1, C2 and D all 0 undone and 0 missing. F (load + whole-line store) undid 1.93 M beside and 2.05 M partial-dword bytes, about 10,300 per million CPU stores, so the test catches it. **`card_bus_speed_of_the_store_pass_card_and_title_memory`** at 64 KiB: about 0.075 ms submit to fence in every case. Only the race layout stood out storing into title memory: 0.229 ms (0.161 ms GPU) against 0.074 into card memory. Full output available if useful.
Author
Owner

@⁠Marsietiss on GitHub · 2026-11-30 22:16 UTC · original

@⁠d0dev thank you, a fourth card and the first Ada one on Windows. It agrees with the others where it matters: plain stores undo nothing (0 over 5.7 billion), the whole-line variant is caught, and one store dispatch per run brings 8 runs from 80x to about 8x with or without the barrier. The lower cost at two runs (5x) is new and fits the idea that the penalty is not the bus alone.

Two things that may interest you: the design moved to discussion #4516 (summary of all cards there, I will add yours), and a tester on an RTX 4090 reports that the gap cost follows the CPU cache attribute of the destination pages (write-combined destinations about 20 ns for 8 runs in one pass). That is being reproduced on the 5080 now; if it holds, the same test with a write-combined destination on your card would be the next data point worth having.

**@⁠Marsietiss** on GitHub · 2026-11-30 22:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/4425#issuecomment-7293618296) @⁠d0dev thank you, a fourth card and the first Ada one on Windows. It agrees with the others where it matters: plain stores undo nothing (0 over 5.7 billion), the whole-line variant is caught, and one store dispatch per run brings 8 runs from 80x to about 8x with or without the barrier. The lower cost at two runs (5x) is new and fits the idea that the penalty is not the bus alone. Two things that may interest you: the design moved to discussion #4516 (summary of all cards there, I will add yours), and a tester on an RTX 4090 reports that the gap cost follows the CPU cache attribute of the destination pages (write-combined destinations about 20 ns for 8 runs in one pass). That is being reproduced on the 5080 now; if it holds, the same test with a write-combined destination on your card would be the next data point worth having.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#4426
No description provided.