📄 vgpcommon.c
字号:
else
{
if(psContext->dwFlags & D3DM_CONTEXT_SWFLAGS_PROCVERT_MODE && b3DCoordsUsed)
{
if(i == 0)
{
VGPINSTG(psSection[dwInst].field, MOV, DEST(OCLIP0, MASKX), dwSrcReg, 0, 0, 0);
dwInst++;
VGPINSTG(psSection[dwInst].field, MOV, DEST(OCLIP0, MASKY), dwSrcReg, 0, 0, 0);
dwInst++;
VGPINSTG(psSection[dwInst].field, MOV, DEST(OCLIP0, MASKX), dwSrcReg, 0, 0, 0);
dwInst++;
}
else
{
VGPINSTG(psSection[dwInst].field, MOV, DEST(OTEX0, MASKX), dwSrcReg, 0, 0, 0);
dwInst++;
VGPINSTG(psSection[dwInst].field, MOV, DEST(OTEX0, MASKY), dwSrcReg, 0, 0, 0);
dwInst++;
VGPINSTG(psSection[dwInst].field, MOV, DEST(OTEX1, MASKX), dwSrcReg, 0, 0, 0);
}
}
else
{
VGPINSTG(psSection[dwInst].field, MOV, DEST(OTEX0 + i, NOMASK), dwSrcReg, 0, 0, 0);
dwInst++;
}
}
}
*pdwSectionSize = dwInst;
}
/*****************************************************************************
FUNCTION : VGPTNLSetConstant
PURPOSE : Core Constant buffer updating function
PARAMETERS : psContext - The current 3D rendering context
dwNum - Constant to be updated
RETURNS : void
****************************************************************************/
VOID VGPTNLSetConstant(LPD3DM_CONTEXT psContext, DWORD dwNum, NTV_TYPE *pntvVal)
{
PHWVGPCONST psVSConsts;
PVGPCONSTFLAGS psConstsChanged;
#ifndef D3DM_NATIVE_FLOAT
IMG_FLOAT fConstVal[4];
DWORD i;
#endif
psVSConsts = (PHWVGPCONST) &psContext->sHWState.sVGPConsts;
psConstsChanged = &psContext->sHWStateCtl.sVGPConstsChanged;
#ifndef D3DM_NATIVE_FLOAT
/* Convert to float */
for(i=0; i<4 ; i++)
{
fConstVal[i]= NTV2FL(*(pntvVal + i));
}
memcpy(psVSConsts + dwNum, &fVal, 1 * sizeof(HWVGPCONST));
#else /* D3DM_NATIVE_FLOAT*/
memcpy(psVSConsts + dwNum, pntvVal, 1 * sizeof(HWVGPCONST));
#endif /* D3DM_NATIVE_FLOAT*/
FlagArraySetFlagRange((PFLAGARRAY)psConstsChanged, dwNum, dwNum);
}
/*****************************************************************************
FUNCTION : VGPTNLSetConstants
PURPOSE : Constant buffer updating for multiple constants
PARAMETERS : psContext - The current 3D rendering context
dwNum - Constant to be updated
RETURNS : void
****************************************************************************/
VOID VGPTNLSetConstants(LPD3DM_CONTEXT psContext,
DWORD dwStart,
DWORD dwCount,
NTV_TYPE *pntvVal)
{
DWORD i;
for (i = dwStart; i < dwStart+dwCount; i++)
{
VGPTNLSetConstant(psContext, i, pntvVal);
pntvVal += 4;
}
}
/*****************************************************************************
FUNCTION : VGPTNLSetConstant1
PURPOSE : Constant buffer updating for single values
PARAMETERS : psContext - The current 3D rendering context
dwNum - Constant to be updated
RETURNS : void
****************************************************************************/
VOID VGPTNLSetConstant1(LPD3DM_CONTEXT psContext, DWORD dwNum, NTV_TYPE ntvVal)
{
NTV_TYPE pntvVal[4];
pntvVal[0] = ntvVal;
pntvVal[1] = ntvVal;
pntvVal[2] = ntvVal;
pntvVal[3] = ntvVal;
VGPTNLSetConstant(psContext, dwNum, pntvVal);
}
/*****************************************************************************
FUNCTION : VGPTNLSetConstant2
PURPOSE : Constant buffer updating for multiple values
PARAMETERS : psContext - The current 3D rendering context
dwNum - Constant to be updated
RETURNS : void
****************************************************************************/
VOID VGPTNLSetConstant2(LPD3DM_CONTEXT psContext,
DWORD dwNum,
NTV_TYPE ntvVal1,
NTV_TYPE ntvVal2,
NTV_TYPE ntvVal3,
NTV_TYPE ntvVal4)
{
NTV_TYPE pntvVal[4];
pntvVal[0] = ntvVal1;
pntvVal[1] = ntvVal2;
pntvVal[2] = ntvVal3;
pntvVal[3] = ntvVal4;
VGPTNLSetConstant(psContext, dwNum, pntvVal);
}
/*****************************************************************************
FUNCTION : VGPTNLOutputColour
PURPOSE : Constant buffer updating for colour values
PARAMETERS : psContext - The current 3D rendering context
dwNum - Constant to be updated
RETURNS : void
****************************************************************************/
VOID VGPTNLOutputColour(LPD3DM_CONTEXT psContext,
DWORD dwNum,
PVR_COLORVALUE* Colour)
{
VGPTNLSetConstant2(psContext,
dwNum,
Colour->b,
Colour->g,
Colour->r,
Colour->a);
}
/*****************************************************************************
FUNCTION : VGPTNLUpdateSWTNLState
PURPOSE : Updates the SW TNL state-flags and data derived from the
current D3DM state
PARAMETERS : psContext - The current 3D rendering context
RETURNS : void
****************************************************************************/
void VGPTNLUpdateSWTNLState(LPD3DM_CONTEXT psContext)
{
PTRANSIENT_STATE psTState;
PSWTNLSTATE psSWTNLState;
DWORD dwConstantFlags;
DWORD dwTNLFlags;
DWORD dwTNLFlags2;
DWORD i;
psTState = &psContext->sTState;
psSWTNLState = &psTState->sSWTNLState;
dwConstantFlags = psSWTNLState->dwConstantFlags;
dwTNLFlags = psSWTNLState->dwTNLFlags;
dwTNLFlags2 = psSWTNLState->dwTNLFlags2;
/*
Process changes in the various flags
*/
if((dwTNLFlags2 & PVRD3DTNL_FLAGS2_TEXGEN_CHANGED) ||
(dwTNLFlags & PVRD3DTNL_FLAGS_DECLARATION_CHANGED) )
{
BOOL bTexGenActive = FALSE;
dwTNLFlags2 &= ~(PVRD3DTNL_FLAGS2_TEXGEN_NEEDNORMAL |
PVRD3DTNL_FLAGS2_TEXGEN_NEEDPOSITION |
PVRD3DTNL_FLAGS2_TEXGEN_NEEDLOCALVIEWER);
/*
Texture coordinate generation/texture transforms can only be used
with non-transformed data
*/
if(dwTNLFlags & PVRD3DTNL_FLAGS_ENABLED)
{
for (i = 0; i < MBX1_MAXTEXTURE_LAYERS; i++)
{
PLAYER_TSTATE psLState;
psLState = &psTState->sLState[i];
if((psLState->dwCoordAutoGenMode != D3DMTSS_TCI_PASSTHRU) ||
((psLState->dwD3DTexTransFlags & ~D3DMTTFF_PROJECTED) != D3DMTTFF_DISABLE))
{
bTexGenActive = TRUE;
}
switch (psLState->dwCoordAutoGenMode)
{
case D3DMTSS_TCI_CAMERASPACENORMAL:
{
dwTNLFlags2 |= PVRD3DTNL_FLAGS2_TEXGEN_NEEDNORMAL;
break;
}
case D3DMTSS_TCI_CAMERASPACEPOSITION:
{
dwTNLFlags2 |= PVRD3DTNL_FLAGS2_TEXGEN_NEEDPOSITION;
break;
}
case D3DMTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
{
dwTNLFlags2 |= PVRD3DTNL_FLAGS2_TEXGEN_NEEDPOSITION |
PVRD3DTNL_FLAGS2_TEXGEN_NEEDNORMAL |
PVRD3DTNL_FLAGS2_TEXGEN_NEEDLOCALVIEWER;
break;
}
}
}
}
if (bTexGenActive)
{
dwTNLFlags2 |= PVRD3DTNL_FLAGS2_TEXGEN_ACTIVE;
}
else
{
dwTNLFlags2 &= ~PVRD3DTNL_FLAGS2_TEXGEN_ACTIVE;
}
}
/* Update the SW TNL-state flags */
psSWTNLState->dwConstantFlags = dwConstantFlags;
psSWTNLState->dwTNLFlags = dwTNLFlags;
psSWTNLState->dwTNLFlags2 = dwTNLFlags2;
}
/*****************************************************************************
FUNCTION : VGPTNLSetUpPassThroughShader
PURPOSE : Configures the passthrough vertex-shader according the passed in
TnL requirements and state
PARAMETERS : psContext - The current 3D rendering context
dwTNLFlags - Flags to use to set up the passthrough shader
RETURNS : void
****************************************************************************/
IMG_VOID VGPTNLSetUpPassThroughShader(LPD3DM_CONTEXT psContext, DWORD dwTNLFlags)
{
DWORD dwSectionStart;
DWORD dwSectionEnd;
DWORD dwTcCount;
DWORD dwSectionsToEnable;
DWORD dwColoursPresent;
DWORD dwBaseInstruction;
DWORD dwCurrentInstruction;
HWVGPINST *pInstBuffer;
pInstBuffer = (HWVGPINST*) &psContext->sHWState.sVGPCode;
/* Start by disabling all sections */
DisableSections(0xFFFFFFFF, psContext);
dwSectionsToEnable = 0;
/* Always enable position passthru */
dwSectionsToEnable |= 1 << VGPTNL_SECTIONORD_POSITION;
/* Get position section first instruction address */
dwBaseInstruction = psContext->ppsFFTNLSections[VGPTNL_SECTIONORD_POSITION]->sConfig.sLoadRange.dwFirst;
dwCurrentInstruction = dwBaseInstruction;
if(!(psContext->sTState.sSWTNLState.dwSectionModFlags & (1 << VGPTNL_SECTIONORD_POSITION)))
{
/*
If this flag hasn't been set, then set it and flag that the passthrough has been loaded
so we know we only need to change 1 instruction and the exe range.
*/
psContext->sTState.sSWTNLState.dwSectionModFlags |= (1 << VGPTNL_SECTIONORD_POSITION);
psContext->sTState.sSWTNLState.dwSectionModFlags |= PVRD3DTNL_FLAGS_PASSTHROUGH_LOADED;
/* Store off current exe range */
psContext->sTState.sSWTNLState.psPTSectionMods[VGPTNL_SECTIONORD_POSITION].sExeRange =
psContext->ppsFFTNLSections[VGPTNL_SECTIONORD_POSITION]->sConfig.sExeRange;
/* Store evicted instruction */
psContext->sTState.sSWTNLState.psPTSectionMods[VGPTNL_SECTIONORD_POSITION].dwInstCount = 1;
psContext->sTState.sSWTNLState.psPTSectionMods[VGPTNL_SECTIONORD_POSITION].psInstructions[0] =
pInstBuffer[dwCurrentInstruction];
}
/* Pass inputs to outputs */
pInstBuffer[dwCurrentInstruction++] = psPositionPassthruSection[0];
/* Set executable range */
SetSectionExeRange(VGPTNL_SECTIONORD_POSITION,
dwBaseInstruction,
dwCurrentInstruction - 1,
psContext);
/* Flag modified instructions */
FlagArraySetFlagRange((PFLAGARRAY)&psContext->sHWStateCtl.sVGPInstsChanged,
dwBaseInstruction,
dwCurrentInstruction - 1);
/*
Configure and enable setting-up of vertex-colour defaults (only if
both vertex colours are not present)
*/
dwColoursPresent = dwTNLFlags & (PVRD3DTNL_FLAGS_DIFFUSE_PRESENT |
PVRD3DTNL_FLAGS_SPECULAR_PRESENT);
if(dwColoursPresent != (PVRD3DTNL_FLAGS_DIFFUSE_PRESENT |
PVRD3DTNL_FLAGS_SPECULAR_PRESENT))
{
/*
Enable the default-colour setup section
*/
dwSectionsToEnable |= 1 << VGPTNL_SECTIONORD_COLOURSETDEFAULTS;
/*
Setup the section execution range to only set the default for the
colour components that are not present
*/
if(dwColoursPresent & PVRD3DTNL_FLAGS_DIFFUSE_PRESENT)
{
dwSectionStart = 1;
}
else
{
dwSectionStart = 0;
}
if(dwColoursPresent & PVRD3DTNL_FLAGS_SPECULAR_PRESENT)
{
dwSectionEnd = 0;
}
else
{
dwSectionEnd = 1;
}
SetSectionExeRange(VGPTNL_SECTIONORD_COLOURSETDEFAULTS,
dwSectionStart,
dwSectionEnd,
psContext);
}
/* Configure and enable vertex-colour passthrough if required */
if(dwColoursPresent)
{
/* Enable the colour passthrough section */
dwSectionsToEnable |= 1 << VGPTNL_SECTIONORD_COLOURPASSTHRU;
/*
Setup the section execution range to only output the
colour components that are present
*/
if(dwColoursPresent & PVRD3DTNL_FLAGS_DIFFUSE_PRESENT)
{
dwSectionStart = 0;
}
else
{
dwSectionStart = 1;
}
if(dwColoursPresent & PVRD3DTNL_FLAGS_SPECULAR_PRESENT)
{
dwSectionEnd = 1;
}
else
{
dwSectionEnd = 0;
}
SetSectionExeRange(VGPTNL_SECTIONORD_COLOURPASSTHRU,
dwSectionStart,
dwSectionEnd,
psContext);
}
/*
Enable and configure the texture coordinate passthrough section
as appropriate.
*/
dwTcCount = (dwTNLFlags & PVRD3DTNL_FLAGS_TC_COUNT_MASK) >>
PVRD3DTNL_FLAGS_TC_COUNT_SHIFT;
if(dwTcCount > 0)
{
dwSectionsToEnable |= 1 << VGPTNL_SECTIONORD_TEXCOORDPASSTHRU;
SetSectionExeRange(VGPTNL_SECTIONORD_TEXCOORDPASSTHRU,
0,
dwTcCount - 1,
psContext);
}
/* Set the required sections */
EnableSections(dwSectionsToEnable, psContext);
}
#if (defined(SUPPORT_VGP) && (COREVERSION >= 13)) || (defined(SUPPORT_VGP_LITE) && (COREVERSION >= 120))
/***********************************************************************************
Function Name : WriteBackVertices
Returns :
Description : Writes transformed and lit vertices back to a user vertex buffer
************************************************************************************/
IMG_VOID WriteBackVertices(LPD3DM_CONTEXT psContext,
PVRSRV_MEM_INFO *psVertices,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -