My code looks like this:
while(running)
{
DoSomePrepare();
RenderToSurface(pASurface); // both RT surface are in D3DPOOL_SYSTEMMEM
DoOthrePrepare();
RenderToSurface(pAnotherSurface);
}
RenderToSurface(IDirect3DSurface9 *pSurface)
{
pRenderToASurface->BeginScene(pSurface, NULL); // BeginScene already in Begin/End pair
RenderScene();
pRenderToSurface->EndScene(D3DX_FILTER_NONE);
}
RenderScene()
{
// Use critical section lock resource
for_each(primitiveInScene)
{
DoCPUApplicationWork();
UpdateShaderParas();
BeginPass();
Render();
EndPass();
}
// Unlock critical section
}
Another question:
Which is more efficient:
1. Begin/End effect for each primitive, just like what I do.
2. Begin/End effect one/several time(s) and use CommitChanges.
Any reply will be appreciated.