📄 srvcalls.c
字号:
/******************************************************************************
<module>
* Name : SRVCalls.c
* Title : Services Wrappers
* Author(s) : Imagination Technologies
* Created : 2 March 2004
*
* Copyright : 2004 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.
*
* Description : Wrappers functions for calls to services
*
* Platform : Windows CE
*
</module>
********************************************************************************/
#include "context.h"
#if (defined(SUPPORT_VGP) && (COREVERSION >= 13)) || (defined(SUPPORT_VGP_LITE) && (COREVERSION >= 120))
#ifdef FIX_HW_PRN_335
PVRSRV_TARENDERINFO *gpTempRenderInfo = IMG_NULL;
/* Dummy vertices to allow Process vertices address to be accepted */
NTV_TYPE psVerts[] =
{
FL2NTV(20.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(20.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(20.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(30.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(50.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(40.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(50.0f), FL2NTV(0.0f), FL2NTV(0.0f), FL2NTV(1.0f),
FL2NTV(50.0f), FL2NTV(10.0f), FL2NTV(0.0f), FL2NTV(1.0f),
};
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DMAcquireProcessVerticesResources
PURPOSE : Acquires the TA and FIFO resources for process vertices case
PARAMETERS: In: psContext - active context
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMAcquireProcessVerticesResources(LPD3DM_CONTEXT psContext, IMG_UINT32 uiDevAddr, IMG_UINT32 dwDestFVFFlags)
{
DWORD dwVGPClipCtl, dwTAPrimCtl, dwStateChanged, j, k;
DWORD dwDataBuffer[64];
VSIFDEF sVSIFDef;
IMG_BOOL bContextHasSwitched;
HWTACTL3DSTATE sTACtl3DState;
PVRSRV_ERROR eError;
DEVICE3D *ps3D;
IMG_UINT32 ui32TAConfig;
IMG_UINT32 ui32ProcVertState[3];
IMG_UINT32 i;
ps3D = &(GetDevInfo(psContext)->sDeviceSpecific.s3D);
/* Acquire 3D Slaveport */
eError = PVRSRVAcquireSlavePort(GetDevInfo(psContext), PVRSRV_SLAVEPORT_3D, TRUE);
if(eError != PVRSRV_OK)
{
return eError;
}
#ifdef SUPPORT_MBX1
HostLockResource(&ps3D->hTAConfigResource, IMG_TRUE);
#endif /* SUPPORT_MBX1 */
ui32TAConfig = ReadHWReg(GetRegisterBase(psContext), MBX1_TAGLOBREG_CONFIG);
ui32TAConfig |= MBX1_TACONFIG_COMPLETEONTERM;
WriteHWReg(GetRegisterBase(psContext), MBX1_TAGLOBREG_CONFIG, ui32TAConfig);
#ifdef SUPPORT_MBX1
HostUnlockResource(&ps3D->hTAConfigResource);
#endif /* SUPPORT_MBX1 */
/*
Horrible Hacky HW_FIX - eugh
We need to ensure that the proc vert address word is immediately following
the State block header word. To do this we send 3 strips of 6 vertices to
a passthrough shader, and then the state header and address. All this is done
BEFORE the TA is started. We must first create a new temp render target to force
a context store on any current scene.
NB: During this process we have to acquire the TA as normal and then discard
the completed scene on completion. In normal circumstances we should just be
able to acquire the 3D slaveport and the TA resource and set the ISR to handle
the TA complete as a ProcVert interrupt.
*/
/* Connect render target */
if (PVRSRVAddRenderTarget (&psContext->sDevData,
100,
100,
0,
&gpTempRenderInfo) != PVRSRV_OK)
{
D3DM_DPF((DPF_ERROR, "D3DMAcquireProcessVerticesResources:Failed to add temporary render target!"));
return PVRSRV_ERROR_GENERIC;
}
#ifdef PDUMP
/* Store PDUMP context pointer in render info */
gpTempRenderInfo->psPDContext = psContext->psPDContext;
#endif
/* Acquire TA */
PVRSRVAcquireTA(GetDevInfo(psContext),
gpTempRenderInfo,
&psContext->sHWInfo,
IMG_TRUE,
IMG_TRUE,
&bContextHasSwitched);
if(eError != PVRSRV_OK)
{
PVR_DPF((PVR_DBG_ERROR,"D3DMAcquireProcessVerticesResources: Failed To Acquire TA"));
return eError;
}
/*
Make sure any initial state changes are passed on to the HW.
We must do this here otherwise a large block of state is sent
between the ProcVert address and TA start which seems to prevent
the uptake of the programmed address.
*/
UpdateTACtlAnd3DState(psContext);
#ifdef 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 |
MBX1_ISPTSPCTL_VTXORDERSTRIP |
MBX1_ISPTSPCTL_DWDISABLE;
#endif
sTACtl3DState.dwTSPObjCtl = MBX1_TSPOBJ_ACMPMODEALWAYS;
sTACtl3DState.dwFPFormat = psContext->dwNativeFPFormat;
dwStateChanged = MBX1_TASTATEPRES_FP_INPUTFORMAT |
MBX1_TASTATEPRES_VGP_IFDEFINITION |
MBX1_TASTATEPRES_ISPCTL |
MBX1_TASTATEPRES_TSPCTL;
/* Set up input format definition */
VSIFDefSetupForFVF(psContext, &sVSIFDef, D3DMFVF_XYZRHW_FLOAT | D3DMFVF_DIFFUSE, (5 << 2));
/* set up the pass-through vertex-shader for this clear data type */
VGPTNLSetUpPassThroughShader(psContext, PVRD3DTNL_FLAGS_DIFFUSE_PRESENT);
/* update Interface Def HW State */
sTACtl3DState.dwVGPIFDef = sVSIFDef.dwVGPIFDef;
/* Write out State */
TACSWriteTACtlAnd3DState(psContext, dwStateChanged, &sTACtl3DState, FALSE);
/* Disable stuff in the VGP-clip control word */
dwVGPClipCtl = psContext->dwVGPClipCtl;
dwVGPClipCtl &= ~(MBX1_VGPCLIPCTL_CLIPPLANES_MASK |
MBX1_VGPCLIPCTL_VIEWPORTTRANS_ENABLE |
MBX1_VGPCLIPCTL_WCLAMP_ENABLE);
dwTAPrimCtl = MBX1_TAPRIM_NONPERSPCORRECT |
MBX1_TAPRIM_ZBIAS_MODEINCREASING |
(0 << MBX1_TAPRIM_ZBIAS_SHIFT) |
MBX1_TAPRIM_CULLMODENONE;
/* Record what state we have changed */
psContext->sHWStateCtl.dwTACtl3DStateChanged |= dwStateChanged;
UpdateVGPControlState(psContext);
UpdateVGPConstants(psContext);
UpdateVGPInstructions(psContext);
i=0;
k=0;
TACSWritePrimHdr(psContext, dwTAPrimCtl, MBX1_TAOBJTYPE_VERTEXFACESTRIP); /* Prim Hdr */
TACSWriteVGPClipWord(psContext, dwVGPClipCtl); /* VGP Clip ctl */
for(j = 0; j < 3; j++)
{
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* X */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Y */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* Z */
dwDataBuffer[i++] = TO_ULONG(psVerts[k++]); /* W */
dwDataBuffer[i++] = 0x0; /* Colour */
TACSWriteData(psContext, (IMG_VOID*) dwDataBuffer, i << 2);
if(j == 2)
{
i=0;
TACSWriteLastPrim(psContext); /* Block Term */
dwDataBuffer[i++] = (MBX1_TAOBJTYPE_STATE |
MBX1_TASTATEPRES_VGP_PROCVERTADDRESS); /* Header */
dwDataBuffer[i++] = uiDevAddr; /* Address */
TACSWriteData(psContext, (IMG_VOID*) dwDataBuffer, i << 2);
}
else
{
TACSWriteEndPrim(psContext);
}
i=0;
}
i=0;
/* Set up process vertices state */
ui32ProcVertState[i++] = (MBX1_TAOBJTYPE_STATE |
MBX1_TASTATEPRES_VGP_PROCVERTSELECTS |
MBX1_TASTATEPRES_VGP_PROCVERTENABLE);
if(dwDestFVFFlags)
{
ui32ProcVertState[i++] = SetVGPOutputEnables(psContext, dwDestFVFFlags, IMG_NULL);
}
else
{
ui32ProcVertState[i++] = MBX1_VGPPROCVERT_SELECTS_REG5;
}
/* Make sure any state changes are passed on to the HW */
UpdateTACtlAnd3DState(psContext);
/* Enable Process vertices mode */
TACSWriteData(psContext, (PVOID) ui32ProcVertState, i << 2);
/* Now start the TA */
TAStart(psContext);
/* Ensure VGP is up to date */
VGPTNLPrePrimSetup(psContext);
UpdateVGPControlState(psContext);
UpdateVGPConstants(psContext);
UpdateVGPInstructions(psContext);
return eError;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DMReleaseProcessVerticesResources
PURPOSE : Acquires the TA and FIFO resources for the passed in render
target. Ensures that AA is set up at the beginning of the scene
and that the scene has been started. Also restarts TA if the
HW Context has changed and performs pre-prim setup.
PARAMETERS: In: psContext - active context
In: bPrePrim - pre-prim setup required
RETURNS : PVRSRV_ERROR
</function>
------------------------------------------------------------------------------*/
PVRSRV_ERROR D3DMReleaseProcessVerticesResources(LPD3DM_CONTEXT psContext)
{
DEVICE3D *ps3D;
PVRSRV_ERROR eError = PVRSRV_OK;
ps3D = &(GetDevInfo(psContext)->sDeviceSpecific.s3D);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -