⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srvcalls.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 3 页
字号:

	/* Finish the scene */
	TACSWriteEndStream(psContext);

	/* Release 3D slaveport */
	PVRSRVReleaseSlavePort(GetDevInfo(psContext), PVRSRV_SLAVEPORT_3D);

	/* Discard our completed TA'd scene */
	PVRSRVDiscardCompletedTAScene(GetDevInfo(psContext),
								  gpTempRenderInfo,
								  &psContext->sHWInfo);

	PVRSRVReleaseTA(GetDevInfo(psContext), IMG_TRUE);

	/* Disconnect render target	*/
	eError = PVRSRVRemoveRenderTarget(&psContext->sDevData, gpTempRenderInfo);
	if(eError != PVRSRV_OK)
	{
		D3DM_DPF((DPF_WARN, "D3DMReleaseProcessVerticesResources:Failed to remove render temporary render target"));
	}

	/* Zero our reserved FIFO space count */
	psContext->dwAllocatedFifoSpaceDWORDS = 0;

	/* Reset the data sent flag	*/
	psContext->psCurrentRenderTarget->sDescription.sSurface.bSceneTADataSent = FALSE;

	/* Force State block header to be sent again to disable proc vert mode with next geometry */
	psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_VGP_IFDEFINITION;

	return eError;
}
#else /* FIX_HW_PRN_335 */
/*----------------------------------------------------------------------------
<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)
{
	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 */

	/* Acquire the TA resource */
	eError = HostLockResource(&ps3D->hTAResource, IMG_TRUE);
	if (eError != PVRSRV_OK)
	{
		goto ErrorExit;
	}


	i=0;

	/* Set up process vertices state */
	ui32ProcVertState[i++] = (MBX1_TAOBJTYPE_STATE					|
							  MBX1_TASTATEPRES_VGP_PROCVERTADDRESS	|
							  MBX1_TASTATEPRES_VGP_PROCVERTSELECTS	|
							  MBX1_TASTATEPRES_VGP_PROCVERTENABLE);

	ui32ProcVertState[i++] = uiDevAddr;

	if(dwDestFVFFlags)
	{
		ui32ProcVertState[i++] = SetVGPOutputEnables(psContext, dwDestFVFFlags, IMG_NULL);
	}
	else
	{
		ui32ProcVertState[i++] = MBX1_VGPPROCVERT_SELECTS_REG5;
	}

	/* Start TA */
	WriteHWReg(GetRegisterBase(psContext), MBX1_TAGLOBREG_START, 1);

	/* Make sure any state changes are passes on to the HW */
	UpdateTACtlAnd3DState(psContext);

	/* Enable Process vertices mode */
	TACSWriteData(psContext, (PVOID) ui32ProcVertState, i << 2);

	/* Ensure VGP is up to date */
	VGPTNLPrePrimSetup(psContext);
	UpdateVGPControlState(psContext);
	UpdateVGPConstants(psContext);
	UpdateVGPInstructions(psContext);

	/* Enable Process vertices mode */
	TACSWriteData(psContext, (PVOID) ui32ProcVertState, i << 2);

	/* Signal process vertices mode to isr */
	ps3D->bProcVertMode = IMG_TRUE;

	return eError;

ErrorExit:

	/* Release 3D slaveport */
	PVRSRVReleaseSlavePort(GetDevInfo(psContext), PVRSRV_SLAVEPORT_3D);

	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;

	ps3D = 	 &(GetDevInfo(psContext)->sDeviceSpecific.s3D);

	/* Finish the scene */
	TACSWriteEndStream(psContext);

	/* Release 3D slaveport */
	PVRSRVReleaseSlavePort(GetDevInfo(psContext), PVRSRV_SLAVEPORT_3D);

	/* Unlock TA resource */
	if(HostUnlockResource(&ps3D->hTAResource) != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR,"HostUnlockResource: failed to unlock resource"));
	}

	/* Zero our reserved FIFO space count */
	psContext->dwAllocatedFifoSpaceDWORDS = 0;

	/* Reset the data sent flag	*/
	psContext->psCurrentRenderTarget->sDescription.sSurface.bSceneTADataSent = FALSE;

	/* Force State block header to be sent again to disable proc vert mode with next geometry */
	psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_VGP_IFDEFINITION;

	if(PollForValue ((volatile IMG_UINT32 *)&ps3D->bProcVertMode,
							IMG_FALSE,
							0xFFFFFFFF,
							MAX_HW_TIME_US/WAIT_TRY_COUNT, 
							WAIT_TRY_COUNT) != PVRSRV_OK)
	{
		PVR_DPF((PVR_DBG_ERROR, "D3DMReleaseProcessVerticesResources: Failed to get ProcVert TA complete"));
	}

	return PVRSRV_OK;
}
#endif /* FIX_HW_PRN_335 */
#endif /*(defined(SUPPORT_VGP) && (COREVERSION >= 13)) || (defined(SUPPORT_VGP_LITE) && (COREVERSION >= 120))*/
/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DMAcquireTAResources

	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 D3DMAcquireTAResources(LPD3DM_CONTEXT psContext, BOOL bPrePrim)
{
	PVRSRV_DEV_INFO		*psDevInfo;
	PVRSRV_HW_INFO		*psHWInfo;
	LPD3DM_SURFACE		psRTSurfData;
	IMG_BOOL			bContextHasSwitched;
	BOOL				bFirstTAInScene;
	PVRSRV_ERROR		eError;
	IMG_BOOL			bTimeout = IMG_TRUE;
	IMG_BOOL			bStart = IMG_FALSE;
	IMG_UINT32			uiStart = 0;
	PPVRSRV_MEM_INFO	psMemInfo;

	psDevInfo		= GetDevInfo(psContext);
	psHWInfo		= &psContext->sHWInfo;
	psRTSurfData	= psContext->psCurrentRenderTarget;
	bFirstTAInScene = (!psRTSurfData->sDescription.sSurface.bSceneTADataSent);
	psMemInfo		= psRTSurfData->psMemInfo;

	PROFILE_START_FUNC(D3DM_ACQUIRE_TA_RESOURCES);

	/* 
		We have to wait here for any Blits to occur on this surface before TA'ing 
		otherwise we get a deadlock in complexscene where the blit gets stuck in the FIFO.
	*/
	do
	{
		if(psMemInfo->psSyncInfo->ui32BlitOpsComplete 
		==	psMemInfo->psSyncInfo->ui32BlitOpsPending)
		{
			bTimeout = IMG_FALSE;
			break;
		}

		if(bStart == IMG_FALSE)
		{
			bStart = IMG_TRUE;
			uiStart = HostClockus();
		}

		HostWaitus(MAX_HW_TIME_US/(WAIT_TRY_COUNT));
		if(psDevInfo->sDeviceSpecific.s3D.b2DIdle)
		{
			SysKickCmdProc(GetKickerAddress(psContext));
		}

	} while ((HostClockus() - uiStart) < MAX_HW_TIME_US);
	
	if(bTimeout == IMG_TRUE)
	{
		D3DM_DPF((DPF_ERROR,"D3DMAcquireTAResources: present blits still pending on target surface"));
		return PVRSRV_ERROR_GENERIC;;
	}

	/*
		Acquire TA
	*/
	eError = PVRSRVAcquireTA(psDevInfo, 
							 psRTSurfData->sDescription.sSurface.psTARenderInfo, 
							 psHWInfo,
							 bFirstTAInScene,
							 TRUE,
							 &bContextHasSwitched);

	if(eError != PVRSRV_OK)
	{	
		PVR_DPF((PVR_DBG_ERROR,"PVRHALAcquireTAResources: Failed To Acquire TA"));
		return eError;
	}

	/*
		Acquire 3D Slaveport
	*/
	eError = PVRSRVAcquireSlavePort(psDevInfo, PVRSRV_SLAVEPORT_3D, TRUE);

	if(eError != PVRSRV_OK)
	{		
		return eError;
	}

	if(psContext->dwFlags & D3DM_CONTEXT_SWFLAGS_NEW_CONTEXT)
	{
		/* Set up initial state */
		UpdateTACtlAnd3DState(psContext);

		psContext->dwFlags &= ~D3DM_CONTEXT_SWFLAGS_NEW_CONTEXT;
	}

	/*
		If the scene hasn't been started do a begin scene
	*/
	if(bFirstTAInScene)
	{
		DoBeginScene(psContext);

		if(bContextHasSwitched)
		{
			ResubmitHWState(psContext);
		}
	}
	else if(bContextHasSwitched)
	{
		/* HW Context has changed, so restart the ta */
		ResubmitHWState(psContext);
		TAStart(psContext);
	}

	/* We only need to do the following if we are about to send prims */
	if(bPrePrim)
	{
		/* Finish up texture stage state processing */
		PostProcessTSState(psContext);

		/* Update Matrices if required */
		UpdateMatrices(psContext);

		/* Check if we need to update any lights */
		UpdateLights(psContext);

		#if defined(SUPPORT_VGP) || defined(SUPPORT_VGP_LITE)
		/*
			Update the current vertex-shader configuration

			NB:	This is required for all shader types (PassThrough, FF-TNL and 
				Programmable), since they all depend upon the current vertex-
				format and/or state:

				o	PassThrough shader: Colour and texture-coord sections 
					configured to match the input vertex-format

				o	FF-TNL: Configured to match TNL state and vertex-format

				o	Programmable: Configured to match clip-plane state
		*/
		VGPTNLPrePrimSetup(psContext);

		/* Set up correct copy function */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -