📄 tsstate.h
字号:
/******************************************************************************
<module>
* Name : TSState.h
* Title : D3DM Texture stage state info
* 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 : Prototypes and structure definitions for D3DM texture stage state
interaction
*
* Platform : Windows CE
*
</module>
********************************************************************************/
#if !defined(_TSSTATE_H_)
#define _TSSTATE_H_
/* Forward declaration */
typedef struct _LAYER_TSTATE_ *PLAYER_TSTATE;
/* D3DM Texture Stage State Function prototypes */
VOID D3DM_TSS_TextureMap(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_ColourOp(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_ColourArg1(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_ColourArg2(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_AlphaOp(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_AlphaArg1(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_AlphaArg2(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_TexCoordIndex(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_Address(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_AddressU(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_AddressV(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MagFilter(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MinFilter(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MipFilter(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MipMapLODBias(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MaxMipLevel(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_MaxAnisotropy(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_TexTransFlags(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
VOID D3DM_TSS_NOP(LPD3DM_CONTEXT psContext, LPD3DM_TEXTURESTAGESTATE psState);
/* Performs final state-update based upon the current texture-stage states */
VOID PostProcessTSState(LPD3DM_CONTEXT psContext);
/* Evaluates the current state for blending operations */
VOID ValidateTextureStageState(D3DM_VALIDATEDEVICE_DATA *psVDD);
/*
Updates the HW addressing mode to use for a given coordinate
(called when the coordinate-set wrap-enable state changes)
*/
void UpdateHWTexAddrMode(LPD3DM_CONTEXT psContext,
PLAYER_TSTATE psLState,
DWORD dwCoord);
/*****************************************************************************
Routines to setup the colour/alpha op tables
*****************************************************************************/
static BOOL SetupColourArgs(DWORD dwSources[4], DWORD *pdwLCtl3);
static BOOL SetupAlphaArgs(DWORD dwSources[4], DWORD *pdwLCtl3);
static BOOL SetupColourOp(DWORD dwOp, DWORD dwArg1, DWORD dwArg2, DWORD *pdwLCtl3);
static BOOL SetupAlphaOp(DWORD dwOp, DWORD dwArg1, DWORD dwArg2, DWORD *pdwLCtl3);
static DWORD GetColourOpOff(DWORD dwOp, DWORD dwFlags);
static DWORD GetColourArgOff(DWORD dwArg, DWORD dwFlags);
static DWORD GetAlphaOpOff(DWORD dwOp, DWORD dwFlags);
static DWORD GetAlphaArgOff(DWORD dwArg, DWORD dwFlags);
DWORD GetColourOpLCtl3(DWORD dwOp, DWORD dwArg1, DWORD dwArg2, DWORD dwFlags);
DWORD GetAlphaOpLCtl3(DWORD dwOp, DWORD dwArg1, DWORD dwArg2, DWORD dwFlags);
/*****************************************************************************
General texture-stage flags (for LAYER_TSTATE::dwLFlags)
*****************************************************************************/
#define LTSTATE_FLAGS_ANISOFILTERINGREQ 0x00000001
#define LTSTATE_FLAGS_MAXANISOLEVELNOTONE 0x00000002
/*
Texture stage Colour-op codes
*/
#define PVR_COLOUROP_SELECTARG1 0
#define PVR_COLOUROP_SELECTARG2 1
#define PVR_COLOUROP_MODULATE 2
#define PVR_COLOUROP_MODULATE2X 3
#define PVR_COLOUROP_MODULATE4X 4
#define PVR_COLOUROP_ADD 5
#define PVR_COLOUROP_ADDSIGNED 6
#define PVR_COLOUROP_ADDSIGNED2X 7
#define PVR_COLOUROP_SUBTRACT 8
#define PVR_COLOUROP_ADDSMOOTH 9
#define PVR_COLOUROP_BLENDDIFFUSEALPHA 10
#define PVR_COLOUROP_BLENDTEXTUREALPHA 11
#define PVR_COLOUROP_BLENDFACTORALPHA 12
#define PVR_COLOUROP_BLENDTEXTUREALPHAPM 13
#define PVR_COLOUROP_BLENDCURRENTALPHA 14
#define PVR_COLOUROP_PREMODULATE 15
#define PVR_COLOUROP_MODULATEALPHA_ADDCOLOR 16
#define PVR_COLOUROP_MODULATECOLOR_ADDALPHA 17
#define PVR_COLOUROP_MODULATEINVALPHA_ADDCOLOR 18
#define PVR_COLOUROP_MODULATEINVCOLOR_ADDALPHA 19
#define PVR_COLOUROP_BUMPENVMAP 20
#define PVR_COLOUROP_BUMPENVMAPLUMINANCE 21
#define PVR_COLOUROP_DOTPRODUCT3 22
/*
Texture stage colour argument codes
*/
#define PVR_COLOURARG_DIFFUSE 0
#define PVR_COLOURARG_CURRENT 1
#define PVR_COLOURARG_TEXTURE 2
#define PVR_COLOURARG_FACTOR 3
#define PVR_COLOURARG_INVDIFFUSE 4
#define PVR_COLOURARG_INVCURRENT 5
#define PVR_COLOURARG_INVTEXTURE 6
#define PVR_COLOURARG_INVFACTOR 7
#define PVR_COLOURARG_DIFFUSEALPHA 8
#define PVR_COLOURARG_CURRENTALPHA 9
#define PVR_COLOURARG_TEXTUREALPHA 10
#define PVR_COLOURARG_FACTORALPHA 11
#define PVR_COLOURARG_INVDIFFUSEALPHA 12
#define PVR_COLOURARG_INVCURRENTALPHA 13
#define PVR_COLOURARG_INVTEXTUREALPHA 14
#define PVR_COLOURARG_INVFACTORALPHA 15
#define PVR_COLOURARG_OPAQUETEXTUREALPHA 16
#define PVR_COLOURARG_INVOPAQUETEXTUREALPHA 17
#define PVR_COLOURARG_NOTEXCOLOUR 18
#define PVR_COLOURARG_INVNOTEXCOLOUR 19
/*
Texture stage Alpha-op codes
*/
#define PVR_ALPHAOP_DISABLE 0 /* DISABLE = CURRENT normally */
#define PVR_ALPHAOP_DISABLESTAGE0 1 /* DISABLE = DIFFUSE for stage 0 */
#define PVR_ALPHAOP_SELECTARG1 2
#define PVR_ALPHAOP_SELECTARG2 3
#define PVR_ALPHAOP_MODULATE 4
#define PVR_ALPHAOP_MODULATE2X 5
#define PVR_ALPHAOP_MODULATE4X 6
#define PVR_ALPHAOP_ADD 7
#define PVR_ALPHAOP_ADDSIGNED 8
#define PVR_ALPHAOP_ADDSIGNED2X 9
#define PVR_ALPHAOP_SUBTRACT 10
#define PVR_ALPHAOP_ADDSMOOTH 11
#define PVR_ALPHAOP_BLENDDIFFUSEALPHA 12
#define PVR_ALPHAOP_BLENDTEXTUREALPHA 13
#define PVR_ALPHAOP_BLENDFACTORALPHA 14
#define PVR_ALPHAOP_BLENDTEXTUREALPHAPM 15
#define PVR_ALPHAOP_BLENDCURRENTALPHA 16
#define PVR_ALPHAOP_PREMODULATE 17
#define PVR_ALPHAOP_DOTPRODUCT3 18
/*
Texture stage alpha argument codes
*/
#define PVR_ALPHAARG_DIFFUSEALPHA 0
#define PVR_ALPHAARG_CURRENTALPHA 1
#define PVR_ALPHAARG_TEXTUREALPHA 2
#define PVR_ALPHAARG_FACTORALPHA 3
#define PVR_ALPHAARG_INVDIFFUSEALPHA 4
#define PVR_ALPHAARG_INVCURRENTALPHA 5
#define PVR_ALPHAARG_INVTEXTUREALPHA 6
#define PVR_ALPHAARG_INVFACTORALPHA 7
#define PVR_ALPHAARG_OPAQUETEXTUREALPHA 8
#define PVR_ALPHAARG_INVOPAQUETEXTUREALPHA 9
/*
Texture stage colour source codes - one for each possible HW
colour source
*/
#define PVR_COLOURSOURCE_DIFFUSE 0
#define PVR_COLOURSOURCE_CURRENT 1
#define PVR_COLOURSOURCE_TEXTURE 2
#define PVR_COLOURSOURCE_FACTOR 3
#define PVR_COLOURSOURCE_INVDIFFUSE 4
#define PVR_COLOURSOURCE_INVCURRENT 5
#define PVR_COLOURSOURCE_INVTEXTURE 6
#define PVR_COLOURSOURCE_INVFACTOR 7
#define PVR_COLOURSOURCE_DIFFUSEALPHA 8
#define PVR_COLOURSOURCE_CURRENTALPHA 9
#define PVR_COLOURSOURCE_TEXTUREALPHA 10
#define PVR_COLOURSOURCE_FACTORALPHA 11
#define PVR_COLOURSOURCE_INVDIFFUSEALPHA 12
#define PVR_COLOURSOURCE_INVCURRENTALPHA 13
#define PVR_COLOURSOURCE_INVTEXTUREALPHA 14
#define PVR_COLOURSOURCE_INVFACTORALPHA 15
/*
The following colour sources are not available as D3D args.
NB: 'ANY' and 'INVANY' are used to represent an arbitrary source,
and are available for all the HW sources.
*/
#define PVR_COLOURSOURCE_ONE 16
#define PVR_COLOURSOURCE_ZERO 17
#define PVR_COLOURSOURCE_ANY 18
#define PVR_COLOURSOURCE_INVANY 19
/*
Texture stage alpha source codes - one for each possible HW
alpha source
*/
#define PVR_ALPHASOURCE_DIFFUSEALPHA 0
#define PVR_ALPHASOURCE_CURRENTALPHA 1
#define PVR_ALPHASOURCE_TEXTUREALPHA 2
#define PVR_ALPHASOURCE_FACTORALPHA 3
#define PVR_ALPHASOURCE_INVDIFFUSEALPHA 4
#define PVR_ALPHASOURCE_INVCURRENTALPHA 5
#define PVR_ALPHASOURCE_INVTEXTUREALPHA 6
#define PVR_ALPHASOURCE_INVFACTORALPHA 7
/*
The following alpha sources are not available as D3D args
NB: 'ANY' and 'INVANY' are used to represent an arbitrary source,
and are available for all the HW sources.
*/
#define PVR_ALPHASOURCE_ONE 8
#define PVR_ALPHASOURCE_ZERO 9
#define PVR_ALPHASOURCE_ANY 10
#define PVR_ALPHASOURCE_INVANY 11
/*
Mapping of input colour arguments (and variants thereof) to their
corresponding HW colour source codes (listed above)
*/
#define PVR_COLOURARGTRANS_ARGMASK 0x1F
#define PVR_COLOURARGTRANS_COMPLEMENT 0x20
#define PVR_COLOURARGTRANS_ALPHAREPLICATE 0x40
/*****************************************************************************
Macro definitions
*****************************************************************************/
/*
The flags below can be added to the requested D3D arg to allow for
special cases such as there being no CURRENT on the first non-bump
stage, or to map TEXTURE alpha to ONE with opaque textures.
*/
#define PVR_ARGTRANSFLAG_STAGEZERO (D3DMTA_ALPHAREPLICATE << 1)
#define PVR_ARGTRANSFLAG_OPAQUETEXTURE (PVR_ARGTRANSFLAG_STAGEZERO << 1)
#define PVR_ARGTRANSFLAG_NOTEXCOLOUR (PVR_ARGTRANSFLAG_OPAQUETEXTURE << 1)
/*******************************************************************************
D3DM Texture Stage State function type
********************************************************************************/
/* Texture-state-state state-change handler function type */
typedef void (*D3DM_TSSTATEFUNC)(LPD3DM_CONTEXT, LPD3DM_TEXTURESTAGESTATE);
/*******************************************************************************
D3DM Texture layer state structure
********************************************************************************/
typedef struct _LAYER_TSTATE_
{
/*
Our surface-data for the texture bound to this stage
(NULL if none is bound)
*/
LPD3DM_SURFACE psSurfData;
/*
General flags (see TLSTATE_FLAGS_FLAGS_xxx for definitions)
*/
DWORD dwLFlags;
/*
Texture D-adjust
*/
NTV_TYPE DAdjust;
/*
Current chosen D3D Colour-operation
*/
DWORD dwCOp;
/*
Current chosen D3D Colour arg1
*/
DWORD dwCArg1;
/*
Current chosen D3D Colour arg2
*/
DWORD dwCArg2;
/*
Current chosen D3D Alpha-operation
*/
DWORD dwAOp;
/*
Current chosen D3D Alpha arg1
*/
DWORD dwAArg1;
/*
Current chosen D3D Alpha arg2
*/
DWORD dwAArg2;
/*
Colour/Alpha remapping flags used when mapping D3D colour/alpha ops and
args to HW per-layer texture-state.
*/
DWORD dwArgTransFlags;
/*
Texture-coordinate auto-generation mode
*/
DWORD dwCoordAutoGenMode;
/*
D3D Texture-transform flags
*/
DWORD dwD3DTexTransFlags;
/*
Which coordinate-set to use
*/
DWORD dwCoordSetNum;
/*
Requested D3DM texture addressing mode (for each coordinate)
*/
D3DMTEXTUREADDRESS pdwD3DAddrMode[2];
/*
Required HW mipmap filtering modes (see MBX1_TSPPL2_MIPCTLxxx)
*/
DWORD dwMipFilterCtl;
/*
Current Maximum mipmap level for this stage
*/
DWORD dwMaxMipLevel;
/*
Current Mag Filter Setting
*/
DWORD dwMagFilter;
/*
Current Min Filter Setting
*/
DWORD dwMinFilter;
/*
HW per-layer texture-state corresponding to this D3D texture-stage
*/
MBX1_TSPLAYER_STATE sTSPLState;
} LAYER_TSTATE, *PLAYER_TSTATE;
/*----------------------------------------------------------------------------
<function>
FUNCTION : AsPowerOfTwo
PURPOSE : Utility to get a texture-size as a power of two
PARAMETERS : psContext - A 3D rendering context
RETURNS : None
</function>
------------------------------------------------------------------------------*/
__inline DWORD AsPowerOfTwo(DWORD nNum)
{
DWORD i, nTest;
nTest = 0x400;
for (i = 10; i > 0; i--)
{
if (nNum & nTest) break;
nTest >>= 1;
}
return(i);
}
#endif // _TSSTATE_H_
/*****************************************************************************
End of file (TSState.h)
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -