Gfx GX Fn GXInitTexObjLOD - wowjinxy/libPorpoise GitHub Wiki

GXInitTexObjLOD

  • Category: Texture
  • Matrix Status: Partial
  • Matrix Notes: SDK-compatible input/range handling now applied; backend remains partial for full hardware LOD bias/clamp/edge/aniso behavior.
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Texture/GXInitTexObjLOD.html
  • SDK source: reference/ACGC-PC-Port/src/static/dolphin/gx/GXTexture.c (GXInitTexObjLOD)
  • SDK behavior:
    • Signature: void GXInitTexObjLOD(GXTexObj* obj, GXTexFilter min_filt, GXTexFilter mag_filt, f32 min_lod, f32 max_lod, f32 lod_bias, GXBool bias_clamp, GXBool do_edge_lod, GXAnisotropy max_aniso).
    • Accepts min filter in [GX_NEAR..GX_LIN_MIP_LIN], mag filter in [GX_NEAR..GX_LINEAR].
    • Clamps lod_bias to [-4.0, 3.99].
    • Clamps min_lod and max_lod to [0.0, 10.0].
    • Stores bias clamp, edge-LOD mode, and anisotropy selection in texture object state.
    • Manual emulator note: some parameters may be partially effective on non-HW backends.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXTexture.h
  • Runtime implementation: src/gx/pc_gx_texture.c (GXInitTexObjLOD)
  • Behavior:
    • Signature matches SDK.
    • Added SDK-style fail-soft range handling:
      • min_filt clamped to GX_LIN_MIP_LIN
      • mag_filt clamped to GX_LINEAR
      • lod_bias clamped to [-4.0, 3.99]
      • min_lod/max_lod clamped to [0.0, 10.0]
      • max_aniso clamped to GX_ANISO_4
    • Stores normalized GXBool values for bias_clamp and edge_lod.
    • State is recorded in GXTexObj and consumed by the PC load path where supported.

SDK vs Porpoise Diff

  • Signature parity:
    • SDK: GXInitTexObjLOD(GXTexObj*, GXTexFilter, GXTexFilter, f32, f32, f32, GXBool, GXBool, GXAnisotropy)
    • Porpoise: same
  • Behavioral parity:
    • SDK: validates/clamps LOD/filter inputs and writes object state.
    • Porpoise: now matches input/range semantics and state writes.
  • Known divergence:
    • Manual-documented emulator caveat still applies: full hardware-accurate effect of lod_bias, bias_clamp, edge_lod, and anisotropy is backend-limited in the current PC renderer.

Validation Checklist

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

Working Notes

  • This function now mirrors SDK parameter range handling, while runtime effect remains bounded by current GL backend capabilities.