不能使用PerfHUD的原因
the reason why we can not use PerfHUD :
usually, the default SwapChain will be used when the d3d device is created.
通常情况下,当创建好d3d设备时,会使用默认的SwapChain,
the process of render is as follows:
渲染流程如下:
d3d9->CreateDevice(AdapterToUse, DeviceType,hwnd, vp, &d3dpp, &Device);
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
Device->BeginScene();
Device->SetStreamSource(0, Triangle, 0, sizeof(Vertex));
Device->SetFVF(Vertex::FVF);
// Draw one triangle.
Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
Device->EndScene();
Device->Present(0, 0, 0, 0);
很多编辑器的渲染结构,不使用上面的方式,而是会创建单独的SwapChain,
这样的好处是可以在多窗口中使用d3d设备
the process is as follows:
流程如下:
d3d9->CreateDevice(AdapterToUse, DeviceType,hwnd, vp, &d3dpp, &Device);
D3DPRESENT_PARAMETERS presentParams = {0};
presentParams.BackBufferFormat = D3DFMT_A8R8G8B8;
presentParams.BackBufferCount = 1;
presentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
presentParams.Windowed = TRUE;
presentParams.hDeviceWindow = hwnd;
presentParams.MultiSampleType = D3DMULTISAMPLE_NONE;
presentParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
Device->CreateAdditionalSwapChain( &presentParams,&SwapChain);
IDirect3DSurface9 *pTempD3dSurface9 = NULL;
SwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &pTempD3dSurface9 );
Device->SetRenderTarget( 0, pTempD3dSurface9 );
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0);
Device->BeginScene();
Device->SetStreamSource(0, Triangle, 0, sizeof(Vertex));
Device->SetFVF(Vertex::FVF);
// Draw one triangle.
Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
Device->EndScene();
SwapChain->Present(0,0,0,0,0);
目前PerfHUD不支持这种另外创建SwapChain的方式