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

📄 tnl.h

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 H
字号:
/******************************************************************************
<module>
* Name         : tnl.h
* Title        : tnl definitions
* 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  : Definition of tnl structures and 
*
* Platform     : Windows CE
*
</module>
********************************************************************************/
#if !defined(_TNL_H_)
#define _TNL_H_

#define TNL_MAXIMUM_LIGHTS							(8)

/*
	Bit defines for SWTNLSTATE::dwTNLFlags
*/														
#define PVRD3DTNL_FLAGS_CHANGE_CLRMSK					0x0002FFFE

#define	PVRD3DTNL_FLAGS_ENABLED							0x00000001
#define	PVRD3DTNL_FLAGS_WORLD_CHANGED					0x00000002
#define	PVRD3DTNL_FLAGS_VIEW_CHANGED					0x00000004
#define	PVRD3DTNL_FLAGS_PROJECTION_CHANGED				0x00000008
#define	PVRD3DTNL_FLAGS_CONSTANTS_CHANGED				0x00000010
#define	PVRD3DTNL_FLAGS_CLIPPLANE_CHANGED				0x00000020
#define PVRD3DTNL_FLAGS_LIGHTS_CHANGED					0x00000040
#define PVRD3DTNL_FLAGS_MATERIAL_CHANGED				0x00000080
#define PVRD3DTNL_FLAGS_CLIPLANE0_CHANGED				0x00000100
#define PVRD3DTNL_FLAGS_CLIPLANE1_CHANGED				0x00000200
#define PVRD3DTNL_FLAGS_FOG_CHANGED						0x00000400
#define PVRD3DTNL_FLAGS_FOG_PARAMS_CHANGED				0x00000800
#define PVRD3DTNL_FLAGS_ZBIAS_PARAMS_CHANGED			0x00004000
#define PVRD3DTNL_FLAGS_COLOURVTX_CHANGED				0x00008000
#define PVRD3DTNL_FLAGS_PASSTHROUGH_LOADED				0x00010000
#define PVRD3DTNL_FLAGS_DECLARATION_CHANGED				0x00020000
#define PVRD3DTNL_FLAGS_DIFFUSE_PRESENT					0x00040000
#define PVRD3DTNL_FLAGS_SPECULAR_PRESENT				0x00080000

#define PVRD3DTNL_FLAGS_TC_COUNT_MASK					0x00F00000
#define PVRD3DTNL_FLAGS_TC_COUNT_CLRMASK				0xFF0FFFFF
#define PVRD3DTNL_FLAGS_TC_COUNT_SHIFT					20

#define	PVRD3DTNL_FLAGS_CLIPENABLE0						0x01000000
#define	PVRD3DTNL_FLAGS_CLIPENABLE1						0x02000000

#define	PVRD3DTNL_FLAGS_CLIPENABLE_SHIFT				24
#define	PVRD3DTNL_FLAGS_CLIPENABLE_CLRMASK				0xFCFFFFFF
#define	PVRD3DTNL_FLAGS_CLIPENABLE_MASK					0x03000000

/*
	Bit defines for SWTNLSTATE::dw
*/
#define PVRD3DTNL_FLAGS2_CHANGE_CLRMSK					0x00FFF841

#define PVRD3DTNL_FLAGS2_POINTSIZECHANGED				0x00000001
#define PVRD3DTNL_FLAGS2_TEXTRANSENABLED				0x00000002
#define PVRD3DTNL_FLAGS2_POINTSCALEENABLE				0x00000004
#define PVRD3DTNL_FLAGS2_POINTSIZE_PRESENT				0x00000008
#define PVRD3DTNL_FLAGS2_INDEXEDVERTEXBLEND_ENABLED		0x00000010
#define PVRD3DTNL_FLAGS2_TEXGEN_CHANGED					0x00000040
#define PVRD3DTNL_FLAGS2_TEXGEN_ACTIVE					0x00000080
#define PVRD3DTNL_FLAGS2_TEXGEN_NEEDNORMAL				0x00000100
#define PVRD3DTNL_FLAGS2_TEXGEN_NEEDPOSITION			0x00000200
#define PVRD3DTNL_FLAGS2_TEXGEN_NEEDLOCALVIEWER			0x00000400

#define PVRD3DTNL_FLAGS2_TEXGEN_MATRIX0_CHANGED			0x00000800
#define PVRD3DTNL_FLAGS2_TEXGEN_MATRIX1_CHANGED			0x00001000
#define PVRD3DTNL_FLAGS2_TEXGEN_MATRIX2_CHANGED			0x00002000
#define PVRD3DTNL_FLAGS2_TEXGEN_MATRIX3_CHANGED			0x00004000
#define PVRD3DTNL_FLAGS2_TEXGEN_MATRIX_CHANGED			0x00007800

/*														
 * Bit defines for vertex shader TNL flags				
 */														
#define PVRD3DTNL_VSFLAGS_CHANGE_MASK					0x00001003

