Skip to content

Ampere F2IP and a task shader's own payload read: Ocarina of Time's untranslated shaders translate, all but one that is data - #1300

Closed
lunks wants to merge 4 commits into
seedds:mainfrom
lunks:pr/ampere-f2ip
Closed

lunks wants to merge 4 commits into
seedds:mainfrom
lunks:pr/ampere-f2ip

Conversation

@lunks

@lunks lunks commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Who needs it: Ocarina of Time (0400486024DEC000) players. ralph303's build log in #1265 lists 20 shaders that do not translate, with Ampere instruction 243 at 0x6ab0 (000fc400000004ff000000272c277243) is not implemented; the open list of #1299 has the same opcode (0x243) for foliage mesh and compute shaders and one task shader on ISBERD mode 0xb8. This adds the missing pieces. The 20 are 10 compute shaders and 8 foliage mesh shaders on F2IP, the task shader, and agl_common's 68bbe98b3bfd9876, which has data in place of code. All but the last translate with this PR.

  • F2IP (0x243), round to nearest. sm_86's F2IP converts two floats to integers and packs them. In the 10 compute shaders it is F2IP.U8.F32.NTZ Rd, a, b, RZ: each source rounded to nearest (ties to even), saturated to 0..255, NaN to 0, b in byte 0 and a in byte 1. They sit in colour converters (a 4x2 block to BT.709 Y and CbCr times 255) that join two results with PRMT 0x5410 before a store, so the byte order matters.
  • F2IP, source A RZ, truncating (second commit). The 8 foliage mesh shaders (Foliage.Product.110, three drawn in Kokiri Forest) have F2IP.U8.F32.NTZ Rd, RZ, b, RZ with bits 78..79 = 3 (0x0000c4ff): F2I's rounding bits, so truncation. Each converts a colour channel times 255 and shifts the byte into an RGBA8 word, which puts b in byte 0 as above. AF2ip now rounds by bits 78..79 and, with a = RZ, returns b's byte alone. Any other encoding stops the shader as before.
  • A task shader's own payload. It stores a payload word at +0x10 (mode 0xb8) and reads it back with ISBERD in the same mode. AIsberd now reads mode 0xb8 from the outputs, where AStageOut writes it.

Results on the game's v131072 files with the task and mesh shaders in the split (#1299's split): 42,850 of 42,851 shaders translate. On the compute-only split of the first commit, 11 of 12 did.

The two other opcodes reported for this game, 0x4a4 and 0x23c, are UIMAD with its immediate in C and HMMA, both translated already; UimadImmediateC adds a test for the game's one UIMAD of that form.

Reference entry: F2IP: two floats into two bytes. Refs #1265, #1299.

Checked

  • Tests (M5 Pro, macOS 27.0): dm/gfx/tests/test_dmsh_*.py with DMSH_TEST_XLATE on the rebuilt translator, 236 tests, 2 skipped, all pass. The new F2ip and F2ipTruncate tests (rounding, saturation and NaN; byte order; the other rounding modes; refused encodings) and StageMemory's own-payload read fail on main's translator and pass here. test_nsp_chain.py, test_xlate_anycpu.py, test_docs.py pass; docs_symptoms.py --check passes.
  • Shaders: the 8 mesh shaders, the 10 compute shaders and the task shader through the translator of this change (same source, built on our fork's stack from an Ocarina build's own package, 18 libraries, through spirv-cross and the Metal compiler): 42,850 of 42,851 translate. Not rerun on this branch.
  • Games run: none with this change. No game was played, so how the converted bytes look on screen is not verified.
  • Devices and OS: M5 Pro, macOS 27.0.
  • regress.py check: not run. Every game's shaders rebuild after a chain change; their translations change only where these instructions stopped a shader before. No other game's shaders were rebuilt.
  • Chain: translator rebuilt on this branch with dotnet publish, the five files copied, tool_lock.py --update-lock and dmsh_chain.py --header run (chain e1d4cc88b078).

Docs

  • The finding is in docs/reference/shaders.md and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change
  • No game files, keys or data extracted from a game in the change or the attachments

…me's 12 untranslated shaders translate; chain e463a2da5c4d

The Legend of Zelda: Ocarina of Time (0400486024DEC000, v131072) leaves 12 of its 42,321 shaders untranslated: 10 compute shaders on Ampere instruction 0x243, its agl task shader 5d3a096025e375a1 on "ISBERD mode b8 in a task or mesh shader", and agl_common's 68bbe98b3bfd9876, which has data in place of code (as in Splatoon Raiders, instruction 0x481).

0x243 is sm_86's F2IP (9-bit opcode 0x043). All 28 in the game are one form, F2IP.U8.F32.NTZ Rd, a, b, RZ, with F2I's fields (unsigned, 8 bits, round to nearest) and bit 74 set. They sit in colour converters that turn a 4x2 block into BT.709 Y and CbCr values times 255, quantize two at a time and join two results with PRMT 0x5410 before a store: the stored bytes are in pixel order only with b in byte 0 and a in byte 1. AF2ip rounds each source to the nearest integer (ties to even), saturates it to 0..255, takes NaN to 0 and packs them so, the upper half zero; any other encoding stops the shader.

The task shader stores a payload word at +0x10 (0x927 mode 0xb8) and reads it back with ISBERD in the same mode. AIsberd reads mode 0xb8 from the outputs, where AStageOut writes it.

The two opcodes others reported for this game, 0x4a4 and 0x23c, are UIMAD with its immediate in C (form 2) and HMMA, both translated already; UimadImmediateC tests the game's one UIMAD of that form (e9213c7fba8ccf93 +0x43c0).

Checked: the 12 shaders through the translator of this change (built from our fork's stack, same source) from the Ocarina build's own jobs: 11 give SPIR-V, 3 of them through spirv-cross and the Metal compiler. On this branch: translator rebuilt, lock and chain header regenerated (chain e463a2da5c4d); test_dmsh_*.py (234 tests, 2 skipped; F2ip and StageMemory's own-payload read fail on main's translator), test_nsp_chain.py, test_xlate_anycpu.py, test_docs.py. The chain changes, so every game's shaders rebuild; no other game's shaders were rebuilt (their translations change only where these two instructions stopped them before), regress.py not run.
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders labels Nov 5, 2026
…e's 8 untranslated foliage mesh shaders translate; chain e1d4cc88b078

On the Ocarina of Time build with task and mesh shaders in its split (0400486024DEC000, 42,851 shaders), 9 shaders still did not translate after the first F2IP: 8 foliage mesh shaders (Foliage.Product.110, three of them drawn in Kokiri Forest) on "F2IP other than .U8.F32.NTZ of two registers with RZ", and agl_common's 68bbe98b3bfd9876, which has data in place of code.

Their 14 F2IPs are one form, F2IP.U8.F32.NTZ Rd, RZ, b, RZ with bits 78..79 = 3 (hi word 0x0000c4ff). Those are F2I's rounding bits (nearest even, floor, ceiling, truncation), so this is .TRUNC. Each one converts a colour channel times 255 (FMUL by 255.0 just before it) and the result is shifted by 16 or 24 into an RGBA8 word (740e2b04db624fb1 +0x370 and +0x3a0), which puts b in byte 0, the same as the colour converters' PRMT 0x5410 showed. AF2ip now rounds by bits 78..79 and, when a is RZ, returns b's byte alone. Any other encoding is still refused. The 10 compute shaders using the round-to-nearest form give byte-identical SPIR-V.

Checked: on our fork's stack (same translator source), the 8 shaders and the 10 round-to-nearest compute shaders through dmsh_build.py from the build's own package (18 libraries; spirv-cross and the Metal compiler), with 42,850 of 42,851 translating. On this branch: translator rebuilt (chain e1d4cc88b078), test_dmsh_*.py (236 tests, 2 skipped; F2ip and F2ipTruncate fail on main's translator), test_nsp_chain.py, test_xlate_anycpu.py, test_docs.py. The chain changes, so every game's shaders rebuild; only F2IP's refused encodings translate differently, and regress.py was not run.
@lunks lunks changed the title Ampere F2IP and a task shader's own payload read: 11 of Ocarina of Time's 12 untranslated shaders translate Ampere F2IP and a task shader's own payload read: Ocarina of Time's untranslated shaders translate, all but one that is data Nov 5, 2026
stan69b pushed a commit to stan69b/nxnative that referenced this pull request Nov 5, 2026
Six upstream commits: the pipeline prebuild takes Metal's concurrent
compile count, VOTEU's uniform predicate, handles under an untied guard,
sparse 3D tiles, one shader library file per game, a lint fix.

Both sides changed the translator: its C# sources merged cleanly, the
dlls, dmsh_chain.lock and dmsh_chain.h conflicted, and
test_dmsh_ampere_alu.py had new classes from both (seedds#1300's F2IP tests,
upstream's VOTEU tests), all kept. Rebuilt from the merged source with
dotnet build -c Release (dlls and pdb, launcher kept), tool_lock.py
--update-lock (Metal 32023.922, as upstream), dmsh_chain.py --header:
chain 6ae95004ec27.

Checked: test_dmsh_*.py with DMSH_TEST_XLATE, test_bnsh_nvn2, test_ndve,
test_nsp_chain, test_xlate_anycpu, test_docs pass.
fpedrolucas95 pushed a commit to fpedrolucas95/nxnative that referenced this pull request Nov 5, 2026
…read) into main

PR 1300 translates Ocarina of Time's last untranslated shaders: F2IP with F2I's rounding modes and source A RZ (the foliage mesh shaders' 0xc4 form the earlier emitter refused) and ISBERD 0xb8. Its emitters replace the narrower ones main had for the same instructions (34b6638): the second AF2ip and its registration go, the ISBERD comment is PR 1300's, and test_dmsh_ampere_mem.py keeps PR 1300's payload test; the old exact-MSL F2IP test is dropped, its forms being test_dmsh_ampere_alu.py's (F2ip, F2ipTruncate). The translator dlls are rebuilt from the merged source: lock and chain header updated, chain fe82b8feb927.

Validation: test_dmsh_ampere_mem and test_dmsh_ampere_alu (DMSH_TEST_XLATE), test_ndve, test_bnsh_nvn2, test_split_ndve, test_nsp_dump, test_nsp_chain, test_docs, test_env_switches, test_dmsh_reflect, test_xlate_anycpu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gnosticgeek added a commit to gnosticgeek/nxforge that referenced this pull request Nov 5, 2026
…#1299, seedds#1300, seedds#1343); chain lock and header regenerated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qteK29T18U8p1c9LsVY8g
Jacob-Tate pushed a commit to Jacob-Tate/nxnative that referenced this pull request Nov 5, 2026
…d) into personal: chain 56742dc9d929

The translator dll is rebuilt from the merged sources (this branch's GlobalToStorage add-tree search and seedds#1299's write log, with seedds#1300's F2IP and ISBERD payload read), so the lock's dll lines are new; its Metal lines stay at 27.2. Ocarina of Time's compute shader 8692b34b521225be, asked for by its first 3D scene, did not translate without F2IP.
fpedrolucas95 pushed a commit to fpedrolucas95/nxnative that referenced this pull request Nov 5, 2026
…pstream's VOTEU, the growing raw pool table): chain c7de80c08992

The merges of seedds#1332 and the pool table commit kept main's translator binaries; this publishes Ryujinx.Graphics.Shader, Ryujinx.Common, Spv.Generator and dmsh_xlate
(osx-arm64, framework-dependent, the universal launcher kept) from the merged source, with the lock and dmsh_chain.h written again. RawGlobal's test takes its own storage
slot setup instead of AtomgCas's, a class of a Star Fox commit not in this tree. Every test_dmsh_*.py passes against it (DMSH_TEST_XLATE), and t_gmem_raw, t_pool_chunks,
t_mesh_indirect, t_deferred_release, t_image_usage, t_image_alias, t_gpu_lost, t_sbw, t_ubp_running and t_unwritten_store pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lunks added 2 commits November 6, 2026 00:11
test_dmsh_ampere_alu.py keeps both sides' tests (F2IP and VOTE). The translator was rebuilt from the merged source (dotnet publish, .NET 10.0.403), dmsh_chain.lock rewritten by tool_lock.py --update-lock, and dmsh_chain.h by dmsh_chain.py --header: chain 08fb901b323b.

Checked: test_dmsh_ampere_alu (16) and test_dmsh_ampere_mem (64) with DMSH_TEST_XLATE, test_nsp_chain, test_xlate_anycpu, test_docs, docs_symptoms.py --check.
Main's 8feddfe changed the translator (F2FP, I2FP and others in InstEmitAmpereAlu.cs, InstEmitAmpereMem.cs, BindlessToArray.cs): F2IP (0x243) and those handle other opcodes and merge without a text conflict. The translator was rebuilt from the merged source (dotnet publish, .NET 10.0.403), dmsh_chain.lock rewritten by tool_lock.py --update-lock and dmsh_chain.h by dmsh_chain.py --header: chain 2b1ed250490c.

Checked: test_dmsh_ampere_alu (16) and test_dmsh_ampere_mem (65) with DMSH_TEST_XLATE, test_nsp_chain, test_xlate_anycpu, test_docs, test_dmsh_pool_arrays, docs_symptoms.py --check.
gnosticgeek pushed a commit to gnosticgeek/nxforge that referenced this pull request Nov 6, 2026
… shader's own payload read: Ocarina of Time's untranslated shaders translate, all but one that is data

Translator binaries, lock and chain header kept until the translator is rebuilt on the Mac; test_dmsh_ampere_alu keeps one Vote class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qteK29T18U8p1c9LsVY8g
gnosticgeek added a commit to gnosticgeek/nxforge that referenced this pull request Nov 6, 2026
…dds#1300 seedds#1359 seedds#1360; chain lock and header regenerated (c5757270bc73)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qteK29T18U8p1c9LsVY8g
gnosticgeek pushed a commit to gnosticgeek/nxforge that referenced this pull request Nov 6, 2026
… texture object holds each shared texture in one lookup (Ocarina of Time's cutscene texture creation 2.4 times cheaper)

Resolved against NXForge's serial table (seedds#1360's program generation, seedds#1300's g_ghost_active):
- serial_put / serial_del keep the program generation and add seedds#1439's held counts
- tex_put keeps the same-object check and the g_ghost_active ring, and counts g_by_serial's names as seedds#1439 does
- t_int_float_view.m keeps main's checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qteK29T18U8p1c9LsVY8g
@seedds

seedds commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thank you. F2IP and the other missing pieces are on main now, and the game's shaders translate, so I'm closing this. Your list of what failed was a useful guide. Final checks on the rebased tree (full shader build, walks, regression) are still running, so please report anything you see.

@seedds seedds closed this Nov 6, 2026
gnosticgeek pushed a commit to gnosticgeek/nxforge that referenced this pull request Nov 6, 2026
) replaces the pull request heads

Upstream landed Ocarina of Time in main (chain adec7d81d970: "holds 60 fps in
Kokiri Forest, 4 GB less") and closed the pull requests it folded in, with
reworded and partly different code. Mixing a pull request head with its landed
version hunk by hunk silently broke things (two GlobalToStorage tables, a
duplicate AF2ip, two mtk_pso definitions), so the rule here is one version per
feature:

- Pull requests upstream closed (seedds#1299, seedds#1300, seedds#1312, seedds#1343, seedds#1345, seedds#1353,
  seedds#1354, seedds#1359, seedds#1360, seedds#1373, seedds#1428, seedds#1430, seedds#1434): their hunks are taken out
  of our side before the three-way merge, so upstream's landed version stands
  alone. Gone with them: bindless pool table patching (reg_bump), the ghost
  table's per-submission hold, the growing raw pool table and its write-log
  sizing, seedds#1428's pool_buf spares (upstream's pool_table_take is the same
  idea), the ixc-based indirect mesh draw (upstream uses mdx), and their tests
  (t_pool_table, t_mesh_indirect, t_gmem_raw, finalized_bindless_pool,
  test_bnsh_nvn2, test_ndve).
- Open pull requests that upstream's landing supersedes: seedds#1394 (upstream's
  mtl_pool_addressed) and seedds#1393 pool_skip_retired (upstream's budgeted pool
  walk; the profile does not use it) are dropped with their tests and docs.
  seedds#1368's mesh pipeline prewarm is dropped too: upstream kept the background
  build in nvn_geometry.inc, and the prewarm's mtk_build / mtk_claim /
  g_warm_mps went with it.
- Kept, as upstream does not have them: NXForge's own features (GPU watchdog,
  present filters and anti-aliasing, aniso floor, quick settings, pipeline
  archive compaction, upload breakdown, memory report lines) and the still
  open pull requests seedds#1304, seedds#1305, seedds#1308, seedds#1320, seedds#1331, seedds#1332, seedds#1355, seedds#1356,
  seedds#1369, seedds#1376, seedds#1377, seedds#1379, seedds#1382, seedds#1390, seedds#1391, seedds#1392, seedds#1414, seedds#1420,
  seedds#1436, seedds#1439, seedds#1446, seedds#1453.
- Combined where both sides changed the same lines: GW_N 1 << 16 with seedds#1320's
  wide-write intervals (GW_PAGES = SBW_WPAGES, 128 slots), the CPU upload log
  with upstream's linear upload route, arch_open_end before the compaction
  limit, cbn_prog in geo_gs_one (seedds#1382).
- Translator: upstream's sources and binaries, plus seedds#1414's
  InstEmitAmpereMem diff and the LDSM SubgroupBarrier in
  InstEmitAmpereTensor.cs. The binaries and dmsh_chain.lock are upstream's
  until the Mac rebuilds them (dotnet publish, tool_lock --update-lock,
  dmsh_chain --header); dmsh_chain.h is regenerated for now.
- RED_ONCE keys: upstream took 153 and 154, so the present anti-aliasing lines
  move to 156 and 157 and seedds#1420's packaged-entry line to 158 (array 159).
- Host: hle_net.c and t_net_eventfd.c are upstream's (its eventfd poll waits
  out the whole timeout, which our 5d7920c fixed another way).
- Kept ours: dm/tools/romfs_image.py and its test, so the 26 GB RomFS image is
  not packed again.

dm/tools tests on Linux: same failures as on 875449e (Linux-only quirks),
plus test_nlg4 and test_dmsh_pool_arrays, which fail on upstream main too.
Not yet built on the Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qteK29T18U8p1c9LsVY8g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) shader chain The shader translation chain (DMSH_CHAIN): a change rebuilds every game's shaders

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants