Skip to content

Trails in the Sky 1st Chapter: current-main integration and GPU memory fix - #1002

Open
jonareyess wants to merge 2 commits into
seedds:mainfrom
jonareyess:codex/trails-in-the-sky-1st-chapter
Open

jonareyess wants to merge 2 commits into
seedds:mainfrom
jonareyess:codex/trails-in-the-sky-1st-chapter

Conversation

@jonareyess

@jonareyess jonareyess commented Nov 2, 2026 •

Copy link
Copy Markdown

Adds the Mac profile for Trails in the Sky 1st Chapter (01002C9022770000, update 1.0.7) on current main. Uses main's pipeline-selected integer outputs and image-view fitting, with the remaining fixes for invocation-private compute scratch, reflected compute group sizes (runtime and offline archive), and GLSLC compute-code offsets.

Fixes excessive GPU allocation from unbounded buffer lookups. Indirect indexed draws created overlapping 80–100 MB views over a 1,507 MB pool, reaching 4,243 MB of shared buffers and GPU out-of-memory errors on M1. Unbounded lookups now share one whole-pool view; short cached views cannot satisfy them. Known-size accesses retain chunking, and existing views remain valid for encoded GPU addresses.

Validation:

  • All 6,602 Mac shaders build, and the corrected app packages successfully.
  • Pool tests: 171 checks pass, including a GPU access 96 MB beyond an unbounded address. The pre-fix renderer fails 20 checks.
  • The full graphics target list, targeted tool/docs/chain tests, and Python/C lint pass.
  • Trails' shader/interface regression against b06f4e0e preserves 6,602/6,602 shaders with no new failures. Two expected MSL changes come from private-scratch lowering.
  • A 70-second scripted save load reaches frame 3,900 without GPU-memory errors; loaded-scene Metal allocation stays at 2,685 MB. A subsequent owner walking/combat session lasts about seven minutes, exits normally without GPU-memory errors, and stabilizes near 3,153 MB.
  • Visual validation on M1: the owner confirms that menu eyes and bestiary lighting are correct with this integration.
  • M1 performance observation: the owner reports substantially fewer severe frame-time drops with DM_RT_FRAME=0. The log confirms the switch and a normal exit without GPU errors. These were manually repeated sessions of different durations; this is a diagnostic result, not an established scheduling fix. No default or profile setting is changed.

Longer-session stability, renewed reflection checks, and the cause of the scheduling-related performance difference remain open. iOS is untested. The game note and shared references record the causes and supporting evidence.

jonareyess pushed a commit to jonareyess/nxnative that referenced this pull request Nov 2, 2026
Both findings already fail on upstream main at 65501fb, in the same
unchanged test and on the same lines as PR seedds#1002. The PR did not introduce
them: the original PR diff does not modify t_geometry_hazards.m.

Main CI evidence:
https://github.com/seedds/nxnative/actions/runs/41481560591
Original PR CI failure:
https://github.com/seedds/nxnative/actions/runs/41527614521

Check the readback buffer allocation before passing it to Metal. Document
the retain-count false positive with a targeted NOLINTNEXTLINE: serial_put
stores the CFBridgingRetain-owned object in g_by_serial's C hash table.
Keep the lint baseline unchanged.

Validation: LLVM 23.1.4 full clang-tidy scan, 218 sources, 271 findings
matching the baseline, zero file/check pairs above or below it. The Metal
geometry hazards test passes 57 checks in each of its three configurations.
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) rewriter The NSO rewriter and per-build patches packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts) docs Documentation shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders game: 01002C9022770000 A game profile new game Adds a game profile that main does not have yet labels Nov 3, 2026
@ricardosousa191

Copy link
Copy Markdown

Tested this PR on my M3 air and the game is working as intended and haven't encountered any type of graphical bugs in my 1 hour of gameplay.

Screenshot:
image

@seedds

seedds commented Nov 13, 2026

Copy link
Copy Markdown
Owner

A note for this PR: main now handles integer colour outputs per pipeline, which overlaps with this PR's "mixed integer/float fragment alternatives selected from the actual attachments".

Trails in the Sky 2nd Chapter (same engine, now on main in 6cb67b8) hit the same red line: a G-buffer with a float target at colour 0 and integer targets at colours 1 to 3, where the integer entry point chosen from the shader's code left out an output that goes to an integer target. Every rule that told integer outputs apart from the shader's code just moved the red line to the next shader.

c398ff3 (chain/dmsh_entry) replaces those rules. main0_u now returns each colour either as a float or as the same bits as an unsigned integer, chosen by a function constant (DMSH_UINT_FC + n, 208 to 215). The host specializes it with the pipeline's own integer-target mask (pso_uint_mask, uint_fn, cached per shader and mask). The alpha-test (main0_u_a) and logic-op (main0_u_l) entry points follow the same switch. The fixed mixed entry point main0_m is gone.

Reference: Integer outputs told by the pipeline's targets.

Checked on the 2nd Chapter (no [RED] in a fresh-save route), Luigi's Mansion 3 (every G-buffer target integer) and Kirby Star Allies (float and integer targets mixed). The logic-op replay (941 checks) and the alpha-test replay (788 checks) pass.

If this PR is rebased onto main, its integer-output alternatives can most likely be dropped in favour of main's. The menu eyes and bestiary lighting would then be worth rechecking on the 1st Chapter. I haven't run the 1st Chapter on main myself.

@jonareyess jonareyess changed the title Trails in the Sky 1st Chapter 1.0.7 plays on the Mac Trails in the Sky 1st Chapter: current-main integration and GPU memory fix Nov 13, 2026
An indirect index address has no CPU-known extent. Guessing 64 MB made
80-100 MB views for successive 16 MB strides, accumulating 4.2 GB of
shared buffers over Trails' 1.5 GB pool, and did not cover legal reads
beyond the guess.

Use one full-pool view for unbounded lookups and reject short cached views.
Keep bounded chunking and existing views for previously encoded addresses.
The regression fixture checks shared views and a GPU access 96 MB beyond
the starting address; the pre-fix renderer fails 20 checks.
Add the 1.0.4/1.0.7 build metadata, shader tables and prewarm list. Preserve
main's integer-output specialization and image-view fitting instead of the
older alternatives from this PR.

Keep the required private-scratch lowering, fixed compute group descriptors
and GLSLC code-offset correction, with their tests and shared references.
Record the current-main memory regression, the older-app comparison and
the corrected host's short load check; long combat validation remains open.
@jonareyess
jonareyess force-pushed the codex/trails-in-the-sky-1st-chapter branch from 01be0ec to 0a7d664 Compare November 13, 2026 22:39
@jonareyess

Copy link
Copy Markdown
Author

Updated on current main, keeping its pipeline-selected integer outputs and removing our older alternatives. I rechecked the menu eyes and bestiary lighting on M1, and both render correctly. The PR now contains two focused commits, with validation details in the description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 01002C9022770000 A game profile new game Adds a game profile that main does not have yet nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers rewriter The NSO rewriter and per-build patches shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants