@勇强 韩 , After investigate the code further, there are two problems in the code.
1.There is a problem with the way about using smart pointers. The original code in RenderFrameRGB is:
else {
…
hres = m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&m_pDXGIBackBuffer.p);
if (FAILED(hres)) {
return false;
}
m_pD3D11Ctx->UpdateSubresource(m_pDXGIBackBuffer, 0, NULL, m_pOneFrame, m_iWidth * 4, 0);
}
&m_pDXGIBackBuffer.p is wrong. This will overwrite the previous pointer value stored in m_pDXGIBackBuffer, causing the object to leak. The correct code is:
CComQIPtr<ID3D11Texture2D> pDXGIBackBuffer;
hres = m_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&pDXGIBackBuffer);
if (FAILED(hres)) {
return false;
}
m_pD3D11Ctx->UpdateSubresource(pDXGIBackBuffer, 0, NULL, m_pOneFrame, m_iWidth * 4, 0);
There are other places do the same thing. Though they are not leaking any objects, I suggest fix all of them.
The following is fine, though, because the function takes an array of pointers and it does not modify the array:
(ID3D11RenderTargetView * const *ppRenderTargetViews):
m_pD3D11Ctx->OMSetRenderTargets(1, &m_pRenderView.p, NULL);
2 . DWM appears to be still in the flip mode for the window.
If you restart DWM.exe, Dx9 Blt (or Dx11 Blt or GDI) starts working. Since the DWM issue is complex and requires more time to investigate, please create a support case so that our engineers can work with you closely and help fix the issue as soon as possible. Please refer to the link below and click the Contact US to open a support case: