mem-probe: how much title memory live placed textures claim more than once (RT-MEMPROBE-TITLE-PLACED-OVERLAP) #2549

Closed
Tyrannys wants to merge 4 commits from upstream-pr/2549 into main
Tyrannys commented 2026-11-28 01:49:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-28T01:49:35Z.


Claimed in the coordination issue as: RT-MEMPROBE-TITLE-PLACED-OVERLAP (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231939255). Stacked on #2547 (its commit is the first one here); review the second commit.

What and why

A texture the title places at its own address (Xbox device slot 133) gets its own GPU image, but on the console that texture is the title's memory there. A new texture placed over the memory of an older one gets its own image too. The older image stays alive until the title releases its resource object: place_at_title_address only stops the older one answering for that address, and title_images keeps both. In world runs the layer's copies of title resources come to more than the title's own GPU pool, so how often this happens matters for VRAM.

With LEONIDA_MEM_PROBE, the breakdown line now ends with, for the live slot-133 textures (sampled ones and GPU-written ones apart):

; title-placed textures 3: 300 MiB of title memory covered, 200 MiB distinct (1 start where another does), 320 MiB of images; title-placed render targets 2: ...

(numbers from the unit test).

  • covered: the title bytes each texture spans, summed.
  • distinct: the union of those spans.
  • covered − distinct: title memory that more than one live texture claims, which the layer backs once per texture.
  • A texture's span is its console layout's size when the title-texture registry knows it, otherwise its image's size.
  • The walk holds title_image_mutex, which ~Resource takes first, once a probe tick.

Logging only: nothing is freed or changed.

Tested

  • memory_breakdown_test, new placed() cases:
    • no textures;
    • two apart (nothing counted twice);
    • two at one address plus one inside a third (0x11000 covered, 0xc000 distinct, one shared start);
    • overlapping tails (0x6000 covered, 0x5000 distinct).
      The line text is checked too, and the part is left out without the share.
  • image_memory_test still passes; gta6rt_d3d12_com builds (MSVC 17, Release). CPU only, no GPU, no game data.

GPUs tested: n/a (CPU tests).

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request. (Stacked on #2547.)
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5535524585 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2549). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-28T01:49:35Z. --- Claimed in the coordination issue as: RT-MEMPROBE-TITLE-PLACED-OVERLAP (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231939255). Stacked on #2547 (its commit is the first one here); review the second commit. ### What and why A texture the title places at its own address (Xbox device slot 133) gets its own GPU image, but on the console that texture *is* the title's memory there. A new texture placed over the memory of an older one gets its own image too. The older image stays alive until the title releases its resource object: `place_at_title_address` only stops the older one answering for that address, and `title_images` keeps both. In world runs the layer's copies of title resources come to more than the title's own GPU pool, so how often this happens matters for VRAM. With `LEONIDA_MEM_PROBE`, the breakdown line now ends with, for the live slot-133 textures (sampled ones and GPU-written ones apart): ``` ; title-placed textures 3: 300 MiB of title memory covered, 200 MiB distinct (1 start where another does), 320 MiB of images; title-placed render targets 2: ... ``` (numbers from the unit test). - **covered:** the title bytes each texture spans, summed. - **distinct:** the union of those spans. - **covered − distinct:** title memory that more than one live texture claims, which the layer backs once per texture. - A texture's span is its console layout's size when the title-texture registry knows it, otherwise its image's size. - The walk holds `title_image_mutex`, which `~Resource` takes first, once a probe tick. Logging only: nothing is freed or changed. ### Tested - `memory_breakdown_test`, new `placed()` cases: - no textures; - two apart (nothing counted twice); - two at one address plus one inside a third (0x11000 covered, 0xc000 distinct, one shared start); - overlapping tails (0x6000 covered, 0x5000 distinct). The line text is checked too, and the part is left out without the share. - `image_memory_test` still passes; `gta6rt_d3d12_com` builds (MSVC 17, Release). CPU only, no GPU, no game data. GPUs tested: n/a (CPU tests). AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. (Stacked on #2547.) - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
zmasi commented 2026-11-28 03:18:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T03:18:17Z.


#2549 | head b81ce41c10 (merged cleanly with main 02f71ccfe7) | ctest --test-dir runtime/build -C RelWithDebInfo -R "^(image_memory|memory_breakdown|d3d12_existing_heap)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: image_memory_test.cpp and memory_breakdown_test.cpp fail to compile (C2039: ImageMemoryPool::Stats::{used_bytes, empty_blocks, largest_free}, TitlePlaced, measure_title_placed, and DeviceShare::{texture_blocks, title_placed} absent on main) | green on PR+main: 3/3 CTests pass (image_memory including 4,000-step churn_stats, memory_breakdown including placed() interval-union overlap tally and formatted summary, and d3d12_existing_heap on RTX 3090); test_ci_registration.py 18/18 OK, check_no_game_data.py 0 violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes

Audited lock acquisition order in the DeviceShare snapshot (d.image_memory->stats(), then d.title_image_mutex, then d.descriptor_mutex, with no nested locks) and saturating UINT64_MAX - start interval union in measure_title_placed.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232964576 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2549#issuecomment-7232964576). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T03:18:17Z. --- #2549 | head b81ce41c1042a11872ad9abcc1a5026e4a3b7a74 (merged cleanly with main 02f71ccfe78160997a02950607be583af87e1180) | `ctest --test-dir runtime/build -C RelWithDebInfo -R "^(image_memory|memory_breakdown|d3d12_existing_heap)$" --output-on-failure` (`LEONIDA_VK_VALIDATION=1`) | red on main: `image_memory_test.cpp` and `memory_breakdown_test.cpp` fail to compile (`C2039`: `ImageMemoryPool::Stats::{used_bytes, empty_blocks, largest_free}`, `TitlePlaced`, `measure_title_placed`, and `DeviceShare::{texture_blocks, title_placed}` absent on `main`) | green on PR+main: `3/3` CTests pass (`image_memory` including 4,000-step `churn_stats`, `memory_breakdown` including `placed()` interval-union overlap tally and formatted summary, and `d3d12_existing_heap` on RTX 3090); `test_ci_registration.py` `18/18` OK, `check_no_game_data.py` `0` violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yes Audited lock acquisition order in the `DeviceShare` snapshot (`d.image_memory->stats()`, then `d.title_image_mutex`, then `d.descriptor_mutex`, with no nested locks) and saturating `UINT64_MAX - start` interval union in `measure_title_placed`.
lixonik commented 2026-11-28 09:28:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T09:28:01Z.

Review: APPROVED


Reviewed the diff (stacked on #2547) and tested merged onto main (493867366) with Ninja Release (MSVC).

Computing covered, distinct (with overflow-safe span end clamping), and shared_start in measure_title_placed while walking d.title_images under title_image_mutex is clean, lock-safe, and well-tested.

Tests run

  • cmake --build <build> --target image_memory_test memory_breakdown_test gta6rt_d3d12_com: built cleanly.
  • ctest --output-on-failure -R "^(image_memory|memory_breakdown)$": 2/2 passed.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6096961296 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2549#pullrequestreview-6096961296). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T09:28:01Z. **Review:** APPROVED --- Reviewed the diff (stacked on #2547) and tested merged onto `main` (`493867366`) with Ninja Release (MSVC). Computing `covered`, `distinct` (with overflow-safe span end clamping), and `shared_start` in `measure_title_placed` while walking `d.title_images` under `title_image_mutex` is clean, lock-safe, and well-tested. ### Tests run - `cmake --build <build> --target image_memory_test memory_breakdown_test gta6rt_d3d12_com`: built cleanly. - `ctest --output-on-failure -R "^(image_memory|memory_breakdown)$"`: **2/2 passed**. AI-assisted (Antigravity, Gemini).
KelboLive commented 2026-11-30 16:53:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T16:53:49Z.


Independent check on Windows (not the author), at b81ce41c1.

  • Built memory_breakdown_test and ran it: exit 0, memory_breakdown: ok.
  • The run reports the live placed-texture overlap accounting: title-placed textures 3: 300 MiB covered, 200 MiB distinct (1 start where another does), 320 MiB of images and the placed render targets line, alongside the existing breakdown.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7285398072 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2549#issuecomment-7285398072). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T16:53:49Z. --- Independent check on Windows (not the author), at `b81ce41c1`. - Built `memory_breakdown_test` and ran it: **exit 0**, `memory_breakdown: ok`. - The run reports the live placed-texture overlap accounting: `title-placed textures 3: 300 MiB covered, 200 MiB distinct (1 start where another does), 320 MiB of images` and the placed render targets line, alongside the existing breakdown. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711. AI-assisted: yes (opencode).
aslan2142 commented 2026-12-01 16:46:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:46:03Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318189569 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2549#issuecomment-7318189569). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:46:03Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

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
ProjectLeonida/mandy!2549
No description provided.