📄 vgp.h
字号:
/******************************************************************************
<module>
* Name : vgp.h
* Title : vgp 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(_VGP_H_)
#define _VGP_H_
/*
vertex-component types (for fixed-function vertex-data)
Required also by sw tnl.
*/
#define FFVTXCOMPONENT_TYPE_POSITION 0x00000001
#define FFVTXCOMPONENT_TYPE_NORMAL 0x00000002
#define FFVTXCOMPONENT_TYPE_DIFFUSE 0x00000004
#define FFVTXCOMPONENT_TYPE_SPECULAR 0x00000008
#define FFVTXCOMPONENT_TYPE_TEX0 0x00000010
#define FFVTXCOMPONENT_TYPE_TEX1 0x00000020
#define FFVTXCOMPONENT_TYPE_TEX2 0x00000040
#define FFVTXCOMPONENT_TYPE_TEX3 0x00000080
#if defined (SUPPORT_VGP) || (SUPPORT_VGP_LITE)
#define INSTCOUNT(x) sizeof(x) / sizeof(*x)
#define VGPTNL_MAXIMUM_LIGHTS (8)
#define VGP_MAX_SECTIONS (16)
#if defined (SUPPORT_VGP)
#define VGP_MAX_INSTRUCTIONS (256)
#elif defined (SUPPORT_VGP_LITE)
#define VGP_MAX_INSTRUCTIONS (128)
#endif
#if defined (SUPPORT_VGP)
/* Following indices MUST match the array of sections */
#define VGPTNL_SECTIONORD_POSITION (0)
#define VGPTNL_SECTIONORD_COLOURSETDEFAULTS (1)
#define VGPTNL_SECTIONORD_COLOURPASSTHRU (2)
#define VGPTNL_SECTIONORD_TEXCOORDPASSTHRU (3)
#define VGPTNL_SECTIONORD_COLOURSOURCESETUP (4)
#define VGPTNL_SECTIONORD_LIGHTINGINIT (5)
#define VGPTNL_SECTIONORD_POSTOVIEW (6)
#define VGPTNL_SECTIONORD_LVIEWERSETUPFROMVERTEX (7)
#define VGPTNL_SECTIONORD_LVIEWERSETUPFROMDEFAULT (8)
#define VGPTNL_SECTIONORD_DIRECTIONLIGHT (9)
#define VGPTNL_SECTIONORD_POINTLIGHT (10)
#define VGPTNL_SECTIONORD_COLOUROUTPUT (11)
#define VGPTNL_SECTIONORD_TEXCOORDGENERATION (12)
#define VGPTNL_SECTIONORD_FOG (13)
#define VGPTNL_MAXIMUM_SECTION (14)
#else
/* Following indices MUST match the array of sections */
#define VGPTNL_SECTIONORD_POSITION (0)
#define VGPTNL_SECTIONORD_COLOURSETDEFAULTS (1)
#define VGPTNL_SECTIONORD_COLOURPASSTHRU (2)
#define VGPTNL_SECTIONORD_TEXCOORDPASSTHRU (3)
#define VGPTNL_SECTIONORD_COLOURSOURCESETUP (4)
#define VGPTNL_SECTIONORD_LIGHTINGINIT (5)
#define VGPTNL_SECTIONORD_POSTOVIEW (6)
#define VGPTNL_SECTIONORD_LVIEWERSETUPFROMVERTEX (7)
#define VGPTNL_SECTIONORD_LVIEWERSETUPFROMDEFAULT (8)
#define VGPTNL_SECTIONORD_GENERICLIGHT (9)
#define VGPTNL_SECTIONORD_COLOUROUTPUT (10)
#define VGPTNL_SECTIONORD_TEXCOORDGENERATION (11)
#define VGPTNL_SECTIONORD_FOG (12)
#define VGPTNL_MAXIMUM_SECTION (13)
#endif
/*
Flags indicating which VGP constants needs to be updated (used for
SWTNLSTATE::dwConstantFlags)
*/
#define VGPTNL_CONST_WVT_CHANGED 0x00000001
#define VGPTNL_CONST_WVPT_CHANGED 0x00000002
#define VGPTNL_CONST_CLIPPLANES_CHANGED 0x00000004
#define VGPTNL_CONST_LIGHTS_CHANGED 0x00000008
#define VGPTNL_CONST_MATERIAL_CHANGED 0x00000010
#define VGPTNL_CONST_WVIT_CHANGED 0x00000020
#define VGPTNL_CONST_VPT_CHANGED 0x00000040
#define VGPTNL_CONST_W1VIT_CHANGED 0x00000080
#define VGPTNL_CONST_W2VIT_CHANGED 0x00000100
#define VGPTNL_CONST_W3VIT_CHANGED 0x00000200
#define VGPTNL_CONST_W4VIT_CHANGED 0x00000400
#define VGPTNL_CONST_W5VIT_CHANGED 0x00000800
#define VGPTNL_CONST_WNVIT_CHANGED 0x00000F80
#define VGPTNL_CONST_STATIC_CONSTANTS 0x00001000
/* Forward declarations */
typedef struct _VSSECTION_ *PVSSECTION;
typedef struct _VTXSOURCE_DATA_ *PVTXSOURCE_DATA;
/*
Maximum number of vertex-components that can be provided by a single
vertex-source
*/
#define MBX1_VTXSTREAM_MAXCOMPONENTS (MBX1_VGPSREG_COUNT)
/*
State flags for VSSECTION::dwFlags
*/
#define VSSECTIONFLAGS_LOADED 0x00000001
#define VSSECTIONFLAGS_ENABLED 0x00000004
/*
Vertex-shader instruction-range
*/
typedef struct _VSINSTRANGE_
{
DWORD dwFirst;
DWORD dwLast;
} VSINSTRANGE, *PVSINSTRANGE;
/*
load/execute configuration for a code-section
*/
typedef struct _VSSECTIONCFG_
{
/*
Required range of instructions to be loaded
*/
VSINSTRANGE sLoadRange;
/*
Required range of instrction to execute
*/
VSINSTRANGE sExeRange;
/*
Requirex section repeat-count
*/
DWORD dwRepeatCount;
} VSSECTIONCFG, *PVSSECTIONCFG;
/*
Vertex-shader code-section details
*/
typedef struct _VSSECTION_ *PVSSECTION;
typedef struct _VSSECTION_
{
/*
General section control flags
*/
DWORD dwFlags;
/*
Section ID (which HW section this code is loaded as)
*/
DWORD dwHWSectionID;
/*
Start instruction (which HW instruction this code starts at)
*/
DWORD dwHWInstStart;
/*
Total number of instructions in the section (starting at psInsts)
*/
DWORD dwInstCount;
/*
Maximum number of instructions that can be held in psInsts
*/
DWORD dwMaxInsts;
/*
Current section configuration
*/
VSSECTIONCFG sConfig;
/*
Section index of a section within the current shader-code
*/
DWORD dwSectionIdx;
/*
HW section definition for this section
*/
DWORD dwHWVGPSectionDef;
/*
The code for the section
*/
PHWVGPINST psInsts;
} VSSECTION, *PVSSECTION;
/*
Data describing an individual vertex component
NB: Each vertex-stream may be composed of several (possible non
contiguous) components
*/
typedef struct _VTXCOMPONENT_
{
/*
Type the vertex component
*/
DWORD dwVGPIFReg;
/*
Size of the vertex component (in bytes)
*/
DWORD dwSize;
/*
Byte offset (within the data for a vertex) of the component
*/
DWORD dwOffset;
/*
Format Flag
*/
IMG_BOOL bFixedPoint;
/*
Colour Flag
*/
IMG_BOOL bColour;
} VTXCOMPONENT, *PVTXCOMPONENT;
typedef enum VERTEX_DATA_FMT_TAG
{
FFVTX_DATA_FMT_FIXED = 0,
FFVTX_DATA_FMT_FLOAT,
FFVTX_DATA_FMT_MIXED,
FFVTX_DATA_FMT_FORCE_DWORD = 0x7fffffff,
} VERTEX_DATA_FMT;
/*
Vertex-shader input-format data
*/
typedef struct _VSIFDEF_
{
/*
Flag signifying combined Data format
*/
VERTEX_DATA_FMT eDataFormat;
/*
FF-components used (for fixed-function shaders only, NULL for
programmable shaders - see FFVTXCOMPONENT_TYPE_xxx)
*/
DWORD dwFFComponents;
/*
HW VGP input-format definitions indicating how the supplied vertex-data
should be read into the VGP input registers (see MBX1_VGPIFDEF_xxx)
*/
DWORD dwVGPIFDef;
/*
Stride (in bytes) from the start of one vertex, to the start of the next.
*/
DWORD dwStride;
/*
Format description for stream:
Number of vertex-components present
*/
DWORD dwNumComponents;
/* Indicates that there is a colour present */
IMG_BOOL bColourPresent;
/*
Details for the vertex-components to be used from this source
*/
VTXCOMPONENT psComponents[MBX1_VTXSTREAM_MAXCOMPONENTS];
} VSIFDEF, *PVSIFDEF;
/******************************************************************************************************
* Code section and constant definitions
******************************************************************************************************/
#define NOMASK (MBX1_VGPINST_DESTMASK_ALL)
#define MASKX (MBX1_VGPINST_DESTMASK_X)
#define MASKY (MBX1_VGPINST_DESTMASK_Y)
#define MASKZ (MBX1_VGPINST_DESTMASK_Z)
#define MASKW (MBX1_VGPINST_DESTMASK_W)
#define MASK_XYZ (MASKX | MASKY | MASKZ)
#define MASK_XY (MASKX | MASKY)
#define MASK_WZ (MASKW | MASKZ)
#define SWZ_XXXX (MBX1_VGPINST_SRCSWIZ_XXXX)
#define SWZ_YYYY (MBX1_VGPINST_SRCSWIZ_YYYY)
#define SWZ_ZZZZ (MBX1_VGPINST_SRCSWIZ_ZZZZ)
#define SWZ_WWWW (MBX1_VGPINST_SRCSWIZ_WWWW)
#define SWZ_YZWX ((MBX1_VGPINST_SRCSWIZ_USEY << MBX1_VGPINST_SRCSWIZ_XSHIFT) | \
(MBX1_VGPINST_SRCSWIZ_USEZ << MBX1_VGPINST_SRCSWIZ_YSHIFT) | \
(MBX1_VGPINST_SRCSWIZ_USEW << MBX1_VGPINST_SRCSWIZ_ZSHIFT) | \
(MBX1_VGPINST_SRCSWIZ_USEX << MBX1_VGPINST_SRCSWIZ_WSHIFT))
#define R0 (MBX1_VGPINST_DESTADDR_TEMP0)
#define R1 (MBX1_VGPINST_DESTADDR_TEMP1)
#define R2 (MBX1_VGPINST_DESTADDR_TEMP2)
#define R3 (MBX1_VGPINST_DESTADDR_TEMP3)
#define R4 (MBX1_VGPINST_DESTADDR_TEMP4)
#define R5 (MBX1_VGPINST_DESTADDR_TEMP5)
#define R6 (MBX1_VGPINST_DESTADDR_TEMP6)
#define R7 (MBX1_VGPINST_DESTADDR_TEMP7)
#define R8 (MBX1_VGPINST_DESTADDR_TEMP8)
#define R9 (MBX1_VGPINST_DESTADDR_TEMP9)
#define R10 (MBX1_VGPINST_DESTADDR_TEMP10)
#define R11 (MBX1_VGPINST_DESTADDR_TEMP11)
#define R12 (MBX1_VGPINST_DESTADDR_TEMP12)
#define R13 (MBX1_VGPINST_DESTADDR_TEMP13)
#define OPOS (MBX1_VGPINST_DESTADDR_POS)
#define OBASE (MBX1_VGPINST_DESTADDR_BASE)
#define OOFF (MBX1_VGPINST_DESTADDR_OFF)
#define OTEX0 (MBX1_VGPINST_DESTADDR_TEX0)
#define OTEX1 (MBX1_VGPINST_DESTADDR_TEX1)
#if defined (SUPPORT_VGP)
#define OCLIP0 (MBX1_VGPINST_DESTADDR_CLIP0)
#define OCLIP1 (MBX1_VGPINST_DESTADDR_CLIP1)
#define OCLIPFR (MBX1_VGPINST_DESTADDR_CLIPFR)
#else
#define OCLIP0 (MBX1_VGPINST_DESTADDR_CLIPFR)
#define OCLIPFR (MBX1_VGPINST_DESTADDR_CLIPFR)
#endif
#define VPOS (FFVTXCOMPONENT_INPUTREG_POS)
#define VNORMAL (FFVTXCOMPONENT_INPUTREG_NORMAL)
#define VDIFFUSE (FFVTXCOMPONENT_INPUTREG_DIFFUSE)
#define VSPECULAR (FFVTXCOMPONENT_INPUTREG_SPECULAR)
#define VTEX0 (FFVTXCOMPONENT_INPUTREG_TEX0)
#define VTEX1 (FFVTXCOMPONENT_INPUTREG_TEX1)
#define NOP (MBX1_VGPINST_OPCODE_NOP)
#define MOV (MBX1_VGPINST_OPCODE_MOV)
#define ADD (MBX1_VGPINST_OPCODE_ADD)
#define MAD (MBX1_VGPINST_OPCODE_MAD)
#define MUL (MBX1_VGPINST_OPCODE_MUL)
#define RCP (MBX1_VGPINST_OPCODE_RCP)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -