📄 tsstate.c
字号:
dwTSPLCtl2 &= ~MBX1_TSPPL2_MAPFILTERENABLE;
break;
}
case D3DMTEXF_LINEAR:
{
break;
}
case D3DMTEXF_ANISOTROPIC:
{
/*
MBX1 does not support anisotropic filtering, but it can
super-sample textures, which gives some improvement.
Flag that anisotropic filtering is requested. If a max-
anisotropy level greater than one is selected, HW texture
super-sampling will be enabled in PostProcessTSState.
*/
psLState->dwLFlags |= LTSTATE_FLAGS_ANISOFILTERINGREQ;
break;
}
default:
{
D3DM_DPF((DPF_WARN,"D3DM_TSS_MagFilter: Unhandled D3D mag-filter mode %d. Defaulting to LINEAR", dwValue));
break;
}
}
psLState->sTSPLState.dwLCtl2 = dwTSPLCtl2;
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MagFilter"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_MinFilter
PURPOSE :
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_MinFilter(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
DWORD dwValue;
DWORD dwTSPLCtl2;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_MinFilter"));
D3DM_DPF((DPF_STATE, "D3DM_TSS_MinFilter: Stage %d: Filter = %d (unsupported)", psState->Stage, psState->Value));
psLState = &psContext->sTState.sLState[(DWORD) psState->Stage];
dwValue = psState->Value;
psLState->dwMinFilter = dwValue;
/* Get the max quality filter type between min and mag */
dwValue = max(psLState->dwMagFilter, psLState->dwMinFilter);
/*
Update the required map filtering mode
*/
dwTSPLCtl2 = psLState->sTSPLState.dwLCtl2;
psLState->dwLFlags &= ~LTSTATE_FLAGS_ANISOFILTERINGREQ;
dwTSPLCtl2 |= MBX1_TSPPL2_MAPFILTERENABLE;
switch (dwValue)
{
case D3DMTEXF_POINT:
{
/* Disable HW texture-filtering */
dwTSPLCtl2 &= ~MBX1_TSPPL2_MAPFILTERENABLE;
break;
}
case D3DMTEXF_LINEAR:
{
break;
}
case D3DMTEXF_ANISOTROPIC:
{
/*
MBX1 does not support anisotropic filtering, but it can
super-sample textures, which gives some improvement.
Flag that anisotropic filtering is requested. If a max-
anisotropy level greater than one is selected, HW texture
super-sampling will be enabled in PostProcessTSState.
*/
psLState->dwLFlags |= LTSTATE_FLAGS_ANISOFILTERINGREQ;
break;
}
default:
{
D3DM_DPF((DPF_WARN,"D3DM_TSS_MinFilter: Unhandled D3D min-filter mode %d. Defaulting to LINEAR", dwValue));
break;
}
}
psLState->sTSPLState.dwLCtl2 = dwTSPLCtl2;
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MinFilter"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_MipFilter
PURPOSE :
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_MipFilter(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
DWORD dwValue;
DWORD dwMipFilterCtl;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_MipFilter"));
D3DM_DPF((DPF_STATE, "D3DM_TSS_MipFilter: Stage %d: Filter Type = %d", psState->Stage, psState->Value));
psLState = &psContext->sTState.sLState[(DWORD) psState->Stage];
dwValue = psState->Value;
/*
If forcing to mipmap then change to point filtering mode
*/
if (
(psContext->sRegData.dwFlags & D3DMREG_AUTO_MIP_MAP) &&
(dwValue == D3DMTEXF_NONE)
)
{
dwValue = D3DMTEXF_POINT;
}
/*
If forcing trilinear if app selects mipmap
*/
if (
(psContext->sRegData.dwFlags & D3DMREG_TEXTURE_TRILIN_FILTER) &&
(dwValue == D3DMTEXF_POINT)
)
{
dwValue = D3DMTEXF_LINEAR;
}
/*
Disable mipmap-filtering altogether?
*/
if (psContext->sRegData.dwIFlags & D3DMREGI_DISABLE_MIPFILTER)
{
dwValue = D3DMTEXF_NONE;
}
/*
Update the required mip-filtering mode
*/
dwMipFilterCtl = psLState->dwMipFilterCtl;
dwMipFilterCtl &= MBX1_TSPPL2_MIPCTLCLRMASK;
switch (dwValue)
{
default:
{
D3DM_DPF((DPF_WARN,"D3DM_TSS_MipFilter: unhandled mipmap-filtering mode %d. Using NONE.", dwValue));
}
case D3DMTEXF_NONE:
{
dwMipFilterCtl |= MBX1_TSPPL2_MIPCTLNOTMIPMAP;
break;
}
case D3DMTEXF_POINT:
{
dwMipFilterCtl |= MBX1_TSPPL2_MIPCTLNOMIPFILTER;
break;
}
case D3DMTEXF_LINEAR:
{
#if defined(FIX_HW_PRN_684)
if(psState->Stage == 1 && (psLState->sTSPLState.dwLCtl1 & MBX1_TSPPL1_TSUPERSAMPLE))
{
/* Layer 1 with supersample enabled. Tri-linear may cause lockups */
dwMipFilterCtl |= MBX1_TSPPL2_MIPCTLNOMIPFILTER;
}
else
{
dwMipFilterCtl |= MBX1_TSPPL2_MIPCTLMIPFILTER;
}
#else
dwMipFilterCtl |= MBX1_TSPPL2_MIPCTLMIPFILTER;
#endif
break;
}
}
psLState->dwMipFilterCtl = dwMipFilterCtl;
/* Reset max mip level to top level if we've just disabled Mip Mapping*/
if(psLState->psSurfData)
{
AdjustForMaxMipLevel(psLState);
}
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MipFilter"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_MipMapLODBias
PURPOSE :
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_MipMapLODBias(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_MipMapLODBias"));
D3DM_DPF((DPF_STATE, "D3DM_TSS_MipMapLODBias: Stage %d: Value = 0x%08X", psState->Stage, psState->Value));
psLState = &psContext->sTState.sLState[(DWORD) psState->Stage];
/*
Save copy of the requested D3D MIPLODBIAS state value.
NB: The corresponding HW bias value used is dependent upon several
other factors, so we only update it one all testure-stage state-
changes have been handled (in PostProcessTSState)
*/
psLState->DAdjust = FL2NTV(LONG_TO_FLOAT(psState->Value));
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MipMapLODBias"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_MaxMipLevel
PURPOSE :
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_MaxMipLevel(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
DWORD dwValue;
LPD3DM_SURFACE psSurface;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_MaxMipLevel"));
D3DM_DPF((DPF_STATE, "D3DM_TSS_MaxMipLevel: Stage %d: Level = %d", psState->Stage, psState->Value));
psLState = &psContext->sTState.sLState[(DWORD)psState->Stage];
dwValue = psState->Value;
psSurface = psLState->psSurfData;
/*
Sets the maximum texture size we should use for a mipmap.
Due to hardware limits, the smallest size we can limit to is 8x8
*/
psLState->dwMaxMipLevel = dwValue;
/*
If a texture has already been supplied then we need adjust its
address and size, otherwise it will be done when a valid texture is
set up.
*/
if(psSurface)
{
AdjustForMaxMipLevel(psLState);
}
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MaxMipLevel"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_MaxAnisotropy
PURPOSE :
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_MaxAnisotropy(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
DWORD dwValue;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_MaxAnisotropy"));
D3DM_DPF((DPF_STATE, "D3DM_TSS_MaxAnisotropy: Stage %d: Level = %d", psState->Stage, psState->Value));
psLState = &psContext->sTState.sLState[(DWORD) psState->Stage];
dwValue = psState->Value;
/*
MBX1 does not support anisotropic filtering. However, it can do
texture-supersampling, so we use that to at least visually improve
filtering when anisotropic filtering is required.
NB: Since anisotropic filtering depends upon the value supplied here
and the desired texture filtering-mode, we setup the HW-controls
later in PostProcessTSState.
*/
if(
(dwValue > 1) ||
(psContext->sRegData.dwFlags & D3DMREG_TEXTURE_SUPER_SAMPLE)
)
{
psLState->dwLFlags |= LTSTATE_FLAGS_MAXANISOLEVELNOTONE;
}
else
{
psLState->dwLFlags &= ~LTSTATE_FLAGS_MAXANISOLEVELNOTONE;
}
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_MaxAnisotropy"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : D3DM_TSS_TexTransFlags
PURPOSE : SWTNL HAL only, set ups flags used by texture coordinate
transforms.
PARAMETERS : psContext - Current D3D context
psLState - Layer state to be applied to...
dwValue - Value to set
RETURNS :
</function>
------------------------------------------------------------------------------*/
void D3DM_TSS_TexTransFlags(LPD3DM_CONTEXT psContext,LPD3DM_TEXTURESTAGESTATE psState)
{
PLAYER_TSTATE psLState;
PSWTNLSTATE psSWTNLState;
DWORD dwValue;
D3DM_DPF((DPF_ENTRY, "->D3DM_TSS_TexTransFlags"));
D3DM_DPF((DPF_STATE, " D3DM_TSS_TexTransFlags: Stage %d: Value = 0x%08X", psState->Stage, psState->Value));
dwValue = psState->Value;
psLState = &psContext->sTState.sLState[(DWORD) psState->Stage];
psSWTNLState = &psContext->sTState.sSWTNLState;
/*
Update the texture coordinate generation count for this stage, and
the overall count of how many stages need coordinate generation
*/
if ((dwValue & ~D3DMTTFF_PROJECTED) != D3DMTTFF_DISABLE)
{
if ((psLState->dwD3DTexTransFlags & ~D3DMTTFF_PROJECTED) == D3DMTTFF_DISABLE)
{
psSWTNLState->dwTexTransformCount++;
}
}
else
{
if ((psLState->dwD3DTexTransFlags & ~D3DMTTFF_PROJECTED) != D3DMTTFF_DISABLE)
{
psSWTNLState->dwTexTransformCount--;
}
}
psLState->dwD3DTexTransFlags = dwValue;
/*
Flag that TNL texture coordinate generation needs updating
*/
psSWTNLState->dwTNLFlags2 |= PVRD3DTNL_FLAGS2_TEXGEN_CHANGED;
D3DM_DPF((DPF_EXIT, "<-D3DM_TSS_TexTransFlags"));
}
/*----------------------------------------------------------------------------
<function>
FUNCTION : ValidateTextureStageState
PURPOSE : ValidateTextureStageState evaluates the current state for
blending operations (including multitexture) and returns the
number of passes the hardware can do it in.
PARAMETERS : psVDD, ptr to D3DM_VALIDATEDEVICE_DATA.
RETURNS :
</function>
------------------------------------------------------------------------------*/
VOID ValidateTextureStageState(D3DM_VALIDATEDEVICE_DATA *psVDD)
{
LPD3DM_CONTEXT psContext;
PTRANSIENT_STATE psTState;
PLAYER_TSTATE psLState;
DWORD dwStage;
/*
D3DM_VALIDATEDEVICE_DATA contains:
nContextId; // in: Context handle.
NumPasses;// out: Number of passes the hardware.
rval; // out: return value.
*/
D3DM_DPF((DPF_ENTRY, "->ValidateTextureStageState"));
D3DM_DPF((DPF_STATE, "Context %#8.8lX", psVDD->nContextId));
/*
Make sure context is valid.
*/
psContext = (LPD3DM_CONTEXT) psVDD->nContextId;
if (!psContext)
{
psVDD->rval = D3DMERR_DRIVERINVALIDCALL;
return;
}
/*
We CAN do everything in one pass ?
*/
psVDD->NumPasses = 1;
psTState = &psContext->sTState;
/*
Go through each of the stages
*/
f
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -