Skip to content

Add game_memory_mb: more game memory for HD texture packs - #1135

Closed
Zarigis wants to merge 1 commit into
Revivedx:testfrom
Zarigis:game-memory-mb
Closed

Zarigis wants to merge 1 commit into
Revivedx:testfrom
Zarigis:game-memory-mb

Conversation

@Zarigis

@Zarigis Zarigis commented Nov 26, 2026

Copy link
Copy Markdown

Adds game_memory_mb, a setting that gives the game more memory so HD texture packs load. The HDPacks.com 4K pack is the one tested. Off by default: with it unset (0), the game keeps its own 3120 MB heap and nothing changes.

Set it in savagewind.ini (game_memory_mb = 6144), or for one run with SAVAGEWIND_GAME_MEMORY_MB, for example from a launcher that starts the game with a pack. It goes up to 6144 MB. There is no menu entry yet.

What this changes

The 4K pack's textures don't fit in the game's fixed memory. Without this, the pack (converted for 1.9.0) crashes at the title screen. With the 4K terrain left out, it loads, but shrine walls and floors are missing.

With game_memory_mb set, the game is given a bigger heap. The resource heaps and the texture pool that the pack overflows are grown from the extra memory. The Vulkan backend can then see the larger heap.

How it works

Guest patches (tools/game_sites.py, tools/patches.py; all sites are optional groups, with known 1.9.0 addresses):

  • The size nninitStartup asks SetMemoryHeapSize for (0xC3000000), and the root heap's size: the heap less the 32 MB that malloc keeps.
  • The resource system's FixedHeap and its TexArcWork heap, where texture archives are tried first. Growing them isn't needed to load, but it means fewer failed first tries. Loading the Shrine of Resurrection with the pack and its terrain gave 24 instead of 41; the game's own files give 10.
  • The GPU texture pool: 500 MB, or 400 MB in the other mode the csel picks.
  • ForResourceL and StarterPackMgr, where the resident packs load: Pack/TitleBG.pack alone grows from 80 to 287 MB with the 4K terrain. ForResourceS is left as it is.

