Skip to content

lower_to_maxwell: a REGMAP marker is never a number another field of the instruction names (overexposed foliage, #696, #667) - #905

Closed
raxis666-cmyk wants to merge 1 commit into
NotRexed:devfrom
raxis666-cmyk:fix/regmap-marker-collision
Closed

raxis666-cmyk wants to merge 1 commit into
NotRexed:devfrom
raxis666-cmyk:fix/regmap-marker-collision

Conversation

@raxis666-cmyk

Copy link
Copy Markdown

What was wrong

When a native instruction names a high GPR in the scratch range (R246 up), the lowering renames that field to a
marker (a uniform-bank number, R216-R245) and the REGMAP_nx2 prefix maps the marker to the extended register.
The marker was picked among the numbers no field seen so far had named, so a field processed later could name the
same number:

  • OoT's foliage mesh d38b0d52a94ab5a8 (program 89ca750f9852b7ca: stalks, grass blades, flower stems) uses GPRs up
    to R252. Its FFMA R247, R180, R216, R247 gave R247 the marker 216.
  • If R216 is an ordinary register, the prefix maps 216 to R247 and the Maxwell FFMA reads R247 for its R216.
    If R216 is extended itself, its run comes after the renamed ones and ApplyRegisterMap (last run wins) maps the
    marker back to R216, so the FFMA writes over R216.
  • In that mesh, R216-R217 hold light-probe weights and R246/R247 accumulate the weighted probe data. The divisor of
    the probe average ended up summing data instead of weights, and the ambient (SH) irradiance of the stalks came out
    about 8x too high.

That's the "overexposed / glowing stalks, grass and flowers" in #696 (RX 9070 XT) and #667 (also RTX 3060 Ti): it is
not vendor-specific.

The fix

The marker search also skips every number any register field of the instruction names (with the same span rules the
renaming uses), so a marker can't alias another field. Instructions with no such collision lower to the same words as
before.

How it was found and checked

  • Measured in game on an RX 9060 XT (Kokiri Forest, near Saria): a stalk pixel's HDR colour went from
    0.18 0.41 0.19 to 0.024 0.018 0.010; the leaves next to it are 0.023 0.021 0.009. The glowing stalks and blades
    are gone; ferns, plants and flowers are all still drawn.
  • The probe pool itself was dumped (guest and GPU views identical) and the 8 probes the stalk blends hold sane values
    (5-28), while the shader's average came out at 264, which is how the broken divisor showed up.
  • --prepare-shaders: 31985 programs, 0 failed. A walking run stayed stable.
  • New game-free test tests/test_lower_regmap_marker.py (registered in tests/run_all.py): it lowers four FFMAs
    with high GPRs, applies the prefix the way ApplyRegisterMap does and checks that every Maxwell field names its
    native register. It fails on dev without the fix (e.g. Rb 503 for R216) and passes with it.
    test_lower_atomg_cas.py and test_lower_depbar.py still pass.

The in-game measurements were made on a tree based on 3f5b0aa (fast-updates). This branch applies the same change
to current dev (232eecb), keeping dev's register_field list (TXD 0xb6c and ATOMG 0x9a8 included).

Fixes #696, fixes #667.

🤖 Generated with Claude Code

…the instruction names (overexposed foliage, NotRexed#696, NotRexed#667)

A high GPR in the scratch range is renamed to a marker of the uniform bank, chosen among the numbers no field seen so
far named. A field after it could name the same number: OoT's foliage mesh d38b0d52 has FFMA R247, R180, R216, R247,
R247 took the marker 216, and the prefix then mapped 216 for both fields (the run for a native R216 comes last and
takes it back). The light probes' weighted average divided by data instead of weights: stalks, grass blades and
flowers came out about 8x too bright. The marker now skips every number any register field of the instruction names.

tests/test_lower_regmap_marker.py lowers four such FFMAs, applies the prefix as ApplyRegisterMap does and checks each
field names its native register (fails on dev without the change, passes with it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NotRexed

NotRexed commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thank you for tracking this down! The same marker collision (a REGMAP marker equal to a number another field of the instruction names: the glowing foliage stems) is fixed on main by #922, and #759's version of the fix has been taken into the maintainer's tree for the next release; this branch now conflicts with both. Closing as superseded. If you have a case that still collides with main plus #759, please open an issue or a small follow-up with it.

@NotRexed NotRexed closed this Nov 9, 2026
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