Skip to content

ProjectScarlett at 3840x2160: native copies of guest textures reach 9.2 GB by the loading screen, and a 12 GB card runs out of memory #292

Backlog

Description

@JeffreyBytes

What happens

With #258 (d50a51c) the RX 6700 XT runs ProjectScarlett without the #191 preload and gets through the page-remap batch, but every run then ends on the story loading screen: VRAM fills, GTT climbs, and the kernel refuses a submit (radv/amdgpu: Not enough memory for command submission, device lost) or the title's watchdog fires on stalled label waits. The run reports are on #258. @DrArroway measured about 28.5 GiB of VRAM + GTT on a 16 GB / 64 GB machine once the world streams, against about 27.5 GiB available on a 12 GB / 32 GB one.

The console has 16 GB in total, so most of that is how the provider holds data, not what the title needs. This issue is a breakdown of where it goes, from one run.

Setup

RX 6700 XT (1002:73df, 12 GB), 32 GB RAM, Mesa RADV 26.3.1, Linux 7.3.6, GE-Proton11-14, ProjectScarlett 1.0.2.1 offline, 3840x2160, shaders prepared, no LD_PRELOAD. Build: #258 at d50a51c plus one local diagnostic commit that counts the provider's live native objects by category and logs them every 5 s (TUXBOX_TRACE_GPU_MEMORY=1). The counters go down when the native object is released. Sizes are approximate (GetResourceAllocationInfo for textures). The commit is on my fork as local/mem-accounting; it is a measuring aid, not something I am proposing to merge as it is.

Result

Native device memory the provider holds, MiB (live objects in parentheses). The page-remap batch is at about 90 s.

time native copies of guest textures render heaps staging total counted CPU-side texture snapshots (host RAM, upper bound) imported guest pages (not new memory)
62 s 1,416 (1,151) 3,022 0 4,562 1,313 1,112
77 s 2,382 (16,253) 3,022 0 5,529 1,360 1,139
107 s 5,971 (17,585) 3,000 0 9,094 5,048 1,446
153 s 7,581 (22,677) 3,000 0 10,705 6,467 1,687
199 s 9,184 (27,566) 3,000 0 12,308 7,895 1,975
234 s (last) 9,222 (28,190) 3,000 1,659 14,009 7,895 2,607

Driver counters for the game process at the last sample (/proc/<pid>/fdinfo): amd-requested-vram 13,425 MiB, amd-requested-gtt 7,626 MiB, drm-memory-vram 9,809 MiB, drm-memory-gtt 11,241 MiB. Card totals: VRAM 12,271 of 12,272 MiB used, GTT 11,335 of 15,913 MiB. This run ended with the label-wait stall and the watchdog at 269 s; the two before it on d50a51c ended the same way or with the submit refused when GTT reached its total.

So:

  • Two thirds of the native memory is copies of guest textures: 9.2 GB in 28,190 native images at the end, growing from 1.4 GB before the title starts streaming. Committed render targets are 64 MiB, and nothing is on default, upload or readback heaps of the provider's own.
  • Each of those textures also has a CPU-side snapshot, up to 7.9 GB of host RAM, on top of the guest pages the title wrote them to. That is the same texel data three times: guest pages, host snapshot, native image.
  • Render heaps are a flat 3.0 GB from the menu on.
  • Imported guest memory is small (2.6 GB of guest pages pinned, no new memory), which matches the hold numbers on xmem: back physical pages with private memory and export backing holds #258.

Where the copies come from (reading the code, not measured further)

  • runtime/d3d12/src/device/placement.rs: a CPU-visible texture placed at a guest address gets a committed native image on a DEFAULT heap, and Contents::previous keeps an exact per-mip copy of what was uploaded so later writes to the guest pages can be detected.
  • runtime/d3d12/src/device/heap.rs (RenderHeaps::acquire): images placed at guest addresses get device heaps while the guest range stays committed.

Buffers are imported in place now (#218, #253, #258). Textures are not, and on Vulkan they probably cannot be in general (console tiling and layouts differ from what a host image can alias), so I am not suggesting that. Cheaper things might be possible: dropping the CPU snapshot where a write-watch or a hash would do, releasing native images the title has stopped referencing, or creating the native image on first use rather than at placement.

What I am asking

Whether someone who knows the placement code sees which of these is realistic. I can run any candidate on this card, where the limit is hit two minutes after the picker, and report the same table.

Not established

  • One run with the accounting; the totals and the shape matched the driver counters of four earlier runs, but the per-category numbers have not been repeated.
  • What the 1.66 GB of staging in the last sample is (four objects that appear in the final 20 s).
  • About 3 GB of amd-requested-gtt at the end that the provider-side counters do not explain; vkd3d-proton's own allocations are not counted.
  • Whether the native images that stay alive are still referenced by the title.

Activity

  1. brcly commented on Nov 27, 2026

    @brcly
    Owner

    Yeah, this seems to be one of the last blockers to getting in the game.

    I can look into a solution and I emplore others to do so as well.

    Realistically, the way we have to handle this is to keep certain resources out of RAM + VRAM and only load when ready to display.

    I'll try and dig and see what I can find.

  2. NickStallman commented on Nov 27, 2026

    @NickStallman
    Contributor

    Some numbers from the NVIDIA side that may help separate the two endings. They come from an RTX 5090 (32 GB), 3840x2160 output, with a local probe build on e76ff6a + #235:

  3. JeffreyBytes commented on Nov 27, 2026

    @JeffreyBytes
    ContributorAuthor

    Follow-up with the question I left open: are the native texture copies in use? On this card, almost none of them are, and almost none have ever had anything uploaded into them.

    I extended the local trace (same branch on my fork, now two commits) to stamp each native copy of a guest texture when a submission uses it, when a view is created over it, and when the provider uploads guest bytes into it. One no-preload run of #258 d50a51c plus the trace, RX 6700 XT, 3840x2160; this one ended with Not enough memory for command submission at 186 s.

    time live native copies never used by any submission never uploaded to CPU snapshots actually allocated staging
    41 s 1,138 / 1,398 MiB 1,121 / 1,357 MiB 1,118 / 1,352 MiB 58 MiB 0.5 MiB
    71 s 16,253 / 2,382 MiB 16,223 / 2,323 MiB 16,220 / 2,318 MiB 84 MiB 0.5 MiB
    101 s 20,968 / 7,376 MiB 20,936 / 7,350 MiB 20,926 / 7,345 MiB 82 MiB 0.8 MiB
    131 s 24,635 / 8,440 MiB 24,603 / 8,415 MiB 24,593 / 8,409 MiB 82 MiB 0.8 MiB
    147 s 25,743 / 8,656 MiB 25,274 / 7,736 MiB 25,255 / 7,729 MiB 1,060 MiB 4,981 MiB
    152 s 25,756 / 8,656 MiB 25,254 / 7,631 MiB 25,237 / 7,627 MiB 1,240 MiB 3,117 MiB
    162 s (last) 25,756 / 8,656 MiB 25,254 / 7,631 MiB 25,237 / 7,627 MiB 1,240 MiB 10,737 MiB (16 objects)

    What I read from it:

    • Up to the point where the world starts drawing, 99.6% of the VRAM held by guest texture copies is images nothing has been uploaded to (8,409 of 8,440 MiB at 131 s), and at the end it is still 88% (7,627 of 8,656 MiB). The native image is allocated when the title creates a view over the guest address (never_titled in the trace: 23,357 of the 25,756 come from address-only SRVs), long before anything draws with it, if anything ever does. Creating the native image at the first upload instead would have kept about 7.6 GB of VRAM free here. That is the "load when ready to display" direction, and this says how much it is worth on this path.
    • A correction to my first table: the CPU-side snapshots are much smaller than the upper bound I gave (7.9 GB). They are only allocated for textures that have been uploaded: 82 MiB during loading, 1.2 GB once drawing starts. They track use, so they are not the problem on a 12 GB card.
    • What actually ends the run is staging. It is flat at under 1 MiB for 130 s, then goes to 5 GB, 3 GB, 7.8 GB and 10.7 GB in 16 objects over the last 15 s, at the same time as the first 500 textures are used. That fits @NickStallman's publication readback buffers (several hundred MiB per job), so his narrowing of the write set looks like the fix for the out-of-memory ending, and it would matter on any card.
    • Possible orphans: 8,397 copies (2.55 GB) are overlapped by a newer image at an overlapping guest address, and the base address of 169 (527 MiB) is no longer committed. None had lost all title references (released=0), so the provider is not parking anything itself; the title, or a descriptor slot, still names them. Nothing evicts a copy today.

    So on a 12 GB card the two things worth doing look like: do not allocate the native image until the first upload (about 7.6 GB here), and bound the publication readback (about 10 GB at the peak here). Both would have to hold before this card can get past the loading screen.

    Limits: one run. "Used" is counted per submission and over-counts when a whole descriptor heap is bound, so the never-used numbers are lower bounds; the never-uploaded column does not have that problem. Descriptor copies and Map are not counted as uses.

    I can run either change on this card when there is a branch, with the same table.

  4. JeffreyBytes commented on Nov 27, 2026

    @JeffreyBytes
    ContributorAuthor

    I'm trying a prototype of the first of those (allocating the native image at first upload instead of at placement or view creation) on this card. I'll post what it does to the table either way; say so if you already have this in hand and I'll test yours instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions