📄 clear.c
字号:
#if defined(FIX_HW_PRN_145)
/*
Setup TA-Ctl/3D state as required
*/
sTACtl3DState.dwISPTSPCtl = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_BLENDOPMODEFOGNONE |
MBX1_ISPTSPCTL_CKDISABLE |
(0 << MBX1_ISPTSPCTL_NUMPASSESSHIFT)|
(0 << MBX1_ISPTSPCTL_UVCOUNTSHIFT) |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE |
MBX1_ISPTSPCTL_VTXORDERSTRIP;
#else
/*
Setup TA-Ctl/3D state as required
*/
sTACtl3DState.dwISPTSPCtl = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_LOGICALOPDISABLE |
MBX1_ISPTSPCTL_CKDISABLE |
(0 << MBX1_ISPTSPCTL_NUMPASSESSHIFT)|
(0 << MBX1_ISPTSPCTL_UVCOUNTSHIFT) |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE |
MBX1_ISPTSPCTL_VTXORDERSTRIP;
#endif
sTACtl3DState.dwTSPObjCtl = MBX1_TSPOBJ_ACMPMODEALWAYS;
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
sTACtl3DState.dwFPFormat = psContext->dwNativeFPFormat;
dwStateChanged = MBX1_TASTATEPRES_FP_INPUTFORMAT;
#endif
dwStateChanged |= (MBX1_TASTATEPRES_ISPCTL |
MBX1_TASTATEPRES_TSPCTL);
/*
Are we fullscreen?
*/
if (bFullScreen)
{
D3DM_DPF((DPF_MESSAGE, "full render srf clip"));
/*
Draw a single enabling triangle
*/
sTACtl3DState.dwISPTSPCtl |= MBX1_ISPTSPCTL_VIEWPORTMASK;
/*
Set the required TA-ctl/3D state
*/
TACSWriteTACtlAnd3DState(psContext,
dwStateChanged,
&sTACtl3DState,
FALSE);
/*
Record what state we have changed
*/
psContext->sHWStateCtl.dwTACtl3DStateChanged |= dwStateChanged;
/*
Setup a fullscreen vertex-strip primitive to set the ISP-mask
*/
ClipRectangle(psContext, psRect, TRUE);
}
else
{
D3DMRECT sViewPortRect;
D3DM_DPF((DPF_MESSAGE, "not full render srf clip - sending fullscreen disable plus smaller enable"));
/*
First draw a full-screen disabling rectangle
*/
sTACtl3DState.dwISPTSPCtl &= ~MBX1_ISPTSPCTL_VIEWPORTMASK;
/*
Set the required TA-ctl/3D state
*/
TACSWriteTACtlAnd3DState(psContext,
dwStateChanged,
&sTACtl3DState,
FALSE);
/*
Record what state we have changed
*/
psContext->sHWStateCtl.dwTACtl3DStateChanged |= dwStateChanged;
/*
Setup a fullscreen vertex-strip primitive to clear the ISP-mask
*/
VLSetRect( &sViewPortRect,
0,
0,
psContext->psCurrentRenderTarget->dwWidth,
psContext->psCurrentRenderTarget->dwHeight);
ClipRectangle(psContext, &sViewPortRect, TRUE);
/*
Now draw an enabling rectangle - the size of D3D viewport
*/
sTACtl3DState.dwISPTSPCtl |= MBX1_ISPTSPCTL_VIEWPORTMASK;
/*
Set the required TA-ctl/3D state
*/
TACSWriteTACtlAnd3DState(psContext,
MBX1_TASTATEPRES_ISPCTL,
&sTACtl3DState,
FALSE);
/*
Record what state we have changed
*/
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_ISPCTL;
/*
Setup a quad vertex-strip primitive to set the ISP-mask for the
required area
*/
ClipRectangle(psContext, psRect, FALSE);
}
/*
Manually insert region clip into control stream,
after viewport enable object.
Ensures that TA clips subsequent objects to nearest
tile boundary around viewport. (clipping geometry in TA
could reduce amount of parameter data passed to core 3d)
*/
sTACtl3DState.dwRegionClip = psContext->sHWState.sTACtl3DState.dwRegionClip;
TACSWriteTACtlAnd3DState(psContext,
MBX1_TASTATEPRES_REGIONCLIP,
&sTACtl3DState,
FALSE);
/*
Record what state we have changed
*/
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_REGIONCLIP;
}
/*****************************************************************************
FUNCTION : SetViewPort
PURPOSE : Sends ISP Clipping Mask Object - first does a full surface disable,
then sends an enable of the D3D viewport size.
PARAMETERS : LPD3DM_CONTEXT psContext, LPD3DMRECT psRect
RETURNS :
*****************************************************************************/
void SetViewPort(LPD3DM_CONTEXT psContext, LPD3DMRECT psRect)
{
LPD3DM_SURFACE psRenderTarget = psContext->psCurrentRenderTarget;
IMG_BOOL bFullScreen;
D3DMRECT sViewPortRect;
D3DM_DPF((DPF_MESSAGE, "SetViewPort"));
/* Rotate viewport rect if required */
bFullScreen = RotateViewportRect(psContext,
&sViewPortRect,
psRect,
psContext->psCurrentRenderTarget->dwWidth,
psContext->psCurrentRenderTarget->dwHeight);
/*
Now setup TA clip region in HW state so that it applies to subsequent primitives...
Calc here, so viewport enable doesnt get clipped by old region clip.
Since it may be an earlier entry in the batched clearlist,
use its rectangle to calc the rgn clip. (The context viewport rect only reflects
the last sent viewport, so we cant use that!).
*/
psContext->sHWState.sTACtl3DState.dwRegionClip = CalcTARegionClip(psContext, &sViewPortRect);
SendViewPort(psContext, &sViewPortRect, bFullScreen);
}
/*****************************************************************************
######################### SW BACKGROUND OBJECT:###############################
*****************************************************************************/
/*****************************************************************************
FUNCTION : TexturedRectangle
PURPOSE : Used to render a textured rectangle for 2d copy blit handled by 3d.
PARAMETERS : Ptr to TEXTUREDRECT structure, containing:
LPD3DM_CONTEXT psContext,
D3DRECT sSrcRect,
D3DRECT sDestRect,
DWORD dwFillDepth,
DWORD dwFillRHW,
float fUScale,
float fVScale,
BOOL bFullScreenClip (used for Background objs)
RETURNS : None.
*****************************************************************************/
void TexturedRectangle(PTEXTUREDRECT psTexRect)
{
PHWSTATE psHWState;
PHWSTATECTL psHWStateCtl;
LPD3DM_CONTEXT psContext = psTexRect->psContext;
DWORD adwVertex[28];
DWORD *pdwVertex;
NTV_TYPE ntvTemp, ntvTempScaled;
DWORD dwU1, dwU2, dwV1, dwV2;
DWORD dwX1, dwX2, dwY1, dwY2;
DWORD dwTAPrimCtl;
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
DWORD dwVGPClipCtl;
DWORD dwFVFCode;
DWORD dwTnLFlags;
VSIFDEF sVSIFDef;
#endif
psHWState = &psContext->sHWState;
psHWStateCtl = &psContext->sHWStateCtl;
/*
Textured background must send a region clip and it must be fullscreen clip.
*/
if (psTexRect->bFullScreenClip)
{
HWTACTL3DSTATE sTACtl3DState;
sTACtl3DState.dwRegionClip = psHWState->sTACtl3DState.dwRegionClip;
TACSWriteTACtlAnd3DState(psContext,
MBX1_TASTATEPRES_REGIONCLIP,
&sTACtl3DState,
FALSE);
/*
Record what state we have changed
*/
psHWStateCtl->dwTACtl3DStateChanged |= MBX1_TASTATEPRES_REGIONCLIP;
}
/*
Setup appropriate primitive block-header controls
*/
dwTAPrimCtl = MBX1_TAPRIM_NONPERSPCORRECT |
MBX1_TAPRIM_ZBIAS_MODEINCREASING |
(0 << MBX1_TAPRIM_ZBIAS_SHIFT) |
MBX1_TAPRIM_CULLMODENONE |
(psContext->dwTAPrimCtl & MBX1_TAPRIM_WBUFFERING_ENABLE);
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
/* Set up the FVF code and TnL flags */
dwFVFCode = D3DMFVF_XYZRHW_FLOAT |
D3DMFVF_DIFFUSE |
D3DMFVF_TEX1 |
D3DMFVF_TEXCOORDSIZE2(0);
dwTnLFlags = PVRD3DTNL_FLAGS_DIFFUSE_PRESENT | (1 << PVRD3DTNL_FLAGS_TC_COUNT_SHIFT);
/* Configure the FVF passthough-shader for the FVF we require */
VSIFDefSetupForFVF(psContext, &sVSIFDef, dwFVFCode, 7<<2);
/* set up the pass-through vertex-shader for this clear data type */
VGPTNLSetUpPassThroughShader(psContext, dwTnLFlags);
/* Ensure our VGP instructions are up to date before sending anything */
UpdateVGPInstructions(psContext);
/* Update the vertex-copy data */
SetupVertexCopyData(psContext, &sVSIFDef);
/* update Interface Def HW State */
psContext->sHWState.sTACtl3DState.dwVGPIFDef = sVSIFDef.dwVGPIFDef;
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_VGP_IFDEFINITION;
/*
Write out all the HW-state that has just changed as a result of
loading the passthrough shader
*/
TACSWriteTACtlAnd3DState(psContext,
MBX1_TASTATEPRES_VGP_IFDEFINITION,
&psHWState->sTACtl3DState,
FALSE);
TACSWriteVGPControlState(psContext,
psHWStateCtl->dwVGPCtlStateChanged,
&psHWState->sVGPControl,
FALSE);
/*
Reset the VGP-control 'state-changed' flags (since all changed
state has now been output)
*/
psHWStateCtl->dwVGPCtlStateChanged = 0;
/*
Disable stuff in the VGP-clip control word
*/
dwVGPClipCtl = psContext->dwVGPClipCtl;
dwVGPClipCtl &= ~(MBX1_VGPCLIPCTL_CLIPPLANES_MASK |
MBX1_VGPCLIPCTL_VIEWPORTTRANS_ENABLE |
MBX1_VGPCLIPCTL_STARTSECTION_MASK);
#endif /* #if defined(SUPPORT_VGP) */
/*
Begin a new vertex-strip
*/
TACSWritePrimHdr(psContext, dwTAPrimCtl, MBX1_TAOBJTYPE_VERTEXFACESTRIP);
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
TACSWriteVGPClipWord(psContext, dwVGPClipCtl);
#endif
/*
Setup vertex data for 2 triangles using 4 vertices.
Clip the vertices to tile boundaries since TA now clips to tile boundaries.
Only need to do bottom right hand corner since full size clears are ALWAYS from 0,0.
*/
ntvTemp = LONG_AS_NTV(psTexRect->sDestRect.x1);
ntvTempScaled = Mul(LONG_AS_NTV(psTexRect->sSrcRect.x1), FL2NTV(psTexRect->fUScale));
dwX1 = TO_ULONG(ntvTemp);
dwU1 = TO_ULONG(ntvTempScaled);
ntvTemp = LONG_AS_NTV(psTexRect->sDestRect.x2);
ntvTempScaled = Mul(LONG_AS_NTV(psTexRect->sSrcRect.x2),FL2NTV(psTexRect->fUScale));
dwX2 = TO_ULONG(ntvTemp);
dwU2 = TO_ULONG(ntvTempScaled);
ntvTemp = LONG_AS_NTV(psTexRect->sDestRect.y1);
ntvTempScaled = Mul(LONG_AS_NTV(psTexRect->sSrcRect.y1), FL2NTV(psTexRect->fVScale));
dwY1 = FLOAT_TO_LONG(ntvTemp);
dwV1 = FLOAT_TO_LONG(ntvTempScaled);
ntvTemp = LONG_AS_NTV(psTexRect->sDestRect.y2);
ntvTempScaled = Mul(LONG_AS_NTV(psTexRect->sSrcRect.y2), FL2NTV(psTexRect->fVScale));
dwY2 = TO_ULONG(ntvTemp);
dwV2 = TO_ULONG(ntvTempScaled);
pdwVertex = adwVertex;
*pdwVertex++ = dwX1;
*pdwVertex++ = dwY2;
*pdwVertex++ = psTexRect->dwFillDepth;
*pdwVertex++ = psTexRect->dwFillRHW;
*pdwVertex++ = 0xFFFFFFFF;
*pdwVertex++ = dwU1;
*pdwVertex++ = dwV2;
*pdwVertex++ = dwX1;
*pdwVertex++ = dwY1;
*pdwVertex++ = psTexRect->dwFillDepth;
*pdwVertex++ = psTexRect->dwFillRHW;
*pdwVertex++ = 0xFFFFFFFF;
*pdwVertex++ = dwU1;
*pdwVertex++ = dwV1;
*pdwVertex++ = dwX2;
*pdwVertex++ = dwY2;
*pdwVertex++ = psTexRect->dwFillDepth;
*pdwVertex++ = psTexRect->dwFillRHW;
*pdwVertex++ = 0xFFFFFFFF;
*pdwVertex++ = dwU2;
*pdwVertex++ = dwV2;
*pdwVertex++ = dwX2;
*pdwVertex++ = dwY1;
*pdwVertex++ = psTexRect->dwFillDepth;
*pdwVertex++ = psTexRect->dwFillRHW;
*pdwVertex++ = 0xFFFFFFFF;
*pdwVertex++ = dwU2;
*pdwVertex++ = dwV1;
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
CopySelect(psContext,
(IMG_UINT8 *)adwVertex,
4,
&sVSIFDef);
#else
TACSWriteData(psContext, (PVOID)adwVertex, (pdwVertex-adwVertex)<<2);
#endif
TACSWriteLastPrim(psContext);
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
/* update Interface Def HW State */
if(psContext->psVertexSource)
{
psContext->sHWState.sTACtl3DState.dwVGPIFDef = psContext->psVertexSource->sVSIFDef.dwVGPIFDef;
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_VGP_IFDEFINITION;
}
#endif /* #if defined(SUPPORT_VGP) */
}
/*****************************************************************************
FUNCTION : SendBackgroundObject
PURPOSE : Sends full rendersurface target initialise & depth clear.
Target initialised with last renderframe image as texture.
Depth initialised to arbitrary depth value (max depth).
Note that we dont have to PDUMP source texture (render surf)
as we want whats currently in the render surface.
N.B. The background object can be forced to be untextured,
via an apphint. Use for hardware regression testing.
PARAMETERS : LPD3DM_CONTEXT psContext
DWORD dwFlags
RETURNS :
*****************************************************************************/
void SendBackgroundObject(LPD3DM_CONTEXT psContext)
{
HWTACTL3DSTATE sTACtl3DState;
TEXTUREDRECT sTexRect;
DWORD dwStateChanged = 0;
DWORD dwWidth;
DWORD dwHeight;
LPD3DM_SURFACE psRenderTarget;
DWORD dwTextureAddress;
DWORD dwMBXTextureFormat;
float fDepth;
BOOL bAccumulatePrevious;
DEVICE3D *ps3DDevice;
PVR3DIF_SHAREDDATA *psSharedData;
NTV_TYPE ntvLastClearZ, ntvDepth;
D3DM_DPF((DPF_MESSAGE, "SendBackgroundObject"));
PDUMPSTRING(psContext->psPDContext, "-- Sending Background Object");
ps3DDevice = &GetDevInfo(psContext)->sDeviceSpecific.s3D;
psRenderTarget = psContext->psCurrentRenderTarget;
psSharedData = psRenderTarget->sDescription.sSurface.psTARenderInfo->psSharedData;
sTexRect.psContext = psContext;
bAccumulatePrevious = TRUE;
#if defined(FIX_HW_PRN_145)
/*
Setup basic TA-Ctl/3D state as required.
*/
sTACtl3DState.dwISPTSPCtl = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_BLENDOPMODEFOGNONE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_OPAQUE |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_VTXORDERSTRIP |
MBX1_ISPTSPCTL_DWDISABLE;
#else
/*
Setup basic TA-Ctl/3D state as required.
*/
sTACtl3DState.dwISPTSPCtl = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_LOGICALOPDISABLE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_OPAQUE |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -