Gfx GX Fn GXSetTevKColorSel HW2 - wowjinxy/libPorpoise GitHub Wiki
GXSetTevKColorSel (HW2)
- Category:
Texture Environment
- Matrix Status:
Implemented
- Matrix Notes: Implemented per-stage konst-color 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/GXSetTevKColorSel.html
- SDK source:
reference/ACGC-PC-Port/src/static/dolphin/gx/GXTev.c (GXSetTevKColorSel)
- SDK behavior:
- HW2-only API that selects the konst color source for one TEV stage.
- Writes a 5-bit field in the stage pair
tevKsel BP register (sel width = 5 bits).
- 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 (GXSetTevKColorSel)
- Shader consumption:
- Stage selectors uploaded via
u_tev_ksel[] from pc_gx.c.
- Interpreted in
src/gx/shaders/default.frag (getKonstC) when GX_CC_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, GXTevKColorSel).
- Behavioral parity:
- Per-stage konst-color selector behavior is implemented and used by TEV shader path.
- Selector bit-width semantics now match hardware field width.
- Known divergence:
- SDK uses direct BP register writes and debug asserts; Porpoise uses fail-soft state storage and shader evaluation.
Validation Checklist
Working Notes
- Runtime parity tweak in this pass: 5-bit selector mask added.