Skip to content

Port: fix dungeon crashes from PC memory and map staging limits - #1

Closed
millerscout wants to merge 23 commits into
betafrom
fix/port-dungeon-memory-budgets
Closed

millerscout wants to merge 23 commits into
betafrom
fix/port-dungeon-memory-budgets

Conversation

@millerscout

Copy link
Copy Markdown
Owner

Summary

  • Bump PORT character model stack budgets and main_buffer headroom so dungeon entry no longer hits ArenaOverflow on human stack 0 (68500 qw retail cap).
  • Enlarge dungeon BuffReadData (1M qw), add PortAssertDungeonReadCursor, and document budgets in docs/PC.md.
  • Move CActiveMonster, CEffectScriptMan, and CMonsterMan off the MainBuffer slab into dedicated arenas so floor map staging cannot corrupt later globals (e.g. TreasureBoxMan on d04f01s).
  • Add CharaMemBudget, DungeonStageBudget, DungeonMapStaging.FloorMapsFitStagingBuffer, and headless DungeonStaging.HeadlessDungeonEntry ctests.

The memory-budget change is commit 08dc183; this branch also includes the local beta stack not yet on origin/beta. Squash or rebase before merge if you want a single commit.

Test plan

  • ctest -R 'CharaMemBudget|DungeonMapStaging|DungeonStageBudget|DungeonStaging.Headless'
  • In-game: load the room that runs _LOAD_DUNGEON_MAP_FILE for d04f01s (cfg d01f01)

Jeffie and others added 23 commits October 15, 2026 20:05
Keep upstream's row-count hit tests and assert the tab-strip gap at y=117.
Use remove_all on mc1 before replacing it with a file so InitForMC's directory
is fully cleared.
Every bag slot draws the same 40x50 koma from mt0, so its dark smudge
reads as a stamped grid at high resolutions. Mirror each slot by a fixed
hash of its row and column (the slot frame is symmetric) and shade a
low-frequency brightness field across the board. Both follow the bag
row, so the pattern scrolls with the board and stays stable.
Mirroring whole slots still left every frame line visible. Draw the
board by stochastic tiling instead: each vertex of a lattice that
ignores the slot grid owns a mirrored patch of the slot's interior
(frame lines excluded), and every lattice cell blends its four corners'
patches with weights that sum to one, so no patch edge shows. The
first pass replaces and the other three add. The capacity line under
the last usable row is kept.
Each patch carried the slot art's dark centre and lighter rim, so the
blended board looked blotchy. Divide that shading back out per vertex
with a cubic fit of the slot's brightness, on a finer lattice, and
soften the macro brightness field.
Entering a dungeon floor with a zipped upscaled pack read about 10,000
PNG headers through ReadPrefix, and each one reopened the multi-gigabyte
archive. Keep one handle per archive mount for those reads instead.
An area registers the same external PNGs many times; their logical extents
are now memoized. KZ_TEXTURE_TRACE also reports where texture registration
spends its time (extents, resolution, decode, upload, mip downsampling).
Area and character IMG sets decoded every pack PNG serially on the main
thread; with 4x packs that is tens of milliseconds per texture. They are
now prefetched in batches of 32 into the decode cache, like glTF images.
Pictures whose decoder names their pixels no longer keep a pristine copy or
decode every palette variant up front; they are compared by name and
alternate variants decode on selection, from the decode cache. Catalog
documents now name their pixels by their source files, so re-entered area
textures are reused without decoding.
stb_image inflates slowly; the png crate behind kazarov::png_decode_rgba
decodes upscaled textures several times faster. stb_image still reads
anything the bridge rejects. Needs Kazarov perf/png-decode.
Kazarov's png_decode_rgba (TheMoonPeople/Kazarov#15); move this to the
merged commit once that pull request lands.
The glTF ApplySkin fast path ignored bind-pose base_matrix and frame_id,
so shoe meshes could lag behind animated feet. Prefer retail palette math
when base_matrix is set, and add VisualMotion regressions.
…a budget.

Use an opaque header and tab band over mnwinback so retail parchment and ghost
tab labels do not show through; Georama polygon budget lives on the Game tab.
Let players shorten chest and floor-clear event pacing via game.dungeon_ceremony_qol (off, manual, auto) on PC overlay and retail options.
Raise character model stack budgets and main_buffer headroom, isolate dungeon monster/FX arenas from MainBuffer, and enlarge BuffReadData with staging guards and tests so large floor maps (e.g. d04f01s) cannot overwrite later globals.
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