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

📄 rstate.c

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

		case D3DMCMP_GREATER:
		{
			dwAlphaTestCtl |= MBX1_TSPOBJ_ACMPMODEGT;
			DBGSETSTR(pszAlphaFuncDesc, "Greater");
			break;
		}

		case D3DMCMP_NOTEQUAL:
		{
			dwAlphaTestCtl |= MBX1_TSPOBJ_ACMPMODENE;
			DBGSETSTR(pszAlphaFuncDesc, "Not Equal");
			break;
		}

		case D3DMCMP_GREATEREQUAL:
		{
			dwAlphaTestCtl |= MBX1_TSPOBJ_ACMPMODEGE;
			DBGSETSTR(pszAlphaFuncDesc, "Greater or Equal");
			break;
		}

		case D3DMCMP_ALWAYS:
		{
			dwAlphaTestCtl |= MBX1_TSPOBJ_ACMPMODEALWAYS;
			DBGSETSTR(pszAlphaFuncDesc, "Always");
			break;
		}

		default:
		{
			/* Unhandled alpha-compare mode. Defaulting to ALWAYS */
			D3DM_DPF((DPF_WARN, "D3DM_RS_AlphaFunc: Unhandled alpha-compare mode %d", dwData));
			dwAlphaTestCtl |= MBX1_TSPOBJ_ACMPMODEALWAYS;
			DBGSETSTR(pszAlphaFuncDesc, "Unknown - setting \"Always\"");
			break;
		}
	}

	psContext->sTState.dwAlphaTest = dwAlphaTestCtl;

	/* Update alpha-test related HW-state */
	ProcessAlphaTestState(psContext);

	D3DM_DPF((DPF_STATE,"D3DM_RS_AlphaFunc: Data = %d (%hs)", dwData, pszAlphaFuncDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_AlphaFunc"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_DitherEnable

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_DitherEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	DBGLPSTR	pszDitherEnableDesc;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_DitherEnable"));

	/* Record new dither-enable state */
	if(dwData)
	{
		psContext->sTState.dwRSFlags |= TSTATE_RSFLAGS_DITHER;
		DBGSETSTR(pszDitherEnableDesc, "Enable");
	}
	else
	{
		psContext->sTState.dwRSFlags &= ~TSTATE_RSFLAGS_DITHER;
		DBGSETSTR(pszDitherEnableDesc, "Disable");
	}

	D3DM_DPF((DPF_STATE,"D3DM_RS_DitherEnable: Data = %d (%hs)", dwData, pszDitherEnableDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_DitherEnable"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_SpecularEnable

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_SpecularEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	PHWTACTL3DSTATE	psTACtl3DState;
	DBGLPSTR		pszSpecularEnableDesc;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_SpecularEnable"));


	psTACtl3DState = &psContext->sHWState.sTACtl3DState;
	if(dwData)
	{
		/*
			Specular-colour add enabled. Make sure the TA doesn't zero the
			offset colour
		*/
		psContext->dwTAPrimCtl &= ~MBX1_TAPRIM_ZEROOFFSETCOL;

		/* Indicate that vertices have an offset colour present	*/
		psTACtl3DState->dwISPTSPCtl |= MBX1_ISPTSPCTL_OFFSET;

		/* Note the new renderstate status */
		psContext->sTState.dwRSFlags |= TSTATE_RSFLAGS_SPECULAR;

		DBGSETSTR(pszSpecularEnableDesc, "Enable");
	}
	else
	{
#if defined(FIX_HW_PRN_145)

		DWORD	dwBlendModeOpCtl;

		/* Only turn off offset colour if vertex fogging also turned off */
		dwBlendModeOpCtl = psTACtl3DState->dwISPTSPCtl & 
						   (~MBX1_ISPTSPCTL_BLENDOPMODECLRMASK);

		if(dwBlendModeOpCtl != MBX1_ISPTSPCTL_BLENDOPMODEVERTEXFOG)
		{
			psTACtl3DState->dwISPTSPCtl &= ~MBX1_ISPTSPCTL_OFFSET;
		}
#else

		if(!(psTACtl3DState->dwISPTSPCtl & MBX1_ISPTSPCTL_FOGENABLE))
		{
			psTACtl3DState->dwISPTSPCtl &= ~MBX1_ISPTSPCTL_OFFSET;
		}

#endif

		/*
			Not using the specular component, so tell the TA to
			use zero for the offset colour.
		*/
		psContext->dwTAPrimCtl |= MBX1_TAPRIM_ZEROOFFSETCOL;

		/* Note the new renderstate status */
		psContext->sTState.dwRSFlags &= ~TSTATE_RSFLAGS_SPECULAR;

		DBGSETSTR(pszSpecularEnableDesc, "Disable");
	}

	/* Flag that the HW ISP/TSP control word has been modified */
	psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_ISPCTL;

	D3DM_DPF((DPF_STATE, "D3DM_RS_SpecularEnable: Data = %d (%hs)", dwData, pszSpecularEnableDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_SpecularEnable"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_Clipping

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_Clipping(LPD3DM_CONTEXT psContext, DWORD dwData)
{
	PTRANSIENT_STATE	psTState;
	DBGLPSTR			pszClippingEnableDesc;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_Clipping"));

	/* Record the new renderstate state	*/
	psTState = &psContext->sTState;

	if(dwData)
	{
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
		if(!(psContext->sTState.dwRSFlags & TSTATE_RSFLAGS_CLIPPING))
		{
			/* We need to update position section */
			psContext->sTState.sSWTNLState.dwSectionModFlags |= (1 << VGPTNL_SECTIONORD_POSITION);
		}
#endif
		psTState->dwRSFlags |= TSTATE_RSFLAGS_CLIPPING;
		DBGSETSTR(pszClippingEnableDesc, "Enable");
	}
	else
	{
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
		if(psContext->sTState.dwRSFlags & TSTATE_RSFLAGS_CLIPPING)
		{
			/* We need to update position section */
			psContext->sTState.sSWTNLState.dwSectionModFlags |= (1 << VGPTNL_SECTIONORD_POSITION);
		}
#endif
		psTState->dwRSFlags &= ~TSTATE_RSFLAGS_CLIPPING;
		DBGSETSTR(pszClippingEnableDesc, "Disable");
	}

	D3DM_DPF((DPF_STATE, "D3DM_RS_Clipping: Data = %d (%hs)", dwData, pszClippingEnableDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_Clipping"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogEnable

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	DBGLPSTR	pszFogEnableDesc;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogEnable"));

	/* Record the new renderstate state	*/
	if(dwData)
	{
		if(!(psContext->sTState.dwRSFlags  & TSTATE_RSFLAGS_FOG))
		{
			psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_CHANGED;
		}

		psContext->sTState.dwRSFlags |= TSTATE_RSFLAGS_FOG;
		DBGSETSTR(pszFogEnableDesc, "Enable");
	}
	else
	{
		psContext->sTState.dwRSFlags &= ~TSTATE_RSFLAGS_FOG;
		DBGSETSTR(pszFogEnableDesc, "Disable");
	}

	/* Update the overall HW fog-state */
	ProcessFogState(psContext);

	D3DM_DPF((DPF_STATE, "D3DM_RS_FogEnable      : Data = %d (%hs)", dwData, pszFogEnableDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogEnable"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogColour

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogColour(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogColour"));

	/*
		Set fog colour for current fog mode.
		Registers & fog clr change objects are sent by SortOutFogColour, which
		is called when primitives sent (in PrePrimSetup)
	*/
	psContext->sTState.dwVertexFogColour = dwData;

	D3DM_DPF((DPF_STATE, "D3DM_RS_FogColour      : Colour = 0x%08X", dwData));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogColour"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogTableMode

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogTableMode(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	DBGLPSTR	pszFogTableMode;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogTableMode"));

	/*
		Record the new table fog mode

		NB:	MBX1 does not support per-pixel fog, so anything other than 
			D3DFOG_NONE will result in no fog at all.
	*/
	psContext->sTState.dwD3DTableFogMode = dwData;

	DBGSETSTR(pszFogTableMode, (!dwData?"None":(dwData==D3DMFOG_EXP?"Exp":(dwData==D3DMFOG_EXP2?"Exp2":"Linear"))));

	/* Update the overall HW fog-state */
	ProcessFogState(psContext);

	D3DM_DPF((DPF_STATE, "D3DM_RS_FogTableMode   : Data = %d (%hs)", dwData, pszFogTableMode));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogTableMode"));
}


/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_RangeFogEnable

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_RangeFogEnable(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	DBGLPSTR	pszRangeFogEnableDesc;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_RangeFogEnable"));

	/* Record the new renderstate state	*/
	if(dwData)
	{
		if(!(psContext->sTState.dwRSFlags  & TSTATE_RSFLAGS_RANGE_FOG))
		{
			psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_CHANGED;
		}

		psContext->sTState.dwRSFlags |= TSTATE_RSFLAGS_RANGE_FOG;
		DBGSETSTR(pszRangeFogEnableDesc, "Enable");
	}
	else
	{
		if(psContext->sTState.dwRSFlags  & TSTATE_RSFLAGS_RANGE_FOG)
		{
			psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_CHANGED;
		}

		psContext->sTState.dwRSFlags &= ~TSTATE_RSFLAGS_RANGE_FOG;
		DBGSETSTR(pszRangeFogEnableDesc, "Disable");
	}

	D3DM_DPF((DPF_STATE, "D3DM_RS_RangeFogEnable      : Data = %d (%hs)", dwData, pszRangeFogEnableDesc));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_RangeFogEnable"));
}


/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogDensity

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogDensity(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogDensity"));

	/* Record density value, even if not using exponential fog	*/
	psContext->sTState.D3DFogDensity = FL2NTV(LONG_TO_FLOAT(dwData));

	psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_PARAMS_CHANGED;

	D3DM_DPF((DPF_STATE,"D3DM_RS_FogDensity: Value = 0x%08X", dwData));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogDensity"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogStart

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogStart(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	NTV_TYPE ntvData;

	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogEnd"));

	ntvData = FL2NTV(LONG_TO_FLOAT(dwData));


	if(psContext->sTState.D3DFogStart != ntvData)
	{
		/* Record fog start value, even if not using linear fog */
		psContext->sTState.D3DFogStart = ntvData;

		/* do one off fog calc's */
		if(psContext->sTState.D3DFogEnd != psContext->sTState.D3DFogStart)
		{
			psContext->sTState.OneOverEndMinusStart = Div(D3DM_One, Sub(psContext->sTState.D3DFogEnd,psContext->sTState.D3DFogStart));
		}
		else
		{
			psContext->sTState.OneOverEndMinusStart = D3DM_Zero;
		}

		psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_PARAMS_CHANGED;
	}

	D3DM_DPF((DPF_STATE," D3DM_RS_FogStart  : Value = 0x%08X", dwData));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogStart"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_FogEnd

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified
				In: dwData - Value of state modification
</function>
------------------------------------------------------------------------------*/
void D3DM_RS_FogEnd(LPD3DM_CONTEXT psContext,DWORD dwData)
{
	NTV_TYPE ntvData;
	D3DM_DPF((DPF_ENTRY, "->D3DM_RS_FogEnd"));

	ntvData = FL2NTV(LONG_TO_FLOAT(dwData));

	if(psContext->sTState.D3DFogEnd != ntvData)
	{
		/* Record fog end value, even if not using linear fog */
		psContext->sTState.D3DFogEnd = ntvData;

		/* do one off fog calc's */
		if(psContext->sTState.D3DFogEnd != psContext->sTState.D3DFogStart)
		{
			psContext->sTState.OneOverEndMinusStart = Div(D3DM_One, Sub(psContext->sTState.D3DFogEnd,psContext->sTState.D3DFogStart));
		}
		else
		{
			psContext->sTState.OneOverEndMinusStart = D3DM_Zero;
		}

		psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_FOG_PARAMS_CHANGED;
	}

	D3DM_DPF((DPF_STATE," D3DM_RS_FogEnd  : Value = 0x%08X", dwData));
	D3DM_DPF((DPF_EXIT, "<-D3DM_RS_FogEnd"));
}

/*----------------------------------------------------------------------------
<function>
	FUNCTION:   D3DM_RS_ZBias

	PURPOSE:    

	PARAMETERS:	In: psContext - Context who's state is to be modified

⌨️ 快捷键说明

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