Gfx GX Fn GXSetTevKAlphaSel HW2 - wowjinxy/libPorpoise GitHub Wiki
GXSetTevKAlphaSel (HW2)
- Category:
Texture Environment
- Matrix Status:
Implemented
- Matrix Notes: Implemented per-stage konst-alpha selector state with BP-field-width masking (
5-bit).
- Matrix Link: Gfx-GX-API-Matrix
Official SDK (Reference)
- Manual page:
reference/man/gfx/gx/Tev/GXSetTevKAlphaSel.html
- SDK source:
reference/ACGC-PC-Port/src/static/dolphin/gx/GXTev.c (GXSetTevKAlphaSel)
- SDK behavior:
- HW2-only API selecting konst alpha source for one TEV stage.
- Selector is written as a 5-bit field into
tevKsel BP register.
- SDK debug path checks GX-begin and asserts
stage < 16.
libPorpoise Implementation
- Public API declaration:
include/dolphin/gx/GXTev.h
- Runtime implementation:
src/gx/pc_gx.c (GXSetTevKAlphaSel)
- Shader consumption:
- Stage selectors uploaded via
u_tev_ksel[] from pc_gx.c.
- Interpreted in
src/gx/shaders/default.frag (getKonstA) when GX_CA_KONST is used.
- Behavior:
- Stores per-stage selector and marks TEV-stage state dirty.
- Applies
sel & 0x1F mask to mirror SDK BP-field width.
- Guards writes with
stage < 16.
SDK vs Porpoise Diff
- Signature parity:
- Signatures match (
GXTevStageID, GXTevKAlphaSel).
- Behavioral parity:
- Per-stage konst-alpha selector behavior is implemented and used in TEV shader path.
- Selector bit-width semantics now match hardware field width.
- Known divergence:
- SDK writes packed BP register state directly; Porpoise stores decoded state and evaluates in shader.
Validation Checklist
Working Notes
- Runtime parity tweak in this pass: 5-bit selector mask added.