Gfx GX Fn GXSetArray - wowjinxy/libPorpoise GitHub Wiki

GXSetArray

  • Category: Geometry and Vertex
  • Matrix Status: Implemented
  • Matrix Notes: SDK parity pass done: valid attr range + NBT aliasing now match Dolphin GXAttr.c.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: E:/GPT5/Porpoise_SDK/libPorpoise/reference/man/gfx/gx/Geometry/GXSetArray.html
  • SDK source parity check area: E:/GPT5/ACGC-PC-Port-Debug-Stuff/src/static/dolphin/gx/GXAttr.c
  • Notes:
    • Signature: void GXSetArray(GXAttr attr, const void* base_ptr, u8 stride).
    • Accepted attrs for this API are GX_VA_POS .. GX_LIGHT_ARRAY (matrix/light arrays plus POS/NRM/CLR/TEX arrays).
    • SDK maps GX_VA_NBT to GX_VA_NRM before programming the CP attribute array register.
    • SDK stores per-attr base and byte stride used for indexed fetch.

libPorpoise Implementation

  • Runtime implementation area: E:/GPT5/Porpoise_SDK/libPorpoise/src/gx/pc_gx.c
  • Public API surface: E:/GPT5/Porpoise_SDK/libPorpoise/include/dolphin/gx/GXGeometry.h
  • Notes:
    • Signature now matches SDK typed form (GXAttr).
    • GX_VA_NBT is now explicitly aliased to GX_VA_NRM.
    • Attr validation now mirrors SDK API domain (GX_VA_POS .. GX_LIGHT_ARRAY).
    • Base/stride state is stored and consumed by indexed paths (GXPosition1x*, GXNormal1x*, GXColor1x*, GXTexCoord1x*) and matrix/light indexed loaders.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK: void GXSetArray(GXAttr attr, const void* base_ptr, u8 stride)
    • Porpoise: now matches.
  • Behavioral parity:
    • SDK: aliases GX_VA_NBT to GX_VA_NRM, validates attr domain, then stores array base/stride.
    • Porpoise: now mirrors this behavior.
  • Known divergence:
    • SDK writes masked physical addresses into CP registers; PC backend stores host pointers directly for software/indexed decode.
    • SDK debug path asserts on invalid args; PC backend uses fail-soft early return.

Validation Checklist

  • GX demo coverage checked
  • Pikmin usage path checked
  • Matrix status/notes updated for this function
  • Notes updated with concrete file/function references

Working Notes

  • This API is central for matrix/light indexed loads too, not just vertex attribute arrays.