Gfx GX Fn GXGetTexBufferSize - wowjinxy/libPorpoise GitHub Wiki

GXGetTexBufferSize

  • Category: Texture
  • Matrix Status: Implemented
  • Matrix Notes: Implemented size calculator following GX tile/block sizing rules (including mip chain accumulation).
  • Matrix Link: Gfx-GX-API-Matrix

Official SDK (Reference)

  • Manual page: reference/man/gfx/gx/Texture/GXGetTexBufferSize.html
  • SDK source: reference/ACGC-PC-Port/src/static/dolphin/gx/GXTexture.c (GXGetTexBufferSize, __GXGetTexTileShift)
  • SDK behavior:
    • Computes tile-padded byte size using per-format tile shift and block size (32-byte blocks; 64-byte blocks for GX_TF_RGBA8 and GX_TF_Z24X8).
    • For mipmaps, accumulates each level up to max_lod (early-out once 1x1 is reached).
    • SDK debug path asserts:
      • width <= 1024, height <= 1024
      • valid texture format
      • when mipmap is enabled: width/height must be powers of two.

libPorpoise Implementation

  • Public API declaration: include/dolphin/gx/GXTexture.h
  • Runtime implementation: src/gx/pc_gx_texture.c (GXGetTexBufferSize)
  • Behavior:
    • Uses GX tile/block math and mip chain accumulation equivalent to SDK for standard texture formats.
    • Includes GX_CTF_YUVA8 in the 64-byte block path (PC extension behavior).
    • Fail-soft for invalid inputs/formats (no assert trap in getter path).

SDK vs Porpoise Diff

  • Signature parity:
    • SDK source takes u8 mipmap; public docs describe GXBool.
    • Porpoise uses GXBool mipmap (doc-compatible).
  • Behavioral parity:
    • Matching core tile-size and mip-level accumulation behavior.
  • Known divergence:
    • SDK debug asserts on invalid dimensions/format/power-of-two mipmap inputs; Porpoise does not assert and instead computes a fail-soft result.
    • Porpoise handles GX_CTF_YUVA8 explicitly as 64-byte block path; SDK ACGC reference does not list that case in GXGetTexBufferSize.

Validation Checklist

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

Working Notes

  • No runtime code change in this pass; parity review focused on documented behavior and explicit divergences.