📄 services_calls.c
字号:
/**************************************************************************
* Name : services_calls.c
* Author : BCB
* Created : 11/08/2003
*
* Copyright : 2003 by Imagination Technologies Limited. All rights reserved.
* : No part of this software, either material or conceptual
* : may be copied or distributed, transmitted, transcribed,
* : stored in a retrieval system or translated into any
* : human or computer language in any form by any means,
* : electronic, mechanical, manual or other-wise, or
* : disclosed to third parties without the express written
* : permission of Imagination Technologies Limited, Unit 8, HomePark
* : Industrial Estate, King's Langley, Hertfordshire,
* : WD4 8LZ, U.K.
*
* Platform : ANSI
*
* $Date: 2004/10/27 16:16:04 $ $Revision: 1.46.1.1 $
* $Log: services_calls.c $
*
* --- Revision Logs Removed ---
**************************************************************************/
#define MODULE_ID MODID_SERVICESCALLS
#include "context.h"
#include "pvr3dif.h"
#include "vgp.h"
/***********************************************************************************
Function Name : GLESCreateParameterBuffer
Inputs : gc
Outputs : -
Returns : success
Description : Creates a parameter buffer.
************************************************************************************/
IMG_BOOL GLESCreateParameterBuffer(GLESContext *gc)
{
DPF((DBG_VERBOSE, "GLESCreateParameterBuffer size 0x%x", gc->sAppHints.ui32ParameterBufferSize));
if(PVRSRVCreateParameterBuffer (gc->sHWContext.ps3DDevData,
gc->sAppHints.ui32ParameterBufferSize) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't create parameter buffer (size: %d)", gc->sAppHints.ui32ParameterBufferSize));
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESCreateRenderSurface
Inputs : -
Outputs : phRenderSurface
Returns : success
Description : Creates a render surface structure
************************************************************************************/
IMG_BOOL GLESCreateRenderSurface(GLESSysContext *psSysContext, GLESAppHints *psAppHints, GLESRenderSurfaceHandle *phRenderSurface)
{
GLESRenderSurface *psRenderSurface = GLESCalloc(0, sizeof(GLESRenderSurface));
if(!psRenderSurface)
return IMG_FALSE;
DPF((DBG_VERBOSE, "GLESCreateParameterBuffer size 0x%x", psAppHints->ui32ParameterBufferSize));
if(PVRSRVCreateParameterBuffer (&psSysContext->s3D, psAppHints->ui32ParameterBufferSize) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't create parameter buffer (size: %d)", psAppHints->ui32ParameterBufferSize));
return IMG_FALSE;
}
*phRenderSurface = (GLESRenderSurfaceHandle)psRenderSurface;
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESDestroyRenderSurface
Inputs : gc
Outputs : -
Returns : success
Description : Creates a render target
************************************************************************************/
IMG_BOOL GLESDestroyRenderSurface(GLESSysContext *psSysContext, GLESRenderSurfaceHandle hRenderSurface)
{
GLESRenderSurface *psRenderSurface = (GLESRenderSurface *)hRenderSurface;
IMG_BOOL bSuccess = IMG_TRUE;
if(psRenderSurface->psTARenderInfo)
{
if(!GLESDestroyRenderTarget(psSysContext, psRenderSurface))
{
DPF((DBG_ERROR,"Couldn't destroy render target"));
bSuccess = IMG_FALSE;
}
}
if(PVRSRVDestroyParameterBuffer (&psSysContext->s3D) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't destroy parameter buffer"));
bSuccess = IMG_FALSE;
}
if(psRenderSurface->psZBufferMemInfo)
{
if(!GLESDestroyDepthBuffer(psSysContext, psRenderSurface))
{
DPF((DBG_ERROR,"Couldn't destroy depth buffer"));
bSuccess = IMG_FALSE;
}
}
GLESFree(0, psRenderSurface);
return bSuccess;
}
/***********************************************************************************
Function Name : GLESCreateRenderTarget
Inputs : gc
Outputs : -
Returns : success
Description : Creates a render target
************************************************************************************/
IMG_BOOL GLESCreateRenderTarget(GLESContext *gc)
{
PVRSRV_HWREG *psTARegs = gc->sHWContext.sRegisters.psTARegs;
GLESRenderSurface *psRenderSurface = gc->psRenderSurface;
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;
}
if(PVRSRVAddRenderTarget(gc->sHWContext.ps3DDevData, gc->sDrawableParams.ui32Width,
gc->sDrawableParams.ui32Height, ui32AAFlags,
&psRenderSurface->psTARenderInfo) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't add render target"));
return IMG_FALSE;
}
GLES_SET_TAREG(psTARegs, TAILPTRBASE, psRenderSurface->psTARenderInfo->psSharedData->TailPtrDevVAddr.uiAddr);
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESDiscardScene
Inputs : psSysContext, psRenderSurface
Outputs : -
Returns : success
Description : Discards an uncompleted scene
************************************************************************************/
IMG_BOOL GLESDiscardScene(GLESSysContext *psSysContext, GLESRenderSurface *psRenderSurface)
{
if(psRenderSurface->bInFrame)
{
if(PVRSRVDiscardTAScene(psSysContext->s3D.psDevInfoUM,
psRenderSurface->psTARenderInfo,
&psSysContext->sHWInfo,
IMG_FALSE) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't discard TAed scene"));
return IMG_FALSE;
}
psRenderSurface->bInFrame = IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESDestroyRenderTarget
Inputs : psSysContext, psRenderSurface
Outputs : -
Returns : success
Description : Destroys a render target
************************************************************************************/
IMG_BOOL GLESDestroyRenderTarget(GLESSysContext *psSysContext, GLESRenderSurface *psRenderSurface)
{
if(!GLESDiscardScene(psSysContext, psRenderSurface))
{
DPF((DBG_ERROR,"Couldn't discard scene"));
return IMG_FALSE;
}
if(PVRSRVRemoveRenderTarget(&psSysContext->s3D, psRenderSurface->psTARenderInfo) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't remove render target"));
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESAllocateDeviceMemory
Inputs : gc, ui32Size, ui32Alignment
Outputs : ppsMemInfo
Returns : success
Description : Allocates device memory
************************************************************************************/
IMG_BOOL GLESAllocateDeviceMemory(GLESContext *gc,
IMG_UINT32 ui32Size,
IMG_UINT32 ui32Alignment,
PVRSRV_MEM_INFO **ppsMemInfo)
{
if(PVRSRVAllocDeviceMem (gc->sHWContext.ps3DDevData, 0, ui32Size, ui32Alignment, ppsMemInfo) != PVRSRV_OK)
{
DPF((DBG_WARNING,"Couldn't allocate device memory"));
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESFreeDeviceMemory
Inputs : gc, psMemInfo
Outputs :
Returns : success
Description : Frees device memory
************************************************************************************/
IMG_BOOL GLESFreeDeviceMemory(GLESContext *gc, PVRSRV_MEM_INFO *psMemInfo)
{
if(PVRSRVFreeDeviceMem (gc->sHWContext.ps3DDevData, psMemInfo) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't free device memory"));
return IMG_FALSE;
}
return IMG_TRUE;
}
/***********************************************************************************
Function Name : GLESAcquireTA
Inputs : gc, psRenderSurface
Outputs :
Returns : success
Description : Acquires the TA and its slaveport. Loads new state if context
has switched.
************************************************************************************/
IMG_BOOL GLESAcquireTA(GLESContext *gc, GLESRenderSurface *psRenderSurface)
{
IMG_BOOL bHasContextSwitched;
IMG_BOOL bTimeout;
IMG_BOOL bStart;
IMG_UINT32 uiStart;
GLES_TIME_START(GLES_TIMES_WAIT_FOR_ACQUIRE);
if(!psRenderSurface->bInFrame)
{
/*
if there is a read dependency between the last presentation blit and
the current render target we are required to flush the blit before starting
the scene. If we don't the blit could get stuck in the FIFO if we hot complex
scene in which case the we get fatal embrace because the partial render can't
proceed because it's waiting for the blit.
n.b. if we have double buffered back buffers we wait for the blit on the surface
that we aren't attempting to render to.
*/
bTimeout = IMG_TRUE;
bStart = IMG_FALSE;
uiStart = 0;
do
{
if(gc->sHWContext.psPrevSync->ui32BlitOpsComplete ==
gc->sHWContext.psPrevSync->ui32BlitOpsPending)
{
bTimeout = IMG_FALSE;
break;
}
if (bStart == IMG_FALSE)
{
bStart = IMG_TRUE;
uiStart = HostClockus();
}
HostWaitus(MAX_HW_TIME_US/WAIT_TRY_COUNT);
SysKickCmdProc (gc->sDrawableParams.psQueueInfo->pui32KickerAddr);
} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
if (bTimeout == IMG_TRUE)
{
DPF((DBG_ERROR,"present blits still pending on target surface"));
return IMG_FALSE;
}
}
if(PVRSRVAcquireTA( gc->sHWContext.ps3DDevData->psDevInfoUM,
psRenderSurface->psTARenderInfo,
gc->sHWContext.psHWInfo,
psRenderSurface->bInFrame ? IMG_FALSE : IMG_TRUE, /* FirstTAInFrame */
IMG_TRUE, /* Block */
&bHasContextSwitched) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't acquire the TA"));
return IMG_FALSE;
}
if(PVRSRVAcquireSlavePort(gc->sHWContext.ps3DDevData->psDevInfoUM, PVRSRV_SLAVEPORT_3D, IMG_TRUE) != PVRSRV_OK)
{
DPF((DBG_ERROR,"Couldn't acquire the slaveport"));
return IMG_FALSE;
}
GLES_TIME_STOP(GLES_TIMES_WAIT_FOR_ACQUIRE);
if(bHasContextSwitched)
{
/* If we were already in frame, need to redump the TA registers */
if(psRenderSurface->bInFrame)
{
WriteHWRegs(gc->sHWContext.psHWInfo->pvRegsBase, GLES_COUNT_SWTAREG, gc->sHWContext.sRegisters.psTARegs);
#ifdef FIX_HW_PRN_296
/* this HW bug results in stream error interrupts persisting after they are handled */
if(gc->sHWContext.ps3DDevData->psDevInfoUM->sDeviceSpecific.s3D.bLastContextStreamError)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -