GPU: batch host mirroring for contiguous descriptor copies #3263

Open
yumaste wants to merge 2 commits from upstream-pr/3265 into main
yumaste commented 2026-11-26 15:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T15:03:19Z.


CopyDescriptorsSimple currently looks up the shader-visible destination heap and locks its pending queue separately for every descriptor. A contiguous, aligned copy into one heap now looks it up once. Pending indices are appended together. Initialized heaps use the existing sync_slots path in bounded batches to skip host slots whose record is already current. Ranges crossing heap boundaries or using a different stride retain the existing per-slot lookup.

An exact self-copy skips the guest byte write and still mirrors the destination, so records written directly into the heap can still become visible. Overlapping ranges with different starts still use memmove semantics. The change is shared across D3D12 adapters and adds no driver-specific defaults.

A synthetic 304-descriptor copy goes from 304 registry lookups to one on this path. The regression covers lazy heap initialization and verifies that a self-copy mirrors a new slot, clears a stale slot, and retains an occupied slot beyond the first batch. The full WARP GPU suite passed twice (247 passed, one ignored); strict Clippy passed. Scoped the existing test-only preparation hook to its own test thread after observing an unrelated test consume the hook during a parallel run. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used.

Inspired by reducing descriptor-store work and batching heap-record work in cool_fox.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5512406211 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T15:03:19Z. --- CopyDescriptorsSimple currently looks up the shader-visible destination heap and locks its pending queue separately for every descriptor. A contiguous, aligned copy into one heap now looks it up once. Pending indices are appended together. Initialized heaps use the existing sync_slots path in bounded batches to skip host slots whose record is already current. Ranges crossing heap boundaries or using a different stride retain the existing per-slot lookup. An exact self-copy skips the guest byte write and still mirrors the destination, so records written directly into the heap can still become visible. Overlapping ranges with different starts still use memmove semantics. The change is shared across D3D12 adapters and adds no driver-specific defaults. A synthetic 304-descriptor copy goes from 304 registry lookups to one on this path. The regression covers lazy heap initialization and verifies that a self-copy mirrors a new slot, clears a stale slot, and retains an occupied slot beyond the first batch. The full WARP GPU suite passed twice (247 passed, one ignored); strict Clippy passed. Scoped the existing test-only preparation hook to its own test thread after observing an unrelated test consume the hook during a parallel run. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used. Inspired by [reducing descriptor-store work](https://github.com/DoubleGhosty/cool_fox/commit/e8d3d918c3ec124fe21d06d33f5200416b45f2b2) and [batching heap-record work](https://github.com/DoubleGhosty/cool_fox/commit/44629de2e648a5f2e205050864286bb2fa1590bf) in cool_fox.
Dukestar69 commented 2026-11-26 15:08:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:08:17Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):

  • Batching contiguous descriptor copies in mirror_copy under one SHADER_HEAPS lookup (with 256-slot sync_slots chunks and a clean fallback for cross-heap/mismatched-stride ranges) and making the test hook WHILE_PREPARING thread-local are clean and sound.
  • cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released (RTX 5090): 22 passed, 0 failed (including descriptor_copies_mirror_batched_slots_before_and_after_host_creation).
  • VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation -- --test-threads=1 (WARP): 1 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6076481866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#pullrequestreview-6076481866). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T15:08:17Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP): - Batching contiguous descriptor copies in `mirror_copy` under one `SHADER_HEAPS` lookup (with 256-slot `sync_slots` chunks and a clean fallback for cross-heap/mismatched-stride ranges) and making the test hook `WHILE_PREPARING` thread-local are clean and sound. - `cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released` (RTX 5090): 22 passed, 0 failed (including `descriptor_copies_mirror_batched_slots_before_and_after_host_creation`). - `VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation -- --test-threads=1` (WARP): 1 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
oni-swr commented 2026-11-26 16:10:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T16:10:03Z.


WARP verification report (test report only, no code changes)

  • PR head: 6c8fc754
  • main: 63bcca43 (control); WARP software adapter forced with VICTORY_WARP=1 VICTORY_D3D12_WARP=1, --features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via VICTORY_DXIL).
  • Each new/changed test run in its own process (--exact), -j 4, synthetic tests only, no game data. Command: cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.
  • New test descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation: passes on the PR (1 passed). The changed tests descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record and descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait also pass (1 passed each).
  • Control on main: the new test only uses existing APIs, so I ran it on main with only the test added. It also passes on main. It guards behaviour the change keeps (contiguous copies still mirror the same slots, and raw writes are picked up), not a bug on main, so it does not distinguish the two.
  • victory-gpu lib suite: PR 247 passed, 0 failed, 1 ignored (1 run); main 246 passed, 0 failed, 1 ignored. No failures.
  • Not tested: physical GPU. Not measured: the lock and lookup cost the change removes.

AI-assisted: verification by Claude Code (Claude Sonnet 5.5)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197272186 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7197272186). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T16:10:03Z. --- WARP verification report (test report only, no code changes) - PR head: `6c8fc754` - main: `63bcca43` (control); WARP software adapter forced with `VICTORY_WARP=1 VICTORY_D3D12_WARP=1`, `--features diagnostics`, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via `VICTORY_DXIL`). - Each new/changed test run in its own process (`--exact`), `-j 4`, synthetic tests only, no game data. Command: `cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>`. - New test `descriptor::tests::descriptor_copies_mirror_batched_slots_before_and_after_host_creation`: **passes on the PR** (1 passed). The changed tests `descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record` and `descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_wait` also pass (1 passed each). - Control on main: the new test only uses existing APIs, so I ran it on main with only the test added. It **also passes on main**. It guards behaviour the change keeps (contiguous copies still mirror the same slots, and raw writes are picked up), not a bug on main, so it does not distinguish the two. - `victory-gpu` lib suite: PR 247 passed, 0 failed, 1 ignored (1 run); main 246 passed, 0 failed, 1 ignored. No failures. - Not tested: physical GPU. Not measured: the lock and lookup cost the change removes. AI-assisted: verification by Claude Code (Claude Sonnet 5.5)
Kajanos commented 2026-11-26 17:36:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kajanos on 2026-11-26T17:36:46Z.


This PR and #3055 merge cleanly but don't compile together. On main 63bcca4 + #3147 + #3047 + #3048 + #3258 #3274 #3061 #3248 #3246 + #3265 + #3055 + #3068:

error[E0599]: no method named `sync_slots` found for reference `&HostHeap` in the current scope
   --> crates\victory-gpu\src\descriptor.rs:201:34
201 |                             host.sync_slots(from, to, start, step);

#3055 replaces the runtime use of HostHeap::sync_slots with sync_ranges and leaves sync_slots under #[cfg(test)], while this PR adds a runtime call to it in descriptor.rs. Whichever lands second needs a rebase onto the other. Both batch heap syncs, so they may also overlap in intent. In that stack I kept #3055 and left this one out.

AI-assisted (Claude Code)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7199322695 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7199322695). Originally posted by [Kajanos](https://github.com/Kajanos) on 2026-11-26T17:36:46Z. --- **This PR and #3055 merge cleanly but don't compile together.** On `main` `63bcca4` + #3147 + #3047 + #3048 + #3258 #3274 #3061 #3248 #3246 + #3265 + #3055 + #3068: ``` error[E0599]: no method named `sync_slots` found for reference `&HostHeap` in the current scope --> crates\victory-gpu\src\descriptor.rs:201:34 201 | host.sync_slots(from, to, start, step); ``` #3055 replaces the runtime use of `HostHeap::sync_slots` with `sync_ranges` and leaves `sync_slots` under `#[cfg(test)]`, while this PR adds a runtime call to it in `descriptor.rs`. Whichever lands second needs a rebase onto the other. Both batch heap syncs, so they may also overlap in intent. In that stack I kept #3055 and left this one out. AI-assisted (Claude Code)
KainanP commented 2026-11-27 13:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-27T13:06:18Z.


I measured this against HostHeap::sync_slots/copy costs in the shape #3425 and borosf's Arc row report, on an RTX 4060 Laptop. It's a large win on the path it targets.

Bench: copy_simple_bench on bench/sync-slots (f233390e, on top of f34bcfb8; both commits cherry-pick onto this PR cleanly). Each frame, 393,216 slots are copied with copy_simple in runs of 1/8/64/1024 to random places in a 2^20-slot placed view heap. Each row runs without and with 5 title threads writing a view every 20 µs. After each row, it checks that every slot's view address is the one its record names. Base 63bcca4 vs this PR's head 6c8fc754, interleaved, medians of 3 runs:

Copies of records the slots already hold (borosf's "heap slots the title copied": 493,568 slots in 36.6 ms is ~74 ns/slot; base here is 71 ns/slot, so this looks like the in-game case):

run length base, alone #3265, alone base, 5 title threads (their wait/frame) #3265, 5 title threads (their wait)
1 43 ms 41 ms 129 ms (76 ms) 108 ms (39 ms)
8 31 ms 11 ms 268 ms (420 ms) 48 ms (50 ms)
64 28 ms 5 ms 256 ms (546 ms) 11 ms (8 ms)
1024 27 ms 3 ms 177 ms (431 ms) 12 ms (33 ms)

Copies that change every record (65,536 slots/frame, 2 runs): the same alone (~45-60 ms both; making the views dominates), and faster under contention for runs ≥ 8 (runs of 64: 167-177 → 50-71 ms; runs of 1024: 167-174 → 45-56 ms). Runs of 1 are unchanged, as expected.

Correctness: 0 wrong slots in every row and run. The PR doesn't touch sync_heaps. In the same harness's heap-sync bench, it sits within noise of base (×0.81-1.04), which I used as the noise control for the other PRs.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7219061729 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7219061729). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-27T13:06:18Z. --- I measured this against `HostHeap::sync_slots`/copy costs in the shape #3425 and borosf's Arc row report, on an RTX 4060 Laptop. It's a large win on the path it targets. **Bench:** `copy_simple_bench` on [`bench/sync-slots`](https://github.com/KainanP/VIctory/commits/bench/sync-slots) (`f233390e`, on top of `f34bcfb8`; both commits cherry-pick onto this PR cleanly). Each frame, 393,216 slots are copied with `copy_simple` in runs of 1/8/64/1024 to random places in a 2^20-slot placed view heap. Each row runs without and with 5 title threads writing a view every 20 µs. After each row, it checks that every slot's view address is the one its record names. Base `63bcca4` vs this PR's head `6c8fc754`, interleaved, medians of 3 runs: **Copies of records the slots already hold** (borosf's "heap slots the title copied": 493,568 slots in 36.6 ms is ~74 ns/slot; base here is 71 ns/slot, so this looks like the in-game case): | run length | base, alone | #3265, alone | base, 5 title threads (their wait/frame) | #3265, 5 title threads (their wait) | |---|---|---|---|---| | 1 | 43 ms | 41 ms | 129 ms (76 ms) | 108 ms (39 ms) | | 8 | 31 ms | **11 ms** | 268 ms (420 ms) | **48 ms** (50 ms) | | 64 | 28 ms | **5 ms** | 256 ms (546 ms) | **11 ms** (8 ms) | | 1024 | 27 ms | **3 ms** | 177 ms (431 ms) | **12 ms** (33 ms) | **Copies that change every record** (65,536 slots/frame, 2 runs): the same alone (~45-60 ms both; making the views dominates), and faster under contention for runs ≥ 8 (runs of 64: 167-177 → 50-71 ms; runs of 1024: 167-174 → 45-56 ms). Runs of 1 are unchanged, as expected. Correctness: 0 wrong slots in every row and run. The PR doesn't touch `sync_heaps`. In the same harness's heap-sync bench, it sits within noise of base (×0.81-1.04), which I used as the noise control for the other PRs. _AI use: Claude Code (Claude Opus 5.5)._
reallyvibe commented 2026-11-29 00:22:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reallyvibe on 2026-11-29T00:22:14Z.


#3139 breaks this PR the same way #3055 does, and the one-line fix costs most of this PR's gain

Following up on Kajanos's note about #3055 above. #3139 (63d630a0) also keeps HostHeap::sync_slots only as a #[cfg(test)] wrapper around sync_ranges. #3139 and this PR (6c8fc754) merge with no conflict (tree fa989c0b, either order), but on that tree:

  • cargo build -p victory-gpu --lib fails: E0599: no method named sync_slots found for reference &HostHeap at descriptor.rs:193:34;
  • cargo test -p victory-gpu --lib --no-run builds, because the test-only wrapper exists. A cargo test run doesn't show the break; only a non-test build (CI's clippy) does, and only on the merged tree.

Whichever of the two lands second needs a change. I tried two:

  • F1 (2 lines): call host.sync_ranges(&[(from, to)], start, step); in mirror_copy. The same line also works against #3055. It builds and passes the correctness checks run here: clippy is clean (default and --all-features), WARP descriptor:: passes 26/26, and with the batched call turned into a no-op this PR's test fails ("a raw write cleared slot 0"). But it gives back most of this PR's gain. Each 256-slot batch then pays sync_ranges's read_into (ReadProcessMemory) plus its range and buffer setup, where sync_slots read the records directly.
  • F3, an experimental alternative (+29/-3 in descriptor/host.rs): keep sync_slots as a production single-range sync with plain reads, i.e. main's body using #3139's with_views. This PR's call site stays as it is, and #3139's sync_heaps path still goes through sync_ranges. It preserves this PR's benchmark performance (table below), and passes clippy (default and --all-features) and WARP descriptor:: 26/26. Its assumption that the records' backing memory stays mapped still needs verification: holding SHADER_HEAPS does not necessarily stop those pages from being unmapped, and a self-copy (dst == src) skips the actual copy, so nothing has just written them. The patch's "a descriptor copy just wrote them" comment doesn't cover that case. #3139 moved sync_ranges to read_into for an earlier probe-to-read race; F3 reintroduces plain reads on the copy path.

KainanP's copy_simple_bench (f233390e), same-record copies, 393,216 slots/frame, no title threads, release, median of 6 interleaved processes, ms:

run length main this PR + #3139 + F1 + #3139 + F3
8 33.9 18.2 54.2 16.9
64 28.1 5.7 17.3 5.9
1024 27.0 3.5 9.2 3.7

0 wrong slots in every row. With F1, runs of 8 come out slower than main. A diagnostic that swaps read_into for a plain copy inside sync_ranges cuts F1's runs of 8 from 54 to 28 ms, so ReadProcessMemory is about two thirds of the overhead and per-call setup is the rest. With 5 title threads, the runs of 64 come out at 68 ms on this PR, 120 ms with F1 and 72 ms with F3 (noisy here). Windows 11, Ryzen 7 7445HS, RTX 4050 Laptop and Radeon 740M (default D3D12 adapter, not logged), a loaded 16 GB machine, synthetic data only.

F3 against the merged tree (experimental)
-    /// Single-range wrapper around [`HostHeap::sync_ranges`].
-    #[cfg(test)]
-    pub(crate) fn sync_slots(&self, first: u32, last: u32, start: u64, step: u64) {
-        self.sync_ranges(&[(first, last)], start, step);
-    }
+    /// A sync of slots `first..last` whose records the caller knows are
+    /// mapped (a descriptor copy just wrote them), at `start` + index ×
+    /// `step`: the diff of [`HostHeap::sync_ranges`] with plain reads instead
+    /// of `read_into`, and no range merging.
+    pub(crate) fn sync_slots(&self, first: u32, last: u32, start: u64, step: u64) {
+        let at = |i: u32| start + u64::from(i) * step;
+        // SAFETY: records in title heap memory the caller found mapped.
+        let records: Vec<[u32; 3]> =
+            (first..last).map(|i| unsafe { (at(i) as *const [u32; 3]).read_unaligned() }).collect();
+        let stale: Vec<u32> = {
+            let made = self.made.lock().unwrap_or_else(|e| e.into_inner());
+            with_views(|views| {
+                (first..last)
+                    .zip(&records)
+                    .filter(|&(i, &[tag, view, generation])| {
+                        let current = tag == VIEW_TAG
+                            && views.get(view as usize).is_some_and(|(_, current)| *current == generation);
+                        match made.get(i as usize) {
+                            Some(&m) if current => m != u64::from(generation) << 32 | u64::from(view),
+                            Some(&m) => m != 0,
+                            None => true,
+                        }
+                    })
+                    .map(|(i, _)| i)
+                    .collect()
+            })
+        };
+        for i in stale {
+            self.mirror(i, at(i), false);
+        }
+    }

Of the 184 open PRs that touch these two files, this is the only one that adds a non-test sync_slots call. The others call it only from tests, or edit the sync_heaps call, which conflicts visibly.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7248064955 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7248064955). Originally posted by [reallyvibe](https://github.com/reallyvibe) on 2026-11-29T00:22:14Z. --- **#3139 breaks this PR the same way #3055 does, and the one-line fix costs most of this PR's gain** Following up on Kajanos's note about #3055 above. #3139 (`63d630a0`) also keeps `HostHeap::sync_slots` only as a `#[cfg(test)]` wrapper around `sync_ranges`. #3139 and this PR (`6c8fc754`) merge with no conflict (tree `fa989c0b`, either order), but on that tree: - `cargo build -p victory-gpu --lib` fails: `E0599: no method named sync_slots found for reference &HostHeap` at `descriptor.rs:193:34`; - `cargo test -p victory-gpu --lib --no-run` builds, because the test-only wrapper exists. A `cargo test` run doesn't show the break; only a non-test build (CI's clippy) does, and only on the merged tree. Whichever of the two lands second needs a change. I tried two: - **F1 (2 lines):** call `host.sync_ranges(&[(from, to)], start, step);` in `mirror_copy`. The same line also works against #3055. It builds and passes the correctness checks run here: clippy is clean (default and `--all-features`), WARP `descriptor::` passes 26/26, and with the batched call turned into a no-op this PR's test fails ("a raw write cleared slot 0"). But it gives back most of this PR's gain. Each 256-slot batch then pays `sync_ranges`'s `read_into` (`ReadProcessMemory`) plus its range and buffer setup, where `sync_slots` read the records directly. - **F3, an experimental alternative (+29/-3 in `descriptor/host.rs`):** keep `sync_slots` as a production single-range sync with plain reads, i.e. main's body using #3139's `with_views`. This PR's call site stays as it is, and #3139's `sync_heaps` path still goes through `sync_ranges`. It preserves this PR's benchmark performance (table below), and passes clippy (default and `--all-features`) and WARP `descriptor::` 26/26. Its assumption that the records' backing memory stays mapped still needs verification: holding `SHADER_HEAPS` does not necessarily stop those pages from being unmapped, and a self-copy (`dst == src`) skips the actual copy, so nothing has just written them. The patch's "a descriptor copy just wrote them" comment doesn't cover that case. #3139 moved `sync_ranges` to `read_into` for an [earlier probe-to-read race](https://github.com/Marvisak/VIctory/pull/3139#issuecomment-7207291570); F3 reintroduces plain reads on the copy path. KainanP's `copy_simple_bench` (`f233390e`), same-record copies, 393,216 slots/frame, no title threads, release, median of 6 interleaved processes, ms: | run length | main | this PR | + #3139 + F1 | + #3139 + F3 | |---|---|---|---|---| | 8 | 33.9 | 18.2 | **54.2** | 16.9 | | 64 | 28.1 | 5.7 | **17.3** | 5.9 | | 1024 | 27.0 | 3.5 | **9.2** | 3.7 | 0 wrong slots in every row. With F1, runs of 8 come out slower than main. A diagnostic that swaps `read_into` for a plain copy inside `sync_ranges` cuts F1's runs of 8 from 54 to 28 ms, so `ReadProcessMemory` is about two thirds of the overhead and per-call setup is the rest. With 5 title threads, the runs of 64 come out at 68 ms on this PR, 120 ms with F1 and 72 ms with F3 (noisy here). Windows 11, Ryzen 7 7445HS, RTX 4050 Laptop and Radeon 740M (default D3D12 adapter, not logged), a loaded 16 GB machine, synthetic data only. <details><summary>F3 against the merged tree (experimental)</summary> ```diff - /// Single-range wrapper around [`HostHeap::sync_ranges`]. - #[cfg(test)] - pub(crate) fn sync_slots(&self, first: u32, last: u32, start: u64, step: u64) { - self.sync_ranges(&[(first, last)], start, step); - } + /// A sync of slots `first..last` whose records the caller knows are + /// mapped (a descriptor copy just wrote them), at `start` + index × + /// `step`: the diff of [`HostHeap::sync_ranges`] with plain reads instead + /// of `read_into`, and no range merging. + pub(crate) fn sync_slots(&self, first: u32, last: u32, start: u64, step: u64) { + let at = |i: u32| start + u64::from(i) * step; + // SAFETY: records in title heap memory the caller found mapped. + let records: Vec<[u32; 3]> = + (first..last).map(|i| unsafe { (at(i) as *const [u32; 3]).read_unaligned() }).collect(); + let stale: Vec<u32> = { + let made = self.made.lock().unwrap_or_else(|e| e.into_inner()); + with_views(|views| { + (first..last) + .zip(&records) + .filter(|&(i, &[tag, view, generation])| { + let current = tag == VIEW_TAG + && views.get(view as usize).is_some_and(|(_, current)| *current == generation); + match made.get(i as usize) { + Some(&m) if current => m != u64::from(generation) << 32 | u64::from(view), + Some(&m) => m != 0, + None => true, + } + }) + .map(|(i, _)| i) + .collect() + }) + }; + for i in stale { + self.mirror(i, at(i), false); + } + } ``` </details> Of the 184 open PRs that touch these two files, this is the only one that adds a non-test `sync_slots` call. The others call it only from tests, or edit the `sync_heaps` call, which conflicts visibly. AI-assisted (Claude Code).
zed6000 commented 2026-11-29 17:41:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zed6000 on 2026-11-29T17:41:52Z.


A/B of this PR on an RX 7900 XTX (native Windows 11, AMD driver 32.0.32029.2010, Ryzen 9 7900X3D), from neonbyte1/VIctory#64.

  • Builds: head 6c8fc7547 merged onto the neonbyte1/VIctory integration tree 8d9b82fd9. The conflicts were adjacent additions, and the merge is eb0d613be on zed6000/VIctory branch eval/64-3265. The control is the same tree without the PR. Both are diag builds sharing one warm pipeline library.
  • Runs: prison yard, median of the last 10 report blocks. 2 control runs and 3 runs with the PR; a third control run was left out, as it was slow in every row and still loading at the capture frames.
ms a frame control with this PR
title frame 379.3 / 373.5 380.4 / 378.5 / 372.6
preparing 144.1 / 141.9 145.0 / 149.6 / 140.7
heap slots the title copied 56.6 / 54.5 59.4 / 57.1 / 55.8
title threads waiting to write views 268.4 / 258.8 288.5 / 281.4 / 251.6
  • Result: no row moves beyond its own spread, and the picture is the same. At frame 1350 the share of pixels differing by more than 32/255 is 2.1-5.4 % between control and PR runs, against 1.9 % control/control and 2.7-5.5 % PR/PR. descriptor:: tests 53/53, the PR's new test included.
  • Not checked here: the runtime's report has no row for time inside CopyDescriptorsSimple, so the 28 → 5 ms copy figure from #3425 is not checked by this. What it shows is that, in this scene on this card, the frame does not move with the PR. On this box the frame follows the heap sync's holds and the view writers' wait (neonbyte1/VIctory#146), and those stay where they were.

AI-assisted (Claude), posted for zed6000; counts and times from VIctory's own report lines; no game data shared.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7259893134 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3265#issuecomment-7259893134). Originally posted by [zed6000](https://github.com/zed6000) on 2026-11-29T17:41:52Z. --- A/B of this PR on an RX 7900 XTX (native Windows 11, AMD driver 32.0.32029.2010, Ryzen 9 7900X3D), from neonbyte1/VIctory#64. - **Builds:** head `6c8fc7547` merged onto the neonbyte1/VIctory integration tree `8d9b82fd9`. The conflicts were adjacent additions, and the merge is `eb0d613be` on zed6000/VIctory branch `eval/64-3265`. The control is the same tree without the PR. Both are diag builds sharing one warm pipeline library. - **Runs:** prison yard, median of the last 10 report blocks. 2 control runs and 3 runs with the PR; a third control run was left out, as it was slow in every row and still loading at the capture frames. | ms a frame | control | with this PR | |---|---|---| | title frame | 379.3 / 373.5 | 380.4 / 378.5 / 372.6 | | preparing | 144.1 / 141.9 | 145.0 / 149.6 / 140.7 | | `heap slots the title copied` | 56.6 / 54.5 | 59.4 / 57.1 / 55.8 | | `title threads waiting to write views` | 268.4 / 258.8 | 288.5 / 281.4 / 251.6 | - **Result:** no row moves beyond its own spread, and the picture is the same. At frame 1350 the share of pixels differing by more than 32/255 is 2.1-5.4 % between control and PR runs, against 1.9 % control/control and 2.7-5.5 % PR/PR. `descriptor::` tests 53/53, the PR's new test included. - **Not checked here:** the runtime's report has no row for time inside `CopyDescriptorsSimple`, so the 28 → 5 ms copy figure from #3425 is not checked by this. What it shows is that, in this scene on this card, the frame does not move with the PR. On this box the frame follows the heap sync's holds and the view writers' wait (neonbyte1/VIctory#146), and those stay where they were. _AI-assisted (Claude), posted for zed6000; counts and times from VIctory's own report lines; no game data shared._
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3265:upstream-pr/3265'
git switch 'upstream-pr/3265'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3265'
git switch 'upstream-pr/3265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3265'
git switch 'upstream-pr/3265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3265'
git switch 'main'
git merge --squash 'upstream-pr/3265'
git switch 'main'
git merge --ff-only 'upstream-pr/3265'
git switch 'main'
git merge 'upstream-pr/3265'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3263
No description provided.