Runtime:

  • runtime/kernel.c: kernel_memory_setup runs once at start, before the renderer. It works out the heap and g_heap_max (the heap plus the same room the game's own has, rounded to 16 MB), and the extra memory each patched heap gets: the root heap is the heap less malloc's 32 MB; texture pool +min(extra × 2/3, 2 GB); ForResourceL and StarterPackMgr each +min(extra / 6, 512 MB); FixedHeap and TexArcWork each +min(extra / 4, 256 MB). GetInfo 6/21 report the larger total.
  • runtime/rt.h: HEAP_MAX becomes the variable g_heap_max. HEAP_MAX_CONSOLE (3.25 GB) and HEAP_MAX_LARGEST (6.25 GB) size what has to be fixed at build time. GUEST_HI moves up to make room; only what the game maps is committed.
  • runtime/nvn/vulkan/exec.c: a heap bigger than the game's own and past maxStorageBufferRange (4095 MB on NVIDIA) is read through two bindings. Where even the second binding would be past the limit, it uses buffer device address. Static arrays sized by the heap use HEAP_MAX_LARGEST.
  • runtime/platform/windows.c: the sparse heap's bitmap covers the largest heap.
  • runtime/settings.*, runtime/main.c: the setting and the environment override. The setting is written to the ini only when it's set.

With the option unset, g_heap_max is the old HEAP_MAX, every patch writes the game's own value, and the Vulkan setup takes the same path as before.

How it was tested

Windows 11, RTX 4080 SUPER, NVIDIA 617.42, 3840×2160, game 1.9.0 with both DLC, on test at 2a51d02.

Run Result
No pack, option unset Loads the save into the world, about 101 fps: unchanged
4K pack, option unset Crashes at the title screen (read at 0x38)
4K pack, game_memory_mb = 6144 Loads into the world, about 101 fps, same as without the pack
Details, and what wasn't measured
  • The pack has to be converted for 1.9.0 first. It ships 1.6.0 copies of whole packs, Pack/Bootup.pack and its own ResourceSizeTable, and as distributed it crashes on 1.9.0 whatever the memory. The converter is a separate PR. The runs here used a converted overlay holding only the pack's textures, its 4K terrain and its fonts.
  • Log with the option set: [kernel] game memory: 6144 MB heap (the game's own: 3120 MB), limit 6352 MB, ForResourceL 694 MB -> 1198 MB, StarterPackMgr 225 MB -> 729 MB.
  • Frame rates are from the [vk] t= lines while standing in the world on the Great Plateau, with a scripted load of the same save.
  • On an earlier build, based on main, the same patch was checked by hand: the Shrine of Resurrection, the Great Plateau, Hyrule Castle (inside), Zora's Domain and Gerudo Town, with the 4K pack and its terrain at 6 GB.
  • The test build these runs came from also had two runtime-only commits for the world map (separate PRs). Neither touches memory or the patches.
  • Not measured: VRAM use and RAM before/after. Only what the guest asks for is committed, so the option should cost nothing while unset. With it set, use grows with what the pack loads.

Checklist

  • Based on the latest test and opened against test
  • Built and run locally, and checked in the game
  • No game files, keys, firmware, generated game code or save files in the changes

The game's heap (3120 MB) and the limits HD texture packs run past grow with
the setting, off by default: the root heap, the models' texture pool (500 MB),
ForResourceL and StarterPackMgr (the resident packs), FixedHeap and TexArcWork.
Each size comes from the runtime (runtime/kernel.c), the game's own without
the setting. The guest window holds a heap of up to 6144 MB; past the device's
storage buffer limit the shaders read it in two bindings or by address.
SAVAGEWIND_GAME_MEMORY_MB overrides the setting for one run.
@Zarigis
Zarigis marked this pull request as ready for review November 26, 2026 01:48
Revivedx added a commit that referenced this pull request Nov 26, 2026
… on light ground, texture filtering

- Mods > HD texture packs > More memory for HD textures (#1135, Zarigis): game_memory_mb gives the
  game 6144 MB instead of its own 3120, and grows its resource heaps and texture pool, so big HD
  texture packs load. Off by default (checked: the 3120 MB heap and the same RAM as before); on, about
  3 GB more RAM, and the shaders read a heap past 4 GB by address. The switch is locked off under
  12 GB of RAM. SAVAGEWIND_GAME_MEMORY_MB sets it for one run.
- The world map's terrain capture follows the window's height (#1137, Zarigis): at 4K it was the
  1080p picture stretched 2x.
- Collectible hints stand out on light ground (#1131, Quorthon13): a small copy of the game image,
  read back a few times a second while the hints show, tells each circle how light the ground is.
- The texture memo follows sampler registration (#1118, Dathinel): a filter the game replaced within
  a frame could stay on a later draw.
- Tegra copies take full 64-byte GOB rows as four fixed sector copies (#1129, Dathinel).
- Render context 1/7: the pass in progress is one struct, ExecPass ps (#1139, Dathinel).
- A keyboard regression test for #1103 (#1119, Dathinel).
- The cascade-cut launch flag described on the start screen, and a CI job that keeps the launch flag
  table in sync (#1128, FictionHub).

Measured on a Ryzen 5 5600X + RTX 3060 at 1080p, Original preset (busy PC, 4 runs each): the runtime
changes move fps by -3 to +5 % per route, within the noise.

Co-authored-by: Dathinel <221246794+Dathinel@users.noreply.github.com>
Co-authored-by: Zarigis <2862464+Zarigis@users.noreply.github.com>
Co-authored-by: Quorthon13 <44161862+Quorthon13@users.noreply.github.com>
Co-authored-by: FictionHub <294548785+FictionHub@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Revivedx

Copy link
Copy Markdown
Owner

Integrated in test as 63b7255d, one clean commit with you as co-author. On top of it there's now a switch: Mods > HD texture packs > More memory for HD textures, which sets game_memory_mb = 6144. It's off by default and locked off under 12 GB of RAM. We checked that, left unset, the game keeps its 3120 MB heap and the same RAM as before. At 6144 the world loads, with the shaders reading the heap by address on NVIDIA. Thanks!

@Revivedx Revivedx closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants