📄 fb.c
字号:
{
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_FALSE;
}
if (gc->sClear.ui32ClearFlags)
{
SendDrawMaskForClear(gc);
DrawClearPrims(gc);
}
if(gc->bDrawMaskInvalid)
SendDrawMaskForPrimitive(gc);
#if !defined(FIX_HW_PRN_302)
if(gc->bFogColorInvalid)
SendFogColorChange(gc);
#endif
}
else
{
IMG_UINT32 ui32AAFlags = 0;
if((gc->ui32FrameEnables & GLES_FS_MULTISAMPLE_ENABLE) || (gc->sAppHints.i32SceneAntiAlias > 0))
{
#if defined(SUPPORT_MBX1_LITE)
if(gc->psMode->ui32AntiAliasMode & (GLES_ANTIALIAS_2x1|GLES_ANTIALIAS_2x2))
ui32AAFlags |= PVRSRV_ADDRENDERTARGET_AAX;
#endif
if(gc->psMode->ui32AntiAliasMode & GLES_ANTIALIAS_2x2)
ui32AAFlags |= PVRSRV_ADDRENDERTARGET_AAY;
}
GLESGetDrawableParameters(gc->hWriteDrawable, &sParams);
gc->psRenderSurface = (GLESRenderSurface *)sParams.hRenderSurface;
if(sParams.ui32Width != gc->psRenderSurface->ui32Width ||
sParams.ui32Height != gc->psRenderSurface->ui32Height ||
ui32AAFlags != gc->psRenderSurface->ui32AAFlags ||
!gc->psRenderSurface->psTARenderInfo)
{
IMG_BOOL bHadDepthBuffer = IMG_FALSE;
if(gc->psRenderSurface->psTARenderInfo)
{
if(!GLESDestroyRenderTarget(gc->sHWContext.psSysContext, gc->psRenderSurface))
{
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_FALSE;
}
}
if(gc->psRenderSurface->psZBufferMemInfo)
{
PVRSRV_HWREG *ps3DRegs = gc->sHWContext.sRegisters.ps3DRegs;
if(!GLESDestroyDepthBuffer(gc->sHWContext.psSysContext, gc->psRenderSurface))
{
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_FALSE;
}
ps3DRegs[GLES_SW3DREG_ZLOADSTORE].ui32RegVal &= (MBX1_ZLOADSTORE_XEXTENTCLR & MBX1_ZLOADSTORE_ZFORMATCLR);
ps3DRegs[GLES_SW3DREG_ZLOADSTORE].ui32RegVal |= MBX1_ZLOADSTORE_ZFORMAT_NO_EXT_Z;
bHadDepthBuffer = IMG_TRUE;
}
/* Check for dynamic rotation */
switch(gc->sDrawableParams.eRotationAngle)
{
case ROTATE_0:
case ROTATE_180:
switch(sParams.eRotationAngle)
{
case ROTATE_90:
case ROTATE_270:
RotateViewportScissor(gc);
break;
default:
break;
}
break;
case ROTATE_90:
case ROTATE_270:
switch(sParams.eRotationAngle)
{
case ROTATE_0:
case ROTATE_180:
RotateViewportScissor(gc);
break;
default:
break;
}
break;
}
gc->sDrawableParams = sParams;
gc->psRenderSurface->ui32Width = sParams.ui32Width;
gc->psRenderSurface->ui32Height = sParams.ui32Height;
gc->psRenderSurface->ui32AAFlags = ui32AAFlags;
if(sParams.ui32Width == 0 && sParams.ui32Height == 0)
{
DPF((DBG_ERROR,"Invalid drawable - what do we do?"));
}
else
{
if(!GLESCreateRenderTarget(gc))
{
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_FALSE;
}
#ifdef PDUMP
gc->psRenderSurface->psTARenderInfo->psPDContext = gc->psPDContext;
#endif
if(bHadDepthBuffer || (gc->sAppHints.bForceExternalZBuffer && gc->psMode->bHaveDepthBuffer))
{
if(!GLESCreateDepthBuffer(gc))
{
/* Should we fail here, or carry on regardless? */
DPF((DBG_ERROR,"Couldn't create external depth buffer"));
}
}
GLESInitRegs(gc);
}
ApplyViewport(gc);
}
/* if we have hit complex scene in a previous scene we need to create a depth buffer
for z load store */
if(gc->psRenderSurface->psTARenderInfo->psSharedData->bAllocateDepthbuffer && gc->psMode->bHaveDepthBuffer)
{
/* only create if we do not have a Z buffer */
if(!gc->psRenderSurface->psZBufferMemInfo)
{
if(!GLESCreateDepthBuffer(gc))
{
/* Should we fail here, or carry on regardless? */
DPF((DBG_ERROR,"Complex Scene: Couldn't create external depth buffer"));
}
GLESInitRegs(gc);
}
}
/*
* Use new Drawable Params for HW BG Object, QueueRender
* Use old Drawable Params for SW BG Obj (allows accumulation across frames), SyncInfo for backbuffer sync
*/
gc->sHWContext.psPrevSync = gc->sDrawableParams.psSyncInfo;
gc->sDrawableParams = sParams;
SetupHWBGObjWords(gc);
if(!GLESAcquireTA(gc, gc->psRenderSurface))
{
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_FALSE;
}
StartFrame(gc);
if (gc->sClear.ui32ClearFlags)
{
SendDrawMaskForClear(gc);
DrawClearPrims(gc);
}
if ((gc->ui32FrameEnables & GLES_FS_SCISSOR_ENABLE) ||
!((gc->sState.sViewport.i32X == 0) && (gc->sState.sViewport.i32Y == 0) &&
(gc->sState.sViewport.ui32Width == psDrawParams->ui32Width) &&
(gc->sState.sViewport.ui32Height == psDrawParams->ui32Height)))
{
gc->bDrawMaskInvalid = IMG_TRUE;
}
if(gc->bDrawMaskInvalid)
SendDrawMaskForPrimitive(gc);
gc->bFogColorInvalid = IMG_FALSE;
}
GLES_TIME_STOP(GLES_TIMER_PREPARE_TO_DRAW_TIME);
return IMG_TRUE;
}
IMG_VOID WaitForPreviousFrame(GLESContext *gc)
{
PVR3DIF_SHAREDDATA *psSharedData = gc->psRenderSurface->psTARenderInfo->psSharedData;
IMG_UINT32 ui32WaitCount = GLES_TEXTURE_LATENCY;
IMG_UINT32 i;
if(PollForValue ((IMG_UINT32*)&psSharedData->aui32ContextStatus[1 - psSharedData->ui32CurrentRenderData],
PVR3DIF_3DCTL_FREE,
0xFFFFFFFF,
MAX_HW_TIME_US/WAIT_TRY_COUNT,
WAIT_TRY_COUNT) != PVRSRV_OK)
{
DPF((DBG_WARNING,"Wait for 3D poll failed after 1s"));
return;
}
for(i=0; i<ui32WaitCount - 1; i++)
{
TexMgrAdvanceOneFrame(gc);
}
}
static IMG_VOID WaitFor3D(GLESContext *gc, GLESRenderSurface *psRenderSurface)
{
PVR3DIF_SHAREDDATA *psSharedData = psRenderSurface->psTARenderInfo->psSharedData;
IMG_UINT32 i=0;
IMG_BOOL bTimeout;
IMG_BOOL bStart;
IMG_UINT32 uiStart;
GLES_TIME_START(GLES_TIMER_WAITING_FOR_3D_TIME);
/*
* Kick command processor and if this doesn't work first 100 times then wait 1ms between kicks.
* Eventually just continue after 1s
*/
bTimeout = IMG_TRUE;
bStart = IMG_FALSE;
uiStart = 0;
i = 0;
do
{
if (psSharedData->aui32ContextStatus[psSharedData->ui32CurrentRenderData] == PVR3DIF_3DCTL_FREE)
{
bTimeout = IMG_FALSE;
break;
}
SysKickCmdProc (gc->sDrawableParams.psQueueInfo->pui32KickerAddr);
if (bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
if (i > 100)
{
HostWaitus (MAX_HW_TIME_US / WAIT_TRY_COUNT);
}
i++;
} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
if (bTimeout == IMG_TRUE)
{
DPF((DBG_ERROR,"Wait for 3D failed after 1s"));
}
GLES_TIME_STOP(GLES_TIMER_WAITING_FOR_3D_TIME);
}
/***********************************************************************************
Function Name : FlushHW
Inputs : gc, psRenderSurface, bWaitForHW
Outputs : -
Returns : Success
Description : Kicks a render.
************************************************************************************/
IMG_GLESERROR FlushHW(GLESContext *gc, GLESRenderSurface *psRenderSurface, IMG_BOOL bWaitForHW)
{
#if defined (PDUMP) || defined (OLDPDUMP) || defined (DEBUG)
GLEStextureManager *psTexMgr = gc->sTexture.psTextureManager;
#endif
IMG_UINT32 ui32TerminateStream = MBX1_TAOBJTYPE_STREAMEND;
#if defined(PDUMP) || defined(OLDPDUMP)
PVRSRV_HWREG *ps3DRegs = gc->sHWContext.sRegisters.ps3DRegs;
GLEStexture *psTex = psTexMgr->psActiveList->psNext;
IMG_UINT32 i=0;
#endif
GLES_TIME_START(GLES_TIMER_FLUSH_HW_TIME);
#if defined (TIMING) || defined (DEBUG)
GetFrameTime(gc);
#endif
if(!ValidateMemory(gc))
{
GLES_TIME_STOP(GLES_TIMER_FLUSH_HW_TIME);
return IMG_GLES_MEMORY_INVALID_ERROR;
}
if(gc->sClear.ui32ClearFlags)
{
DPF((DBG_MESSAGE,"FlushHW: Flushing clears through start of frame"));
/* If we can't flush clears - just continue to record state. */
if(PrepareToDraw(gc))
{
GLESReleaseTA(gc, IMG_FALSE);
}
else
{
DPF((DBG_ERROR,"Can't flush clears"));
}
}
if(psRenderSurface->bInFrame)
{
if(!GLESAcquireTA(gc, psRenderSurface))
{
/*
need to take out of frame so we can recover for next frame
(cause - scene invalidate asserted in services)
*/
psRenderSurface->bInFrame = IMG_FALSE;
DPF((DBG_ERROR,"FlushHW: Can't acquire TA for terminate"));
GLES_TIME_STOP(GLES_TIMER_FLUSH_HW_TIME);
return IMG_GLES_GENERIC_ERROR;
}
EmitState(gc, &ui32TerminateStream, 1);
GLESReleaseTA(gc, IMG_TRUE);
DPF((DBG_MESSAGE,"Scheduling render for frame number %d\n",psTexMgr->ui32CurrentFrame));
#ifdef PDUMP
PDUMPPRIM(gc->psPDContext);
while(psTex && psTex->ui32LevelsConsistent != GLES_TEX_DUMMY)
{
if(psTex->psMemInfo && !psTex->bIsDumped)
{
PDUMPTEX(gc->psPDContext, psTex->psMemInfo);
psTex->bIsDumped = IMG_TRUE;
}
psTex = psTex->psNext;
}
PDUMPREGARRAY(gc->psPDContext, PDUMPTAGS_REG_MBX, ps3DRegs, GLES_COUNT_SW3DREG);
PDUMPUPDATEFRAME(gc->psPDContext);
#elif defined(OLDPDUMP)
PDUMP_PRIM(gc);
while(psTex && psTex->ui32LevelsConsistent != GLES_TEX_DUMMY)
{
if(psTex->psMemInfo && !psTex->bIsDumped)
{
PDUMP_TEX(gc, psTex);
psTex->bIsDumped = IMG_TRUE;
}
psTex = psTex->psNext;
}
for(i=0 ; i < GLES_COUNT_SW3DREG; i++)
{
PDUMP_WRITEREG(gc, ps3DRegs[i].ui32RegAddr, ps3DRegs[i].ui32RegVal);
}
#endif
psRenderSurface->bInFrame = IMG_FALSE;
/* disable TA to investigate performance */
#if defined(DISABLE_HARDWARE_TA)
gc->sHWContext.ps3DDevData->psDevInfoUM->sDeviceSpecific.s3D.bTAIdle = IMG_TRUE;
psRenderSurface->psTARenderInfo->psSharedData->aui32ContextStatus[psRenderSurface->psTARenderInfo->psSharedData->ui32CurrentRenderData] = PVR3DIF_3DCTL_FREE;
#endif
}
if( bWaitForHW && (psRenderSurface->psTARenderInfo) )
WaitFor3D(gc, psRenderSurface);
GLES_TIME_STOP(GLES_TIMER_FLUSH_HW_TIME);
return IMG_GLES_NO_ERROR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -