GPU: title memory in place by default where the host GPU shares memory with the CPU (stacked on #2112, #2912, #2921) #2943

Closed
0xkn0wh3r3 wants to merge 34 commits from upstream-pr/2945 into main
0xkn0wh3r3 commented 2026-11-26 01:12:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T01:12:22Z.


Stacked on #2112 (desplmfao), #2912 and #2921. New here: 7b6882b7, 1c87ba06, 1fc54410 and 3ed7d725; the rest is those three PRs merged. Draft until they land.

Problem

On a host whose GPU shares memory with the CPU (an AMD or Intel APU, an integrated GPU, Apple silicon under a translation layer), host copies of title memory buy no GPU time. A synthetic benchmark on the Ryzen 7900X's integrated Radeon (the benchmark summarised in #2912) measured every placement within noise of every other: today's copies, title memory opened in place, upload heaps and "video memory".

The copies there only cost their refreshes and copy-backs, which are 45–76 ms per synthetic world frame on main. #2112 can read title memory in place, but it is opt-in on every host.

Also, while a heap is open over title memory, Windows refuses VirtualProtect, UnmapViewOfFile2 and VirtualFree (error 87), so the title cannot free or remap that memory. #2921 adds a registry for exactly this; #2112's heaps were not in it.

What this changes

  • Self-test (moved here from #2912 on its triage): crate::unified::self_test.

    1. A write-watched block is opened with OpenExistingHeapFromAddress1.
    2. A copy queue does a round trip through it, and both directions are checked.

    It runs once, the first time the default is asked, and only where #2912's detection reports UMA. Discrete hosts never run it. It catches layers that have the method but don't share the memory (vkd3d-proton without VK_EXT_external_memory_host makes new memory). It takes 3-20 ms.

  • Default: with VICTORY_IN_PLACE unset, in place is on where the host reports UMA and the self-test passes. The log says so once, or logs why the copies stay.

    • =1 keeps it on everywhere.
    • Any other value turns it off, as before.
    • Discrete GPUs are unchanged: in place there reads across the bus as the copies do, and a title-level gain is not shown yet.
  • Pins: every heap #2112 opens is registered with crate::pinned:

    • a sub-range heap per buffer, released with let_go_in_place(start, len);
    • a whole-allocation heap on hosts without ID3D12Device13, released with let_go_heap(id).

    The title's frees, protections and remaps (#2921's wrappers, xmem's unmapping) first stop handing out what is placed there; the change then succeeds once the heap goes. The registration is forgotten when the heap is destroyed (ID3DDestructionNotifier), so pins don't pile up. Each placed buffer holds its heap through private data (SetPrivateDataInterface), so the heap, and its pin, last as long as the buffer on every backend. vkd3d-proton destroyed a sub-range heap as soon as in_place_buffer returned, while the buffer still lived (reported by pickles976 on Wine/vkd3d-proton, NVIDIA; fixed in 1fc54410). A buffer that cannot hold its heap is refused.

  • README: the VICTORY_IN_PLACE paragraph says when it is on by default.

Limits

  • A list that used the buffer keeps it, and so its heap, until the title resets that list (#2112's keep_in_place). If the title frees memory a not-yet-reset list still names, the free is still refused after #2921's 100 ms retry, as on #2112 today.
  • #2112's 1 MiB floor stays. Smaller buffers keep copies, though the bus cost behind the floor does not exist on a unified host. Each open costs about 0.3 ms on the APU, so lowering it should wait for a measurement there.
  • No title run on an APU yet. The synthetic numbers are from #2912.

Tests

  • shadow::tests::the_title_frees_memory_a_window_is_in_place_over:
    1. A window is put in place over a 1 MiB allocation.
    2. title_memory_change with the title's VirtualFree drops the window and its heap first.
    3. The free succeeds and the pin is gone.
    4. Then a heap that goes by itself takes its pin along.
  • shadow::tests::a_buffer_in_place_holds_its_heap_and_pin: on the sub-range and the whole-allocation path, with nothing but the returned buffer holding the heap, the pin stays while the buffer lives and goes with it. Passes on the RTX 5070 Ti; not yet rerun on vkd3d-proton. On CI's WARP the pages were let go a little after the buffer went, so the tests that free right after now retry for up to 1 s (3ed7d725), as title_memory_change does for 100 ms.
  • title_memory_is_in_place_by_default_on_a_unified_host: the default equals "UMA and self-test passed".
  • unified::tests::the_answer_names_what_was_not_shared and title_memory_opens_in_place_on_warp: the self-test.
  • On WARP (a unified host; diagnostics build with VICTORY_D3D12_WARP=1), in place came on by default, and 268 of 269 victory-gpu tests passed. The failure, frame::tests::waits_end_on_ticks_and_count_frames, is a timing test and passed three times alone.
  • On the RTX 5070 Ti (default off): 253 passed, 2 failed. The two, dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, fail the same way on clean main on this machine.
  • victory-hle: 154 passed. Workspace clippy (both configurations) is clean.
  • #2734: video memory for hot buffers on discrete GPUs (stacked on #2112).
  • #2929: ranks copies by what video memory would save.
  • #2371 / #1630: adapter choice. On a laptop whose default adapter is the integrated GPU, this turns in place on there.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6617215995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T01:12:22Z. --- **Stacked on #2112 (desplmfao), #2912 and #2921.** New here: 7b6882b7, 1c87ba06, 1fc54410 and 3ed7d725; the rest is those three PRs merged. Draft until they land. ### Problem On a host whose GPU shares memory with the CPU (an AMD or Intel APU, an integrated GPU, Apple silicon under a translation layer), host copies of title memory buy no GPU time. A synthetic benchmark on the Ryzen 7900X's integrated Radeon (the benchmark summarised in #2912) measured every placement within noise of every other: today's copies, title memory opened in place, upload heaps and "video memory". The copies there only cost their refreshes and copy-backs, which are 45–76 ms per synthetic world frame on main. #2112 can read title memory in place, but it is opt-in on every host. Also, while a heap is open over title memory, Windows refuses `VirtualProtect`, `UnmapViewOfFile2` and `VirtualFree` (error 87), so the title cannot free or remap that memory. #2921 adds a registry for exactly this; #2112's heaps were not in it. ### What this changes - **Self-test (moved here from #2912 on its triage):** `crate::unified::self_test`. 1. A write-watched block is opened with `OpenExistingHeapFromAddress1`. 2. A copy queue does a round trip through it, and both directions are checked. It runs once, the first time the default is asked, and only where #2912's detection reports UMA. Discrete hosts never run it. It catches layers that have the method but don't share the memory (vkd3d-proton without `VK_EXT_external_memory_host` makes new memory). It takes 3-20 ms. - **Default:** with `VICTORY_IN_PLACE` unset, in place is on where the host reports UMA and the self-test passes. The log says so once, or logs why the copies stay. - `=1` keeps it on everywhere. - Any other value turns it off, as before. - Discrete GPUs are unchanged: in place there reads across the bus as the copies do, and a title-level gain is not shown yet. - **Pins:** every heap #2112 opens is registered with `crate::pinned`: - a sub-range heap per buffer, released with `let_go_in_place(start, len)`; - a whole-allocation heap on hosts without `ID3D12Device13`, released with `let_go_heap(id)`. The title's frees, protections and remaps (#2921's wrappers, xmem's unmapping) first stop handing out what is placed there; the change then succeeds once the heap goes. The registration is forgotten when the heap is destroyed (`ID3DDestructionNotifier`), so pins don't pile up. Each placed buffer holds its heap through private data (`SetPrivateDataInterface`), so the heap, and its pin, last as long as the buffer on every backend. vkd3d-proton destroyed a sub-range heap as soon as `in_place_buffer` returned, while the buffer still lived (reported by pickles976 on Wine/vkd3d-proton, NVIDIA; fixed in 1fc54410). A buffer that cannot hold its heap is refused. - README: the `VICTORY_IN_PLACE` paragraph says when it is on by default. ### Limits - A list that used the buffer keeps it, and so its heap, until the title resets that list (#2112's `keep_in_place`). If the title frees memory a not-yet-reset list still names, the free is still refused after #2921's 100 ms retry, as on #2112 today. - #2112's 1 MiB floor stays. Smaller buffers keep copies, though the bus cost behind the floor does not exist on a unified host. Each open costs about 0.3 ms on the APU, so lowering it should wait for a measurement there. - No title run on an APU yet. The synthetic numbers are from #2912. ### Tests - `shadow::tests::the_title_frees_memory_a_window_is_in_place_over`: 1. A window is put in place over a 1 MiB allocation. 2. `title_memory_change` with the title's `VirtualFree` drops the window and its heap first. 3. The free succeeds and the pin is gone. 4. Then a heap that goes by itself takes its pin along. - `shadow::tests::a_buffer_in_place_holds_its_heap_and_pin`: on the sub-range and the whole-allocation path, with nothing but the returned buffer holding the heap, the pin stays while the buffer lives and goes with it. Passes on the RTX 5070 Ti; not yet rerun on vkd3d-proton. On CI's WARP the pages were let go a little after the buffer went, so the tests that free right after now retry for up to 1 s (3ed7d725), as `title_memory_change` does for 100 ms. - `title_memory_is_in_place_by_default_on_a_unified_host`: the default equals "UMA and self-test passed". - `unified::tests::the_answer_names_what_was_not_shared` and `title_memory_opens_in_place_on_warp`: the self-test. - **On WARP** (a unified host; diagnostics build with `VICTORY_D3D12_WARP=1`), in place came on by default, and 268 of 269 victory-gpu tests passed. The failure, `frame::tests::waits_end_on_ticks_and_count_frames`, is a timing test and passed three times alone. - **On the RTX 5070 Ti** (default off): 253 passed, 2 failed. The two, `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, fail the same way on clean main on this machine. - victory-hle: 154 passed. Workspace clippy (both configurations) is clean. ### Related - #2734: video memory for hot buffers on discrete GPUs (stacked on #2112). - #2929: ranks copies by what video memory would save. - #2371 / #1630: adapter choice. On a laptop whose default adapter is the integrated GPU, this turns in place on there.
fuzeofficlal commented 2026-11-26 02:07:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:35:16Z.


Code review and triple-adapter (NVIDIA RTX 5090 discrete + AMD Radeon RDNA2 iGPU + WARP) verification at head 7b6882b773c0 (stacked on #2112, #2912, #2921):

  • UMA / CacheCoherentUMA & pinning audit (title/shadow.rs:1184, 1201-1226, title/pinned.rs):
    • Defaulting in_place_enabled() to h.memory.uma && h.memory.in_place.is_ok() (without requiring CacheCoherentUMA == true, instead guarding on the startup unified::self_test bidirectional visibility + write-watch probe) is validated directly by hardware below; explicit VICTORY_IN_PLACE overrides cleanly.
    • Every opened in-place heap pins its range via pin_heap and unpins via ID3DDestructionNotifier::RegisterDestructionCallback (with immediate cleanup on registration failure).
  • Live triple-adapter uma_probe results (Windows 11, Rust 1.98.1):
    1. NVIDIA GeForce RTX 5090 (discrete): uma=false, ReBAR, 31419 MiB local / 45969 MiB non-local -> default in_place_enabled() == false.
    2. AMD Radeon(TM) Graphics (RDNA2 iGPU): unified with the CPU's, cache-coherent false; title memory opens in place; budgets 47991 MiB local, 0 MiB non-local (4.06 ms) — private 4 MiB, private write-watched 4 MiB, and section view all report GPU sees CPU writes true, CPU sees GPU writes true, GPU write triggers 0 watch pages, and CPU write to 2 pages triggers 2 watch pages. Directly confirms enabling in-place on AMD APUs despite CacheCoherentUMA=false.
    3. Microsoft Basic Render Driver (WARP): uma=true, cache-coherent true; title memory opens in place -> default in_place_enabled() == true.
  • Verified (VICTORY_D3D12_DEBUG=1):
    • cargo xtask policy: 195 files ok; cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
    • RTX 5090 (unified:: title_memory_is_in_place_by_default the_title_frees_memory_a_window_is_in_place_over pinned::): 10/10 passed
    • WARP (--features diagnostics, unified:: shadow:: pinned::): 33/33 passed; victory-hle -- xmem memoryapi: 16/16 passed.

Looks great once the stacked prerequisites (#2112/#2912/#2921) land; LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179921753 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945#issuecomment-7179921753). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:35:16Z. --- Code review and **triple-adapter** (NVIDIA RTX 5090 discrete + AMD Radeon RDNA2 iGPU + WARP) verification at head `7b6882b773c0` (stacked on `#2112`, `#2912`, `#2921`): - **UMA / `CacheCoherentUMA` & pinning audit (`title/shadow.rs:1184, 1201-1226`, `title/pinned.rs`)**: - Defaulting `in_place_enabled()` to `h.memory.uma && h.memory.in_place.is_ok()` (without requiring `CacheCoherentUMA == true`, instead guarding on the startup `unified::self_test` bidirectional visibility + write-watch probe) is validated directly by hardware below; explicit `VICTORY_IN_PLACE` overrides cleanly. - Every opened in-place heap pins its range via `pin_heap` and unpins via `ID3DDestructionNotifier::RegisterDestructionCallback` (with immediate cleanup on registration failure). - **Live triple-adapter `uma_probe` results (Windows 11, Rust 1.98.1)**: 1. **NVIDIA GeForce RTX 5090 (discrete)**: `uma=false`, ReBAR, `31419 MiB local / 45969 MiB non-local` -> default `in_place_enabled() == false`. 2. **AMD Radeon(TM) Graphics (RDNA2 iGPU)**: `unified with the CPU's, cache-coherent false; title memory opens in place; budgets 47991 MiB local, 0 MiB non-local (4.06 ms)` — `private 4 MiB`, `private write-watched 4 MiB`, and `section view` all report `GPU sees CPU writes true, CPU sees GPU writes true`, GPU write triggers `0` watch pages, and CPU write to 2 pages triggers `2` watch pages. Directly confirms enabling in-place on AMD APUs despite `CacheCoherentUMA=false`. 3. **Microsoft Basic Render Driver (WARP)**: `uma=true, cache-coherent true; title memory opens in place` -> default `in_place_enabled() == true`. - **Verified (`VICTORY_D3D12_DEBUG=1`)**: - `cargo xtask policy`: `195 files ok`; `cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings` (default + `--features diagnostics`): 0 warnings - RTX 5090 (`unified:: title_memory_is_in_place_by_default the_title_frees_memory_a_window_is_in_place_over pinned::`): **10/10 passed** - WARP (`--features diagnostics`, `unified:: shadow:: pinned::`): **33/33 passed**; `victory-hle -- xmem memoryapi`: **16/16 passed**. Looks great once the stacked prerequisites (`#2112`/`#2912`/`#2921`) land; LGTM.
kotekompotek commented 2026-11-26 03:04:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:53:07Z.

Review: APPROVED


LGTM — reviewed the delta on top of the stacked PRs (7b6882b7, cdf12e9e).

  • in_place_enabled semantics match the PR description exactly: =1 on everywhere, any other set value off, unset → UMA + self_test pass. The OnceLock runs the self-test at most once, lazily on first use, and only on UMA hosts — discrete hosts never pay it.
  • Moving self_test out of detect is the right call: every host creation used to run a 3-20 ms GPU round trip whose answer nothing consumed. detect is now the cheap queries it's described as; Memory no longer carries the in_place field.
  • pin_heap covers both heap paths: whole-allocation opens pin [start, start+size) with let_go_in_place(start, len) releasing the placed window, and sub-range heaps pin their own range with let_go_heap(id). The two destruction outcomes are handled symmetrically — heap destroyed by itself → forget drops the registration; title tries to change pinned memory → release runs first, outside the registry lock. The RegisterDestructionCallback failure path correctly leaves the pin registered rather than silently losing it.
  • the_title_frees_memory_a_window_is_in_place_over is discriminating on both halves: held_over 1→0 across title_memory_change+VirtualFree, LOOSE entry removed, then heap self-destruction drops its own registration.
  • uma_bench.rs removal is fair — the benchmark was the justification evidence; its summary is in #2912 and history keeps it.

Noting scope per the PR description: I reviewed the new commits only; the base mechanics are #2112/#2912/#2921's.

<!-- greyfinch-sync:Marvisak/VIctory:review:6067918266 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945#pullrequestreview-6067918266). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T02:53:07Z. **Review:** APPROVED --- LGTM — reviewed the delta on top of the stacked PRs (7b6882b7, cdf12e9e). - **`in_place_enabled` semantics** match the PR description exactly: `=1` on everywhere, any other set value off, unset → UMA + `self_test` pass. The `OnceLock` runs the self-test at most once, lazily on first use, and only on UMA hosts — discrete hosts never pay it. - **Moving `self_test` out of `detect`** is the right call: every host creation used to run a 3-20 ms GPU round trip whose answer nothing consumed. `detect` is now the cheap queries it's described as; `Memory` no longer carries the `in_place` field. - **`pin_heap` covers both heap paths**: whole-allocation opens pin `[start, start+size)` with `let_go_in_place(start, len)` releasing the placed window, and sub-range heaps pin their own range with `let_go_heap(id)`. The two destruction outcomes are handled symmetrically — heap destroyed by itself → `forget` drops the registration; title tries to change pinned memory → `release` runs first, outside the registry lock. The `RegisterDestructionCallback` failure path correctly leaves the pin registered rather than silently losing it. - **`the_title_frees_memory_a_window_is_in_place_over`** is discriminating on both halves: `held_over` 1→0 across `title_memory_change`+VirtualFree, LOOSE entry removed, then heap self-destruction drops its own registration. - `uma_bench.rs` removal is fair — the benchmark was the justification evidence; its summary is in #2912 and history keeps it. Noting scope per the PR description: I reviewed the new commits only; the base mechanics are #2112/#2912/#2921's.
pickles976 commented 2026-11-26 04:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-26T03:32:00Z.


Important Wine/vkd3d-proton 3.2.0 RTX 4060 Laptop GPU (discrete, 16 GiB system RAM) caveat before anyone enables VICTORY_IN_PLACE=1: on exact earlier stacked head 7b6882b7, the PR test shadow::tests::the_title_frees_memory_a_window_is_in_place_over failed 0/1 at the held_over assertion. in_place_buffer returned a valid placed buffer, but held_over had already fallen to 0, expected 1. Local logs: .compat-runtime/logs/verify-pr2945-wine-inplace-pin{,-probe}.log (not attached). In a temporary test-only diagnostic, the pin was 1 immediately after registration, then the heap destruction callback fired before the caller asserted; diagnostic edit was restored.

The opened heap COM handle appears to be dropped when in_place_buffer returns only the placed buffer/GPU address/numeric heap ID; on this Wine backend that destroys the heap COM object while the placed buffer is still alive, so its notifier forgets the pin prematurely. A later title VirtualFree/remap could bypass the intended release. Please retain a strong heap lifetime with the placed resource (or otherwise tie the pin to the lifetime of all placed resources), and add a test that asserts pin is held for as long as the returned buffer is alive, then relinquished before the title changes memory. The newer 1c87ba06 commit changes UMA-default/self-test behavior but not this failing pin path, so I have not rerun the same failure.

This is a Wine/backend-specific negative, not a claim the PR fails on native Windows or UMA. The PR defaults in-place off on this discrete GPU; it is not a safe 16 GiB loading workaround here. No title launched with this mode.

Revised-head verification: 3ed7d725f6895fe1a235eb6fa8ff2485261ca151, including the actual heap-retention fix 1fc54410, now passes the earlier title-free regression and the new both-path pin-lifetime regression on this Wine/NVIDIA backend. 3passed/0failed/0ignored,0.75s, fresh compile8.85s, NVIDIA enumerated. Third check locally invokes your unified::self_test(&host.device) on the selected discrete NVIDIA host: the real CPU→GPU→CPU aliasing round trip passed too. No forced in-place title run yet.

Local test-only differences: missing host or refused heap now fails rather than silently returning in the two lifetime fixtures, plus the selected-host self-test entry point. Production unchanged from head. This clears the specific early-pin-drop and real-aliasing gates reported above; it does not certify all release/remap or rendering behavior. Latest #2112 29decb3 changes GPU-write invalidation, which is absent from this stacked head and is a separate correctness consideration before a title experiment.

Environment: Wine11.0, NVIDIA590.48.1, DXVK3.1.1, diagnostic relaxed vkd3d-proton3.2.0 2576c0b4adfae4a+, assertions disabled and allocator/list from_iface vtable checks removed, null checks retained. Not stock-runtime certification. Same6,000MiB GPU/2,048MiB availableRAM/10GiB disk guards and9GiB/512MiB scope caps. Log .compat-runtime/logs/verify-pr2945-fixed-pin-alias.log and sampled metrics.

Mixed local title follow-through (2026-11-26, Wine/NVIDIA)

After the three exact-production-head pin/alias fixtures passed, I tested a mixed local integration, not pristine #2945: 3ed7d725f6895fe1a235eb6fa8ff2485261ca151 plus only #2112 commit 29decb3719142296cad124453a3b8651068f22f6's GPU-write notification fix, a read-only logical-span probe, and test hardening. This retains the stack's fixed 256 KiB loose window and default 1 MiB in-place floor, rather than claiming current #2112 defaults. The notification port passed a local two-real-view alias tracking regression (including subsequent CPU writes); that regression is not a GPU-dispatch test.

A fresh release build named this checkout. VICTORY_IN_PLACE=1, with account selection at 20 s, produced actual loading artwork at 60/90 s. RAM guard stopped loading at 112.88 s: available RAM 2,012.1 MiB (2,048 MiB floor); GPU peak 3,297 MiB; scope peak 7,693.2 MiB, anonymous peak 3,079.9 MiB; user-available disk minimum 19.090 GiB. Exit 137 was the guard, not an unhandled title exception. No gameplay, controls, or gameplay FPS claim.

Last logical-span probe (~112 s):

Category Copy count Copy span MiB In-place count In-place span MiB
Registered 3433 510.38 39 193.75
Loose 2813 1120.50 4866 390.94

These are logical resource spans: they can overlap and exclude allocation/driver overhead. Not total RAM or unique physical bytes. They show the in-place path is active, but copy-backed growth still exceeds this machine's safe loading budget. Different stacks/loading timing make earlier no-in-place runs unsuitable for a matched-stage savings claim. Host compute PSOs b68f0931f1f47e61, 13dfdd3b1136e407, 88994c3496045f51 still returned 0x80070057; a missing-host-pipeline dispatch was also logged.

Local artifacts: .compat-runtime/logs/20261126T062146Z-{console.log,resources.csv,guard-events.jsonl}, screenshots menu-20261126T062246996159Z.png / menu-20261126T062317003405Z.png, and verify-pr2945-gpu-write-notification.log.

Environment remains Wine 11.0, RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1, 16 GiB system RAM, diagnostic relaxed vkd3d-proton 3.2.0 2576c0b4adfae4a+ (assertions disabled, allocator/list vtable identity checks removed; null checks retained), not stock-runtime certification. Same GPU 6000 MiB / RAM 2048 MiB / available-disk 10 GiB guards and 9 GiB cgroup / 512 MiB swap caps; no limits raised. No code PR/push.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181801784 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945#issuecomment-7181801784). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-26T03:32:00Z. --- Important Wine/vkd3d-proton 3.2.0 **RTX 4060 Laptop GPU** (discrete, 16 GiB system RAM) caveat before anyone enables `VICTORY_IN_PLACE=1`: on exact earlier stacked head `7b6882b7`, the PR test `shadow::tests::the_title_frees_memory_a_window_is_in_place_over` **failed 0/1** at the `held_over` assertion. `in_place_buffer` returned a valid placed buffer, but `held_over` had already fallen to **0, expected 1**. Local logs: `.compat-runtime/logs/verify-pr2945-wine-inplace-pin{,-probe}.log` (not attached). In a temporary test-only diagnostic, the pin was **1 immediately after registration**, then the heap destruction callback fired before the caller asserted; diagnostic edit was restored. The opened heap COM handle appears to be dropped when `in_place_buffer` returns only the placed buffer/GPU address/numeric heap ID; on this Wine backend that destroys the heap COM object while the placed buffer is still alive, so its notifier forgets the pin prematurely. A later title `VirtualFree`/remap could bypass the intended release. Please retain a strong heap lifetime with the placed resource (or otherwise tie the pin to the lifetime of all placed resources), and add a test that asserts pin is held for as long as the returned buffer is alive, then relinquished before the title changes memory. The newer `1c87ba06` commit changes UMA-default/self-test behavior but not this failing pin path, so I have **not rerun the same failure**. This is a Wine/backend-specific negative, not a claim the PR fails on native Windows or UMA. The PR defaults in-place off on this discrete GPU; it is not a safe 16 GiB loading workaround here. No title launched with this mode. **Revised-head verification:** `3ed7d725f6895fe1a235eb6fa8ff2485261ca151`, including the actual heap-retention fix `1fc54410`, now passes the earlier title-free regression and the new both-path pin-lifetime regression on this Wine/NVIDIA backend. **3passed/0failed/0ignored,0.75s**, fresh compile8.85s, NVIDIA enumerated. Third check locally invokes your `unified::self_test(&host.device)` on the selected discrete NVIDIA host: the real CPU→GPU→CPU aliasing round trip passed too. No forced in-place title run yet. Local test-only differences: missing host or refused heap now fails rather than silently returning in the two lifetime fixtures, plus the selected-host self-test entry point. Production unchanged from head. This clears the **specific early-pin-drop and real-aliasing gates** reported above; it does not certify all release/remap or rendering behavior. Latest #2112 `29decb3` changes GPU-write invalidation, which is absent from this stacked head and is a separate correctness consideration before a title experiment. Environment: Wine11.0, NVIDIA590.48.1, DXVK3.1.1, **diagnostic relaxed vkd3d-proton3.2.0 `2576c0b4adfae4a+`**, assertions disabled and allocator/list `from_iface` vtable checks removed, null checks retained. Not stock-runtime certification. Same6,000MiB GPU/2,048MiB availableRAM/10GiB disk guards and9GiB/512MiB scope caps. Log `.compat-runtime/logs/verify-pr2945-fixed-pin-alias.log` and sampled metrics. ### Mixed local title follow-through (2026-11-26, Wine/NVIDIA) After the three exact-production-head pin/alias fixtures passed, I tested a **mixed local integration**, not pristine #2945: `3ed7d725f6895fe1a235eb6fa8ff2485261ca151` plus only #2112 commit `29decb3719142296cad124453a3b8651068f22f6`'s GPU-write notification fix, a read-only logical-span probe, and test hardening. This retains the stack's fixed 256 KiB loose window and default 1 MiB in-place floor, rather than claiming current #2112 defaults. The notification port passed a local two-real-view alias tracking regression (including subsequent CPU writes); that regression is not a GPU-dispatch test. A fresh release build named this checkout. `VICTORY_IN_PLACE=1`, with account selection at 20 s, produced actual loading artwork at 60/90 s. **RAM guard stopped loading at 112.88 s**: available RAM 2,012.1 MiB (2,048 MiB floor); GPU peak 3,297 MiB; scope peak 7,693.2 MiB, anonymous peak 3,079.9 MiB; user-available disk minimum 19.090 GiB. Exit 137 was the guard, not an unhandled title exception. No gameplay, controls, or gameplay FPS claim. Last logical-span probe (~112 s): | Category | Copy count | Copy span MiB | In-place count | In-place span MiB | |---|---:|---:|---:|---:| | Registered | 3433 | 510.38 | 39 | 193.75 | | Loose | 2813 | 1120.50 | 4866 | 390.94 | These are logical resource spans: they can overlap and exclude allocation/driver overhead. **Not total RAM or unique physical bytes.** They show the in-place path is active, but copy-backed growth still exceeds this machine's safe loading budget. Different stacks/loading timing make earlier no-in-place runs unsuitable for a matched-stage savings claim. Host compute PSOs `b68f0931f1f47e61`, `13dfdd3b1136e407`, `88994c3496045f51` still returned `0x80070057`; a missing-host-pipeline dispatch was also logged. Local artifacts: `.compat-runtime/logs/20261126T062146Z-{console.log,resources.csv,guard-events.jsonl}`, screenshots `menu-20261126T062246996159Z.png` / `menu-20261126T062317003405Z.png`, and `verify-pr2945-gpu-write-notification.log`. Environment remains Wine 11.0, RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1, 16 GiB system RAM, **diagnostic relaxed vkd3d-proton 3.2.0 `2576c0b4adfae4a+`** (assertions disabled, allocator/list vtable identity checks removed; null checks retained), not stock-runtime certification. Same GPU 6000 MiB / RAM 2048 MiB / available-disk 10 GiB guards and 9 GiB cgroup / 512 MiB swap caps; no limits raised. No code PR/push.
0xkn0wh3r3 commented 2026-11-26 04:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T03:36:30Z.


@pickles976 thanks, you were right. Fixed in 1fc54410: each placed buffer now holds its heap through SetPrivateDataInterface, on both the sub-range and the whole-allocation paths. So the heap, and the pin it carries, live exactly as long as the buffer, whatever the backend does with the opened heap's handle. A buffer that can't hold its heap is refused rather than placed.

The new test a_buffer_in_place_holds_its_heap_and_pin checks both paths with only the returned buffer holding the heap: the pin stays while the buffer lives and goes with it. It passes on an RTX 5070 Ti. It hasn't been run on vkd3d-proton yet, so a rerun of your case on that backend would confirm it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181867504 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945#issuecomment-7181867504). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T03:36:30Z. --- @pickles976 thanks, you were right. Fixed in 1fc54410: each placed buffer now holds its heap through `SetPrivateDataInterface`, on both the sub-range and the whole-allocation paths. So the heap, and the pin it carries, live exactly as long as the buffer, whatever the backend does with the opened heap's handle. A buffer that can't hold its heap is refused rather than placed. The new test `a_buffer_in_place_holds_its_heap_and_pin` checks both paths with only the returned buffer holding the heap: the pin stays while the buffer lives and goes with it. It passes on an RTX 5070 Ti. It hasn't been run on vkd3d-proton yet, so a rerun of your case on that backend would confirm it.
upstream-sync closed this pull request 2026-11-26 09:05:28 +00:00
0xkn0wh3r3 commented 2026-11-26 09:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T08:05:47Z.


Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186180508 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2945#issuecomment-7186180508). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T08:05:47Z. --- Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

Pull request closed

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!2943
No description provided.