The large vertex buffer was generated once and rendered
multiple times. The following is the rendering code.
In face, I render the large vertex buffer I mentions to a
texture. So the following code is before the BeginScene
()/EndScene() pair. If I delete the line of
DrawIndexedPrimitives() in the following code, the frame
rate will be normal, so I think the bottle-neck is
between the followings lines.
m_pRefVB and m_pRefIB is the large vertex buffer and
index buffer I mentioned.
m_renderprocess is variable, which encapsulates the
routine of rendering to any surface.(I do not use
ID3DXRenderToSurface, because I find it can use
multisample type).
The vertex buffer has the D3DFVF_XYZRHW set, with which I
want to bypass the vertex processing and pass my data
directly to the pixel shader.
Thanks a lot!
/////////////////////////////////////////////////////////
D3DVERTEXBUFFER_DESC desc;
m_pRefVB->GetDesc(&desc);
UINT numVertex=desc.Size/sizeof(TMeshFVF);
D3DINDEXBUFFER_DESC indexdesc;
m_pRefIB->GetDesc(&indexdesc);
UINT numIndices=indexdesc.Size/2;
IDirect3DSurface9* pSurface;
m_pShadowTexture->GetSurfaceLevel(0, &pSurface);
D3DVIEWPORT9 vp;
vp.Width=(DWORD)((m_rtWnd.right-
m_rtWnd.left)/2.0f);
vp.Height=(DWORD)((m_rtWnd.bottom-
m_rtWnd.top)/2.0f);
vp.MinZ=0.0f;
vp.MaxZ=1.0f;
vp.X=vp.Y=0;
m_renderprocess.EnableMultiSample
(FALSE,D3DMULTISAMPLE_NONE,0);
m_renderprocess.BeginRender(pSurface, vp);
m_pD3DDev9->Clear(0, NULL,
D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB
(255,255,255), 1.0f, 0);
m_pEffect->SetTechnique("ObjApproximate");
m_pEffect->SetFloatArray("vLightPos",
&m_sceneInfo.lightx, 3);
m_pEffect->SetFloat("sLightRange",
m_sceneInfo.lightrange);
UINT numPass;
m_pEffect->Begin(&numPass, 0);
m_pEffect->Pass(4);
m_pD3DDev9->SetFVF(SHADOWMAPFVF);
m_pD3DDev9->SetStreamSource(0, m_pRefVB, 0, sizeof
(TMeshFVF));
m_pD3DDev9->SetIndices(m_pRefIB);
HRESULT hr=m_pD3DDev9->DrawIndexedPrimitive
(D3DPT_TRIANGLELIST, 0, 0, numVertex, 0, numIndices/3);
m_pEffect->End();
m_renderprocess.EndRender();
pSurface->Release();
/////////////////////////////////////////////////////////