Skip to content

The back face's stencil reference value reaches Metal: Mario Golf: Super Rush's ground decals draw - #2351

Closed
secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:stencil-back-ref
Closed

secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:stencil-back-ref

Conversation

@secretlemur28

Copy link
Copy Markdown
Contributor

What and why

Mario Golf: Super Rush (0100C9C00E25C000, 4.0.0, #814): the driving range's scoring target in Golf Adventure (a ring with a blue centre on the fairway) is not drawn, in the normal view or the top view, and nothing in the log says why.

SetStencilRef takes a face and the replay keeps both values (S.st_ref[0], [1]), but enc_r_stencil_ref sent Metal the front one for both faces (setStencilReferenceValue:). The game's ground decals are volumes drawn twice: front faces mark stencil bit 0x80 where the volume lies behind the ground, then back faces draw the colour where stencil & 0x90 equals the back value 0x10 (the terrain's mark), with a front value of 0. Tested against the front value, the colour draw passed nowhere on the ground.

Both values now reach Metal (setStencilFrontReferenceValue:backReferenceValue: when they differ), the per-encoder state cache compares both, and the deferred recorder's RO_R_SREF carries both.

Reference entry: "Front and back stencil reference values" in docs/reference/rendering.md, with its line in the symptom index.

Checked

  • Games run: Mario Golf: Super Rush 4.0.0, Golf Adventure's driving-range lesson, on a branch that carries this change with others (secretlemur28/nxnative@golf-tess, commit 8ff8ae1b): the target (pass with fragment shader 6f91c05c60985a33, four draws of 384 indices: two decals, two draws each) shows in the top view and from the tee, where it was missing before.
  • On main at 47607fe0 with this change (and A subsdk a provisional profile gains from the NRO collection also goes into its build rows #2215, cra.py reads the 2021 layout of Camelot's archive (Mario Golf: Super Rush 4.0.0) #2216, which the game needs to build): the host builds and the Rookie Course's first tee draws and runs as before (frame time p50 16.67 ms). Not rerun on the range on main: reaching it needs a save well into Golf Adventure.
  • Devices and OS: MacBook Pro M1 Pro, 16 GB, macOS 27.0.1.
  • Not checked: other games (only this one is on this Mac), so no regress.py report; the graphics test suite; iOS. Any game whose front and back reference values differ now draws differently, which is the point, but it is a path every game takes.

Docs

  • The finding is in docs/reference/rendering.md, and python3 dm/tools/docs_symptoms.py was run
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

…e served both faces, so a draw of back faces that compares against its own value passed nowhere (Mario Golf: Super Rush's ground decals: the driving range's scoring target was missing)

SetStencilRef takes a face and the replay keeps both values, but enc_r_stencil_ref sent the front one for both (setStencilReferenceValue:). The game's decals are volumes drawn twice: front faces mark stencil bit 0x80 where the volume lies behind the ground, then back faces draw the colour where stencil & 0x90 equals the back value 0x10, the ground's mark, with a front value of 0. Both values now go to Metal (setStencilFrontReferenceValue:backReferenceValue: when they differ), the per-encoder cache compares both, and the deferred recorder's RO_R_SREF carries both.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 11, 2026
seedds added a commit that referenced this pull request Nov 12, 2026
SetStencilRef takes a face and the replay kept both values, but
enc_r_stencil_ref sent Metal the front one for both faces, while the
depth-stencil state already gave each face its own compare function,
operations and masks. A back face therefore tested the front value.
Mario Golf: Super Rush's ground decals draw their volumes' back faces
where stencil & 0x90 equals the back value 0x10 with a front value of 0,
so the driving range's target was never drawn.

Both values now go to Metal (setStencilFrontReferenceValue:
backReferenceValue:), the per-encoder state cache compares both, and the
deferred recorder's RO_R_SREF carries both, as the Vulkan layer already
did. Reference entry: "Front and back stencil reference values" in
docs/reference/rendering.md.

Checked: regress.py check on Bastion (screenshots move by its known
animation noise only, no new red line, frame time unchanged) and a
Bastion boot with DM_NVN_ENC_THREAD=1. Mario Golf was checked by the PR
author on their branch.

Co-authored-by: secretlemur28 <354896836+secretlemur28@users.noreply.github.com>
@seedds

seedds commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Landed on main as 2fb8200, with you as co-author. Thanks for the clear diagnosis.

Changes from the PR:

  • enc_r_stencil_ref and RO_R_SREF always call setStencilFrontReferenceValue:backReferenceValue:, with no separate branch for equal values.
  • The reference entry states the general symptom (back faces tested against the front value), with Mario Golf as the example. It notes that the depth-stencil state already split every other stencil field by face and that the Vulkan layer already sent both values. The Found on line uses the form for a game with no profile.
  • The symptom index was regenerated, which also resolves the conflict with main.

Checked here: regress.py check on Bastion (screenshots move only by its usual animation noise, no new red line, frame time unchanged) and a Bastion boot with deferred encoding on (DM_NVN_ENC_THREAD=1). We couldn't rerun the driving range on main. If you can check it on main once #2215 and #2216 are in, a note here would help.

@seedds seedds closed this Nov 12, 2026
dsi-hub pushed a commit to dsi-hub/nxnative that referenced this pull request Nov 15, 2026
…ds#2351)

SetStencilRef takes a face and the replay kept both values, but
enc_r_stencil_ref sent Metal the front one for both faces, while the
depth-stencil state already gave each face its own compare function,
operations and masks. A back face therefore tested the front value.
Mario Golf: Super Rush's ground decals draw their volumes' back faces
where stencil & 0x90 equals the back value 0x10 with a front value of 0,
so the driving range's target was never drawn.

Both values now go to Metal (setStencilFrontReferenceValue:
backReferenceValue:), the per-encoder state cache compares both, and the
deferred recorder's RO_R_SREF carries both, as the Vulkan layer already
did. Reference entry: "Front and back stencil reference values" in
docs/reference/rendering.md.

Checked: regress.py check on Bastion (screenshots move by its known
animation noise only, no new red line, frame time unchanged) and a
Bastion boot with DM_NVN_ENC_THREAD=1. Mario Golf was checked by the PR
author on their branch.

Co-authored-by: secretlemur28 <354896836+secretlemur28@users.noreply.github.com>
(cherry picked from commit 2fb8200)
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants