trying to speed up render of model ?

Started by
0 comments, last by mmakrzem 12 years, 11 months ago


void CRenderManager::RenderModel(SMesh* meshPointer, SShader* shaderPointer)
{
if (!meshPointer->m_HasGeometry)
return;

m_meshPointerNew = meshPointer;

if (m_meshPointerOld != m_meshPointerNew) // runs about 15% faster with this
{
m_meshPointerOld = m_meshPointerNew;

// Select vertex and index buffer - assuming all data will be as triangle lists
UINT offset = 0;
g_pd3dDevice->IASetVertexBuffers( 0, 1, &meshPointer->m_VertexBuffer, &meshPointer->m_VertexSize, &offset );
g_pd3dDevice->IASetInputLayout( meshPointer->m_VertexLayout );
g_pd3dDevice->IASetIndexBuffer( meshPointer->m_IndexBuffer, DXGI_FORMAT_R16_UINT, 0 );
g_pd3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
}

// Render the model. All the data and shader variables are prepared, now select the technique to use and draw.
// The loop is for advanced techniques that need multiple passes - we will only use techniques with one pass
D3D10_TECHNIQUE_DESC techDesc;
shaderPointer->m_shaderTechniqueMap->GetDesc( &techDesc );
for( UINT p = 0; p < techDesc.Passes; ++p )
{
shaderPointer->m_shaderTechniqueMap->GetPassByIndex( p )->Apply( 0 );
g_pd3dDevice->DrawIndexed( meshPointer->m_NumIndices, 0, 0 );
}
}



cant figure out how to make this run faster , is there any other obviuos ways ?
Advertisement
how many vertices are in your mesh?

This topic is closed to new replies.

Advertisement