GPU: copy into title memory without asking for its region first #322

Manually merged
github merged 1 commit from gh-pr/322/head into gh-pr/322/base 2026-11-26 03:59:14 +00:00
Owner

@⁠jsthope on GitHub · 2026-11-24 02:16 UTC · original
jsthope:gpu/title-copies-without-region-queries → main · +124 −19 · 1 files · 1 commits · merged 2026-11-25 00:16 UTC

What

Two copies into title memory ask the host about the destination before every copy:

  • copy_mapped with a title destination (a list's buffer copies) first checks that the whole destination is committed, with VirtualQuery (texture::committed).
  • write_mapped (the copy-back of what shaders wrote) uses WriteProcessMemory, which asks for the destination's region before it writes, for every 64 KiB piece.

copy_mapped's comment already says what such a query costs when it was asked about the source ("about 2 ms per copy in the title's big pools"): it walks the page tables to the end of the region with the same state, whatever the size of the copy. In the world the destinations were private pools of about 600 MiB.

Change

Both use the kernel copy the other copies already go through (ReadProcessMemory on our own process). It fails on a destination page that is not mapped writable as it does on a source page it cannot read, without faulting.

  • copy_mapped: the copy runs first. A title destination is asked for its region only once its copy has failed, which keeps the page retries (they write their zeros themselves) off unmapped memory.
  • write_mapped: the same pieces as before, written by the kernel copy.

One file, crates/victory-gpu/src/host.rs.

Behaviour

  • write_mapped: unchanged. Mapped pages are written, unmapped and read-only pages are not. Compared with WriteProcessMemory on reserved, partly committed and read-only memory: same result, same partial copy.
  • copy_mapped: one difference. A title destination that was not all mapped used to be left alone. Now the bytes before its first unmapped page may arrive, because the kernel copy stops at that page; nothing is written from that page on. In the run below none of the 3,274 title copies had such a destination, and none failed.

Numbers

World (first mission's intro); i7-13650HX, RTX 4060 Laptop, Windows 11, diagnostics build. Temporary counters, not in this PR, timed the old and the new call on the same copies of one run, 41 frames of about 1.15 s each:

per frame before after
title copies 80 copies, 0.45 MB 59.5 ms (the check alone) 0.56 ms (the whole copy)
copy-back 110 pieces, 4.9 MB 38.6 ms 0.55 ms

That is 98 ms of a frame (8.6 %) down to about 1 ms.

Stacks of the submitting thread sampled at 10 Hz (VICTORY_STACKS): VirtualQuery under these two calls was 47 of 462 samples before and 0 of 189 after. The VirtualQuery left in that profile is the one in watch::guard, which #119 addresses. This merges cleanly with #119, #202 and #124.

Synthetic, same machine: writing a 64 KiB piece into a committed view of 64 MiB / 512 MiB / 2 GiB takes 118 µs / 1.1 ms / 8.0 ms with WriteProcessMemory, and 6 µs with the kernel copy whatever the view.

Tested

  • cargo test -p victory-gpu: 45 passed, 1 ignored, also with --features diagnostics. Two new tests run both copies against reserved memory with a committed block on each side of a hole (no GPU, no game data).
  • cargo clippy -p victory-gpu --all-targets: no new warning. cargo xtask policy: ok.
  • Two runs through the menus and loading into the world with the change, on Windows 11 and NVIDIA. On this machine every world run ends with the host GPU hanging after 20 to 80 s, on main (five runs out of five) as with this change.
  • Not tested under Wine.

No game assets or derived data are included.

AI-Assisted

**@⁠jsthope** on GitHub · 2026-11-24 02:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/322) `jsthope:gpu/title-copies-without-region-queries` → `main` · +124 −19 · 1 files · 1 commits · merged 2026-11-25 00:16 UTC ## What Two copies into title memory ask the host about the destination before every copy: - `copy_mapped` with a title destination (a list's buffer copies) first checks that the whole destination is committed, with `VirtualQuery` (`texture::committed`). - `write_mapped` (the copy-back of what shaders wrote) uses `WriteProcessMemory`, which asks for the destination's region before it writes, for every 64 KiB piece. `copy_mapped`'s comment already says what such a query costs when it was asked about the source ("about 2 ms per copy in the title's big pools"): it walks the page tables to the end of the region with the same state, whatever the size of the copy. In the world the destinations were private pools of about 600 MiB. ## Change Both use the kernel copy the other copies already go through (`ReadProcessMemory` on our own process). It fails on a destination page that is not mapped writable as it does on a source page it cannot read, without faulting. - `copy_mapped`: the copy runs first. A title destination is asked for its region only once its copy has failed, which keeps the page retries (they write their zeros themselves) off unmapped memory. - `write_mapped`: the same pieces as before, written by the kernel copy. One file, `crates/victory-gpu/src/host.rs`. ## Behaviour - `write_mapped`: unchanged. Mapped pages are written, unmapped and read-only pages are not. Compared with `WriteProcessMemory` on reserved, partly committed and read-only memory: same result, same partial copy. - `copy_mapped`: one difference. A title destination that was not all mapped used to be left alone. Now the bytes before its first unmapped page may arrive, because the kernel copy stops at that page; nothing is written from that page on. In the run below none of the 3,274 title copies had such a destination, and none failed. ## Numbers World (first mission's intro); i7-13650HX, RTX 4060 Laptop, Windows 11, diagnostics build. Temporary counters, not in this PR, timed the old and the new call on the same copies of one run, 41 frames of about 1.15 s each: | | per frame | before | after | |---|---|---:|---:| | title copies | 80 copies, 0.45 MB | 59.5 ms (the check alone) | 0.56 ms (the whole copy) | | copy-back | 110 pieces, 4.9 MB | 38.6 ms | 0.55 ms | That is 98 ms of a frame (8.6 %) down to about 1 ms. Stacks of the submitting thread sampled at 10 Hz (`VICTORY_STACKS`): `VirtualQuery` under these two calls was 47 of 462 samples before and 0 of 189 after. The `VirtualQuery` left in that profile is the one in `watch::guard`, which #119 addresses. This merges cleanly with #119, #202 and #124. Synthetic, same machine: writing a 64 KiB piece into a committed view of 64 MiB / 512 MiB / 2 GiB takes 118 µs / 1.1 ms / 8.0 ms with `WriteProcessMemory`, and 6 µs with the kernel copy whatever the view. ## Tested - `cargo test -p victory-gpu`: 45 passed, 1 ignored, also with `--features diagnostics`. Two new tests run both copies against reserved memory with a committed block on each side of a hole (no GPU, no game data). - `cargo clippy -p victory-gpu --all-targets`: no new warning. `cargo xtask policy`: ok. - Two runs through the menus and loading into the world with the change, on Windows 11 and NVIDIA. On this machine every world run ends with the host GPU hanging after 20 to 80 s, on `main` (five runs out of five) as with this change. - Not tested under Wine. No game assets or derived data are included. AI-Assisted
Two copies into title memory asked the host about the destination before
every copy. copy_mapped's own comment tells what that costs: asking
VirtualQuery about the source took about 2 ms per copy in the title's big
pools, because the query walks the page tables to the end of the region
with the same state, whatever the size of the copy.

- A list's copy into title memory checked that the whole destination was
  committed first, with VirtualQuery. The destinations were private pools
  of about 600 MiB.
- The copy-back of what shaders wrote used WriteProcessMemory, which asks
  for the destination's region before it writes: the same walk for every
  64 KiB piece.

Both now rely on the kernel copy the other copies already use
(ReadProcessMemory on our own process). It fails on a destination page
that is not mapped writable as it does on a source page it cannot read,
without faulting. A title destination is asked for its region only after
its copy has failed, which keeps the page retries (they write their zeros
themselves) off unmapped memory. write_mapped does what it did: mapped
pages are written, unmapped and read-only ones are not.

One difference: a title destination that was not all mapped used to be
left alone, and the bytes before its first unmapped page may now arrive
(the kernel copy stops at that page). No title copy of the run below had
such a destination, and none failed.

Measured in the world (first mission's intro; i7-13650HX, RTX 4060
Laptop, diagnostics build), with the old and the new call timed on the
same copies of one run, 41 frames of about 1.15 s each:

  title copies, 80 per frame (0.45 MB): the check alone 59.5 ms per
  frame; the whole copy now 0.56 ms
  copy-back, 110 pieces per frame (4.9 MB): 38.6 ms per frame; now
  0.55 ms

That is 98 ms of a frame (8.6 %) down to about 1 ms. In stacks of the
submitting thread sampled at 10 Hz, VirtualQuery under these two calls
was 47 of 462 samples before and 0 of 189 after.

Two tests run both copies against reserved memory with a committed block
on each side of a hole (no GPU, no game data).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:12 +00:00
github manually merged commit b58d198d95 into gh-pr/322/base 2026-11-26 03:59:14 +00:00
Author
Owner

@⁠ifBars on GitHub · 2026-11-24 02:31 UTC · original

On Windows 10 I compared this with Causeway's previous destination-region query on the same buffers. Median time for a 64 KiB write-back into a touched, committed 64 MiB mapping fell from 205 to 3.86 µs. On a 512 MiB mapping it fell from 4,890 to 3.75 µs. A sparse write spanning a reserved 64 KiB hole went the other way, from 27.6 to 81.9 µs.

Our adaptation also exercises a read-only destination with an unaligned source. The fallback stops the title copy at the inaccessible page and preserves the unmapped-hole behavior on write-back. These are synthetic CPU measurements. We haven't measured story frame time on this change.

**@⁠ifBars** on GitHub · 2026-11-24 02:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7120235910) On Windows 10 I compared this with Causeway's previous destination-region query on the same buffers. Median time for a 64 KiB write-back into a touched, committed 64 MiB mapping fell from 205 to 3.86 µs. On a 512 MiB mapping it fell from 4,890 to 3.75 µs. A sparse write spanning a reserved 64 KiB hole went the other way, from 27.6 to 81.9 µs. Our adaptation also exercises a read-only destination with an unaligned source. The fallback stops the title copy at the inaccessible page and preserves the unmapped-hole behavior on write-back. These are synthetic CPU measurements. We haven't measured story frame time on this change.
Author
Owner

@⁠tcurtsinger on GitHub · 2026-11-24 02:41 UTC · original · edited 2026-11-24 02:55 UTC

Tested f7bfa64 against d2a4bae on Windows 11 build 26300, Ryzen 9 9950X3D. Each value is microseconds per 64 KiB piece copied by the production function into a fully committed, pre-touched pool.

Destination pool Write-back, main → PR Title-to-title copy, main → PR
64 MiB mapped view 119.55 → 2.61 119.66 → 2.61
512 MiB mapped view 1,044.09 → 2.59 1,022.95 → 2.60
512 MiB private allocation 745.52 → 2.65 746.73 → 2.67

Four fresh processes per revision ran in interleaved order. In each process a batch used 32 disjoint destinations, with three warm-up batches and nine timed batches. The table shows medians of the four process medians. We changed the input pattern each batch, verified every copied byte and checked a sentinel on either side. The two title-copy tests in this PR also passed on this machine.

We have since run the user-controlled intro on the RTX 4080 with this PR. The local build also included #87's reporting fix and the free-slot diagnostics on #251. The menu held 30 FPS. The single detailed report above 1,000 draws per frame registered 0.8 FPS at 3,795 draws, including 111.7 ms in the whole copy-back phase for 10.7 MB. The window later reported 433.9 ms per frame (about 2.3 FPS) at 1,925 draws. The game exited after a GPU hang 64.3 seconds after launch. Peak process memory was 22.85 GiB private and 12.84 GiB resident.

The previous build logged four busy samples at 1,205–2,248 draws with 48.5–68.5 ms of copy-back time. The workloads differed, and the phase timer includes both comparing snapshots and writing changed bytes. This single run did not establish a change in intro FPS attributable to this PR. Previous native run.

AI-assisted testing (Codex).

**@⁠tcurtsinger** on GitHub · 2026-11-24 02:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7120382356) · edited 2026-11-24 02:55 UTC Tested `f7bfa64` against `d2a4bae` on Windows 11 build 26300, Ryzen 9 9950X3D. Each value is microseconds per 64 KiB piece copied by the production function into a fully committed, pre-touched pool. | Destination pool | Write-back, main → PR | Title-to-title copy, main → PR | | --- | ---: | ---: | | 64 MiB mapped view | 119.55 → 2.61 | 119.66 → 2.61 | | 512 MiB mapped view | 1,044.09 → 2.59 | 1,022.95 → 2.60 | | 512 MiB private allocation | 745.52 → 2.65 | 746.73 → 2.67 | Four fresh processes per revision ran in interleaved order. In each process a batch used 32 disjoint destinations, with three warm-up batches and nine timed batches. The table shows medians of the four process medians. We changed the input pattern each batch, verified every copied byte and checked a sentinel on either side. The two title-copy tests in this PR also passed on this machine. We have since run the user-controlled intro on the RTX 4080 with this PR. The local build also included #87's reporting fix and the free-slot diagnostics on #251. The menu held 30 FPS. The single detailed report above 1,000 draws per frame registered 0.8 FPS at 3,795 draws, including 111.7 ms in the whole copy-back phase for 10.7 MB. The window later reported 433.9 ms per frame (about 2.3 FPS) at 1,925 draws. The game exited after a GPU hang 64.3 seconds after launch. Peak process memory was 22.85 GiB private and 12.84 GiB resident. The previous build logged four busy samples at 1,205–2,248 draws with 48.5–68.5 ms of copy-back time. The workloads differed, and the phase timer includes both comparing snapshots and writing changed bytes. This single run did not establish a change in intro FPS attributable to this PR. [Previous native run](https://git.gtahub.st/github/Marvisak--VIctory/issues/325). AI-assisted testing (Codex).
Author
Owner

@⁠Kadthicu on GitHub · 2026-11-24 09:33 UTC · original

Small documentation suggestion for copy_mapped: could its doc comment explicitly mention that a failed copy may already have modified the destination prefix? The test with the unmapped middle block checks that the third block stays untouched and leaves the first block unspecified. read() already mentions possible partial copies, so this would make the same contract clear at the caller-facing helper. Reviewed the diff with OpenAI Codex (GPT-6 family). No Windows test run.

**@⁠Kadthicu** on GitHub · 2026-11-24 09:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7127573883) Small documentation suggestion for `copy_mapped`: could its doc comment explicitly mention that a failed copy may already have modified the destination prefix? The test with the unmapped middle block checks that the third block stays untouched and leaves the first block unspecified. `read()` already mentions possible partial copies, so this would make the same contract clear at the caller-facing helper. Reviewed the diff with OpenAI Codex (GPT-6 family). No Windows test run.
Author
Owner

@⁠elamriz on GitHub · 2026-11-24 12:01 UTC · original · edited 2026-11-24 12:10 UTC

Windows RTX 4070 Ti A/B for b58d198. I applied #322 to the same local 6aa72a6 + #454 integration used for the baseline. The title watchdog was enabled for both runs. Both used the hardware adapter (driver 621.14), D3D12 Debug and DRED, a fresh cache, the same scripted input, and the same offline AppContainer setup. Both reached the 300-second harness limit without a device removal or unhandled exception.

Medians of the logged samples below 2 FPS, one run per build:

Build Samples Frame Copy-back GPU
Baseline 27 9,166.7 ms 7,769.6 ms 729.0 ms
+ #322 43 1,566.7 ms 663.6 ms 394.3 ms

This run agrees in direction with #400, with a larger effect on this setup. The reported workload varies, and I have not verified visual playability or run-to-run variance. AI-assisted testing and reporting. No raw logs or title files attached.

Cold-cache repeat with a few local frame captures: 40 logged samples below 2 FPS, median 1,366.4 ms per frame, 340.3 ms copying back, and 361.8 ms on the GPU. The run reached the same 300-second limit without device removal or an unhandled exception. The captures show loading art fading to a black frame. Later black-frame warnings continue while draws are submitted. 3D gameplay remains unverified.

**@⁠elamriz** on GitHub · 2026-11-24 12:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7130858198) · edited 2026-11-24 12:10 UTC Windows RTX 4070 Ti A/B for `b58d198`. I applied #322 to the same local `6aa72a6` + #454 integration used for the baseline. The title watchdog was enabled for both runs. Both used the hardware adapter (driver 621.14), D3D12 Debug and DRED, a fresh cache, the same scripted input, and the same offline AppContainer setup. Both reached the 300-second harness limit without a device removal or unhandled exception. Medians of the logged samples below 2 FPS, one run per build: | Build | Samples | Frame | Copy-back | GPU | | --- | ---: | ---: | ---: | ---: | | Baseline | 27 | 9,166.7 ms | 7,769.6 ms | 729.0 ms | | + #322 | 43 | 1,566.7 ms | 663.6 ms | 394.3 ms | This run agrees in direction with #400, with a larger effect on this setup. The reported workload varies, and I have not verified visual playability or run-to-run variance. AI-assisted testing and reporting. No raw logs or title files attached. Cold-cache repeat with a few local frame captures: 40 logged samples below 2 FPS, median 1,366.4 ms per frame, 340.3 ms copying back, and 361.8 ms on the GPU. The run reached the same 300-second limit without device removal or an unhandled exception. The captures show loading art fading to a black frame. Later black-frame warnings continue while draws are submitted. 3D gameplay remains unverified.
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-24 16:37 UTC · original

