Gfx GX Fn GXSetNumTexGens - wowjinxy/libPorpoise GitHub Wiki

GXSetNumTexGens

  • Category: Texture Coordinate Generation
  • Matrix Status: Partial
  • Matrix Notes: Verified docs-range behavior (0..8) and state update wiring; count now gates TEV-stage texcoord availability on the PC path including GX_TEXCOORD0..7 routing for implemented TEV stages, with remaining backend TEV-stage breadth limits called out below.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Geometry/GXSetNumTexGens.html
  • SDK behavior:
    • Signature: void GXSetNumTexGens(u8 nTexGens).
    • Sets number of generated texcoords available to TEV.
    • Valid range is 0..8 (consecutive from GX_TEXCOORD0).
    • 0 means no texcoords are generated/available.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXGeometry.h
  • Runtime implementation: src/gx/pc_gx.c (GXSetNumTexGens)
  • Behavior:
    • API signature matches SDK.
    • Flushes in-progress begin batch before changing state.
    • Stores texgen count with hard clamp to 8.
    • Marks texgen/TEV/texture state dirty so the new count takes effect immediately.
    • TEV stage sampling now checks texcoord availability against num_tex_gens before enabling stage texture sampling on the PC backend path.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK: void GXSetNumTexGens(u8 nTexGens)
    • Porpoise: same
  • Behavioral parity:
    • SDK: defines generated/available texcoord count in range 0..8.
    • Porpoise: matches range clamp and now applies availability gating in TEV stage usage.
  • Known divergence:
    • Fragment-side TEV execution path is still limited to the currently implemented shader-stage breadth (stage expansion beyond the active path is not yet complete), so full hardware 16-stage parity is still pending.
    • Manual's broader pipeline guarantees depend on other subsystems (TEV stage count/path), so this function is still tracked as partial in matrix terms.

Validation Checklist

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

Working Notes

  • Manual confirms nTexGens range and "available to TEV" semantics.
  • Implementation now uses stored count to gate TEV texture-stage coordinate usage in PC path.