Refactor GPUREG_TEXUNIT_CONFIG state (in preparation of future changes)
This commit is contained in:
parent
73f4039a9c
commit
82b9eea410
@ -70,6 +70,7 @@ bool C3D_Init(size_t cmdBufSize)
|
||||
C3D_FragOpMode(GPU_FRAGOPMODE_GL);
|
||||
C3D_FragOpShadow(0.0, 1.0);
|
||||
|
||||
ctx->texConfig = BIT(12);
|
||||
ctx->texEnvBuf = 0;
|
||||
ctx->texEnvBufClr = 0xFFFFFFFF;
|
||||
|
||||
@ -165,22 +166,29 @@ void C3Di_UpdateContext(void)
|
||||
|
||||
if (ctx->flags & C3DiF_TexAll)
|
||||
{
|
||||
GPU_TEXUNIT units = 0;
|
||||
|
||||
u32 units = 0;
|
||||
for (i = 0; i < 3; i ++)
|
||||
{
|
||||
static const u8 parm[] = { GPU_TEXUNIT0, GPU_TEXUNIT1, GPU_TEXUNIT2 };
|
||||
|
||||
if (ctx->tex[i])
|
||||
{
|
||||
units |= parm[i];
|
||||
units |= BIT(i);
|
||||
if (ctx->flags & C3DiF_Tex(i))
|
||||
C3Di_SetTex(parm[i], ctx->tex[i]);
|
||||
C3Di_SetTex(i, ctx->tex[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Enable texture units and clear texture cache
|
||||
ctx->texConfig &= ~7;
|
||||
ctx->texConfig |= units | BIT(16);
|
||||
ctx->flags &= ~C3DiF_TexAll;
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNIT_CONFIG, 0x00011000|units); // Enable texture units
|
||||
ctx->flags |= C3DiF_TexStatus;
|
||||
}
|
||||
|
||||
if (ctx->flags & C3DiF_TexStatus)
|
||||
{
|
||||
ctx->flags &= ~C3DiF_TexStatus;
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNIT_CONFIG, ctx->texConfig);
|
||||
ctx->texConfig &= ~BIT(16); // Remove clear-texture-cache flag
|
||||
}
|
||||
|
||||
if (ctx->flags & C3DiF_TexEnvBuf)
|
||||
|
@ -38,6 +38,7 @@ typedef struct
|
||||
C3D_Effect effect;
|
||||
C3D_LightEnv* lightEnv;
|
||||
|
||||
u32 texConfig;
|
||||
C3D_Tex* tex[3];
|
||||
C3D_TexEnv texEnv[6];
|
||||
|
||||
@ -71,6 +72,7 @@ enum
|
||||
C3DiF_VshCode = BIT(11),
|
||||
C3DiF_GshCode = BIT(12),
|
||||
C3DiF_CmdBuffer = BIT(13),
|
||||
C3DiF_TexStatus = BIT(14),
|
||||
|
||||
#define C3DiF_Tex(n) BIT(23+(n))
|
||||
C3DiF_TexAll = 7 << 23,
|
||||
@ -99,7 +101,7 @@ void C3Di_AttrInfoBind(C3D_AttrInfo* info);
|
||||
void C3Di_BufInfoBind(C3D_BufInfo* info);
|
||||
void C3Di_FrameBufBind(C3D_FrameBuf* fb);
|
||||
void C3Di_TexEnvBind(int id, C3D_TexEnv* env);
|
||||
void C3Di_SetTex(GPU_TEXUNIT unit, C3D_Tex* tex);
|
||||
void C3Di_SetTex(int unit, C3D_Tex* tex);
|
||||
void C3Di_EffectBind(C3D_Effect* effect);
|
||||
|
||||
void C3Di_LightMtlBlend(C3D_Light* light);
|
||||
|
@ -255,7 +255,7 @@ void C3D_TexDelete(C3D_Tex* tex)
|
||||
tex->data = NULL;
|
||||
}
|
||||
|
||||
void C3Di_SetTex(GPU_TEXUNIT unit, C3D_Tex* tex)
|
||||
void C3Di_SetTex(int unit, C3D_Tex* tex)
|
||||
{
|
||||
u32 reg[10];
|
||||
u32 regcount = 5;
|
||||
@ -277,15 +277,15 @@ void C3Di_SetTex(GPU_TEXUNIT unit, C3D_Tex* tex)
|
||||
|
||||
switch (unit)
|
||||
{
|
||||
case GPU_TEXUNIT0:
|
||||
case 0:
|
||||
GPUCMD_AddIncrementalWrites(GPUREG_TEXUNIT0_BORDER_COLOR, reg, regcount);
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNIT0_TYPE, tex->fmt);
|
||||
break;
|
||||
case GPU_TEXUNIT1:
|
||||
case 1:
|
||||
GPUCMD_AddIncrementalWrites(GPUREG_TEXUNIT1_BORDER_COLOR, reg, 5);
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNIT1_TYPE, tex->fmt);
|
||||
break;
|
||||
case GPU_TEXUNIT2:
|
||||
case 2:
|
||||
GPUCMD_AddIncrementalWrites(GPUREG_TEXUNIT2_BORDER_COLOR, reg, 5);
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNIT2_TYPE, tex->fmt);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user