#define PVRD3DTNL_VSFLAGS_CLIPPLANE0_CHANGED			0x00000001
#define PVRD3DTNL_VSFLAGS_CLIPPLANE1_CHANGED			0x00000002
#define PVRD3DTNL_VSFLAGS_CLIPPLANE_CHANGED				0x00001000

#define PVRD3DTNL_VSFLAGS_CLIPENABLE0					0x00000040
#define PVRD3DTNL_VSFLAGS_CLIPENABLE1					0x00000080

#define	PVRD3DTNL_VSFLAGS_CLIPENABLE_SHIFT				6
#define	PVRD3DTNL_VSFLAGS_CLIPENABLE_CLRMASK			0xFFFFFF3F
#define	PVRD3DTNL_VSFLAGS_CLIPENABLE_MASK				0x000000C0

/*
	Fixed-function TNL FVF vertex-component input register mappings
*/
/*
	Fixed-function / Passthrough vertex-component input registers	

	NB:	These vertex-component to input-register mappings are used by both the
		passthough (pre-transformed) and fixed-function TNL code.

		Allocation of input registers:

		v0 = Position
		v3 = Normal
		v4 = Diffuse colour
		v5 = Specular colour
		v6 = Texture coordinate one
		v7 = Texture coordinate two
*/
#define FFVTXCOMPONENT_INPUTREG_POS				(0)
#define FFVTXCOMPONENT_INPUTREG_NORMAL			(3)
#define FFVTXCOMPONENT_INPUTREG_DIFFUSE			(4)
#define FFVTXCOMPONENT_INPUTREG_SPECULAR		(5)
#define FFVTXCOMPONENT_INPUTREG_TEX0			(6)
#define FFVTXCOMPONENT_INPUTREG_TEX1			(7)

/*
	Light colour-source type (used as index into array of current colour-
	sources for lighting - see TRANSIENT_STATE::sColourSources)
*/
typedef enum _TNLCOLSRCTYPE_
{
	TNLCOLSRCTYPE_DIFFUSE		= 0,
	TNLCOLSRCTYPE_SPECULAR,
	TNLCOLSRCTYPE_AMBIENT,
	TNLCOLSRCTYPE_COUNT,		/* number of colour-source types */
	TNLCOLSRCTYPE_FORCEDWORD	= 0x7FFFFFFF
} TNLCOLSRCTYPE, *PTNLCOLSRCTYPE;

typedef struct _PVR_NATIVE_VERTEX_
{
	PVR_VECTOR4		sObj;
	PVR_VECTOR4		sNormal;
	PVR_VECTOR4		sEye;
	PVR_VECTOR4		sClip;
	PVR_VECTOR4		sWindow;
		
	PVR_COLORVALUE	sDiffuseIn;
	PVR_COLORVALUE	sDiffuseOut;

	PVR_COLORVALUE	sSpecularIn;
	PVR_COLORVALUE	sSpecularOut;

	NTV_TYPE		Fog;
	
	IMG_UINT32		ui32TexCount;
	PVR_TEXVECTOR	sTextures[2];
	
	IMG_UINT32		ui32Flags;
	
	NTV_TYPE		WorldNormalZ;
	
} PVR_NATIVE_VERTEX;

#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
/* Structure to hold temporarily evicted instructions */
typedef struct _PT_SECTION_MOD_
{
	/* Count of instructions */
	DWORD		dwInstCount;

	/* Exe Range */
	VSINSTRANGE		sExeRange;

	/* Instruction store */
	HWVGPINST	psInstructions[2];
}PT_SECTION_MOD;

#endif

