Skip to content

Add Ghost Trick: Phantom Detective support - #138

Closed
Nishikori-Yui wants to merge 4 commits into
seedds:mainfrom
Nishikori-Yui:ghost-trick-pr
Closed

Nishikori-Yui wants to merge 4 commits into
seedds:mainfrom
Nishikori-Yui:ghost-trick-pr

Conversation

@Nishikori-Yui

Copy link
Copy Markdown
Contributor

Summary

  • Add the Ghost Trick: Phantom Detective (010029B018432000) game profile and shader tables.
  • Fix 3D image atomic indexing in generated Metal shaders for the game's compute shaders.
  • Enable uploads for UI ASTC textures written through CPU-visible pools without an explicit flush.
  • Document the Mac and iPhone bring-up route and stable 60 fps results.

The base game 1.0.0 profile includes the Bonus Content add-on index, RE Engine pak shader extraction, and the memory settings required by the rewritten modules. All 7,744 shaders compile for Mac and iOS.

Validation

  • Mac and iPhone routes reach the language screen at a stable 60 fps with no unhandled host import, crash, or red line.
  • make -C dm/host/tests GAME=010029B018432000 run
  • make -C dm/gfx/tests GAME=010029B018432000 t_nvn
  • dm/gfx/tests/t_nvn (124 checks, 0 failed)
  • git diff --check

Save behavior remains to be tested.

seedds added a commit that referenced this pull request Oct 25, 2026
…0, Capcom's RE Engine on SDK 13.3.0, with the Bonus Content add-on): game profile, and finalized pool buffers no longer kept by a guest thread's autorelease pool (every game). Plays on the iPhone (IPA 3.0 GB, user)

The profile is the NSP script's provisional one with tex_flush_upload and tex_dirty_upload: RE Engine writes its UI textures (ASTC) into CPU-visible pools in place, as Monster Hunter Rise does, and without both keys the language screen's background and buttons were magenta (with tex_flush_upload alone they still were). 7,744 shaders from the PAK's SDF definitions and main; 7,739 build. The other 5 are compute shaders with atomics on a 3D image, which SPIRV-Cross indexes with an int3, as Octopath Traveler 0's 16; none was requested on the routes below. PR #138 (Nishikori-Yui) built them by flattening the coordinate in dmsh_build.py, a chain change that would rebuild every game's libraries, so it is left out until a run requests one (the game note). PR #138's profile is the same as this one (the same keys and shader tables).

Host fix: the memory line's "freed but alive" count only grew in most games (Animal Crossing: New Horizons 3,113 after 27,900 frames, Pokémon Sword 2,050, Super Smash Bros. Ultimate 1,279; Ghost Trick 125 to 146 buffers, 6.6 to 8.7 GB of zero-copy buffers, so GPU allocated read 9.9 to 11.7 GB against 2.2 GB resident). A temporary census of every host table that can hold a texture over a pool buffer found no holder: mtl_pool_del runs on the guest thread that finalizes the pool, whose implicit autorelease pool never drains, and adding the buffer to the weak table g_dead_pools left it autoreleased there. containsObject: / removeObject: on a weak NSHashTable do the same (a standalone test), and res_add / res_remove call them on guest threads too. mtl_pool_del, res_add_at and res_remove now have their own @autoreleasepool. Ghost Trick: 0 freed but alive, GPU allocated 1.7 GB instead of 8.3 GB 300 frames into the boot and 2.9 GB in Chapter 1, resident memory, frame times and pictures unchanged; Pokémon Sword: 8 to 0 at the title after 90 s, the same frame pacing.

On the Mac: the opening movies, the language screen, the first-boot notices, save creation, the Bonus Content notices and Chapter 1's opening in the junkyard (the Ghost World, the first trick), and a second boot that loads the save, at 60 fps (frame interval p99 about 17 to 19 ms), about 2.3 GB resident, no red line; the Wwise sound plays (a muted run with DM_AUDIO_DUMP). Checked: the tool tests (57, the docs check among them), t_nvn (124 checks), a boot of the rebased host. README (games gallery, a Mac picture of the junkyard), AGENTS.md's count (sixty-two: the gallery's cells), the game note, the games table, docs/reference/nvn-objects.md and the symptom index say so
@seedds

seedds commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thank you for this port. Ghost Trick is now on main in 7d368c4, ported independently with your PR as a reference, so I'm closing this one.

What went in, and how it relates to this PR:

  • Profile: the same as yours: the NSP script's provisional profile plus tex_flush_upload and tex_dirty_upload. Your note about the magenta UI ASTC textures was right. I checked it: without both keys the language screen is magenta, and tex_flush_upload alone isn't enough. The shader tables match yours too.
  • 3D image atomics (image_atomic_3d in dmsh_build.py): left out for now. It changes the shader translation chain, so every game's shader libraries would have to be rebuilt, for 5 compute shaders in this game. None of the 5 was requested in about 25 minutes of Mac runs (the opening, the menus, Chapter 1's junkyard). The game note (dm/games/010029B018432000/README.md, "Files and shaders") points to this PR, to be picked up if a run ever requests one of them.
  • Docs: the repository's docs moved to per-game notes and docs/reference/ since this PR, so the notes were written in the new layout instead of docs/development.md and 04-graphics.md.

The port also turned up a host bug that affects every game. Finalized memory-pool buffers stayed alive in the finalizing guest thread's autorelease pool: in this game 125–146 buffers, 6.6–8.7 GB of GPU allocations. It is fixed in the same commit. The game plays on the iPhone, and saves are created and loaded.

@seedds seedds closed this Oct 25, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…0, Capcom's RE Engine on SDK 13.3.0, with the Bonus Content add-on): game profile, and finalized pool buffers no longer kept by a guest thread's autorelease pool (every game). Plays on the iPhone (IPA 3.0 GB, user)

The profile is the NSP script's provisional one with tex_flush_upload and tex_dirty_upload: RE Engine writes its UI textures (ASTC) into CPU-visible pools in place, as Monster Hunter Rise does, and without both keys the language screen's background and buttons were magenta (with tex_flush_upload alone they still were). 7,744 shaders from the PAK's SDF definitions and main; 7,739 build. The other 5 are compute shaders with atomics on a 3D image, which SPIRV-Cross indexes with an int3, as Octopath Traveler 0's 16; none was requested on the routes below. PR seedds#138 (Nishikori-Yui) built them by flattening the coordinate in dmsh_build.py, a chain change that would rebuild every game's libraries, so it is left out until a run requests one (the game note). PR seedds#138's profile is the same as this one (the same keys and shader tables).

Host fix: the memory line's "freed but alive" count only grew in most games (Animal Crossing: New Horizons 3,113 after 27,900 frames, Pokémon Sword 2,050, Super Smash Bros. Ultimate 1,279; Ghost Trick 125 to 146 buffers, 6.6 to 8.7 GB of zero-copy buffers, so GPU allocated read 9.9 to 11.7 GB against 2.2 GB resident). A temporary census of every host table that can hold a texture over a pool buffer found no holder: mtl_pool_del runs on the guest thread that finalizes the pool, whose implicit autorelease pool never drains, and adding the buffer to the weak table g_dead_pools left it autoreleased there. containsObject: / removeObject: on a weak NSHashTable do the same (a standalone test), and res_add / res_remove call them on guest threads too. mtl_pool_del, res_add_at and res_remove now have their own @autoreleasepool. Ghost Trick: 0 freed but alive, GPU allocated 1.7 GB instead of 8.3 GB 300 frames into the boot and 2.9 GB in Chapter 1, resident memory, frame times and pictures unchanged; Pokémon Sword: 8 to 0 at the title after 90 s, the same frame pacing.

On the Mac: the opening movies, the language screen, the first-boot notices, save creation, the Bonus Content notices and Chapter 1's opening in the junkyard (the Ghost World, the first trick), and a second boot that loads the save, at 60 fps (frame interval p99 about 17 to 19 ms), about 2.3 GB resident, no red line; the Wwise sound plays (a muted run with DM_AUDIO_DUMP). Checked: the tool tests (57, the docs check among them), t_nvn (124 checks), a boot of the rebased host. README (games gallery, a Mac picture of the junkyard), AGENTS.md's count (sixty-two: the gallery's cells), the game note, the games table, docs/reference/nvn-objects.md and the symptom index say so
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 11, 2026
…s memory pressure, large empty images share memory again on Turnip, soft textures go further' (seedds#138) from Omnicrash/BananaNative-fork:pr/memory into android

Reviewed-on: https://git.eden-emu.dev/moceure/BananaNative/pulls/138
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