Low-VRAM GPUs (4 GB, no Resizable BAR; GTX 1650/1660-class laptops): where memory goes today, and a budget-aware placement proposal

オープン
#2,375 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp, python

調査の方向性

This is a multi-item design proposal, not a single change. Start with the allocation path in runtime/shims/d3d12_vulkan.cpp (DeviceState::allocate near lines 930-948, and the texture allocation near line 1440) and the memory type policy in docs/d3d12_vulkan.md. Done would mean the proposal is split into items with owners, and the budget and spill behaviour is agreed by maintainers.

索引モデルが issue の本文から書いたものです。

説明

The game doesn't boot yet, so this has no frame numbers. It records what the layer does with memory on a 4 GB card without Resizable BAR, measured on hardware and read from main (4eb6155), and proposes an order of work. Most of it builds on items that already have owners. I'm not claiming anything with this issue. The coordinator can split it into items, or close it if the plan is elsewhere.

The hardware

NVIDIA GeForce GTX 1650 Mobile (Turing TU117), NVIDIA 620.70.06, Linux. vulkaninfo: a 4 GiB DEVICE_LOCAL heap, a 246 MiB DEVICE_LOCAL | HOST_VISIBLE heap (no Resizable BAR), 22.65 GiB of host memory, and VK_EXT_memory_budget available. The GPU suite is clean on it (#166 entry). GTX 1650/1660 (Super/Ti), RTX 3050 Laptop 4 GB, RX 6500 XT/6400 and many laptops are in this class, and most of them have no Resizable BAR.

What the layer does today (main 4eb6155)
  1. Textures: each one gets its own vkAllocateMemory, preferring DEVICE_LOCAL (runtime/shims/d3d12_vulkan_device.cpp:1440). DeviceState::allocate (:930-948) tries each type from memory_type_order and takes the first that succeeds. So when VRAM is full, a texture silently lands in host memory: nothing is logged, and the game is told nothing.
  2. Arena: 256 MiB by default (LEONIDA_ARENA_MB), HOST_VISIBLE | HOST_COHERENT, preferring DEVICE_LOCAL. It is larger than the 246 MiB BAR heap, so memory_type_order skips that heap and every default-heap buffer, shader-visible descriptor heap and shader program lives in system memory here. That is the documented M0–M3 policy (docs/d3d12_vulkan.md, "Memory type policy"), with M4+ planned as a DEVICE_LOCAL arena plus staging. Not a bug, but on this class of GPU the M4+ step decides whether GPU-read buffers go over PCIe every frame.
  3. Placed textures are charged twice: the ID3D12Heap reserves its full range in the arena (:1951-1954), and every texture placed in it allocates its own memory as well (:1943-1945). #770 (D3D-88, aliasing) would remove that.
  4. No budget in the layer: the device does not enable VK_EXT_memory_budget. Only the DXGI shim reads it, for QueryVideoMemoryInfo (runtime/shims/dxgi_com.cpp:585-605). MakeResident/Evict check their arguments and do nothing (:3403-3432), because Vulkan has no residency API and paging under pressure is the kernel driver's job. D3D-253 (@wiverlord78, claimed in #313) adds budget reporting at device start and at allocation milestones.
  5. What the game is told: DedicatedVideoMemory is the real heap size (dxgi_com.cpp:670-682). XSystemGetAppMemoryUsageLimit returns total physical RAM (runtime/shims/xgameruntime.cpp:289-293). Whether the game sizes its pools from either is unknown until it boots (docs/d3d12_vulkan.md:1877-1878).
Proposal, in order

None of this changes behaviour on GPUs with enough VRAM.

  1. Measure first. Land D3D-253. Also log once per device when a resource that preferred DEVICE_LOCAL was placed elsewhere, with its size and the running total, so a first boot on a 4 GB card shows what spilled. I'll test D3D-253 on the GTX 1650 when it's up, if that helps @wiverlord78.
  2. Spill on purpose, not by accident. Once the budget is known, decide what may live in host memory rather than taking whatever fails last. Render targets, depth and UAV textures stay in VRAM. Large sampled textures created after the budget is reached are the first candidates for host memory. This only uses memory_type_order's existing fallback, with a budget check before it.
  3. Don't charge placed textures twice (#770).
  4. M4+ arena staging, already planned in docs/d3d12_vulkan.md: on a GPU without Resizable BAR this moves GPU-read buffers out of system memory. It costs a few hundred MiB of VRAM, so it competes with item 2, and the budget numbers from item 1 should decide.
  5. Later, only with the game running: the game's own quality profile. LEONIDA_DEVICE_TYPE=6 (Series S, xgameruntime.cpp:259-334) is the obvious first A/B, since it is the console profile with the least memory.

Not proposed: rendering on the CPU, and shrinking render targets inside the layer. The game picks those sizes, and changing them behind its back breaks views, copies and shader constants.

Also looked at, not proposed yet
  • The integrated GPU (Radeon Vega next to the GTX 1650 here). On a muxless laptop the iGPU already scans out, and the dGPU's frames are copied to it every frame anyway. Splitting rendering work between the two would need a cross-device copy through system memory per frame, which costs more than it saves. Frame generation on the iGPU already exists outside the project (Lossless Scaling / lsfg-vk on Linux). It needs no layer code, so it has no item here.
  • Smaller textures. Leaving the top mips out could save the most memory, but only in one of two ways:
    • in the layer: allocate fewer mips in create_texture and remap every copy's subresource index;
    • offline: a pool writer served through the file_system.cpp overlay.
      Neither exists yet, and both should wait for ttpf_mips.py vram's totals on a real corpus, so we know the saving first.
  • Lighter models and shorter draw distances. These come from the game's own LOD data (lodDist/childLodDist, docs/world.md:207) and its streaming. Scaling them would mean rewriting map and archetype files, and nothing writes those formats today. Not proposed until the game runs.
What I can offer
  • Testing on a GTX 1650 Mobile (4 GB, 246 MiB BAR, Linux): D3D-253, #770, and later the arena staging.
  • Two small tools on a local branch (not a PR yet), which I can open if they're wanted:
    • tools/ttpf_mips.py vram sums the bytes of the 2D TTPF textures at full size and with 1–3 top mips dropped. It reads metadata only and prints counts and byte totals.
    • tools/frametime_stats.py turns a MangoHud log into average FPS, P95/P99 frame time, 1% low and stutter count, and compares two runs, for one-change-at-a-time tuning once the game renders.

AI-assisted (Claude Code). No game files used.

主要言語
Python
スター
14.9k
フォーク
1.2k
平均マージ
1時間 58分
マージ済み PR(30日)
40

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ItsNotRexed/Leonida のほかの issue

ItsNotRexed/Leonida の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。