perf(gpu,hle): add opt-in in-place section heap import #3470

Open
legayclightning22 wants to merge 2 commits from upstream-pr/3470 into main
legayclightning22 commented 2026-11-27 04:23:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T04:23:09Z.


Summary

This PR is now scoped to the opt-in in-place section heap path only. The descriptor marks, raw CBV reads, fine write guards and sharded journal from the earlier bundled commits have been split out; the current head does not enable any of those paths.

The title creates its pagefile-backed physical-page sections lazily by default. With VICTORY_PORT_CONSTANTS=1, on a non-low-memory host, sections that fit the bounded budget are committed whole, tracked against a 512 MiB reservation, imported once as D3D12 placed buffers from an owned mapped view, and their mapped title views are fed into the existing memory page table. CPU writes by the title and UAV writes by the emulator then land in the same physical pages, and pages served in place do not schedule a host copy-back. The mapped view is unmapped when the import is dropped; the heap is not opened from the title's file-mapping handle, which leaked commit on Windows 11 26300.

Default path

With VICTORY_PORT_CONSTANTS off (the default):

  • title_memory_reserve_section() returns false; no whole-section SEC_COMMIT is requested.
  • title_memory_section(), title_memory_view(), title_memory_freeing() and title_memory_section_gone() are early returns.
  • No section is imported, no descriptor pair is allocated, and no page-table entry is changed.
  • Wine keeps its existing whole-commit policy; GPU import still requires the opt-in reservation.
  • Low-host detection and the 512 MiB cap remain in force when the switch is on.

Changes

  • victory-gpu::port: replace the inert/leaky open-region hook with bounded reservation/release, committed-section and mapped-view tracking, subrange-preserving remap bookkeeping, generation reporting and default-off early returns.
  • victory-gpu::memory: import eligible sections once as placed buffers from an owned mapped view, add their views to the page table with section-relative offsets, mark those pages IN_PLACE so copy-back is skipped, combine section changes into the table generation, use typed owner keys so a recycled handle cannot reuse an old descriptor pair, and drop imports and unmap views when the runtime closes a section.
  • victory-hle::xmem: reserve/commit eligible sections only under the opt-in, fall back to lazy SEC_RESERVE if the whole commit is refused, skip per-view VirtualAlloc commits for sections already committed whole, release reservations on creation failure, and report mapped views through the existing hook.
  • victory-gpu::watch: use the remap hook as an idempotent invalidation funnel for in-place views, preserving compatibility with remaps that do not pass through xmem::unmap.
  • Add focused tests for bounded reservations, default-off inertness, subrange remaps, section-offset mapping, copy precedence and IN_PLACE pages.

Verification

  • cargo test --locked -p victory-gpu -p victory-hle -p victory-loader -p victory-shader: 236 passed, 3 failed, 1 ignored. The five new tests pass. The same three WARP/descriptor-cap failures (dynamic_slots_are_held_until_released, a_texture_written_in_one_format_reads_in_another_through_a_placed_view, lists_share_a_table_and_copies_keep_their_views) also occur on the unmodified PR head fb52e2a; they are not introduced here.
  • cargo check --all-targets --locked: passed.
  • cargo clippy --locked -p victory-gpu -p victory-hle -p victory-loader -p victory-shader --all-targets --all-features -- -D warnings: passed.
  • cargo xtask policy: passed (192 files ok).

A local RDNA4/gameplay reproduction is not available here, so the visual findings still need a reviewer rerun on this head with the switch off and on.

Overlap with #2494

This patch and #2494 both touch xmem.rs and memory.rs. They use the same hook points (title_memory_view, title_memory_remapped) and both keep the section commit bounded; this PR does not change watch.rs. If both land, the remaining work is to choose one section-commit policy rather than stack two reservations.

AI-assisted: local validation, summaries and reviewer reply prepared with the OpenCode harness; all reported commands were run locally.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5521155966 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-27T04:23:09Z. --- ## Summary This PR is now scoped to the opt-in **in-place section heap** path only. The descriptor marks, raw CBV reads, fine write guards and sharded journal from the earlier bundled commits have been split out; the current head does not enable any of those paths. The title creates its pagefile-backed physical-page sections lazily by default. With `VICTORY_PORT_CONSTANTS=1`, on a non-low-memory host, sections that fit the bounded budget are committed whole, tracked against a 512 MiB reservation, imported once as D3D12 placed buffers from an owned mapped view, and their mapped title views are fed into the existing memory page table. CPU writes by the title and UAV writes by the emulator then land in the same physical pages, and pages served in place do not schedule a host copy-back. The mapped view is unmapped when the import is dropped; the heap is not opened from the title's file-mapping handle, which leaked commit on Windows 11 26300. ## Default path With `VICTORY_PORT_CONSTANTS` off (the default): - `title_memory_reserve_section()` returns `false`; no whole-section `SEC_COMMIT` is requested. - `title_memory_section()`, `title_memory_view()`, `title_memory_freeing()` and `title_memory_section_gone()` are early returns. - No section is imported, no descriptor pair is allocated, and no page-table entry is changed. - Wine keeps its existing whole-commit policy; GPU import still requires the opt-in reservation. - Low-host detection and the 512 MiB cap remain in force when the switch is on. ## Changes - `victory-gpu::port`: replace the inert/leaky open-region hook with bounded reservation/release, committed-section and mapped-view tracking, subrange-preserving remap bookkeeping, generation reporting and default-off early returns. - `victory-gpu::memory`: import eligible sections once as placed buffers from an owned mapped view, add their views to the page table with section-relative offsets, mark those pages `IN_PLACE` so copy-back is skipped, combine section changes into the table generation, use typed owner keys so a recycled handle cannot reuse an old descriptor pair, and drop imports and unmap views when the runtime closes a section. - `victory-hle::xmem`: reserve/commit eligible sections only under the opt-in, fall back to lazy `SEC_RESERVE` if the whole commit is refused, skip per-view `VirtualAlloc` commits for sections already committed whole, release reservations on creation failure, and report mapped views through the existing hook. - `victory-gpu::watch`: use the remap hook as an idempotent invalidation funnel for in-place views, preserving compatibility with remaps that do not pass through `xmem::unmap`. - Add focused tests for bounded reservations, default-off inertness, subrange remaps, section-offset mapping, copy precedence and `IN_PLACE` pages. ## Verification - `cargo test --locked -p victory-gpu -p victory-hle -p victory-loader -p victory-shader`: **236 passed, 3 failed, 1 ignored**. The five new tests pass. The same three WARP/descriptor-cap failures (`dynamic_slots_are_held_until_released`, `a_texture_written_in_one_format_reads_in_another_through_a_placed_view`, `lists_share_a_table_and_copies_keep_their_views`) also occur on the unmodified PR head `fb52e2a`; they are not introduced here. - `cargo check --all-targets --locked`: passed. - `cargo clippy --locked -p victory-gpu -p victory-hle -p victory-loader -p victory-shader --all-targets --all-features -- -D warnings`: passed. - `cargo xtask policy`: passed (192 files ok). A local RDNA4/gameplay reproduction is not available here, so the visual findings still need a reviewer rerun on this head with the switch off and on. ## Overlap with #2494 This patch and #2494 both touch `xmem.rs` and `memory.rs`. They use the same hook points (`title_memory_view`, `title_memory_remapped`) and both keep the section commit bounded; this PR does not change `watch.rs`. If both land, the remaining work is to choose one section-commit policy rather than stack two reservations. AI-assisted: local validation, summaries and reviewer reply prepared with the OpenCode harness; all reported commands were run locally.
borosf commented 2026-11-27 07:21:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T07:21:31Z.


@legayclightning22 — I compared the three in-place PRs in #880 (comment 7212390146). Two overlaps from it: this PR and #2494 both touch xmem.rs and watch.rs (yours changes the guards' lock to shared and journals per-block writes, #2494 adds a section hook), and the in-place heap here cannot be judged against the other two while it is bundled with the descriptor marks, raw CBV and journal — splitting it would let each part be decided on its own.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212393637 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7212393637). Originally posted by [borosf](https://github.com/borosf) on 2026-11-27T07:21:31Z. --- @legayclightning22 — I compared the three in-place PRs in #880 (comment 7212390146). Two overlaps from it: this PR and #2494 both touch `xmem.rs` and `watch.rs` (yours changes the guards' lock to shared and journals per-block writes, #2494 adds a section hook), and the in-place heap here cannot be judged against the other two while it is bundled with the descriptor marks, raw CBV and journal — splitting it would let each part be decided on its own.
oddmaniv commented 2026-11-27 08:19:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-27T08:19:02Z.


Independent verification of the PR author's concurrent WARP pipeline/draw test at 616b6f903ce51aebd056de4b9fc2196d59085007.

cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture

Tree Result
Unmodified PR head 1 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 1 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 1 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7213400173 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7213400173). Originally posted by [oddmaniv](https://github.com/oddmaniv) on 2026-11-27T08:19:02Z. --- Independent verification of the PR author's concurrent WARP pipeline/draw test at `616b6f903ce51aebd056de4b9fc2196d59085007`. `cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 1 passed, 0 failed, 0 ignored; native exit 0 | | Unmodified main | 1 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 1 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
futurepro62 commented 2026-11-27 10:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T10:06:24Z.


NVIDIA full-suite run, to go with the reports above by oddmaniv, since none of them names a GPU run. Tested exact head 616b6f9 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 887 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: caps_disable_low_hosts, only_32_bit_graphics_memory_is_wanted_with_the_switch, a_stretch_of_one_committed_section_is_found, raw_table_views_need_sixteen_bytes, raw_reads_follow_the_shader_switch, marks_layout_matches_the_loader, marked_slots_are_taken_once_as_runs, audit_pages_are_bounded_and_round_robin, plan_parts_keeps_marked_runs_and_check_pages_disjoint, ranges_name_their_parts, claims_are_per_shard_and_per_generation, advancing_settles_old_claims, without_the_switch_every_page_is_fresh, test_flags_are_thread_local, busy_claims_are_per_block, shared_guards_yield_to_a_writer, the_sites_lea_their_stores_address, byte_check_gates_every_site, other_bytes_are_left_alone, raw_root_cbv_needs_the_switch_and_a_root_descriptor, constants_raw_is_opt_in.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7215480791 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7215480791). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T10:06:24Z. --- NVIDIA full-suite run, to go with the reports above by oddmaniv, since none of them names a GPU run. Tested exact head `616b6f9` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **887 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `caps_disable_low_hosts`, `only_32_bit_graphics_memory_is_wanted_with_the_switch`, `a_stretch_of_one_committed_section_is_found`, `raw_table_views_need_sixteen_bytes`, `raw_reads_follow_the_shader_switch`, `marks_layout_matches_the_loader`, `marked_slots_are_taken_once_as_runs`, `audit_pages_are_bounded_and_round_robin`, `plan_parts_keeps_marked_runs_and_check_pages_disjoint`, `ranges_name_their_parts`, `claims_are_per_shard_and_per_generation`, `advancing_settles_old_claims`, `without_the_switch_every_page_is_fresh`, `test_flags_are_thread_local`, `busy_claims_are_per_block`, `shared_guards_yield_to_a_writer`, `the_sites_lea_their_stores_address`, `byte_check_gates_every_site`, `other_bytes_are_left_alone`, `raw_root_cbv_needs_the_switch_and_a_root_descriptor`, `constants_raw_is_opt_in`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
legayclightning22 commented 2026-11-27 13:41:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T13:41:36Z.


Thanks @borosf for checking the overlap with #880 and #2494. Splitting this makes total sense—I will separate the in-place graphics heap (port.rs / xmem.rs) into its own focused PR so it can be judged independently against the other #880 approaches, and keep this PR scoped cleanly to the opt-in descriptor marks, raw CBV reads, fine write guards, and sharded submit journal.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7219820948 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7219820948). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-27T13:41:36Z. --- Thanks @borosf for checking the overlap with #880 and #2494. Splitting this makes total sense—I will separate the in-place graphics heap (`port.rs` / `xmem.rs`) into its own focused PR so it can be judged independently against the other #880 approaches, and keep this PR scoped cleanly to the opt-in descriptor marks, raw CBV reads, fine write guards, and sharded submit journal.
rpmaster2 commented 2026-11-27 18:07:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-27T18:07:02Z.


RDNA4 (RX 9070 XT, 32 GB): the PR regresses the world even with every flag off; with the ports on it is unplayable and the copies balloon.

Setup

GPU Radeon RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2, driver 32.0.32029.2010, host wave lanes min=32 max=64
CPU / RAM Ryzen 5 5600 (6 cores / 12 threads), 32 GB DDR4-3600, page file 32-48 GB on the game NVMe
OS Windows 11 10.0.26100.9974
Build this PR, 616b6f9, cargo build --locked --profile diag -p victory --features diagnostics (27.6 s)
Title 1.0.2.1, the same dump and the same save for every run
Settings --console series-x, VICTORY_PRESENT_TARGET=1x1:1, scripted keys, nothing else
Caches shader and pipeline caches warm (cache-upstream, built by translate --cache --pipelines 28,164 pipelines), the driver's own shader cache emptied and the machine rebooted before the pair, so both runs start from the same state

Method: two runs of 300 s, base first (no flags) and then with VICTORY_PORT_CBV=1 VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1; private bytes, working set, free RAM, commit and page-file usage sampled every 20 s.

Results

base, no flags + PORT_CBV/_GUARD/_JOURNAL control: main 63bcca4, same machine
frames 0.3-1.4 fps, 693-3,351 ms 0.3-1.0 fps, 1,029-3,111 ms 0.5-1.2 fps, 810-2,126 ms
draws a frame 627-1,953 684-817 2,004-7,195
copies 33-99 ms, 76-203 MB 165-247 ms, 235-609 MB 137-492 ms, 465-994 MB
copy-back 105-109 ms 95-109 ms 104-142 ms
on the GPU 98-100 ms 65-147 ms 211-270 ms
black frames logged 3 4 5
faults 0 0 0

Memory, sampled every 20 s:

base:  15.6 -> 19.7 -> 23.5 -> 25.1 GB private; page file 99 MB -> 2.8 GB at 300 s
ports: 15.1 -> 18.4 -> 19.2 -> 24.3 GB private; page file ~1.0 GB throughout
main:  15.6 -> 25.6 -> 28.1 GB private; page file 2.86 GB

What was on screen

  • base, no flags: black screen from the start, white by the end of the 300 s; the picture never assembled. Draw counts confirm it: 627-1,953 against 2,004-7,195 on main.
  • with the ports: the start splash takes minutes to come up, the picture is black, and the audio plays in bursts of a fraction of a second every few seconds. Not playable in any sense.

That is with all port flags at their default (off) in the first run, which is the part I would look at first: on this card the PR changes the world even when the switches are not set. The signature (black, then white, subtitle text drawn over itself, very low draw counts) is the same one I saw when testing the in-place sections of #2494, so my guess is that the in-place heap or the descriptor marks are taking effect outside their flag, or that they change the copy path for ranges the switch was meant to leave alone. That is a guess from the outside; the logs above are the facts.

Also worth noting for the ports run: copies go up, not down (235-609 MB a frame against 76-203 MB in the base run and 465-994 MB on main), and dropped stays at 314-455 a frame, so the switches are not doing here what they do in the AMD fork on the same card, where PORT_CBV and the journal were worth ~10 ms and the copies fell.

What would help me help you

  • tell me whether the in-place path is supposed to be inert without a flag; if it is, this is a plain bug on RDNA4 and I can bisect it inside the PR by reverting file by file on this card;
  • if you want the flags judged separately, I can run PORT_CBV alone, PORT_GUARD alone and PORT_JOURNAL alone, 5 minutes each, on the same save — I have the machine and the warm caches, it is ~15 minutes of runs;
  • for reference, the AMD fork's own port switches on this card gave: base 59.8-61.4 ms, PORT_* all on 48.7-51.1 ms in a scene of ~3,000 draws, with the copies halved. So the idea is sound; what I see here is that this implementation, on RDNA4, does not reach that state.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; counts, switches and driver version only, no game files or paths.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7225141950 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7225141950). Originally posted by [rpmaster2](https://github.com/rpmaster2) on 2026-11-27T18:07:02Z. --- **RDNA4 (RX 9070 XT, 32 GB): the PR regresses the world even with every flag off; with the ports on it is unplayable and the copies balloon.** ## Setup | | | |---|---| | GPU | Radeon RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2, driver 32.0.32029.2010, `host wave lanes min=32 max=64` | | CPU / RAM | Ryzen 5 5600 (6 cores / 12 threads), 32 GB DDR4-3600, page file 32-48 GB on the game NVMe | | OS | Windows 11 10.0.26100.9974 | | Build | this PR, `616b6f9`, `cargo build --locked --profile diag -p victory --features diagnostics` (27.6 s) | | Title | 1.0.2.1, the same dump and the same save for every run | | Settings | `--console series-x`, `VICTORY_PRESENT_TARGET=1x1:1`, scripted keys, nothing else | | Caches | shader and pipeline caches warm (`cache-upstream`, built by `translate --cache --pipelines` 28,164 pipelines), the driver's own shader cache emptied and the machine rebooted before the pair, so both runs start from the same state | Method: two runs of 300 s, base first (no flags) and then with `VICTORY_PORT_CBV=1 VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1`; private bytes, working set, free RAM, commit and page-file usage sampled every 20 s. ## Results | | base, no flags | + `PORT_CBV`/`_GUARD`/`_JOURNAL` | control: `main` 63bcca4, same machine | |---|---|---|---| | frames | 0.3-1.4 fps, 693-3,351 ms | 0.3-1.0 fps, 1,029-3,111 ms | 0.5-1.2 fps, 810-2,126 ms | | draws a frame | 627-1,953 | 684-817 | **2,004-7,195** | | copies | 33-99 ms, 76-203 MB | **165-247 ms, 235-609 MB** | 137-492 ms, 465-994 MB | | copy-back | 105-109 ms | 95-109 ms | 104-142 ms | | on the GPU | 98-100 ms | 65-147 ms | 211-270 ms | | black frames logged | 3 | 4 | 5 | | faults | 0 | 0 | 0 | Memory, sampled every 20 s: ``` base: 15.6 -> 19.7 -> 23.5 -> 25.1 GB private; page file 99 MB -> 2.8 GB at 300 s ports: 15.1 -> 18.4 -> 19.2 -> 24.3 GB private; page file ~1.0 GB throughout main: 15.6 -> 25.6 -> 28.1 GB private; page file 2.86 GB ``` ## What was on screen - **base, no flags**: black screen from the start, white by the end of the 300 s; the picture never assembled. Draw counts confirm it: 627-1,953 against 2,004-7,195 on `main`. - **with the ports**: the start splash takes minutes to come up, the picture is black, and the audio plays in bursts of a fraction of a second every few seconds. Not playable in any sense. That is with **all port flags at their default (off)** in the first run, which is the part I would look at first: on this card the PR changes the world even when the switches are not set. The signature (black, then white, subtitle text drawn over itself, very low draw counts) is the same one I saw when testing the in-place sections of #2494, so my guess is that the in-place heap or the descriptor marks are taking effect outside their flag, or that they change the copy path for ranges the switch was meant to leave alone. That is a guess from the outside; the logs above are the facts. Also worth noting for the ports run: copies go *up*, not down (235-609 MB a frame against 76-203 MB in the base run and 465-994 MB on `main`), and `dropped` stays at 314-455 a frame, so the switches are not doing here what they do in the AMD fork on the same card, where `PORT_CBV` and the journal were worth ~10 ms and the copies fell. ## What would help me help you - tell me whether the in-place path is supposed to be inert without a flag; if it is, this is a plain bug on RDNA4 and I can bisect it inside the PR by reverting file by file on this card; - if you want the flags judged separately, I can run `PORT_CBV` alone, `PORT_GUARD` alone and `PORT_JOURNAL` alone, 5 minutes each, on the same save — I have the machine and the warm caches, it is ~15 minutes of runs; - for reference, the AMD fork's own port switches on this card gave: base 59.8-61.4 ms, `PORT_*` all on 48.7-51.1 ms in a scene of ~3,000 draws, with the copies halved. So the idea is sound; what I see here is that this implementation, on RDNA4, does not reach that state. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs; counts, switches and driver version only, no game files or paths.
legayclightning22 commented 2026-11-28 04:41:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-28T04:41:29Z.


Thanks @rpmaster2 and @borosf — pushed an updated commit gating every in-place heap and descriptor-mark path strictly behind its opt-in switch so default-off execution is identical to upstream/main and preventing redundant copy inflation when ports are enabled.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234198177 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7234198177). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-28T04:41:29Z. --- Thanks @rpmaster2 and @borosf — pushed an updated commit gating every in-place heap and descriptor-mark path strictly behind its opt-in switch so default-off execution is identical to `upstream/main` and preventing redundant copy inflation when ports are enabled.
rpmaster2 commented 2026-11-28 08:35:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-28T08:35:55Z.


RDNA4 (RX 9070 XT, 32 GB): the gating commit helps the default path but does not make it main, and the ports still leave the character materials wrong. Four runs, old and fresh save.

Setup: RX 9070 XT 16 GB, Adrenalin 26.11.2 (32.0.32029.2010), Ryzen 5 5600, 32 GB DDR4-3600, Windows 11 10.0.26100.9974. This PR at fb52e2a, cargo build --locked --profile diag -p victory --features diagnostics (35.9 s). --console series-x, VICTORY_PRESENT_TARGET=1x1:1, shader and pipeline caches warm, driver cache emptied after a reboot. Each run 300 s, memory sampled every 20 s, and a person watching the screen (draw counters alone have fooled me before — see my correction in #2428).

Two saves: old = the state we have used all week (prologue/interior), fresh = 7952987A moved aside so the title's own first-run setup is redone, then played with scripted keys (Enter at 4, 8, 12, 16, 20, 25, 30, 40, 50, 60 s).

The four runs

run frames draws copies black private (peak) page file on screen
old save, no flags 0.8-1.0 fps, 1,004-1,251 ms 3,142-6,664 88-162 ms, 196-503 MB 48 27.7 GB 2.76 GB grey/black alternating, letterboxed card with no text, subtitles drawn over each other
old save, PORT_CBV+_GUARD+_JOURNAL 30 fps at 6-10 draws, then 0.4-0.7 fps, 1,469-2,799 ms 10, then 2,356-2,796 up to 910.9 ms, 1,885.9 MB in one frame 4 23.5 GB at 100 s 0.97 GB stuck in menus with 1,842 pipelines queued; faint prison outlines only at the end
fresh save, no flags 1.3-1.7 fps, 600-775 ms 526-812 106-152 ms, 399-557 MB 6 26.4 GB, then fell to 13.7 GB at 180 s (title relaunched) 2.7 GB partial scene: fence, palm trees; the male lead appeared in a car at the end; no NPCs
fresh save, ports on 1.8-3.2 fps, 314-556 ms 1,581-1,753 60-247 ms, 288-468 MB 21 32.5 GB peak, 30.9 GB at 300 s 3.9 GB the scene plays (slideshow); both leads visible but with black skin; police never appear; background buildings missing; skin was correct in one small scene and went again at the next

Control on the same machine, main 63bcca4, old save: 0.5-1.2 fps, 810-2,126 ms, 2,004-7,195 draws, copies 137-492 ms / 465-994 MB, private 26.2-27.6 GB, 5 black frames.

What I take from it

  • The default-off path improved but is not main yet. The white screen and the 627-1,953-draw collapse of 616b6f9 are gone; the new head draws 3,142-6,664 on the old save like main does. But it logs 48 black frames where main logs 5, and the picture is grey/black with overlapping subtitles, which main does not do on the same save. So "default-off execution identical to upstream/main" is not what this card sees.
  • The ports still fill the frame badly. On the old save they stall in the menus (6-10 draws, 1,842 pipelines queued) and produce a frame with 1,885.9 MB of copies — the copy inflation the commit was meant to prevent is still there on this card, at its worst so far.
  • The fresh save is the interesting one. With the ports it is the best this machine has run upstream: 1,581-1,753 draws at 1.8-3.2 fps / 314-556 ms. The scene plays. But both leads have black skin, the police never draw, background buildings are missing, and the skin came back for one small scene and went again — i.e. a per-scene material/texture problem, not a permanent one.
  • Memory is the ceiling in the best run: 32.5 GB peak private, 3.9 GB of page file, 1.0 GB free RAM at 260 s. That is the 32 GB machine, not the PR, but it bounds what can be measured here.

What I would try next, if useful

  1. Take the fresh save and run one port flag at a time (PORT_CBV alone, then _GUARD, then _JOURNAL), 5 min each: on the old save the three together stall the menus, and it would be good to know which one does it.
  2. With the ports on and the fresh save, dump the skin material's translated shader and its texture view at the moment the skin is black (VICTORY_SHADER_SAVE, and whatever the fork's VICTORY_TEXTURE_STORE equivalent is here); if the draw is there and the texture is not, that is a different bug from the one I can see from outside.
  3. If you want the main comparison on the fresh save too, I can do that — I only have the old-save control so far.

I have the machine and warm caches, so any of these is a 20-40 minute loop.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and the observations of the person at the screen; counts and versions only, no game files or paths.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236686436 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7236686436). Originally posted by [rpmaster2](https://github.com/rpmaster2) on 2026-11-28T08:35:55Z. --- **RDNA4 (RX 9070 XT, 32 GB): the gating commit helps the default path but does not make it `main`, and the ports still leave the character materials wrong. Four runs, old and fresh save.** Setup: RX 9070 XT 16 GB, Adrenalin 26.11.2 (32.0.32029.2010), Ryzen 5 5600, 32 GB DDR4-3600, Windows 11 10.0.26100.9974. This PR at `fb52e2a`, `cargo build --locked --profile diag -p victory --features diagnostics` (35.9 s). `--console series-x`, `VICTORY_PRESENT_TARGET=1x1:1`, shader and pipeline caches warm, driver cache emptied after a reboot. Each run 300 s, memory sampled every 20 s, and a person watching the screen (draw counters alone have fooled me before — see my correction in #2428). Two saves: **old** = the state we have used all week (prologue/interior), **fresh** = `7952987A` moved aside so the title's own first-run setup is redone, then played with scripted keys (`Enter` at 4, 8, 12, 16, 20, 25, 30, 40, 50, 60 s). ## The four runs | run | frames | draws | copies | black | private (peak) | page file | on screen | |---|---|---|---|---|---|---|---| | old save, no flags | 0.8-1.0 fps, 1,004-1,251 ms | 3,142-6,664 | 88-162 ms, 196-503 MB | **48** | 27.7 GB | 2.76 GB | grey/black alternating, letterboxed card with no text, subtitles drawn over each other | | old save, `PORT_CBV`+`_GUARD`+`_JOURNAL` | 30 fps at 6-10 draws, then 0.4-0.7 fps, 1,469-2,799 ms | 10, then 2,356-2,796 | up to **910.9 ms, 1,885.9 MB in one frame** | 4 | 23.5 GB at 100 s | 0.97 GB | stuck in menus with 1,842 pipelines queued; faint prison outlines only at the end | | fresh save, no flags | 1.3-1.7 fps, 600-775 ms | 526-812 | 106-152 ms, 399-557 MB | 6 | 26.4 GB, then fell to 13.7 GB at 180 s (title relaunched) | 2.7 GB | partial scene: fence, palm trees; the male lead appeared in a car at the end; no NPCs | | fresh save, ports on | **1.8-3.2 fps, 314-556 ms** | 1,581-1,753 | 60-247 ms, 288-468 MB | **21** | **32.5 GB peak**, 30.9 GB at 300 s | 3.9 GB | the scene plays (slideshow); both leads visible but with **black skin**; police never appear; background buildings missing; skin was correct in one small scene and went again at the next | Control on the same machine, `main` `63bcca4`, old save: 0.5-1.2 fps, 810-2,126 ms, 2,004-7,195 draws, copies 137-492 ms / 465-994 MB, private 26.2-27.6 GB, **5 black frames**. ## What I take from it - **The default-off path improved but is not `main` yet.** The white screen and the 627-1,953-draw collapse of `616b6f9` are gone; the new head draws 3,142-6,664 on the old save like `main` does. But it logs **48 black frames where `main` logs 5**, and the picture is grey/black with overlapping subtitles, which `main` does not do on the same save. So "default-off execution identical to `upstream/main`" is not what this card sees. - **The ports still fill the frame badly.** On the old save they stall in the menus (6-10 draws, 1,842 pipelines queued) and produce a frame with **1,885.9 MB of copies** — the copy inflation the commit was meant to prevent is still there on this card, at its worst so far. - **The fresh save is the interesting one.** With the ports it is the best this machine has run upstream: 1,581-1,753 draws at 1.8-3.2 fps / 314-556 ms. The scene plays. But both leads have **black skin**, the police never draw, background buildings are missing, and the skin came back for one small scene and went again — i.e. a per-scene material/texture problem, not a permanent one. - **Memory** is the ceiling in the best run: 32.5 GB peak private, 3.9 GB of page file, 1.0 GB free RAM at 260 s. That is the 32 GB machine, not the PR, but it bounds what can be measured here. ## What I would try next, if useful 1. Take the fresh save and run **one port flag at a time** (`PORT_CBV` alone, then `_GUARD`, then `_JOURNAL`), 5 min each: on the old save the three together stall the menus, and it would be good to know which one does it. 2. With the ports on and the fresh save, dump the skin material's translated shader and its texture view at the moment the skin is black (`VICTORY_SHADER_SAVE`, and whatever the fork's `VICTORY_TEXTURE_STORE` equivalent is here); if the draw is there and the texture is not, that is a different bug from the one I can see from outside. 3. If you want the `main` comparison on the fresh save too, I can do that — I only have the old-save control so far. I have the machine and warm caches, so any of these is a 20-40 minute loop. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and the observations of the person at the screen; counts and versions only, no game files or paths.
legayclightning22 commented 2026-11-28 20:53:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-28T20:53:53Z.


Thanks @rpmaster2 and @borosf. I have narrowed this PR to the opt-in in-place section heap only. The descriptor marks, raw CBV, fine guard and sharded journal work from the earlier bundled commits is no longer in this branch, so PORT_CBV / PORT_GUARD / PORT_JOURNAL runs no longer exercise this PR.

@rpmaster2 — yes: the in-place path is intended to be completely inert without VICTORY_PORT_CONSTANTS=1. In the updated head, title_memory_reserve_section() returns false, the section/view hooks early-return, nothing is imported into D3D12, and no page-table entry or copy-back decision changes. Wine keeps its existing whole-commit policy, and GPU import still requires the opt-in reservation. The default-off residual you saw at fb52e2a came from the old inert/leaky open-region hook, which has now been removed.

Could you rerun this head on the RDNA4 machine with:

  1. no flags at all, and
  2. VICTORY_PORT_CONSTANTS=1 only, same save and warm caches?

If the grey/black image and excess black frames remain in run 1, that is not this patch and I will help bisect it against main. If the black skin / missing police / missing buildings remain in run 2, please capture the translated shader and texture view for the skin draw (VICTORY_SHADER_SAVE plus the texture-store equivalent) at the moment the skin is black; that will tell us whether the section page table or the material/texture path is at fault. I do not have an RDNA4 host locally, so I cannot reproduce those visuals myself.

@borosf — agreed on the overlap. This branch now deliberately uses the same xmem.rs / memory.rs hook points as #2494, keeps watch::title_memory_remapped as the invalidation funnel, and restores the SEC_COMMIT → SEC_RESERVE fallback so commit pressure does not fail the title's allocation. The remaining differences are intentional policy choices: this PR is off by default, low-host gated, and bounded to 512 MiB total instead of #2494's always-on per-section commit. If both land, we should choose one policy rather than stack two reservations.

Local validation on this head: cargo check --all-targets --locked, strict Clippy for the four affected crates, and cargo xtask policy pass. The four-crate test suite adds five passing tests (231 → 236 passes); the same three WARP/descriptor-cap failures also occur on the untouched PR head.

AI-assisted: comment prepared with the OpenCode harness from the local diff and validation logs; all reported commands were run locally.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7245623676 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7245623676). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-28T20:53:53Z. --- Thanks @rpmaster2 and @borosf. I have narrowed this PR to the **opt-in in-place section heap only**. The descriptor marks, raw CBV, fine guard and sharded journal work from the earlier bundled commits is no longer in this branch, so `PORT_CBV` / `PORT_GUARD` / `PORT_JOURNAL` runs no longer exercise this PR. @rpmaster2 — yes: the in-place path is intended to be completely inert without `VICTORY_PORT_CONSTANTS=1`. In the updated head, `title_memory_reserve_section()` returns `false`, the section/view hooks early-return, nothing is imported into D3D12, and no page-table entry or copy-back decision changes. Wine keeps its existing whole-commit policy, and GPU import still requires the opt-in reservation. The default-off residual you saw at `fb52e2a` came from the old inert/leaky open-region hook, which has now been removed. Could you rerun this head on the RDNA4 machine with: 1. no flags at all, and 2. `VICTORY_PORT_CONSTANTS=1` only, same save and warm caches? If the grey/black image and excess black frames remain in run 1, that is not this patch and I will help bisect it against `main`. If the black skin / missing police / missing buildings remain in run 2, please capture the translated shader and texture view for the skin draw (`VICTORY_SHADER_SAVE` plus the texture-store equivalent) at the moment the skin is black; that will tell us whether the section page table or the material/texture path is at fault. I do not have an RDNA4 host locally, so I cannot reproduce those visuals myself. @borosf — agreed on the overlap. This branch now deliberately uses the same `xmem.rs` / `memory.rs` hook points as #2494, keeps `watch::title_memory_remapped` as the invalidation funnel, and restores the `SEC_COMMIT` → `SEC_RESERVE` fallback so commit pressure does not fail the title's allocation. The remaining differences are intentional policy choices: this PR is off by default, low-host gated, and bounded to 512 MiB total instead of #2494's always-on per-section commit. If both land, we should choose one policy rather than stack two reservations. Local validation on this head: `cargo check --all-targets --locked`, strict Clippy for the four affected crates, and `cargo xtask policy` pass. The four-crate test suite adds five passing tests (231 → 236 passes); the same three WARP/descriptor-cap failures also occur on the untouched PR head. AI-assisted: comment prepared with the OpenCode harness from the local diff and validation logs; all reported commands were run locally.
rpmaster2 commented 2026-11-29 07:31:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-29T07:31:26Z.


Both runs on the RX 9070 XT, 600 s each, the same first-run save restored before each, warm caches, --console series-x, scripted key presses:

1. No flags: 3.4–4.3 fps, 230–292 ms a frame at 1,000–1,578 draws, 8,489 draws peak, 6 black frames; the dumps have content (512/1024 = 80 / 121 of 255). It crashed at 280 s with 0xc0000005 read 0xffffffffffffffff in the title image.

2. VICTORY_PORT_CONSTANTS=1 only: 0.4–0.5 fps, 2,050–2,474 ms a frame at 1,144–2,350 draws, 9,261 draws peak, 3 black frames; the dumps have content as well, so it renders — it is an order of magnitude slower. Private bytes stay at 28.7 GB, but the process working set the OS reports grows from 6 GB to 1.1 TB over the run; that is not physical memory and looks like very large page mappings.

On screen the loading is longer and lighting artifacts appear with the flag.

This pair has been tested several times, shorter windows included, and the result keeps repeating in the same direction: with the flag the frames are several times longer, never the other way round. The pair above is the first clean one — the earlier attempts were disturbed by the save state, which is why the setup was redone.

I have no NVIDIA host, so this is RDNA4 only, and it is one clean pair rather than repeated measurements; but an 8× frame-time cost is well outside noise. Is the in-place path expected to map title memory into the process, which would explain the working-set figure, and is there anything in it that could serialise frames like this on a card where the section heap is not native?

AI-assisted: written by DeepSeek (OpenCode harness) from the run logs; counts and versions only, no game files or paths.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7252524993 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3470#issuecomment-7252524993). Originally posted by [rpmaster2](https://github.com/rpmaster2) on 2026-11-29T07:31:26Z. --- Both runs on the RX 9070 XT, 600 s each, the same first-run save restored before each, warm caches, `--console series-x`, scripted key presses: **1. No flags:** 3.4–4.3 fps, 230–292 ms a frame at 1,000–1,578 draws, 8,489 draws peak, 6 black frames; the dumps have content (512/1024 = 80 / 121 of 255). It crashed at 280 s with `0xc0000005 read 0xffffffffffffffff` in the title image. **2. `VICTORY_PORT_CONSTANTS=1` only:** 0.4–0.5 fps, 2,050–2,474 ms a frame at 1,144–2,350 draws, 9,261 draws peak, 3 black frames; the dumps have content as well, so it renders — it is an order of magnitude slower. Private bytes stay at 28.7 GB, but the process working set the OS reports grows from 6 GB to 1.1 TB over the run; that is not physical memory and looks like very large page mappings. On screen the loading is longer and lighting artifacts appear with the flag. This pair has been tested several times, shorter windows included, and the result keeps repeating in the same direction: with the flag the frames are several times longer, never the other way round. The pair above is the first clean one — the earlier attempts were disturbed by the save state, which is why the setup was redone. I have no NVIDIA host, so this is RDNA4 only, and it is one clean pair rather than repeated measurements; but an 8× frame-time cost is well outside noise. Is the in-place path expected to map title memory into the process, which would explain the working-set figure, and is there anything in it that could serialise frames like this on a card where the section heap is not native? AI-assisted: written by DeepSeek (OpenCode harness) from the run logs; counts and versions only, no game files or paths.
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/3470:upstream-pr/3470'
git switch 'upstream-pr/3470'

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