Skip to content

Commit 8a62d70

Browse files
committed
shaderapidx9: Speedup hot CMeshDX8::CheckIndices in DEBUG mode
1 parent 130c910 commit 8a62d70

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

materialsystem/shaderapidx9/meshdx8.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,33 +3352,34 @@ void CMeshDX8::CheckIndices( CPrimList *pPrim, int numPrimitives )
33523352
{
33533353
Assert( pPrim->m_FirstIndex >= 0 && pPrim->m_FirstIndex < g_pLastIndex->IndexCount() );
33543354

3355-
const int maxVertexIdx = (int)( s_FirstVertex + m_FirstIndex );
3355+
const unsigned maxVertexIdx = s_FirstVertex + m_FirstIndex;
33563356

33573357
{
33583358
CVertexBuffer* pMesh = g_pLastVertex;
33593359

3360-
Assert( pMesh && maxVertexIdx < pMesh->VertexCount() );
3360+
Assert( pMesh && maxVertexIdx < (unsigned)pMesh->VertexCount() );
33613361
}
33623362

3363+
if ( g_pLastColorMesh )
33633364
{
3364-
CVertexBuffer* pMesh = g_pLastColorMesh ? g_pLastColorMesh->m_pVertexBuffer : NULL;
3365+
CVertexBuffer* pMesh = g_pLastColorMesh->m_pVertexBuffer;
33653366

3366-
if ( pMesh )
3367-
{
3368-
Assert( maxVertexIdx < pMesh->VertexCount() );
3369-
}
3367+
Assert( maxVertexIdx < (unsigned)pMesh->VertexCount() );
33703368
}
33713369

3372-
for (int j = 0; j < nIndexCount; j++)
3370+
const int upperPrimIndexBound = nIndexCount + pPrim->m_FirstIndex;
3371+
const int upperShadowIndexBound = s_FirstVertex + s_NumVertices;
3372+
3373+
for (int j = pPrim->m_FirstIndex; j < upperPrimIndexBound; j++)
33733374
{
3374-
const unsigned int index = g_pLastIndex->GetShadowIndex( j + pPrim->m_FirstIndex );
3375+
const unsigned index = g_pLastIndex->GetShadowIndex( j );
33753376

3376-
if (index >= s_FirstVertex && index < s_FirstVertex + s_NumVertices)
3377+
if (index >= s_FirstVertex && index < upperShadowIndexBound)
33773378
{
33783379
continue;
33793380
}
33803381

3381-
Warning("%s invalid index: %d [%u..%u]\n", __FUNCTION__, index, s_FirstVertex, s_FirstVertex + s_NumVertices - 1);
3382+
Warning("%s invalid index: %u [%u..%u]\n", __FUNCTION__, index, s_FirstVertex, upperShadowIndexBound - 1);
33823383

33833384
Assert( false );
33843385
}
@@ -3451,7 +3452,7 @@ void CMeshDX8::RenderPass()
34513452

34523453
numPrimitives );// Number of primitives to render. The number of vertices used is a function of the primitive count and the primitive type.
34533454
}
3454-
}
3455+
}
34553456
}
34563457
}
34573458

0 commit comments

Comments
 (0)