Gfx GX Fn GXSetIndTexOrder - wowjinxy/libPorpoise GitHub Wiki

GXSetIndTexOrder

  • Category: Indirect Texturing
  • Matrix Status: Implemented
  • Matrix Notes: Parity-checked vs SDK mapping semantics (including GX_TEXMAP_NULL/GX_TEXCOORD_NULL fallback to stage 0).
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Indirect/GXSetIndTexOrder.html
  • SDK source: reference/gx/GXBump.c (GXSetIndTexOrder, around lines 299+)
  • Verified SDK behavior:
    • Accepts indirect stage id GX_INDTEXSTAGE0..3.
    • Treats GX_TEXMAP_NULL as GX_TEXMAP0.
    • Treats GX_TEXCOORD_NULL as GX_TEXCOORD0.
    • Validates texmap/texcoord ranges and marks indirect state dirty.

libPorpoise Implementation

  • Runtime implementation area: src/gx
  • Public API surface: include/dolphin/gx
  • Current implementation:
    • src/gx/pc_gx.c: GXSetIndTexOrder now flushes pending begin state, maps null texmap/texcoord to stage 0, validates ranges, then writes indirect stage mapping.
    • Runtime upload path maps this state into u_ind_tc_src[] and indirect sampler bindings.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK: void GXSetIndTexOrder(GXIndTexStageID ind_stage, GXTexCoordID tex_coord, GXTexMapID tex_map)
    • Porpoise: same
  • Behavioral parity:
    • SDK: null selectors resolve to stage 0 selectors before validation/write.
    • Porpoise: same semantics now mirrored before runtime state write.
  • Known divergence:
    • Invalid-argument handling is fail-soft early return instead of SDK debug assert.

Validation Checklist

  • GX demo coverage checked (indirect mapping path)
  • Pikmin usage path checked (indirect sampler source selection)
  • Matrix status updated if needed
  • Notes updated with concrete file/function references

Working Notes

  • Build sanity target after update: pikmin_demo (Win32 Debug).