📄 validate.c
字号:
*/
ui32TSPObjectWord = (gc->sHWContext.ui32TSPObjectWord & ~MBX1_TSPOBJ_FACTORCLRMASK) |
gc->sState.sRaster.ui32AlphaFuncRef;
/*
* Start with ISPTSP word from context which contains: Shade control;Vertex format
*/
ui32ISPTSP = gc->sHWContext.ui32ISPTSPWord & ( MBX1_ISPTSPCTL_GOURAUD |
MBX1_ISPTSPCTL_OFFSET |
MBX1_ISPTSPCTL_UVCOUNT |
~MBX1_ISPTSPCTL_CKCLRMASK |
~MBX1_ISPTSPCTL_NUMPASSESCLRMASK);
#ifndef FIX_HW_PRN_145
/*
* Alpha blending defers to logical ops in OGLES. If logical ops are enabled, use logic op from state
* Set object type to translucent.
* More performance - if logical op is copy, don't set translucent. If it is noop, set TW disable
*/
if(gc->ui32RasterEnables & GLES_RS_LOGICOP_ENABLE)
{
ui32ISPTSP |= gc->sState.sRaster.ui32LogicOp | MBX1_ISPTSPCTL_LOGICALOP_FB;
if(gc->sState.sRaster.ui32LogicOp != MBX1_ISPTSPCTL_LO_COPY)
{
if(gc->sState.sRaster.ui32LogicOp == MBX1_ISPTSPCTL_LO_NOOP)
{
ui32ISPTSP |= MBX1_ISPTSPCTL_TAGWDISABLE;
}
else
{
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSTRANS;
}
}
}
/* If alpha blending is enabled, use blend src/dst from state */
else if(gc->ui32RasterEnables & GLES_RS_ALPHABLEND_ENABLE)
{
ui32ISPTSP |= (gc->sState.sRaster.ui32BlendSrcDst | MBX1_ISPTSPCTL_LOGICALOPDISABLE);
/*
* If blend is one,zero - not really blending, otherwise if zero,one not updating FB - so TW disable.
* If we are blending, then change object type to be translucent
*/
if(gc->sState.sRaster.ui32BlendSrcDst != (MBX1_ISPTSPCTL_SRCBLENDONE|MBX1_ISPTSPCTL_DESTBLENDZERO))
{
if(gc->sState.sRaster.ui32BlendSrcDst == (MBX1_ISPTSPCTL_SRCBLENDZERO|MBX1_ISPTSPCTL_DESTBLENDONE))
{
ui32ISPTSP |= MBX1_ISPTSPCTL_TAGWDISABLE;
}
else
{
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSTRANS;
}
}
}
else
{
/* If no blending/logical ops are enabled, use blend one/zero */
ui32ISPTSP |= (MBX1_ISPTSPCTL_SRCBLENDONE | MBX1_ISPTSPCTL_DESTBLENDZERO | MBX1_ISPTSPCTL_LOGICALOPDISABLE);
}
/*
* If fog is enabled, enable vertex fog.
*/
if(gc->ui32RasterEnables & GLES_RS_FOG_ENABLE)
{
ui32ISPTSP |= MBX1_ISPTSPCTL_FOGENABLE;
}
ui32BlendOpMode = 0;
#else
ui32BlendOpMode = MBX1_ISPTSPCTL_BLENDOPMODEFOGNONE;
/*
* Alpha blending defers to logical ops in OGLES. If logical ops are enabled, use logic op from state
* Set BlendOp mode to logical ops (will prevent fogging). Set object type to translucent.
* More orthogonality - if logical op is copy, then do one,zero blending instead.
* Performance - if it is noop - do tag write disable and zero one blending.
*/
if(gc->ui32RasterEnables & GLES_RS_LOGICOP_ENABLE)
{
if(gc->sState.sRaster.ui32LogicOp == MBX1_ISPTSPCTL_LO_COPY)
{
ui32ISPTSP |= (MBX1_ISPTSPCTL_SRCBLENDONE|MBX1_ISPTSPCTL_DESTBLENDZERO);
}
else if(gc->sState.sRaster.ui32LogicOp == MBX1_ISPTSPCTL_LO_NOOP)
{
ui32ISPTSP |= (MBX1_ISPTSPCTL_SRCBLENDZERO|MBX1_ISPTSPCTL_DESTBLENDONE|MBX1_ISPTSPCTL_TAGWDISABLE);
}
else
{
ui32ISPTSP |= gc->sState.sRaster.ui32LogicOp | MBX1_ISPTSPCTL_LOGICALOP_FB;
ui32BlendOpMode = MBX1_ISPTSPCTL_BLENDOPMODELOGICALOP;
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSTRANS;
}
}
/* If alpha blending is enabled, use blend src/dst from state */
else if(gc->ui32RasterEnables & GLES_RS_ALPHABLEND_ENABLE)
{
ui32ISPTSP |= gc->sState.sRaster.ui32BlendSrcDst;
/*
* If blend is (not from dest),zero - not really blending, otherwise if zero,one not updating FB - so TW disable.
* If we are blending, then change object type to be translucent
*/
switch(gc->sState.sRaster.ui32BlendSrcDst)
{
case (MBX1_ISPTSPCTL_SRCBLENDZERO|MBX1_ISPTSPCTL_DESTBLENDZERO):
case (MBX1_ISPTSPCTL_SRCBLENDONE|MBX1_ISPTSPCTL_DESTBLENDZERO):
case (MBX1_ISPTSPCTL_SRCBLENDSRCALPHA|MBX1_ISPTSPCTL_DESTBLENDZERO):
case (MBX1_ISPTSPCTL_SRCBLENDINVSRCALPHA|MBX1_ISPTSPCTL_DESTBLENDZERO):
break;
case (MBX1_ISPTSPCTL_SRCBLENDZERO|MBX1_ISPTSPCTL_DESTBLENDONE):
ui32ISPTSP |= MBX1_ISPTSPCTL_TAGWDISABLE;
break;
default:
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSTRANS;
break;
}
}
else
{
/* If no blending/logical ops are enabled, use blend one/zero */
ui32ISPTSP |= (MBX1_ISPTSPCTL_SRCBLENDONE|MBX1_ISPTSPCTL_DESTBLENDZERO);
}
/*
* If fog is enabled, set BlendOp mode to vertex fog. I have chosen to allow logical ops to take
* precendence over fogging.
*/
if(ui32BlendOpMode != MBX1_ISPTSPCTL_BLENDOPMODELOGICALOP)
{
if(gc->ui32RasterEnables & GLES_RS_FOG_ENABLE)
{
ui32BlendOpMode = MBX1_ISPTSPCTL_BLENDOPMODEVERTEXFOG;
}
}
#endif
/*
* We cannot correctly support colormask. If no channels are enabled, Set TW disable and
* make the object type opaque, for performance.
*/
if(!gc->sState.sRaster.ui32ColorMask)
{
ui32ISPTSP |= MBX1_ISPTSPCTL_TAGWDISABLE;
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_OPAQUE;
}
/*
* If depth test is enabled, use func from state, otherwise set depth compare always.
* Note: OGLES disallows depth writes if the depth test is disabled, so set DW disable.
*/
if(gc->ui32RasterEnables & GLES_RS_DEPTHTEST_ENABLE)
{
ui32ISPTSP |= gc->sState.sDepth.ui32TestFunc;
}
else
{
ui32ISPTSP |= MBX1_ISPTSPCTL_DCMPMODEALWAYS | MBX1_ISPTSPCTL_DWDISABLE;
}
/*
* If alpha test is enabled, attempt to optimise always pass and always fail cases.
* In the always fail case, set DW and TW disable for performance. In the general case,
* ensure TW disable is not set, and setup the object type as PT or FPT depending on
* the previously set translucency/opacity of the object.
*/
if(gc->ui32RasterEnables & GLES_RS_ALPHATEST_ENABLE)
{
if((ui32TSPObjectWord == (MBX1_TSPOBJ_ACMPMODEGE | (0 << MBX1_TSPOBJ_ALPHAREFSHIFT))) ||
(ui32TSPObjectWord == (MBX1_TSPOBJ_ACMPMODELE | (255 << MBX1_TSPOBJ_ALPHAREFSHIFT))))
{
ui32TSPObjectWord &= MBX1_TSPOBJ_ALPHACMPCLRMASK;
ui32TSPObjectWord |= MBX1_TSPOBJ_ACMPMODEALWAYS;
}
else if((ui32TSPObjectWord == MBX1_TSPOBJ_ACMPMODENEVER) ||
(ui32TSPObjectWord == (MBX1_TSPOBJ_ACMPMODEGT | (255 << MBX1_TSPOBJ_ALPHAREFSHIFT))) ||
(ui32TSPObjectWord == (MBX1_TSPOBJ_ACMPMODELT | (0 << MBX1_TSPOBJ_ALPHAREFSHIFT))))
{
ui32TSPObjectWord &= MBX1_TSPOBJ_ALPHACMPCLRMASK;
ui32TSPObjectWord |= MBX1_TSPOBJ_ACMPMODENEVER;
ui32ISPTSP |= MBX1_ISPTSPCTL_DWDISABLE | MBX1_ISPTSPCTL_TAGWDISABLE;
}
else
{
ui32ISPTSP &= ~MBX1_ISPTSPCTL_TAGWDISABLE;
#ifndef FIX_HW_PRN_271
if(ui32ObjectType == MBX1_ISPTSPCTL_OBJTYPE_PSTRANS)
{
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSPT;
}
else
{
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_FASTPT;
}
#else
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_PSPT;
#endif
}
}
else
{
ui32TSPObjectWord |= MBX1_TSPOBJ_ACMPMODEALWAYS;
}
/*
* TW, DW disable together with translucency marks a special fog colour change object. We don't
* want to set this condition incidentally, so in this case reset the object type to Opaque.
*/
if(ui32ObjectType == MBX1_ISPTSPCTL_OBJTYPE_PSTRANS &&
((ui32ISPTSP & (MBX1_ISPTSPCTL_DWDISABLE | MBX1_ISPTSPCTL_TAGWDISABLE)) ==
(MBX1_ISPTSPCTL_DWDISABLE | MBX1_ISPTSPCTL_TAGWDISABLE)))
{
ui32ObjectType = MBX1_ISPTSPCTL_OBJTYPE_OPAQUE;
}
fWClampVal = 1.0e-5f;
gc->sHWContext.ui32ISPTSPWord = ui32ISPTSP | ui32ObjectType | ui32BlendOpMode;
gc->sHWContext.ui32TSPObjectWord = ui32TSPObjectWord;
gc->sHWContext.ui32TAControland3DState |= ( MBX1_TASTATEPRES_ISPCTL |
MBX1_TASTATEPRES_TSPCTL);
}
IMG_VOID GLESEmitState(GLESContext *gc)
{
GLES_TIME_START(GLES_TIMER_TOTAL_STATE_TIME);
EmitState(gc, &gc->sHWContext.ui32TAControland3DState, 1);
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_ISPCTL)
{
EmitState(gc, &gc->sHWContext.ui32ISPTSPWord, 1);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_TSPCTL)
{
EmitState(gc, &gc->sHWContext.ui32TSPObjectWord, 1);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_LAYER0CTL)
{
EmitState(gc, gc->sHWContext.asLayerState[0].aui32LayerWord, 3);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_LAYER1CTL)
{
EmitState(gc, gc->sHWContext.asLayerState[1].aui32LayerWord, 3);
}
#if defined(SUPPORT_VGP) || defined(SUPPORT_VGP_LITE)
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_VGP_IFDEFINITION)
{
EmitState(gc, &gc->sHWContext.ui32StreamFormat, 1);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_FP_INPUTFORMAT)
{
EmitState(gc, &gc->sHWContext.ui32FPControlWord, 1);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_VGP_VIEWPORTTRANS)
{
EmitState(gc, (IMG_UINT32 *)&gc->sState.sViewport.fXCenter, 6);
}
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_VGP_WCLAMPVAL)
{
IMG_FLOAT fWClampVal = 1.0e-5f;
EmitState(gc, (IMG_UINT32 *)&fWClampVal, 1);
}
#else
if(gc->sHWContext.ui32TAControland3DState & MBX1_TASTATEPRES_FP_INPUTFORMAT)
{
EmitState(gc, &gc->sHWContext.ui32FPControlWord, 1);
}
#endif
gc->sHWContext.ui32TAControland3DState &= MBX1_TASTATEPRES_CLRMASK;
GLES_TIME_STOP(GLES_TIMER_TOTAL_STATE_TIME);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -