GX Vertex Format Fixes (#938)

* Update vertex attribute formats in `d_a_hookshot.cpp` for improved correctness.

* Fix texture coordinate formats in `J3DSys.cpp` to use `GX_TEX_ST` for improved semantics.

* Update vertex attribute formats in `JFWDisplay.cpp` for improved semantics.

* Update texture coordinate vertex format in `J2DWindow.cpp` to use `GX_TEX_ST` for improved semantics.

* Refactor `J2DWindow.cpp` for improved readability: update constructor initialization style, inline function arguments, and add spacing for clarity in GX rendering logic.

* Update vertex attribute formats in `JUTResFont.cpp` for improved correctness and semantic clarity.

* Update vertex attribute format in `d_kankyo_rain.cpp` to use `GX_POS_XYZ` for improved correctness.

* Update texture coordinate formats in `d_ovlp_fade2.cpp` to use `GX_TEX_ST` for improved semantics.

* Update texture coordinate format in `d_ovlp_fade4.cpp` to use `GX_TEX_ST` for improved semantics

* Format vertex attribute and texture coordinate initialization in `d_a_goal_flag.cpp` for improved consistency and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_majuu_flag.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_pirate_flag.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_sail.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_player_particle.inc` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_player_particle.inc` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_sea.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_wood.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `m_Do_ext.cpp` for improved correctness and semantics.

* Undid formatting of `halftofull` array in `JUTResFont.cpp`

* Update vertex attribute and texture coordinate formats in `d_tree.cpp` for improved correctness and semantics.

* Update vertex attribute and texture coordinate formats in `d_a_bwdg.cpp` for improved correctness and semantics.
This commit is contained in:
Briggs Baltzell
2026-03-14 17:47:46 -05:00
committed by GitHub
parent ff60c624ce
commit f64d5000b6
18 changed files with 316 additions and 255 deletions
+33 -17
View File
@@ -14,7 +14,13 @@
#include "dolphin/gx/GX.h"
/* 802D12E0-802D1820 .text __ct__9J2DWindowFP7J2DPaneP20JSURandomInputStream */
J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1) : mpFrameTexture1(NULL), mpFrameTexture2(NULL), mpFrameTexture3(NULL), mpFrameTexture4(NULL), mpContentsTexture(NULL), mpPalette(NULL) {
J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1)
: mpFrameTexture1(NULL),
mpFrameTexture2(NULL),
mpFrameTexture3(NULL),
mpFrameTexture4(NULL),
mpContentsTexture(NULL),
mpPalette(NULL) {
s32 local_188 = param_1->getPosition();
u32 header[2];
param_1->read(header, 8);
@@ -129,13 +135,9 @@ void J2DWindow::draw_private(const JGeometry::TBox2<f32>& frameBox, const JGeome
f32 bottom = y + mpFrameTexture1->getHeight();
u16 s0, s1, t0, t1;
drawFrameTexture(mpFrameTexture1, x, y,
(field_0x110 >> 7) & 1,
(field_0x110 >> 6) & 1, true);
drawFrameTexture(mpFrameTexture1, x, y, (field_0x110 >> 7) & 1, (field_0x110 >> 6) & 1, true);
bool r7 = (field_0x111 & 1) ? true : false;
drawFrameTexture(mpFrameTexture2, right, 0.0f,
(field_0x110 >> 5) & 1,
(field_0x110 >> 4) & 1, r7);
drawFrameTexture(mpFrameTexture2, right, 0.0f, (field_0x110 >> 5) & 1, (field_0x110 >> 4) & 1, r7);
s0 = ((field_0x110 >> 5) & 1) ? (u16)0x8000 : (u16)0;
t0 = ((field_0x110 >> 4) & 1) ? (u16)0 : (u16)0x8000;
@@ -143,9 +145,7 @@ void J2DWindow::draw_private(const JGeometry::TBox2<f32>& frameBox, const JGeome
drawFrameTexture(mpFrameTexture2, left, 0.0f, right - left, (f32)mpFrameTexture2->getHeight(), s0, t0, s0, t1, false);
r7 = (field_0x111 & 2) ? true : false;
drawFrameTexture(mpFrameTexture4, right, top,
(field_0x110 >> 1) & 1,
(field_0x110 >> 0) & 1, r7);
drawFrameTexture(mpFrameTexture4, right, top, (field_0x110 >> 1) & 1, (field_0x110 >> 0) & 1, r7);
s0 = ((field_0x110 >> 1) & 1) ? (u16)0x8000 : (u16)0;
t0 = ((field_0x110 >> 0) & 1) ? (u16)0 : (u16)0x8000;
@@ -158,9 +158,7 @@ void J2DWindow::draw_private(const JGeometry::TBox2<f32>& frameBox, const JGeome
drawFrameTexture(mpFrameTexture4, right, bottom, (f32)mpFrameTexture4->getWidth(), top - bottom, s0, t0, s1, t0, false);
r7 = (field_0x111 & 4) ? true : false;
drawFrameTexture(mpFrameTexture3, 0.0f, top,
(field_0x110 >> 3) & 1,
(field_0x110 >> 2) & 1, r7);
drawFrameTexture(mpFrameTexture3, 0.0f, top, (field_0x110 >> 3) & 1, (field_0x110 >> 2) & 1, r7);
s0 = ((field_0x110 >> 3) & 1) ? (u16)0 : (u16)0x8000;
s1 = (u16)(s0 ^ 0x8000);
@@ -206,7 +204,7 @@ void J2DWindow::drawSelf(f32 x, f32 y) {
}
/* 802D2190-802D2288 .text drawSelf__9J2DWindowFffPA3_A4_f */
void J2DWindow::drawSelf(f32 x, f32 y, Mtx *pMtx) {
void J2DWindow::drawSelf(f32 x, f32 y, Mtx* pMtx) {
JGeometry::TBox2<f32> globalBounds = mGlobalBounds;
globalBounds.addPos(JGeometry::TVec2<f32>(x, y));
@@ -250,15 +248,23 @@ void J2DWindow::drawContents(const JGeometry::TBox2<f32>& contentsBox) {
}
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(contentsBox.i.x, contentsBox.i.y, 0.0f);
GXColor1u32(drawColorTL);
GXPosition3f32(contentsBox.f.x, contentsBox.i.y, 0.0f);
GXColor1u32(drawColorTR);
GXPosition3f32(contentsBox.f.x, contentsBox.f.y, 0.0f);
GXColor1u32(drawColorBR);
GXPosition3f32(contentsBox.i.x, contentsBox.f.y, 0.0f);
GXColor1u32(drawColorBL);
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
if (mpContentsTexture != NULL) {
@@ -285,6 +291,7 @@ void J2DWindow::drawFrameTexture(JUTTexture* pTexture, f32 x0, f32 y0, f32 w, f3
JUtility::TColor vtxColor(mDrawAlpha | 0xFFFFFF00);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(x0, y0, 0.0f);
@@ -304,17 +311,24 @@ void J2DWindow::drawFrameTexture(JUTTexture* pTexture, f32 x0, f32 y0, f32 w, f3
GXTexCoord2s16(s1, t0);
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
}
/* 802D26E4-802D2784 .text drawFrameTexture__9J2DWindowFP10JUTTextureffbbb */
void J2DWindow::drawFrameTexture(JUTTexture* pTexture, f32 x, f32 y, bool flipS, bool flipT, bool bSetupTev) {
drawFrameTexture(pTexture, x, y, pTexture->getWidth(), pTexture->getHeight(),
drawFrameTexture(
pTexture,
x,
y,
pTexture->getWidth(),
pTexture->getHeight(),
flipS ? (u16)0 : (u16)0x8000,
flipT ? (u16)0 : (u16)0x8000,
flipS ? (u16)0x8000 : (u16)0,
flipT ? (u16)0x8000 : (u16)0,
bSetupTev);
bSetupTev
);
}
/* 802D2784-802D29F4 .text drawContentsTexture__9J2DWindowFffff */
@@ -331,8 +345,10 @@ void J2DWindow::drawContentsTexture(f32 x0, f32 y0, f32 w, f32 h) {
mpContentsTexture->load(GX_TEXMAP0);
setTevMode(mpContentsTexture, 0x00000000, 0xFFFFFFFF);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA6, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(x0, y0, 0.0f);
+8 -8
View File
@@ -164,14 +164,14 @@ void J3DSys::drawInit() {
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR1, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX1, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX2, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX3, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX4, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX5, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX6, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX7, GX_CLR_RGBA, GX_RGBA4, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX1, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX2, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX3, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX4, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX5, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX6, GX_TEX_ST, GX_S16, 7);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX7, GX_TEX_ST, GX_S16, 7);
GXSetNumIndStages(0);
reinitTexture();
+2 -2
View File
@@ -414,8 +414,8 @@ void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GX
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGBX8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_U16, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U8, 0);
GXSetNumChans(0);
GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GXSetChanCtrl(GX_COLOR1A1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
+22 -8
View File
@@ -178,9 +178,11 @@ void JUTResFont::setGX() {
GXSetChanCtrl(GX_COLOR0A0, false, GX_SRC_REG, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
GXSetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRC_ALPHA, GX_BL_INV_SRC_ALPHA, GX_LO_SET);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U16, 0xf);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
@@ -209,9 +211,11 @@ void JUTResFont::setGX(JUtility::TColor col1, JUtility::TColor col2) {
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRC_ALPHA, GX_BL_INV_SRC_ALPHA, GX_LO_SET);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 15);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_U16, 0xf);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
@@ -256,6 +260,7 @@ f32 JUTResFont::drawChar_scale(f32 posX, f32 posY, f32 scaleX, f32 scaleY, int c
s32 v2 = ((mHeight + mpGlyphBlocks[field_0x66]->cellHeight) * 0x8000) / mpGlyphBlocks[field_0x66]->textureHeight;
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
// Bottom Left
@@ -278,6 +283,8 @@ f32 JUTResFont::drawChar_scale(f32 posX, f32 posY, f32 scaleX, f32 scaleY, int c
GXColor1u32(mColor3);
GXTexCoord2s16(u1, v2);
GXEnd();
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
return retval;
@@ -361,7 +368,7 @@ int JUTResFont::getFontCode(int chr) const {
ret = chr - map->startCode;
break;
} else if (map->mappingMethod == 2) {
ret = *(&mpMapBlocks[i]->mLeading + ((chr - mpMapBlocks[i]->startCode)));
ret = *(&mpMapBlocks[i]->mLeading + (chr - mpMapBlocks[i]->startCode));
break;
} else if (map->mappingMethod == 3) {
u16* leading_temp = &map->mLeading;
@@ -420,9 +427,16 @@ void JUTResFont::loadImage(int code, GXTexMapID id) {
mHeight = cellRow * mpGlyphBlocks[i]->cellHeight;
if (pageIdx != mTexPageIdx || i != field_0x66) {
GXInitTexObj(&mTexObj, &mpGlyphBlocks[i]->data[pageIdx * mpGlyphBlocks[i]->textureSize],
mpGlyphBlocks[i]->textureWidth, mpGlyphBlocks[i]->textureHeight,
(GXTexFmt)mpGlyphBlocks[i]->textureFormat, GX_CLAMP, GX_CLAMP, 0);
GXInitTexObj(
&mTexObj,
&mpGlyphBlocks[i]->data[pageIdx * mpGlyphBlocks[i]->textureSize],
mpGlyphBlocks[i]->textureWidth,
mpGlyphBlocks[i]->textureHeight,
(GXTexFmt)mpGlyphBlocks[i]->textureFormat,
GX_CLAMP,
GX_CLAMP,
0
);
GXInitTexObjLOD(&mTexObj, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, 0U, 0U, GX_ANISO_1);
mTexPageIdx = pageIdx;