Test report on an RTX 3050 6 GB Laptop (i7-13700H, 16 GB RAM, Windows 11 26300), diag build, title 1.0.2.1, Series X profile. Base tree: main ffe310e + #208 + #223 #233 #320 #439 + #452 + #579 (VICTORY_SKIP_WAVE64=mesh), from #1232. #472, #322 and #1024 merge cleanly onto it.

tree world frames frame preparing copies textures GPU copying back
base 35 4,641 ms 2,915 943 242 931 741
+ #472 + #322 + #1024 60 4,101 ms 2,615 607 180 836 604

So about 12% shorter frames, mostly copies (−36%) and copy-back (−18%). One run each, and the three were
not separated.

On this 16 GB machine much of the rest looks like paging: private bytes reach 22.9 GB and the working set is trimmed to 2-5 GB (numbers in #1232).

AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title on my machine and drafted this note; results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-24 16:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7137945947) Test report on an RTX 3050 6 GB Laptop (i7-13700H, 16 GB RAM, Windows 11 26300), diag build, title 1.0.2.1, Series X profile. Base tree: `main` `ffe310e` + #208 + #223 #233 #320 #439 + #452 + #579 (`VICTORY_SKIP_WAVE64=mesh`), from #1232. #472, #322 and #1024 merge cleanly onto it. | tree | world frames | frame | preparing | copies | textures | GPU | copying back | |---|---|---|---|---|---|---|---| | base | 35 | 4,641 ms | 2,915 | 943 | 242 | 931 | 741 | | + #472 + #322 + #1024 | 60 | **4,101 ms** | 2,615 | **607** | 180 | 836 | **604** | So about 12% shorter frames, mostly copies (−36%) and copy-back (−18%). One run each, and the three were not separated. On this 16 GB machine much of the rest looks like paging: private bytes reach 22.9 GB and the working set is trimmed to 2-5 GB (numbers in #1232). AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title on my machine and drafted this note; results are from the runs described.
Author
Owner

@⁠EgoraWyn on GitHub · 2026-11-24 15:13 UTC · original · edited 2026-11-24 17:09 UTC

Test report: NVIDIA RTX 3060 Laptop 6 GB, process held to 4 CPUs. With this PR copy-back drops from 531 ms to 125 ms per world frame; the call it replaces cost 2.35 ms per 64 KiB piece here.

Setup: Windows 11 build 26300, driver 596.21 (32.0.15.9621), i5-12450H, 32 GB RAM, title 1.0.2.1 (own copy), Rust 1.98.1, diag build.
Base: main ffe310e + #493 (c48b240) + #206 (05981dd) + #189 (b472733) + #454 (d2c93fa) + #211 (24a387d) + #492 (b57e10d) + #431 (23ced70) + MIN_DYNAMIC = 1 << 18 (#747) + the log line of #952, plus local timers around the steps of copy_back and the refresh (measuring code only, not for upstream). This PR at b58d198 merges onto it without conflicts. Series S mode, VICTORY_NO_WATCHDOG=1 VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_D3D12_DRED=1, 420 s per run. Figures are for the world phase: from 20 s after the first 5-second log line with more than 100 draws per frame, to the end of the run.

