From 128f7644f6272409c7a92b8c9b1bd8e5038c082e Mon Sep 17 00:00:00 2001 From: James Dansereau <106631954+jkdansereau@users.noreply.github.com> Date: Fri, 28 Aug 2026 16:09:30 -0400 Subject: [PATCH] Reapply "D95: double the -mgfx master-DL buffer on PC (16-byte Gfx vs N64 8-byte)" This reverts commit 9f53c260eeb0430e55bc838bac030d84999543ae. --- src/game/dyn.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/game/dyn.c b/src/game/dyn.c index d76aa017..a13f12e0 100644 --- a/src/game/dyn.c +++ b/src/game/dyn.c @@ -53,9 +53,26 @@ void dynInitMemory(void) { g_VtxSizesByPlayerCount[getPlayerCount() - 1] = strtol(tokenFind(1, "-mvtx"), NULL, 0) * 1024; } +#ifdef PORT + /* D95: the -mgfx budget (from boss.c's per-level memallocstringtable) is a + * byte count sized for N64 8-byte `Gfx` slots. On x86-64 a `Gfx` is 16 + * bytes, so the same master display list needs 2x the bytes -- otherwise + * `gdl` (bumped with a bare `gdl++` by every render fn, no bounds check) + * marches past g_GfxBuffers[1]/[2], off the stage mempool, and eventually + * faults at the end of the 8 MB emulated DRAM (0x70800000) while writing a + * GBI command. Scale by sizeof(Gfx)/8. Vtx/Mtx are 16/64 bytes on both + * targets, so g_VtxBuffers is left alone. */ + { + s32 gfxHalf = g_GfxSizesByPlayerCount[getPlayerCount() - 1] * ((s32)sizeof(Gfx) / 8); + g_GfxBuffers[0] = mempAllocBytesInBank(gfxHalf * 2, MEMPOOL_STAGE); + g_GfxBuffers[1] = (g_GfxBuffers[0] + gfxHalf); + g_GfxBuffers[2] = (g_GfxBuffers[1] + gfxHalf); + } +#else g_GfxBuffers[0] = mempAllocBytesInBank(g_GfxSizesByPlayerCount[getPlayerCount() - 1] * 2, MEMPOOL_STAGE); g_GfxBuffers[1] = (g_GfxBuffers[0] + g_GfxSizesByPlayerCount[getPlayerCount() - 1]); g_GfxBuffers[2] = (g_GfxBuffers[1] + g_GfxSizesByPlayerCount[getPlayerCount() - 1]); +#endif g_VtxBuffers[0] = mempAllocBytesInBank(g_VtxSizesByPlayerCount[getPlayerCount() - 1] * 2, MEMPOOL_STAGE); g_VtxBuffers[1] = (g_VtxBuffers[0] + g_VtxSizesByPlayerCount[getPlayerCount() - 1]);