When I drew 3D objects and text together, the first frame was fine. However, the second frame failed. This bug took me very long time to debug. The pseudo code looks like this:
EveryFrame(){
Draw3d();
DrawText();
}
The shader generated following output:
D3D10: ERROR: ID3D10Device::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that the input stage requires Semantic/Index (POSITION,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND ]
Here is a post about the detail. Breafly speaking, DirectX DrawText() function changes the inner state of device; therefore, the input layout is changed after the first frame and, of course, the program failed in the second frame.
The solution is to use D3DX10_SPRITE_SAVE_STATE flag.
void cGraphicsLayer::DrawTextString(int x, int y,
D3DXCOLOR color, const TCHAR* strOutput)
{
m_pFontSprite->Begin(D3DX10_SPRITE_SAVE_STATE);
RECT rect = {x, y, m_rcScreenRect.right, m_rcScreenRect.bottom};
m_pFont->DrawText(m_pFontSprite, strOutput, -1, &rect, DT_LEFT, color);
m_pFontSprite->End();
}