Low-VRAM GPUs (4 GB, no Resizable BAR; GTX 1650/1660-class laptops): where memory goes today, and a budget-aware placement proposal
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 15/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
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)
- Textures: each one gets its own
vkAllocateMemory, preferringDEVICE_LOCAL(runtime/shims/d3d12_vulkan_device.cpp:1440).DeviceState::allocate(:930-948) tries each type frommemory_type_orderand 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. - Arena: 256 MiB by default (
LEONIDA_ARENA_MB),HOST_VISIBLE | HOST_COHERENT, preferringDEVICE_LOCAL. It is larger than the 246 MiB BAR heap, somemory_type_orderskips 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 aDEVICE_LOCALarena plus staging. Not a bug, but on this class of GPU the M4+ step decides whether GPU-read buffers go over PCIe every frame. - Placed textures are charged twice: the
ID3D12Heapreserves 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. - No budget in the layer: the device does not enable
VK_EXT_memory_budget. Only the DXGI shim reads it, forQueryVideoMemoryInfo(runtime/shims/dxgi_com.cpp:585-605).MakeResident/Evictcheck 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. - What the game is told:
DedicatedVideoMemoryis the real heap size (dxgi_com.cpp:670-682).XSystemGetAppMemoryUsageLimitreturns 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.
- Measure first. Land D3D-253. Also log once per device when a resource that preferred
DEVICE_LOCALwas 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. - 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. - Don't charge placed textures twice (#770).
- 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. - 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_textureand remap every copy's subresource index; - offline: a pool writer served through the
file_system.cppoverlay.
Neither exists yet, and both should wait forttpf_mips.py vram's totals on a real corpus, so we know the saving first.
- in the layer: allocate fewer mips in
- 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 vramsums 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.pyturns 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ItsNotRexed/Leonida のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ItsNotRexed/Leonida#3990 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 25/100
ItsNotRexed/Leonida#4257 · コメント 18 件 ·
メンテナーはふだん 1 日以内に返信
-
Python SPIR-V assembler encodes BF16 constants as IEEE half対応中かも @lumenpearson が今日担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 25/100
ItsNotRexed/Leonida#4237 ·
メンテナーはふだん 1 日以内に返信
-
SPIR-V reflection rejects Int8 array length constants対応中かも @lumenpearson が今日担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 22/100
ItsNotRexed/Leonida#4221 ·
メンテナーはふだん 1 日以内に返信
-
Interrupted stub rebuild can truncate a valid SPIR-V output対応中かも @lumenpearson が今日担当しました。 オープンbug
難易度 3/5 半日 初心者へのやさしさ 18/100
ItsNotRexed/Leonida#4183 ·
メンテナーはふだん 1 日以内に返信
ItsNotRexed/Leonida の issue をすべて見る
似ている issue
-
pydanty:is-working
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
pydantic/pydantic-ai#14187 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: legacy_json_to_doc crashes on persisted docs with "relationships": null対応中かも @Harsh23Kashyap が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
run-llama/llama_index#24392 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
pathintegral-institute/mcpm.sh#568 ·
メンテナーはふだん 21 日以内に返信