Skip to content

nvn: inherit aliased virtual pool flags and bound sampler pool IDs - #2519

Open
LNPANDY wants to merge 1 commit into
seedds:mainfrom
LNPANDY:nvn-vpool-alias-sampler-oob
Open

LNPANDY wants to merge 1 commit into
seedds:mainfrom
LNPANDY:nvn-vpool-alias-sampler-oob

Conversation

@LNPANDY

@LNPANDY LNPANDY commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Inherit physical backing pool storage flags on 1:1 aliased virtual memory pools (vmode == 1) via pool_host_flags, allowing CPU-written textures in pools such as 0x22 and 0x24 to upload and flush while preserving virtual pool CPU_NO_ACCESS behavior in nvnBufferMap and nvnMemoryPoolMap.
  • Record pre-mapping pool usage via vpool_note_used so pools already bound to a texture, buffer, command memory, or GPU address stay in sparse mode (vmode == 2) instead of being aliased on the first MapVirtual.
  • Record sampler descriptor pool capacity in mtl_set_samp_pool_n and return nil for out-of-range sampler IDs (such as sentinel 4095) without false [RED] logs while keeping in-pool unregistered ID checks strict.
  • Carry host_flags and samp_pool_n in frame capture and replay (nvn_capture and nvn_replay).
  • Add Metal regression test dm/gfx/tests/t_vpool_alias.m.

Verification

  • make -C dm/gfx/tests GAME=01007EF00011E000 check_t_vpool_alias: t_vpool_alias: ok (36 checks) with MTL_DEBUG_LAYER=1 (negative check removing the fix failed 10/36 assertions).
  • t_border: 113 checks, 0 failed.
  • t_readback: 217 cases, 0 failed.
  • t_sparse_tiles: 4253 checks, 0 failed.
  • t_copy_alias: 126 checks, 0 failed.
  • t_large_mdi: passed.
  • t_serial_owner: 176 checks, 0 failed.
  • t_res_commit: 8 checks, 0 failed (MTL_DEBUG_LAYER=1).
  • nvn_replay: compiled cleanly.
  • python3 dm/tools/lint_c.py compdb: 291 sources (clang-tidy not installed locally).
  • python3 -m unittest dm/tools/tests/test_docs.py dm/tools/tests/test_pr_areas.py: 11 tests OK.

Refs #2513

Two NVN issues found when bringing up Super Mario Party (010036B0034E4000):

1. Aliased virtual memory pools (vmode == 1) now keep the physical backing pool storage flags in host_flags (read via pool_host_flags) for texture initial fills, storage uploads, and FlushMappedRange dirty tracking, while nvnBufferMap and nvnMemoryPoolMap still inspect the virtual pool flags so CPU_NO_ACCESS remains enforced. If any texture, buffer, or pool GPU address is obtained before the first MapVirtual call, vpool_note_used marks the pool used so MapVirtual preserves sparse mode (vmode == 2) instead of aliasing over it. Frame capture and replay preserve host_flags.

2. nvnSamplerPoolInitialize now records the sampler pool capacity via mtl_set_samp_pool_n, and samp_by_id treats out-of-range sentinel sampler IDs (such as 4095) as empty slots returning nil without [RED] errors, while in-pool unregistered IDs still report [RED]. Frame capture and replay preserve samp_pool_n.

Includes regression test dm/gfx/tests/t_vpool_alias.m covering uncached (0x22) and cached (0x24) aliased texture uploads, pre-mapping vmode == 2 preservation, and sampler pool capacity bounds.

Refs seedds#2513
@github-actions github-actions Bot added the nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) label Nov 12, 2026
LNPANDY added a commit to LNPANDY/NX2Apple that referenced this pull request Nov 12, 2026
…l IDs (#1227)

Add patch 0045 (forwarded to seedds/nxnative#2519, Refs seedds/nxnative#2513) to resolve two NVN bugs hit during Super Mario Party (010036B0034E4000):

1. Aliased virtual memory pools (vmode == 1) now inherit the backing physical pool flags in host_flags while nvnBufferMap and nvnMemoryPoolMap still check virtual pool flags for CPU_NO_ACCESS, and pre-mapping pool use forces sparse mode (vmode == 2) via vpool_note_used.
2. nvnSamplerPoolInitialize records sampler pool capacity via mtl_set_samp_pool_n so out-of-range sentinel sampler IDs (such as 4095) return an empty slot cleanly instead of emitting [RED] errors, and dm_gfx_teardown resets g_spool_n and g_stat_samp_oob between iOS shell game runs.
3. Add dm/gfx/tests/t_vpool_alias.m (36 checks) and isolate nvn_hle_teardown in the single-TU test build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant