mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #443] d3d12/vulkan: add 4 GB low-VRAM budget steering, priority/pageable memory, and LEONIDA_RT_AS=off (VK-LOW-VRAM-BUDGET) #494
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#494
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/443
Author: @jujumoneylol
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:pr/vulkan-low-vram📝 Commits (2)
d62f113d3d12/vulkan: add 4 GB low-VRAM budget steering, priority/pageable memory, and LEONIDA_RT_AS=off9222350d3d12/vulkan: cap VRAM budget in d3d12_low_vram_test for >4.5 GiB GPUs and document env vars📊 Changes
7 files changed (+738 additions, -34 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+14 -1)📝
runtime/CMakeLists.txt(+9 -0)📝
runtime/shims/d3d12_com.h(+27 -1)📝
runtime/shims/d3d12_vulkan_device.cpp(+255 -32)📝
runtime/src/vulkan_memory.h(+145 -0)➕
runtime/test/d3d12_low_vram_test.cpp(+207 -0)📝
runtime/test/d3d12_state_map_test.cpp(+81 -0)📄 Description
Claimed in the coordination issue as: VK-LOW-VRAM-BUDGET (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122816234)
What and why
Adds an automatic low-VRAM survival layer in the Vulkan D3D12 shim for discrete GPUs with <= 4.5 GiB dedicated VRAM (e.g., 4 GB GTX 1650 / RTX 3050 4 GB) while leaving larger GPUs (>= 6 GB) and UMA iGPUs untouched by default.
VK_EXT_memory_budget,VK_EXT_memory_priority, andVK_EXT_pageable_device_local_memorywhen advertised by the driver, chainingVkMemoryPriorityAllocateInfoEXT(1.0for critical render targets / depth-stencil / arena allocations vs0.25for spillable textures/buffers).runtime/src/vulkan_memory.h,runtime/shims/d3d12_vulkan_device.cpp):DEVICE_LOCALVRAM (overridable viaLEONIDA_LOW_VRAM=on|off|auto,LEONIDA_VRAM_RESERVE_MB,LEONIDA_VRAM_CAP_MB,LEONIDA_VRAM_LOG=1).DEVICE_LOCALheadroom reserve for critical RT/DS targets; once liveVK_EXT_memory_budgetheadroom drops below the reserve, spillable allocations are proactively routed to system RAM (HOST_VISIBLE) instead of evicting render targets or causingVK_ERROR_OUT_OF_DEVICE_MEMORY.Heap::tiles) to fall back to system memory when VRAM is exhausted instead of returningE_OUTOFMEMORY.LEONIDA_RT_AS=off): cleanly disables RT acceleration structures on non-RT / low-VRAM GPUs and answersGetRaytracingAccelerationStructurePrebuildInfowith minimal 256-byte aligned sizes so callers do not allocate or divide by zero.runtime/test/d3d12_state_map_test.cppand a live GPU stress test (runtime/test/d3d12_low_vram_test.cpp) that oversubscribes VRAM past 100% and verifies critical RT/DS pinning + spillable steering +LEONIDA_RT_AS=off.Tested
d3d12_state_map_test,d3d12_low_vram_test, andd3d12_vulkan_device_testwith MSVC 19.44 (vcvars64) + Ninja on top ofmain8f481cf16.d3d12_state_map_test: PASSED (including new low-VRAM policy & placement unit tests).d3d12_low_vram_test: ALL CHECKS PASSED on GTX 1650 (3,935 MiB VRAM,budget=1 priority=1 pageable=1, 512 MiB reserve):LEONIDA_RT_AS=offdisables RT and returns 256-byte prebuild sizes.d3d12_vulkan_device_test: PASSED (60/60 resolves matched, 20/20ID3D12Heap::GetDescmatched, host-image/staging copies, castable formats, and Xbox-ABI proxy checks matched).py -3.13 -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/d3d12_com.h runtime/shims/d3d12_vulkan_device.cpp runtime/src/vulkan_memory.h runtime/test/d3d12_low_vram_test.cpp runtime/test/d3d12_state_map_test.cpp: clean.GPUs tested: NVIDIA GeForce GTX 1650 Mobile 4 GB (driver 592.00, Vulkan 1.4.325, Windows 11 26200)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — Vulkan D3D12 runtime only)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.