📄 srvcalls.c
字号:
SetupVertexCopyData(psContext, &psContext->psVertexSource->sVSIFDef);
#endif /* #if defined(SUPPORT_VGP) */
#if !defined(FIX_HW_PRN_302)
/* Handle fog colour changes */
SortOutFogColour(psContext);
#endif
/* Make sure any state/constant/code changes are passes on to the HW */
UpdateTACtlAnd3DState(psContext);
#if defined(SUPPORT_VGP) || defined(SUPPORT_VGP_LITE)
UpdateVGPControlState(psContext);
UpdateVGPConstants(psContext);
UpdateVGPInstructions(psContext);
#endif /* #if defined(SUPPORT_VGP) */
}
PROFILE_STOP_FUNC(D3DM_ACQUIRE_TA_RESOURCES);
return PVRSRV_OK;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DMReleaseTAResources
PURPOSE : Releases TA and 3D FIFO resources, and zero's our allocated
slaveport space counter.
PARAMETERS: In: psContext - active context
In: bTerminate - flag to indicate if scene should be terminated
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMReleaseTAResources(LPD3DM_CONTEXT psContext, BOOL bTerminate)
{
PVRSRV_DEV_INFO *psDevInfo = GetDevInfo(psContext);
PROFILE_START_FUNC(D3DM_RELEASE_TA_RESOURCES);
/*
Release 3D slaveport
*/
PVRSRVReleaseSlavePort(psDevInfo, PVRSRV_SLAVEPORT_3D);
/*
Release TA
*/
PVRSRVReleaseTA(psDevInfo, bTerminate);
/*
Zero our reserved FIFO space count
*/
psContext->dwAllocatedFifoSpaceDWORDS = 0;
PROFILE_STOP_FUNC(D3DM_RELEASE_TA_RESOURCES);
return PVRSRV_OK;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DMConnectRenderTarget
PURPOSE : Connects a D3DM surface to PVR servicesas a render target
PARAMETERS: In: psContext - active context
In: psSurface - render target surface
In: ui32AAFlags - Antialias settings
In: dwPBPages - size of PB in 4K pages
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMConnectRenderTarget(LPD3DM_CONTEXT psContext,
LPD3DM_SURFACE psSurface,
DWORD dwAAFlags,
DWORD dwPBPages)
{
CHAR szTemp[128];
DWORD dwPBRegPageCount = 0;
PROFILE_START_FUNC(D3DM_CONNECT_RENDER_TARGET);
/* Check registry for parameter buffer size */
sprintf(szTemp, "%s%s", POWERVR_REG_ROOT, D3DM_REGAPPHINTCOMMON_ROOT);
D3DMGetAppHint(0, szTemp, "ParameterBufferPages", &dwPBRegPageCount );
/* Check for valid PB size */
if(dwPBRegPageCount <= 0)
{
D3DM_DPF((DPF_MESSAGE, "D3DMConnectRenderTarget:Invalid Parameter Buffer size requested. Setting to %u pages.", dwPBPages));
dwPBRegPageCount = dwPBPages;
}
/* Create parameter buffer */
if(PVRSRVCreateParameterBuffer (&psSurface->psContext->sDevData, dwPBRegPageCount * 4096) != PVRSRV_OK)
{
D3DM_DPF((DPF_ERROR, "D3DMConnectRenderTarget:Failed to create parameter buffer!"));
return PVRSRV_ERROR_GENERIC;
}
/* Connect render target */
if (PVRSRVAddRenderTarget (&psContext->sDevData,
psSurface->dwWidth,
psSurface->dwHeight,
dwAAFlags,
&psSurface->sDescription.sSurface.psTARenderInfo) != PVRSRV_OK)
{
D3DM_DPF((DPF_ERROR, "D3DMConnectRenderTarget:Failed to add render target!"));
return PVRSRV_ERROR_GENERIC;
}
/* We'll need a command queue for this surface's render commands */
if(PVRSRVCreateCommandQueue(&psContext->sDevData, D3DM_COMMANDQUEUE_SIZE, &psSurface->sDescription.sSurface.psQueue) != PVRSRV_OK)
{
D3DM_DPF((DPF_ERROR, "D3DMConnectRenderTarget:Failed to create command queue!"));
return PVRSRV_ERROR_GENERIC;
}
#ifdef PDUMP
/* Store PDUMP context pointer in render info */
psSurface->sDescription.sSurface.psTARenderInfo->psPDContext = psContext->psPDContext;
#endif
PROFILE_STOP_FUNC(D3DM_CONNECT_RENDER_TARGET);
return PVRSRV_OK;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DMDisconnectRenderTarget
PURPOSE :
PARAMETERS: In: psContext - active context
In:
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMDisconnectRenderTarget(LPD3DM_CONTEXT psContext, LPD3DM_SURFACE psSurface)
{
PROFILE_START_FUNC(D3DM_DISCONNECT_RENDER_TARGET);
/* Discard current TA'd scene if we've started it */
if(psSurface->sDescription.sSurface.bSceneTADataSent)
{
D3DMAcquireTAResources(psContext, FALSE);
PVRSRVDiscardTAScene(psContext->sDevData.psDevInfoUM,
psSurface->sDescription.sSurface.psTARenderInfo,
&psContext->sHWInfo,
FALSE);
D3DMReleaseTAResources(psContext, TRUE);
}
/* Destroy the Queue */
PVRSRVDestroyCommandQueue(&psContext->sDevData, psSurface->sDescription.sSurface.psQueue);
/* Disconnect render target */
if(PVRSRVRemoveRenderTarget(&psContext->sDevData, psSurface->sDescription.sSurface.psTARenderInfo) != PVRSRV_OK)
{
D3DM_DPF((DPF_WARN, "D3DMDisconnectRenderTarget:Failed to remove render target"));
}
/* Destroy parameter buffer */
PVRSRVDestroyParameterBuffer (&psContext->sDevData);
PROFILE_STOP_FUNC(D3DM_DISCONNECT_RENDER_TARGET);
return PVRSRV_OK;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DMAllocDeviceMem
PURPOSE : Pass through function to services allocation function
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMAllocDeviceMem (PVRSRV_DEV_DATA *psDevData,
IMG_UINT32 ui32Flags,
IMG_UINT32 ui32Size,
IMG_UINT32 ui32Alignment,
PVRSRV_MEM_INFO **ppsMemInfo)
{
PROFILE_START_FUNC(D3DM_ALLOC_DEVICE_MEM);
return PVRSRVAllocDeviceMem(psDevData,
ui32Flags | PVRSRV_MEMFLG_SAVERESTORE,
ui32Size,
ui32Alignment,
ppsMemInfo);
PROFILE_STOP_FUNC(D3DM_ALLOC_DEVICE_MEM);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DMFreeDeviceMem
PURPOSE : Pass through function to services deallocation function
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMFreeDeviceMem(PVRSRV_DEV_DATA *psDevData, PVRSRV_MEM_INFO *psMemInfo)
{
PROFILE_START_FUNC(D3DM_FREE_DEVICE_MEM);
return PVRSRVFreeDeviceMem(psDevData, psMemInfo);
PROFILE_STOP_FUNC(D3DM_FREE_DEVICE_MEM);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DMFlushOpsOnSurface
PURPOSE : Flushes All pending ops on a surface
RETURNS : VOID
</function>
------------------------------------------------------------------------------*/
IMG_VOID D3DMFlushOpsOnSurface(LPD3DM_SURFACE psTarget)
{
PPVRSRV_MEM_INFO psMemInfo = psTarget->psMemInfo;
IMG_BOOL bTimeout = IMG_TRUE;
IMG_BOOL bStart = IMG_FALSE;
IMG_UINT32 uiStart = 0;
IMG_UINT32 *puiKicker = (IMG_UINT32*) GetKickerAddress(psTarget->psContext);
PROFILE_START_FUNC(D3DM_FLUSH_OPS_ON_SURFACE);
/*
Wait for any ops to complete as destroying parameter buffer will,
destroy 3D blit resources (possibly mid-blit) causing any pending
3d blits to hang
*/
do
{
if ((psMemInfo->psSyncInfo->ui32ReadOpsComplete ==
psMemInfo->psSyncInfo->ui32ReadOpsPending) &&
(*psMemInfo->psSyncInfo->pui32LastWriteOp ==
psMemInfo->psSyncInfo->ui32NextWriteOp -1))
{
bTimeout = IMG_FALSE;
break;
}
if(bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
HostWaitus(MAX_HW_TIME_US/(WAIT_TRY_COUNT));
SysKickCmdProc(puiKicker);
} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
if(bTimeout == IMG_TRUE)
{
D3DM_DPF((DPF_ERROR, "D3DMFlushOpsOnSurface:Failed to flush surface ops"));
}
PROFILE_STOP_FUNC(D3DM_FLUSH_OPS_ON_SURFACE);
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DMFlushAllQueues
PURPOSE : Flushes All Queues for given context
RETURNS : VOID
</function>
------------------------------------------------------------------------------*/
IMG_VOID D3DMFlushAllQueues(LPD3DM_CONTEXT psContext)
{
LPD3DM_SURFACE psTarget = psContext->sChain.psPrimary;
LPD3DM_SURFACE psTemp = psContext->psNonChainRenderTargets;
DWORD i;
PROFILE_START_FUNC(D3DM_FLUSH_ALL_QUEUES);
/* Flush Context Queue */
PVRSRVFlushQueue(psContext->psContextQueue);
/* First flush the primary if we're flipping */
if(psContext->SwapEffect == D3DMSWAPEFFECT_FLIP)
{
if(psTarget != NULL)
{
PVRSRVFlushQueue(psTarget->sDescription.sSurface.psQueue);
D3DMFlushOpsOnSurface(psTarget);
}
}
/* Flush All backbuffers */
for(i=0; i<MAX_FLIP_SURFACES -1; i++)
{
psTarget = psContext->sChain.psBackBuffers[i];
if(psTarget)
{
PVRSRVFlushQueue(psTarget->sDescription.sSurface.psQueue);
D3DMFlushOpsOnSurface(psTarget);
}
}
/* Flush non chain Rendertargets */
while(psTemp != NULL)
{
PVRSRVFlushQueue(psTemp->sDescription.sSurface.psQueue);
D3DMFlushOpsOnSurface(psTemp);
psTemp = psTemp->psNext;
}
PROFILE_STOP_FUNC(D3DM_FLUSH_ALL_QUEUES);
}
/*****************************************************************************
End of file (SRVCalls.c)
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -