Gfx GX Fn GXInitLightDistAttn - wowjinxy/libPorpoise GitHub Wiki

GXInitLightDistAttn

  • Category: Lighting
  • Matrix Status: Implemented
  • Matrix Notes: Verified SDK-parity GX_DA_* distance-attenuation formulas and guard/fallback behavior for invalid reference inputs.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual root: reference/rvlsdk/man/en_US/gx
  • Primary SDK source area: demos/PikminDemo/src/gx (GC-style Dolphin GX source)
  • Notes:
    • Confirm official signature/prototype
    • Confirm documented side effects (register/state updates)
    • Confirm special behavior and edge cases from manual

libPorpoise Implementation

  • Runtime implementation area: src/gx
  • Public API surface: include/dolphin/gx
  • Notes:
    • Confirm API signature matches SDK
    • Confirm state writes match SDK semantics
    • Confirm backend behavior in PC renderer path

SDK vs Porpoise Diff

  • Signature parity:
    • SDK:
    • Porpoise:
  • Behavioral parity:
    • SDK:
    • Porpoise:
  • Known divergence:

Validation Checklist

  • GX demo coverage checked
  • Pikmin usage path checked
  • Matrix status updated if needed
  • Notes updated with concrete file/function references

Working Notes

  • Docs checked against reference/man/gfx/gx/Lighting/GXInitLightDistAttn.html and SDK source in reference/gx/GXLight.c.
  • SDK behavior:
    • Invalid inputs force dist_func = GX_DA_OFF:
      • ref_dist < 0
      • ref_br <= 0 || ref_br >= 1
    • Computes and writes k0/k1/k2 by selected distribution:
      • GX_DA_GENTLE, GX_DA_MEDIUM, GX_DA_STEEP, GX_DA_OFF.
  • Runtime behavior in src/gx/pc_gx.c:
    • Mirrors the same guard conditions and per-mode formulas.
    • Writes only distance attenuation terms (k0..k2) into the light object.
  • Result:
    • Function semantics match SDK for distance attenuation setup.