/*
	TNL-related software state
*/
typedef struct _SWTNLSTATE_
{
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
	/*
		Flags indicating which VGP constants need to be updated
		(see VGPTNL_CONST_xxx for definitions)
	*/
	DWORD					dwConstantFlags;

	/*
		TNL state-change tracking flags related to programmable shaders only 
		(see PVRD3DTNL_VSFLAGS_xxx)
	*/
	DWORD					dwVSFlags;

	/*
		TNL state-change tracking flags for the current FF-TNL shader
		configuration
	*/
	DWORD					dwTNLActiveFlags;

	/*
		TNL state-change tracking flags for the current FF-TNL shader
		configuration
	*/
	DWORD					dwTNLActiveFlags2;

	/*
		TNL state-change tracking flags used to configure the current
		programmable shader
	*/
	DWORD					dwVSActiveFlags;

	/*
		The number of clip-planes enabled
	*/
	DWORD					dwClipPlaneCount;

	/*
		Tracks required modifications of code sections
	*/
	DWORD					dwSectionModFlags;

	/*
		Array of temporary store for exe ranges when passthrough is loaded
	*/
	PT_SECTION_MOD			psPTSectionMods[VGP_MAX_SECTIONS];

	/* 
		Keeps track of co-ordinate counts for process vertices cases 
	*/
	DWORD					dwPVDestTexLayerCoordCount[MBX1_MAXTEXTURE_LAYERS];
#endif

	/*
		TNL state-change tracking flags (see PVRD3DTNL_FLAGS_xxx)
	*/
	DWORD					dwTNLFlags;

	/*
		More TNL state-change tracking flags (see PVRD3DTNL_FLAGS2_xxx)
	*/
	DWORD					dwTNLFlags2;

	/*
		App-supplied object->world transformations
	*/
	PVR_44_MATRIX			sWorldMatrix;

	/*
		App-supplied world->view transformation
	*/
	PVR_44_MATRIX			sViewMatrix;

	/*
		App-supplied view->projection transformation
	*/
	PVR_44_MATRIX			sProjMatrix;

	/*
		App-supplied texture-coordinate transformations
	*/
	PVR_44_MATRIX			sTexMatrix[4];

	/*
		D3D material data
	*/
	PVR_MATERIAL				sMaterial;

	/*
		Lighting colour sources selected by the renderstates
	*/
	D3DMMATERIALCOLORSOURCE	psD3DColourSourceSel[TNLCOLSRCTYPE_COUNT];

	/*
		Lighting colour source to use
	*/
	D3DMMATERIALCOLORSOURCE	sColourSourcesReq[TNLCOLSRCTYPE_COUNT];

	/*
		Global ambient colour
	*/
	PVR_COLORVALUE			sAmbientColour;

	/*
		Number of enabled lights (max VGPTNL_MAXIMUM_LIGHTS)
	*/
	DWORD					dwLightCount;

	/*
		List of current enabled lights (+1 for a sentinel)
	*/
	PLIGHTDATA				ppsEnabledLights[TNL_MAXIMUM_LIGHTS + 1];

#if defined (SUPPORT_VGP)

	/*
		Light-data sorted by light type (diffuse first, then point)
	*/
	PLIGHTDATA				ppsSortedLightData[TNL_MAXIMUM_LIGHTS];
#endif

	/*
		concatenated world, view and projection matrices
	*/
	PVR_44_MATRIX			sWorldViewProj;

#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
	/*
		Transpose of the concatenated world, view and projection matrices
	*/
	PVR_44_MATRIX			sWorldViewProjT;
#endif

	/*
		The concatenated world and view matrices
	*/
	PVR_44_MATRIX			sWorldView;

	/*
		Transpose of the concatenated world and view matrices
	*/
	PVR_44_MATRIX			sWorldViewT;

	/*
		Inverse of the concatenated world and view matrices
	*/
	PVR_44_MATRIX			sWorldViewInvT;

	/*
		Inverse Transpose of the view matrix
	*/
	PVR_44_MATRIX			sViewInvT;

	/*
		The number of texture coordinate sets that need to be generated	
	*/
	DWORD					dwTexTransformCount;

#if defined (SUPPORT_VGP)
	/*
		Number of directional-lights enabled
	*/
	DWORD					dwDirectionalLightCount;

	/*
		Number of point-lights enabled
	*/
	DWORD					dwPointLightCount;
#endif

	/*
		Current Flat shading diffuse colour 
	*/
	PVR_COLORVALUE		*psCurrentFlatShadeDiffuse;

	/* 
		Current Flat shading specular colour 
	*/
	PVR_COLORVALUE		*psCurrentFlatShadeSpecular;

	/*
		Specular lighting threshold
	*/
	NTV_TYPE				SpecularThreshold;///FIXME:??????????????

	/*
		Vertex store for extra vertices generated from clipping
	*/

	PVR_NATIVE_VERTEX		asClipVertex[D3DM_MAX_CLIP_VERTICES*2];
	PVR_NATIVE_VERTEX		*psNextClipTemp;
	PVR_NATIVE_VERTEX		*apsOutputVert[D3DM_NUM_CLIP_PLANES][D3DM_MAX_CLIP_VERTICES];
	PVR_NATIVE_VERTEX		**ppsOutputArray;

	PVR_VP_TRANSFORM		sVPTransform;
} SWTNLSTATE, *PSWTNLSTATE;

IMG_VOID DoClipTestandVPTransform(LPD3DM_CONTEXT	psContext, 
								  PVR_NATIVE_VERTEX **ppsVertex, 
								  IMG_UINT32		ui32Count);

NTV_TYPE TriangleMaxDepthSlope(PVR_NATIVE_VERTEX* psVertex);

IMG_VOID CalculateDepthBias(LPD3DM_CONTEXT psContext, NTV_TYPE ntvNewDepthM);

IMG_VOID ValidateVertex(LPD3DM_CONTEXT psContext, 
					 PVR_NATIVE_VERTEX **ppsVertex, 
					 IMG_UINT32 ui32Count);

IMG_VOID UpdateMatrices(LPD3DM_CONTEXT psContext);

#endif /* #if !defined(_TNL_H_) */
/*****************************************************************************
 End of file (tnl.h)
*****************************************************************************/

⌨️ 快捷键说明

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