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

📄 vgp.h

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
#define RSQRT		(MBX1_VGPINST_OPCODE_RSQRT)
#define DP3			(MBX1_VGPINST_OPCODE_DP3)
#define	DP4			(MBX1_VGPINST_OPCODE_DP4)
#define	MIN			(MBX1_VGPINST_OPCODE_MIN)
#define	MAX			(MBX1_VGPINST_OPCODE_MAX)
#define	SLT			(MBX1_VGPINST_OPCODE_SLT)
#define	SGE			(MBX1_VGPINST_OPCODE_SGE)
#define	EXPP		(MBX1_VGPINST_OPCODE_EXPP)
#define	LOGP		(MBX1_VGPINST_OPCODE_LOGP)
#define	LIT			(MBX1_VGPINST_OPCODE_LIT)
#define	DST			(MBX1_VGPINST_OPCODE_DST)
#define	FRC			(MBX1_VGPINST_OPCODE_FRC)
#define	AMV			(MBX1_VGPINST_OPCODE_AMV)
#define	EXP			(MBX1_VGPINST_OPCODE_EXP)
#define	LOG			(MBX1_VGPINST_OPCODE_LOG)

/*
	Macros for constructing VGP instructions and sub-parts thereof
*/				
#define DEST_A0X					(DEST(0, MASKX))

#define DEST(X, Y)					(((X) << 4) | ((Y) << 0))

#define SRC_VN(X)					((0 << 15) | \
									 (0 << 13) | \
									 ((X) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (0 << 0))


#define SRC_SWZVN(X, SWZ)			((0 << 15) | \
									 (0 << 13) | \
									 ((X) << 9) | \
									 ((SWZ) << 1) | \
									 (0 << 0))

#define SRC_NEGVN(X)				((0 << 15) | \
									 (0 << 13) | \
									 ((X) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (1 << 0))

#define SRC_CN(X)					(((((X) & 0x70) >> 4) << 15) | \
									 (1 << 13) | \
									 (((X) & 0xF) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (0 << 0))

#define SRC_NEGCN(X)				(((((X) & 0x70) >> 4) << 15) | \
									 (1 << 13) | \
									 (((X) & 0xF) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (1 << 0)) 

#define SRC_SWZCN(X, SWZ)			(((((X) & 0x70) >> 4) << 15) | \
									 (1 << 13) | \
									 (((X) & 0xF) << 9) | \
									 ((SWZ) << 1) | \
									 (0 << 0)) 

#define SRC_NEGSWZCN(X, SWZ)		(((((X) & 0x70) >> 4) << 15) | \
									 (1 << 13) | \
									 (((X) & 0xF) << 9) | \
									 ((SWZ) << 1) | \
									 (1 << 0)) 

#define SRC_RN(X)					((0 << 15) | \
									 (2 << 13) | \
									 ((X) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (0 << 0))

#define SRC_SWZRN(X, SWZ)			((0 << 15) | \
									 (2 << 13) | \
									 ((X) << 9) | \
									 ((SWZ) << 1) | \
									 (0 << 0))

#define SRC_NEGSWZRN(X, SWZ)		((0 << 15) | \
									 (2 << 13) | \
									 ((X) << 9) | \
									 ((SWZ) << 1) | \
									 (1 << 0))

#define SRC_NEGRN(X)				((0 << 15) | \
									 (2 << 13) | \
									 ((X) << 9) | \
									 (MBX1_VGPINST_SRCSWIZ_XYZW << 1) | \
									 (1 << 0))

#define VGPINST(OP, DST, SRC0, SRC1, SRC2, CAD) \
{\
	OP, \
	(SRC0 & 0x1) >> 0, \
	(SRC1 & 0x1) >> 0, \
	(SRC2 & 0x1) >> 0, \
	(SRC0 & 0x1FE) >> 1, \
	(SRC1 & 0x1FE) >> 1, \
	(SRC2 & 0x1FE) >> 1, \
	(SRC0 & 0x1E00) >> 9, \
	(SRC1 & 0x1E00) >> 9, \
	(SRC2 & 0x1E00) >> 9, \
	((SRC0 & 0x38000) >> 15) | \
	((SRC1 & 0x38000) >> 15) | \
	((SRC2 & 0x38000) >> 15), \
	CAD, \
	(SRC0 & 0x6000) >> 13, \
	(SRC1 & 0x6000) >> 13, \
	(SRC2 & 0x6000) >> 13, \
	(DST & 0xF) >> 0, \
	(DST & 0x1F0) >> 4, \
	0 \
}