base base + this PR
world phase measured 276 s (39 log lines) 308 s (48 log lines)
frame rate, median of the 5-second lines 0.40 fps 0.60 fps
frame time, median 2634 ms 1761 ms
of it: preparing (copies) 1050 ms (846 ms) 1163 ms (928 ms)
of it: on the GPU 284 ms 278 ms
of it: copying back 531 ms 125 ms
local timers, mean per 5 s: pieces written back 445 614
time inside write_mapped 1046 ms (2.35 ms per piece) 6 ms (0.01 ms per piece)
the byte merge of those pieces 14 ms 19 ms
  • On this machine the cost of copy-back was the write call itself, as the description says; the merge is nothing next to it.
  • No device removal in either run, and the same overlays are drawn.
  • What is left of a frame here is the refresh before each submission: the write-watch queries take 1.7–2.2 s of every 5 s (ranges adding up to 18–26 GB asked per 5 s), and the snapshots for copy-back 0.56–0.65 s (2.2–3.1 GB copied per 5 s).
  • I had measured the same thing from the other side before finding this PR: a plain kernel write tried first, with WriteProcessMemory kept as the second try, gave 132 ms of copy-back per frame and a median of 0.60 fps on the same tree. This PR makes that unnecessary.

One run per column.

Correction, later the same day. The runs above had VICTORY_D3D12_DRED=1, and DRED makes Windows' write-watch queries several times slower on this machine. On a later tree (the base above with this PR, #189 at 54b333f in its emulate mode, the lane fix of #940 and a local change to when refreshes are flushed), the same world run with and without DRED, one run each:

DRED on DRED off
frame time, median 1232 ms 810 ms
frame rate, median 0.80 fps 1.20 fps
write-watch queries, mean per 5 s 1339 ms 229 ms
time inside write_mapped, mean per 5 s 7 ms 9 ms

So the bullet above about the refresh ("the write-watch queries take 1.7–2.2 s of every 5 s") describes DRED, not what is left of a frame. This PR's effect is not touched by that: the write call stays at a few milliseconds per 5 s either way. Without DRED the larger costs here are, per 5 s: the snapshots for copy-back 1.2 s (6.0 GB copied), the stale-page copies of the refresh 1.2 s, and the copy-back loop 0.5 s.

AI use: Claude Code (Claude Fable 5.2) built the trees, wrote the local timers, ran the runs and wrote this report from the logs; a second tool (Codex) checked the numbers against the logs. The hardware, the title copy and the runs are the user's.

**@⁠EgoraWyn** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7135660423) · edited 2026-11-24 17:09 UTC **Test report: NVIDIA RTX 3060 Laptop 6 GB, process held to 4 CPUs. With this PR copy-back drops from 531 ms to 125 ms per world frame; the call it replaces cost 2.35 ms per 64 KiB piece here.** Setup: Windows 11 build 26300, driver 596.21 (32.0.15.9621), i5-12450H, 32 GB RAM, title 1.0.2.1 (own copy), Rust 1.98.1, diag build. Base: `main` `ffe310e` + #493 (`c48b240`) + #206 (`05981dd`) + #189 (`b472733`) + #454 (`d2c93fa`) + #211 (`24a387d`) + #492 (`b57e10d`) + #431 (`23ced70`) + `MIN_DYNAMIC = 1 << 18` (#747) + the log line of #952, plus local timers around the steps of `copy_back` and the refresh (measuring code only, not for upstream). This PR at `b58d198` merges onto it without conflicts. Series S mode, `VICTORY_NO_WATCHDOG=1 VICTORY_SHADER_LOOP_LIMIT=32 VICTORY_D3D12_DRED=1`, 420 s per run. Figures are for the world phase: from 20 s after the first 5-second log line with more than 100 draws per frame, to the end of the run. | | base | base + this PR | |---|---|---| | world phase measured | 276 s (39 log lines) | 308 s (48 log lines) | | frame rate, median of the 5-second lines | 0.40 fps | **0.60 fps** | | frame time, median | 2634 ms | **1761 ms** | | of it: preparing (copies) | 1050 ms (846 ms) | 1163 ms (928 ms) | | of it: on the GPU | 284 ms | 278 ms | | of it: copying back | 531 ms | **125 ms** | | local timers, mean per 5 s: pieces written back | 445 | 614 | | time inside `write_mapped` | 1046 ms (2.35 ms per piece) | 6 ms (0.01 ms per piece) | | the byte merge of those pieces | 14 ms | 19 ms | - On this machine the cost of copy-back was the write call itself, as the description says; the merge is nothing next to it. - No device removal in either run, and the same overlays are drawn. - What is left of a frame here is the refresh before each submission: the write-watch queries take 1.7–2.2 s of every 5 s (ranges adding up to 18–26 GB asked per 5 s), and the snapshots for copy-back 0.56–0.65 s (2.2–3.1 GB copied per 5 s). - I had measured the same thing from the other side before finding this PR: a plain kernel write tried first, with `WriteProcessMemory` kept as the second try, gave 132 ms of copy-back per frame and a median of 0.60 fps on the same tree. This PR makes that unnecessary. One run per column. **Correction, later the same day.** The runs above had `VICTORY_D3D12_DRED=1`, and DRED makes Windows' write-watch queries several times slower on this machine. On a later tree (the base above with this PR, #189 at `54b333f` in its emulate mode, the lane fix of #940 and a local change to when refreshes are flushed), the same world run with and without DRED, one run each: | | DRED on | DRED off | |---|---|---| | frame time, median | 1232 ms | 810 ms | | frame rate, median | 0.80 fps | 1.20 fps | | write-watch queries, mean per 5 s | 1339 ms | 229 ms | | time inside `write_mapped`, mean per 5 s | 7 ms | 9 ms | So the bullet above about the refresh ("the write-watch queries take 1.7–2.2 s of every 5 s") describes DRED, not what is left of a frame. This PR's effect is not touched by that: the write call stays at a few milliseconds per 5 s either way. Without DRED the larger costs here are, per 5 s: the snapshots for copy-back 1.2 s (6.0 GB copied), the stale-page copies of the refresh 1.2 s, and the copy-back loop 0.5 s. *AI use: Claude Code (Claude Fable 5.2) built the trees, wrote the local timers, ran the runs and wrote this report from the logs; a second tool (Codex) checked the numbers against the logs. The hardware, the title copy and the runs are the user's.*
Author
Owner

@⁠Daniel333313131 on GitHub · 2026-11-24 20:29 UTC · original

The AMD side of the #400 measurement for this PR. As on the RTX 5070 Ti, copying back clearly drops. Whole frames are not clearly shorter.

Setup: AMD Radeon RX 7900 XTX 24 GB, driver 32.0.32029.2010; Ryzen 7 9800X3D, 32 GB; Windows 11 10.0.26300. Diag build of this PR's head b58d198 merged alone onto main ffe310e. Each run used its own empty VICTORY_CACHE_DIR, VICTORY_D3D12_DRED=1, and VICTORY_KEYS set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s. The method and the main numbers are in #400.

run frame copies on the GPU copying back device removed
main 1 972 410 ms 178 155 143 s
main 2 873 391 ms 179 135 170 s
main 3 679 267 ms 157 109 76 s
#322 1 674 207 ms 204 52 75 s
#322 2 801 307 ms 140 65 103 s
#322 3 1065 378 ms 213 70 75 s
  • Copying back is 52–70 ms against 109–155 ms on main, outside main's range in every run. That matches what #400 saw on NVIDIA.
  • Copies into title memory (207–378 ms) and whole frames (674–1065 ms) stay within main's spread.
  • All three runs end in a page fault inside a freed texture, the same failure as main on this GPU. That one is addressed by #431, not by this PR. Because removal came early, there are only 5, 10 and 5 world lines per run.
  • Not tested: this PR together with #431, which would give longer runs.

AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.

**@⁠Daniel333313131** on GitHub · 2026-11-24 20:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7143632606) The AMD side of the #400 measurement for this PR. As on the RTX 5070 Ti, copying back clearly drops. Whole frames are not clearly shorter. **Setup:** AMD Radeon RX 7900 XTX 24 GB, driver 32.0.32029.2010; Ryzen 7 9800X3D, 32 GB; Windows 11 10.0.26300. Diag build of this PR's head `b58d198` merged alone onto `main` `ffe310e`. Each run used its own empty `VICTORY_CACHE_DIR`, `VICTORY_D3D12_DRED=1`, and `VICTORY_KEYS` set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s. The method and the `main` numbers are in https://git.gtahub.st/github/Marvisak--VIctory/issues/400. | | run | frame | copies | on the GPU | copying back | device removed | |---|---|---|---|---|---|---| | `main` | 1 | 972 | 410 ms | 178 | 155 | 143 s | | `main` | 2 | 873 | 391 ms | 179 | 135 | 170 s | | `main` | 3 | 679 | 267 ms | 157 | 109 | 76 s | | **#322** | 1 | 674 | 207 ms | 204 | 52 | 75 s | | **#322** | 2 | 801 | 307 ms | 140 | 65 | 103 s | | **#322** | 3 | 1065 | 378 ms | 213 | 70 | 75 s | - Copying back is 52–70 ms against 109–155 ms on `main`, outside `main`'s range in every run. That matches what #400 saw on NVIDIA. - Copies into title memory (207–378 ms) and whole frames (674–1065 ms) stay within `main`'s spread. - All three runs end in a page fault inside a freed texture, the same failure as `main` on this GPU. That one is addressed by #431, not by this PR. Because removal came early, there are only 5, 10 and 5 world lines per run. - Not tested: this PR together with #431, which would give longer runs. **AI use:** Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.
Author
Owner

@⁠Daniel333313131 on GitHub · 2026-11-24 20:43 UTC · original

Follow-up to my comment above: the same test with #431 merged too. #431 keeps the title in the world for longer on this GPU. With both PRs, whole frames are now shorter than with #431 alone.

Setup: as above (RX 7900 XTX, driver 32.0.32029.2010, Ryzen 7 9800X3D, diag build). main ffe310e with #431 23ced70 and this PR b58d198 merged. Each run used its own empty VICTORY_CACHE_DIR, VICTORY_D3D12_DRED=1, and VICTORY_KEYS set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s.

run world lines frame copies on the GPU copying back device removed
main 1 / 2 / 3 16 / 20 / 4 972 / 873 / 679 410 / 391 / 267 178 / 179 / 157 155 / 135 / 109 143 / 170 / 76 s
#431 1 / 2 / 3 21 / 22 / 23 1037 / 936 / 929 441 / 403 / 411 217 / 185 / 170 124 / 126 / 134 169 s / none / none
#431 + #322 1 / 2 / 3 22 / 22 / 23 807 / 814 / 747 367 / 390 / 369 211 / 177 / 143 68 / 67 / 67 none / none / none
  • Copying back is about halved (67–68 ms against 124–134 ms with #431 alone), the same as without #431.
  • With enough world lines per run, whole frames are now clearly shorter: 747–814 ms against 929–1037 ms with #431 alone. That is outside #431's range in every run, about 150–200 ms per frame.
  • Copies into title memory and GPU time stay in the same range.
  • None of the three runs was removed within 180 s, and the log went on to the end of each run.
  • Caveat: three runs per side, and nothing measured past 180 s.

AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.

**@⁠Daniel333313131** on GitHub · 2026-11-24 20:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/322#issuecomment-7143961757) Follow-up to my comment above: the same test with #431 merged too. #431 keeps the title in the world for longer on this GPU. With both PRs, whole frames are now shorter than with #431 alone. **Setup:** as above (RX 7900 XTX, driver 32.0.32029.2010, Ryzen 7 9800X3D, diag build). `main` `ffe310e` with #431 `23ced70` and this PR `b58d198` merged. Each run used its own empty `VICTORY_CACHE_DIR`, `VICTORY_D3D12_DRED=1`, and `VICTORY_KEYS` set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s. | | run | world lines | frame | copies | on the GPU | copying back | device removed | |---|---|---|---|---|---|---|---| | `main` | 1 / 2 / 3 | 16 / 20 / 4 | 972 / 873 / 679 | 410 / 391 / 267 | 178 / 179 / 157 | 155 / 135 / 109 | 143 / 170 / 76 s | | #431 | 1 / 2 / 3 | 21 / 22 / 23 | 1037 / 936 / 929 | 441 / 403 / 411 | 217 / 185 / 170 | 124 / 126 / 134 | 169 s / none / none | | **#431 + #322** | 1 / 2 / 3 | 22 / 22 / 23 | **807 / 814 / 747** | 367 / 390 / 369 | 211 / 177 / 143 | **68 / 67 / 67** | **none / none / none** | - Copying back is about halved (67–68 ms against 124–134 ms with #431 alone), the same as without #431. - With enough world lines per run, whole frames are now clearly shorter: 747–814 ms against 929–1037 ms with #431 alone. That is outside #431's range in every run, about 150–200 ms per frame. - Copies into title memory and GPU time stay in the same range. - None of the three runs was removed within 180 s, and the log went on to the end of each run. - Caveat: three runs per side, and nothing measured past 180 s. **AI use:** Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!322
No description provided.