Renders on Dolphin also.
This commit is contained in:
@@ -87,62 +87,6 @@ errorret_t textureInitDolphin(
|
||||
// );
|
||||
// break;
|
||||
|
||||
// case TEXTURE_FORMAT_ALPHA: {
|
||||
// assertTrue(
|
||||
// (width % 4) == 0 && (height % 4) == 0,
|
||||
// "GX_TF_I8 requires w/h multiple of 4 (or pad)"
|
||||
// );
|
||||
|
||||
// // 1 byte per pixel (I8), GX expects 4x4 tiled layout
|
||||
// const size_t alphaSize = (size_t)width * (size_t)height;
|
||||
|
||||
// texture->alpha = (u8*)memalign(32, alphaSize);
|
||||
// assertNotNull(texture->alpha, "Failed to allocate alpha texture data");
|
||||
|
||||
// const u32 tilesPerRow = ((u32)width) >> 3; // /8
|
||||
|
||||
// for (u32 y = 0; y < (u32)height; ++y) {
|
||||
// const u32 tileY = y >> 2; // /4
|
||||
// const u32 inTileY = (y & 3) << 3; // (y%4)*8
|
||||
|
||||
// for (u32 x = 0; x < (u32)width; ++x) {
|
||||
// const u32 srcI = y * (u32)width + x;
|
||||
// const u8 srcA = data.alpha.data[srcI]; // linear input
|
||||
|
||||
// const u32 tileX = x >> 3; // /8
|
||||
// const u32 tileIndex = tileY * tilesPerRow + tileX;
|
||||
|
||||
// const u32 tileBase = tileIndex * 32; // 8*4*1 = 32 bytes per tile
|
||||
// const u32 inTile = inTileY + (x & 7); // (y%4)*8 + (x%8)
|
||||
|
||||
// texture->alpha[tileBase + inTile] = 0xFF - srcA;// Fixes inverted alpha.
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Flush CPU cache so GX sees the swizzled I8 texture data
|
||||
// DCFlushRange(texture->alpha, alphaSize);
|
||||
|
||||
// // Initialize GX texture object with swizzled data
|
||||
// GX_InitTexObj(
|
||||
// &texture->texObj,
|
||||
// texture->alpha,
|
||||
// width, height,
|
||||
// GX_TF_I8,
|
||||
// GX_REPEAT, GX_REPEAT,
|
||||
// GX_FALSE
|
||||
// );
|
||||
|
||||
// GX_InitTexObjLOD(
|
||||
// &texture->texObj,
|
||||
// GX_NEAR, GX_NEAR,
|
||||
// 0.0f, 0.0f, 0.0f,
|
||||
// GX_FALSE,
|
||||
// GX_FALSE,
|
||||
// GX_ANISO_1
|
||||
// );
|
||||
// break;
|
||||
// }
|
||||
|
||||
// case TEXTURE_FORMAT_PALETTE: {
|
||||
// // Not supported, convert to RGBA using lookup
|
||||
// color_t* formatted = memoryAllocate(width * height * sizeof(color_t));
|
||||
@@ -176,6 +120,13 @@ errorret_t textureInitDolphin(
|
||||
}
|
||||
|
||||
errorret_t textureBindDolphin(texturedolphin_t *texture) {
|
||||
if(texture == NULL) {
|
||||
GX_SetNumChans(0);
|
||||
errorOk();
|
||||
}
|
||||
|
||||
GX_SetNumChans(1);
|
||||
GX_LoadTexObj(&texture->texObj, GX_TEXMAP0);
|
||||
errorOk();
|
||||
}
|
||||
|
||||
@@ -184,5 +135,71 @@ errorret_t textureDisposeDolphin(texturedolphin_t *texture) {
|
||||
}
|
||||
|
||||
void textureDolphinUploadTEV(void) {
|
||||
if(TEXTURE_BOUND == NULL) {
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(
|
||||
GX_COLOR0A0,
|
||||
GX_DISABLE,
|
||||
GX_SRC_REG,
|
||||
GX_SRC_VTX,
|
||||
GX_LIGHTNULL,
|
||||
GX_DF_NONE,
|
||||
GX_AF_NONE
|
||||
);
|
||||
GX_SetChanAmbColor(GX_COLOR0A0, (GXColor){0, 0, 0, 0});
|
||||
GX_SetChanMatColor(GX_COLOR0A0, (GXColor){255, 255, 255, 255});
|
||||
|
||||
GX_SetNumTexGens(0);
|
||||
|
||||
GX_SetNumTevStages(1);
|
||||
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
|
||||
GX_SetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_CLEAR);
|
||||
GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Add channel for vertex color
|
||||
GX_SetNumChans(1);
|
||||
GX_SetChanCtrl(
|
||||
GX_COLOR0A0,// Store in color channel 0
|
||||
GX_DISABLE,// Lighting disabled
|
||||
GX_SRC_REG,// Ambient color?
|
||||
GX_SRC_VTX,// Material color?
|
||||
GX_LIGHTNULL,// Light Mask
|
||||
GX_DF_NONE,// Diffuse function
|
||||
GX_AF_NONE// Attenuation function
|
||||
);
|
||||
|
||||
// One set of UVs
|
||||
GX_SetNumTexGens(1);
|
||||
GX_SetTexCoordGen(
|
||||
GX_TEXCOORD0,
|
||||
GX_TG_MTX2x4,
|
||||
GX_TG_TEX0,
|
||||
GX_IDENTITY
|
||||
);
|
||||
|
||||
// Basically the shader setup
|
||||
switch(TEXTURE_BOUND->format) {
|
||||
case TEXTURE_FORMAT_RGBA:
|
||||
// One TEV stage: vertex color * texture color
|
||||
GX_SetNumTevStages(1);
|
||||
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
GX_SetTevOrder(
|
||||
GX_TEVSTAGE0,
|
||||
GX_TEXCOORD0,
|
||||
GX_TEXMAP0,
|
||||
GX_COLOR0A0
|
||||
);
|
||||
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||
GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
assertUnreachable("Unknown texture format in meshDraw");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user