Skip to content

The fragment's shading-rate size (system register 0x84) reads 1 x 1: Nintendo Switch Sports Resort's sea is no longer black - #2103

Closed
FifteenPen wants to merge 1 commit into
seedds:mainfrom
FifteenPen:pr/shading-rate-size
Closed

FifteenPen wants to merge 1 commit into
seedds:mainfrom
FifteenPen:pr/shading-rate-size

Conversation

@FifteenPen

Copy link
Copy Markdown
Contributor

What and why

Nintendo Switch Sports Resort's sea (title screen, menus) drew black: its normals were right, its colour 0.

Cause. 612 of the game's 11,059 shaders, all pixel shaders, read system register 0x84 with S2UR: the fragment's size in pixels (X in bits 8..15, Y in 16..23; Mesa NAK's NAK_SV_VARIABLE_RATE), which variable rate shading makes 2 or 4. The translator did not know the register and gave 0. The sea shaders divide a blend weight by the fragment's area, so the colour came out NaN, which blend_zero (dm_az) writes as 0.

Change. SReg.VariableRate (132) reads 0x10100 in EmitSReg: the host shades every pixel, so 1 x 1. Chain change (cdef7a05ad69): translator binaries rebuilt, dmsh_chain.lock and dmsh_chain.h updated.

Reference entry: The fragment's shading-rate size reads 1 x 1.

Checked

  • Tests, on this branch (main 5e1c1ae + this change), Apple silicon:
    • DMSH_TEST_XLATE=… python3 dm/gfx/tests/test_dmsh_ampere_mem.py: the new ShadingRate test passes (float(65792)); main's translator gives float(0). The file's three Pokopia tests fail with main's committed translator as well, before this change.
    • python3 -m unittest dm/tools/tests/test_docs.py, python3 dm/tools/docs_symptoms.py.
  • Game run: Nintendo Switch Sports Resort (04008E001F098000, v65536), a Mac app from a provisional profile. The tree was main 04811a6 with other PRs (the game needs NVN: account for four-byte direct indexed draws using control memory #1609, SDK 21 virtual output device properties and event-only stream open (Wonder Edition movie) #1561 and the file system and hid PRs opened beside this one to boot), with this translator change: all 11,059 shaders build, and the sea on the title screen and in the menus draws blue instead of black.
  • Devices and OS: Apple M4 Pro, macOS 27.2.
  • Other games: the shader packages of the six other Switch 2 games on this Mac (Donkey Kong Bananza, Drag x Drive, Kirby Air Riders, Mario Kart World, Star Fox, and two builds of Ocarina of Time) have no S2R / S2UR of register 0x84, so their translation changes only in the chain version. regress.py impact: none of the profiles with usage manifests is affected; regress.py check was not run.
  • Not checked: iOS.

Docs

  • The finding is in its docs/reference/<subsystem>.md entry, 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

… 1 x 1 instead of 0: Nintendo Switch Sports Resort's sea, which divides by the fragment's area, is no longer black (chain cdef7a05ad69)
@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 10, 2026
seedds added a commit that referenced this pull request Nov 12, 2026
…so Nintendo Switch Sports Resort's sea is no longer black and its avatars' hair and clothes are no longer flat black (PR #2103): S2UR of system register 0x84 (Mesa NAK's NAK_SV_VARIABLE_RATE) is the fragment's size in pixels, X in bits 8..15 and Y in bits 16..23, which variable rate shading makes 2 or 4. The translator did not know the register and gave 0, the default for an unknown one; 612 of the game's 11,059 shaders, all pixel shaders, read it, and the sea shaders (01a6b85e2f6ea3d4, b3203175c76cda20, 2271b2e0293b3c55) divide a blend weight by the fragment's area: an infinite weight, NaN, written as 0 by blend_zero, with black dots of NaN noise spread by the auto-exposure; the avatar material c30f0edd6c669a61 takes it into a shading factor. SReg.VariableRate (132, Decoders/InstDecoders.cs) reads 0x10100 in EmitSReg (Instructions/InstEmitMove.cs), which Maxwell's S2R and Ampere's S2R / S2UR (InstEmitAmpereAlu.AS2r) both go through: the host shades every pixel. Chosen over bymaxmarc's PR #2373 (the same value in AS2r only, with the avatars' material found); FifteenPen found the black sea first. The translator was rebuilt with Microsoft's .NET SDK 10.0.404 (native_tools.sh; Homebrew's links its own OpenSSL and is refused), dmsh_chain.lock updated: chain change, DMSH_CHAIN 3856a9225d68, every game's shaders are translated again once. New reference entry (The fragment's shading-rate size reads 1 x 1), symptom index regenerated. Checked: test_dmsh_ampere_mem with DMSH_TEST_XLATE, 86 tests (ShadingRate: float(65792) for colour 0).

Co-authored-by: FifteenPen <354289956+FifteenPen@users.noreply.github.com>
@seedds

seedds commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Landed on main as b581efc with you credited as co-author, as part of the Nintendo Switch Sports Resort port (profile and note: f4b7e77). Chosen over #2373, which puts the same value in AS2r only: EmitSReg is reached by both Maxwell's S2R and Ampere's S2R / S2UR. Thank you!

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