#define VGPINSTG(ID, OP, DST, SRC0, SRC1, SRC2, CAD) \
	ID.opcode = OP; \
	ID.sign1 = (BYTE)((SRC0 & 0x1) >> 0); \
	ID.sign2 = (BYTE)((SRC1 & 0x1) >> 0); \
	ID.sign3 = (BYTE)((SRC2 & 0x1) >> 0); \
	ID.swiz1 = (BYTE)((SRC0 & 0x1FE) >> 1); \
    ID.swiz2 = (BYTE)((SRC1 & 0x1FE) >> 1); \
	ID.swiz3 = (BYTE)((SRC2 & 0x1FE) >> 1); \
	ID.sadd1 = (BYTE)((SRC0 & 0x1E00) >> 9); \
    ID.sadd2 = (BYTE)((SRC1 & 0x1E00) >> 9); \
    ID.sadd3 = (BYTE)((SRC2 & 0x1E00) >> 9); \
	ID.cext = (BYTE)(((SRC0 & 0x38000) >> 15) | ((SRC1 & 0x38000) >> 15) | ((SRC2 & 0x38000) >> 15)); \
	ID.caddrel = (BYTE)(CAD); \
	ID.ssel1 = (BYTE)((SRC0 & 0x6000) >> 13); \
	ID.ssel2 = (BYTE)((SRC1 & 0x6000) >> 13);\
	ID.ssel3 = (BYTE)((SRC2 & 0x6000) >> 13); \
	ID.dmask = (BYTE)((DST & 0xF) >> 0); \
	ID.daddr = (BYTE)((DST & 0x1F0) >> 4); \
	ID.reserved = 0;

/*
 * Global allocation of temporay registers for lighting calculations
 *   r0 = Position in view space
 *   r1 = Normal
 *   r2 = Through diffuse
 *   r3 = Through specular
 *   r4 = Ambient source
 *   r5 = Diffuse source
 *   r6 = Specular source
 *   r7 = Value of the address register.
 *   r8 = Local viewer position.
 */
#define VGPTNL_RVIEWSPACEPOS					(0)
#define VGPTNL_OUT_RVIEWSPACEPOS				(R0)
#define VGPTNL_RNORMAL							(1)
#define VGPTNL_OUT_RNORMAL						(R1)
#define VGPTNL_RTDIFFUSE						(2)
#define VGPTNL_OUT_RTDIFFUSE					(R2)
#define VGPTNL_RTSPECULAR						(3)
#define VGPTNL_OUT_RTSPECULAR					(R3)
#define VGPTNL_RAMBIENTSRC						(4)
#define VGPTNL_OUT_RAMBIENTSRC					(R4)
#define VGPTNL_RDIFFUSESRC						(5)
#define VGPTNL_OUT_RDIFFUSESRC					(R5)
#define VGPTNL_RSPECULARSRC						(6)
#define VGPTNL_OUT_RSPECULARSRC					(R6)
#define VGPTNL_RADDRESS							(7)
#define VGPTNL_OUT_RADDRESS						(R7)
#define VGPTNL_RLOCALVIEWERPOS					(8)
#define VGPTNL_OUT_RLOCALVIEWERPOS				(R8)

/*
 * Definitions of the various constants.
 */
/* ModelToProj matrix row 0 */
#define CONST_MODELTOPROJ_ROW0						(0)
/* ModelToProj matrix row 1 */
#define CONST_MODELTOPROJ_ROW1						(1)
/* ModelToProj matrix row 2 */
#define CONST_MODELTOPROJ_ROW2						(2)
/* ModelToProj matrix row 3 */
#define CONST_MODELTOPROJ_ROW3						(3)

/* ModelToView matrix row 0. */
#define CONST_MODELTOVIEW_ROW0						(4)
/* ModelToView matrix row 1. */
#define CONST_MODELTOVIEW_ROW1						(5)
/* ModelToView matrix row 2. */
#define CONST_MODELTOVIEW_ROW2						(6)
/* ModelToView matrix row 3. */
#define CONST_MODELTOVIEW_ROW3						(7)

/* ModelToView matrix inverse row 0. */
#define CONST_MODELTOVIEWINV_ROW0					(8)
/* ModelToView matrix inverse row 1. */
#define CONST_MODELTOVIEWINV_ROW1					(9)
/* ModelToView matrix inverse row 2. */
#define CONST_MODELTOVIEWINV_ROW2					(10)
/* ModelToView matrix inverse row 3. */
#define CONST_MODELTOVIEWINV_ROW3					(11)

/* Constant zero. */
#define CONST_ZERO									(12)
/* Material ambient colour */
#define CONST_MATERIAL_AMBIENT_COLOUR				(13)
/* Specular threshold. */
#define CONST_SPECULAR_THRESHOLD					(14)
/* Material power. */
#define CONST_MATERIAL_POWER						(15)
/* Number of constants used for a light. */
#define CONST_LIGHT_SIZE							(16)

/* Front clip-plane equation */
#define CONST_CLIPPLANEFRONT						(17)
/* Rear clip-plane equation */
#define CONST_CLIPPLANEREAR							(18)

/* Z Bias params */
#define CONST_ZBIAS_PARAMS							(19)

/* Viewport tansform scale values */
#define CONST_VPORT_SCALE							(20)
/* Viewport tansform offset values */
#define CONST_VPORT_OFFSET							(21)

/* ModelToWorld matrix row 0. */
#define CONST_MODELTOWORLD_ROW0						(25)
/* ModelToWorld matrix row 1. */
#define CONST_MODELTOWORLD_ROW1						(26)
/* ModelToWorld matrix row 2. */
#define CONST_MODELTOWORLD_ROW2						(27)
/* ModelToWorld matrix row 3. */
#define CONST_MODELTOWORLD_ROW3						(28)

/* Material diffuse colour. */
#define CONST_MATERIAL_DIFFUSE_COLOUR				(29)
/* Material specular colour. */
#define CONST_MATERIAL_SPECULAR_COLOUR				(30)
/* Local viewer default position. */
#define CONST_LOCAL_VIEWER_DEFAULT					(31)
/* Global ambient colour. */
#define CONST_GLOBAL_AMBIENT_COLOUR					(32)

/* Fog parameters contant */
#define CONST_FOG_PARAMS							(33)

/* One. */
#define CONST_ONE									(34)

/* Base of lighting constant registers. */
#define CONST_LIGHTING_ADDRESS_BASE					(35)

/* Point size constants (A, B, C, VIEWPORT_HEIGHT) */
#define CONST_POINTSIZE								(36)

/* Point size bounds (MIN, MAX, POINTSIZE, 0) */
#define CONST_POINTSIZEBOUNDS						(37)

/* Half. */
#define CONST_HALF									(38)

/* Base of the texture matrices. */
#define CONST_TEXMAT_BASE							(39)

/* WorldToProj matrix row 0 */
#define CONST_WORLDTOPROJ_ROW0						(42)
/* WorldToProj matrix row 1 */
#define CONST_WORLDTOPROJ_ROW1						(43)
/* WorldToProj matrix row 2 */
#define CONST_WORLDTOPROJ_ROW2						(44)
/* WorldToProj matrix row 3 */
#define CONST_WORLDTOPROJ_ROW3						(45)

/* WorldToView matrix row 0 */
#define CONST_WORLDTOVIEW_ROW0						(46)
/* WorldToView matrix row 1 */
#define CONST_WORLDTOVIEW_ROW1						(47)
/* WorldToView matrix row 2 */
#define CONST_WORLDTOVIEW_ROW2						(48)
/* WorldToView matrix row 3 */
#define CONST_WORLDTOVIEW_ROW3						(49)

/* Default diffuse colour */
#define CONST_DEFAULT_DIFFUSE						(50)
/* Default specular colour */
#define CONST_DEFAULT_SPECULAR						(51)

/* Number of constants used for a light. */
#define VGPTNL_CONSTANTS_PER_LIGHT					(7)
/* Start of the light data in the constant array. */
#define VGPTNL_CONSTANTS_LIGHT_BASE					(52)
/* Start of the texture matrix data in the constant array. */
#define VGPTNL_CONSTANTS_TEXMAT_BASE				(VGPTNL_CONSTANTS_LIGHT_BASE + (VGPTNL_MAXIMUM_LIGHTS * VGPTNL_CONSTANTS_PER_LIGHT))

/* Directional light ambient colour. */
#define CONST_DIRLIGHT_AMBIENT						(0)
/* Directional light direction. */
#define CONST_DIRLIGHT_DIRECTION					(1)
/* Directional light diffuse colour. */
#define CONST_DIRLIGHT_DIFFUSE						(2)
/* Directional light specular colour. */
#define CONST_DIRLIGHT_SPECULAR						(3)

/* Point or spot light position in eye space. */
#define CONST_PSLIGHT_POS							(0)
/* Point or spot light parameters: Range squared, attenuation 0, attenuation 1, attenuation 2 */
#define CONST_PSLIGHT_PARAMS						(1)
/* Point or spot light ambient colour */
#define CONST_PSLIGHT_AMBIENT						(2)
/* Point or spot light diffuse colour */
#define CONST_PSLIGHT_DIFFUSE						(3)
/* Point or spot light specular colour. */
#define CONST_PSLIGHT_SPECULAR						(4)
/* Point or spot light direction in eye. */
#define CONST_PSLIGHT_DIRECTION						(5)
/* Specific to light type to allow generic lighting */
#define CONST_PSLIGHT_TYPESPECIFIC					(6)

/******************************************************************************************************
* Function Prototypes
******************************************************************************************************/
IMG_VOID SetSectionExeRange(DWORD			dwSectionIdx,
							DWORD			dwFirstInst,
							DWORD			dwLastInst,
							LPD3DM_CONTEXT	psContext);

IMG_VOID EnableSections(DWORD			dwSectionsToEnable,
						LPD3DM_CONTEXT	psContext);
IMG_VOID DisableSections(DWORD			dwSectionsToDisable,
						LPD3DM_CONTEXT	psContext);
IMG_VOID SetSectionRepeat(DWORD				dwSectionIdx,
						  DWORD				dwCount,
						  LPD3DM_CONTEXT	psContext);
IMG_VOID RebindSection(PVSSECTION psSection, LPD3DM_CONTEXT psContext);

IMG_BOOL VGPTNLSetup(LPD3DM_CONTEXT psContext);
IMG_VOID VGPTNLCleanup(LPD3DM_CONTEXT psContext);
IMG_VOID VGPTNLPrePrimSetup(LPD3DM_CONTEXT psContext);
IMG_BOOL VSIFDefSetupForFVF(LPD3DM_CONTEXT psContext,
						PVSIFDEF psVSIFDef, 
						DWORD dwFVFCode,
						DWORD dwVertexStride);
IMG_VOID SetupVertexCopyData(LPD3DM_CONTEXT psContext, PVSIFDEF psShader);
IMG_VOID VGPTNLSetUpPassThroughShader(LPD3DM_CONTEXT psContext, DWORD dwTNLFlags);
IMG_VOID VGPTNLUpdateFFTNLShader(LPD3DM_CONTEXT psContext);
IMG_VOID VGPTNLUpdateSWTNLState(LPD3DM_CONTEXT psContext);
IMG_VOID VGPTNLUpdateConstants(LPD3DM_CONTEXT psContext);
VOID VGPTNLGenerateFogSection(LPD3DM_CONTEXT	psContext,  PDWORD pdwSectionSize, PHWVGPINST psSection);
VOID VGPTNLGenerateTextureCoordSection(LPD3DM_CONTEXT	psContext,
									   PDWORD			pdwSectionSize,
									   PHWVGPINST		psSection);
VOID VGPTNLSetConstant(LPD3DM_CONTEXT psContext, DWORD dwNum, NTV_TYPE *pntvVal);
VOID VGPTNLSetConstants(LPD3DM_CONTEXT	psContext,
						DWORD			dwStart,
						DWORD			dwCount,
						NTV_TYPE		*pntvVal);
VOID VGPTNLSetConstant1(LPD3DM_CONTEXT psContext, DWORD dwNum, NTV_TYPE ntvVal);
VOID VGPTNLSetConstant2(LPD3DM_CONTEXT	psContext,
						DWORD			dwNum,
						NTV_TYPE		ntvVal1,
						NTV_TYPE		ntvVal2,
						NTV_TYPE		ntvVal3,
						NTV_TYPE		ntvVal4);
VOID VGPTNLOutputColour(LPD3DM_CONTEXT		psContext,
						DWORD				dwNum,
						PVR_COLORVALUE*		Colour);
IMG_VOID VGPTNLSetUpPassThroughShader(LPD3DM_CONTEXT psContext, DWORD dwTNLFlags);
#endif /* #ifdef SUPPORT_VGP */
#endif /* #if !defined(_VGP_H_) */
/*****************************************************************************
 End of file (vgp.h)
*****************************************************************************/

⌨️ 快捷键说明

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