📄 drawprim.c
字号:
/* reset process vertices mode */
psContext->dwFlags &= ~D3DM_CONTEXT_SWFLAGS_PROCVERT_MODE;
/* Reset rotation mode */
if(dwCurrentRotation != 0)
{
psContext->dwRotationAngle = dwCurrentRotation;
SetupViewportTransform(psContext);
}
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_ProcessVertices"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_DrawPrimitive
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_DrawPrimitive(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i=0;
ULONG ulBytesProcessed;
LPD3DM_DRAWPRIMITIVE psCurrentOp;
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_DRAWPRIMITIVE) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_DrawPrimitive"));
D3DMAcquireTAResources(psContext, IMG_TRUE);
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current operation */
DrawPrimitive ( psContext,
psCurrentOp->PrimType,
psCurrentOp->StartVertex,
psCurrentOp->PrimitiveCount);
ulBytesProcessed += sizeof(D3DM_DRAWPRIMITIVE);
}
D3DMReleaseTAResources(psContext, IMG_FALSE);
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_DrawPrimitive"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_DrawIndexedPrimitive
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_DrawIndexedPrimitive(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i;
ULONG ulBytesProcessed;
LPD3DM_DRAWINDEXEDPRIMITIVE psCurrentOp;
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_DRAWINDEXEDPRIMITIVE) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_DrawIndexedPrimitive"));
D3DMAcquireTAResources(psContext, IMG_TRUE);
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current operation */
DrawIndexedPrimitive ( psContext,
psCurrentOp->PrimType,
psCurrentOp->MinIndex,
psCurrentOp->NumVertices,
psCurrentOp->StartIndexOffset,
psCurrentOp->PrimitiveCount,
psCurrentOp->BaseVertexIndex);
ulBytesProcessed += sizeof(D3DM_DRAWINDEXEDPRIMITIVE);
}
D3DMReleaseTAResources(psContext, IMG_FALSE);
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_DrawIndexedPrimitive"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_VertexBuffer
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_VertexBuffer(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i;
ULONG ulBytesProcessed;
LPD3DM_VERTEXBUFFER psCurrentOp;
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
WORD j;
DWORD dwTNLFlags;
DWORD dwFFComponents;
DWORD dwTexCoordSetCount;
IMG_BOOL bCurrentHasRHW = IMG_FALSE;
#endif
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_VERTEXBUFFER) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_VertexBuffer"));
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current operation */
ulBytesProcessed += sizeof(D3DM_VERTEXBUFFER);
psContext->psVertexSource = (LPD3DM_VBUFFER) psCurrentOp->BufferId;
if(!psContext->psVertexSource)
{
continue;
}
#if defined (SUPPORT_VGP) || defined (SUPPORT_VGP_LITE)
/* Check status of current VGP position section */
if(psContext->dwVGPLastFVF != 0)
{
bCurrentHasRHW = (psContext->dwVGPLastFVF & D3DMFVF_XYZRHW_FLOAT ||
psContext->dwVGPLastFVF & D3DMFVF_XYZRHW_FIXED);
}
if((psContext->psVertexSource->dwFVFFlags & D3DMFVF_POSITION_MASK) == D3DMFVF_XYZRHW_FLOAT ||
(psContext->psVertexSource->dwFVFFlags & D3DMFVF_POSITION_MASK) == D3DMFVF_XYZRHW_FIXED)
{
psContext->sTState.sSWTNLState.dwTNLFlags &= ~PVRD3DTNL_FLAGS_ENABLED;
if(!bCurrentHasRHW)
{
/* We need to update position section */
psContext->sTState.sSWTNLState.dwSectionModFlags |= (1 << VGPTNL_SECTIONORD_POSITION);
}
}
else
{
psContext->sTState.sSWTNLState.dwTNLFlags |= PVRD3DTNL_FLAGS_ENABLED;
if(bCurrentHasRHW || (psContext->dwVGPLastFVF == 0))
{
/* We need to update position section */
psContext->sTState.sSWTNLState.dwSectionModFlags |= (1 << VGPTNL_SECTIONORD_POSITION);
}
}
/* Store off current FVF */
psContext->dwVGPLastFVF = psContext->psVertexSource->dwFVFFlags;
/* Update the TNL flags based upon the new vertex data type type */
dwTNLFlags = psContext->sTState.sSWTNLState.dwTNLFlags;
dwTNLFlags &= ~(PVRD3DTNL_FLAGS_DECLARATION_CHANGED |
PVRD3DTNL_FLAGS_DIFFUSE_PRESENT |
PVRD3DTNL_FLAGS_SPECULAR_PRESENT |
PVRD3DTNL_FLAGS_TC_COUNT_MASK);
dwTNLFlags |= PVRD3DTNL_FLAGS_DECLARATION_CHANGED;
dwFFComponents = psContext->psVertexSource->sVSIFDef.dwFFComponents;
if(dwFFComponents & FFVTXCOMPONENT_TYPE_DIFFUSE)
{
dwTNLFlags |= PVRD3DTNL_FLAGS_DIFFUSE_PRESENT;
}
if(dwFFComponents & FFVTXCOMPONENT_TYPE_SPECULAR)
{
dwTNLFlags |= PVRD3DTNL_FLAGS_SPECULAR_PRESENT;
}
dwTexCoordSetCount = 0;
for (j = 0; j < MBX1_MAXTEXTURE_LAYERS; j++)
{
if (dwFFComponents & (FFVTXCOMPONENT_TYPE_TEX0 << j))
{
dwTexCoordSetCount++;
}
}
dwTNLFlags &= ~PVRD3DTNL_FLAGS_TC_COUNT_MASK;
dwTNLFlags |= (dwTexCoordSetCount << PVRD3DTNL_FLAGS_TC_COUNT_SHIFT) &
PVRD3DTNL_FLAGS_TC_COUNT_MASK;
/*
If lighting is enabled, Update the lighting colour sources
since they depend upon the vertex format
*/
if(psContext->sTState.dwRSFlags & TSTATE_RSFLAGS_LIGHTING)
{
ProcessLightingColourSources(psContext);
}
psContext->sTState.sSWTNLState.dwTNLFlags = dwTNLFlags;
/* update Interface Def HW State */
psContext->sHWState.sTACtl3DState.dwVGPIFDef = psContext->psVertexSource->sVSIFDef.dwVGPIFDef;
psContext->sHWStateCtl.dwTACtl3DStateChanged |= MBX1_TASTATEPRES_VGP_IFDEFINITION;
#endif
}
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_VertexBuffer"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_IndexBuffer
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_IndexBuffer(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i;
ULONG ulBytesProcessed;
LPD3DM_INDEXBUFFER psCurrentOp;
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_INDEXBUFFER) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_IndexBuffer"));
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current operation */
ulBytesProcessed += sizeof(D3DM_INDEXBUFFER);
psContext->psIndexSource = (LPD3DM_IBUFFER) psCurrentOp->BufferId;
if(psContext->psIndexSource)
{
psContext->ui32IndexMask = (psContext->psIndexSource->eFormat == D3DMFMT_INDEX16) ? 0x0000FFFF : 0xFFFFFFFF;
}
}
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_IndexBuffer"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_ColorFill
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_ColorFill(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i;
ULONG ulBytesProcessed;
LPD3DM_COLORFILL psCurrentOp;
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_COLORFILL) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_ColorFill"));
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current ColourFill */
ColourFill(psCurrentOp);
ulBytesProcessed += sizeof(D3DM_COLORFILL);
}
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_ColorFill"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: D3DM_DP_OP_StretchRect
PURPOSE:
PARAMETERS: In: psContext - Context to operate on
In: pvCommandData - Pointer to command ops to execute
In: nCount - number of ops of this type to process
RETURNS: number of bytes processed
</function>
------------------------------------------------------------------------------*/
ULONG D3DM_DP_OP_StretchRect(LPD3DM_CONTEXT psContext, LPVOID pvCommandData, WORD nCount)
{
WORD i;
ULONG ulBytesProcessed;
LPD3DM_STRETCHRECT psCurrentOp;
ulBytesProcessed = 0;
psCurrentOp = (LPD3DM_STRETCHRECT) pvCommandData;
D3DM_DPF((DPF_ENTRY, "->D3DM_DP_OP_StretchRect"));
for(i=0; i <nCount; i++, psCurrentOp++)
{
/* Process current StretchRect */
StretchRect(psCurrentOp);
ulBytesProcessed += sizeof(D3DM_STRETCHRECT);
}
D3DM_DPF((DPF_EXIT, "<-D3DM_DP_OP_StretchRect"));
return ulBytesProcessed;
}
/*----------------------------------------------------------------------------
<function>
FUNCTION: PVRD3DM_DrawPrimitive
PURPOSE: Entry Point for Processing a series of DP commands from the
supplied command buffer.
PARAMETERS: In: pdpd - Data for command buffer execution
RETURNS: D3DM_DRIVER_HANDLED
</function>
------------------------------------------------------------------------------*/
DWORD PVRD3DM_DrawPrimitive(D3DM_DRAWPRIMITIVE_DATA *pdpd)
{
LPD3DM_CONTEXT psContext;
LPD3DM_COMMAND psCurrentCommand;
LPVOID pvCommands;
LPVOID pvFirstOp;
ULONG ulCurrentOffset;
ULONG ulEndOffset;
D3DM_DPF((DPF_ENTRY, "->PVRD3DM_DrawPrimitive"));
psContext = (LPD3DM_CONTEXT) pdpd->nContextId;
ulCurrentOffset = pdpd->nStartOffset;
ulEndOffset = pdpd->nEndOffset;
pvCommands = pdpd->pCommands;
psContext->hrLastError = D3DM_OK;
while(ulCurrentOffset < ulEndOffset)
{
/* Parse the command tokens */
psCurrentCommand = (LPD3DM_COMMAND)((LPBYTE)pvCommands + ulCurrentOffset);
ulCurrentOffset += sizeof(D3DM_COMMAND);
pvFirstOp = (LPVOID)((LPBYTE)pvCommands + ulCurrentOffset);
/* Call into the DP Op handler table */
ulCurrentOffset +=
psContext->ppfnsDPOpHandlers[psCurrentCommand->nCommand](psContext,
pvFirstOp,
psCurrentCommand->nCount);
}
/* return last error */
pdpd->rval = psContext->hrLastError;
D3DM_DPF((DPF_EXIT, "<-PVRD3DM_DrawPrimitive"));
return D3DM_DRIVER_HANDLED;
}
/*****************************************************************************
End of file (DrawPrim.c)
*****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -