I would like to have a very fast screen capture in a loop, extracting a portion of this data to send to a server. To start, I made some small additions to your (great) code, to try and benchmark the capturing of multiple desktops.
- Brought everything into Visual Studio 17, x64
- Made changes to get things to compile, for four CComQIPtr assignments:
CComQIPtr<ID3D11Texture2D> spTextureResource = CComQIPtr<ID3D11Texture2D>(spDXGIResource);
CComQIPtr<IDXGISurface1> spDXGISurface = CComQIPtr<IDXGISurface1>(spD3D11Texture2D);
CComQIPtr<IDXGIOutput1> spDXGIOutput1 = CComQIPtr<IDXGIOutput1>(*OutputIter);
CComQIPtr<IDXGIDevice1> spDXGIDevice = CComQIPtr<IDXGIDevice1>(spD3D11Device);
- Added a loop around GetOutputBits, and timed it (using std::chrono, not shown)
for (int j = 0; j < 10; j++) {
int i = 0;
do {
hr = g_DXGIManager.GetOutputBits(pBuf, rcDim);
i++;
} while (hr == DXGI_ERROR_WAIT_TIMEOUT || i < 2);
if( FAILED(hr) ) {
printf("GetOutputBits failed with hr=0x%08x\n", hr);
return hr;
}
}
When I run this, it takes a long time, if I don't move the mouse. With no mouse movement, it typically takes 3.6 - 4.2s. If I move the mouse continuously, then run, it takes 137 ms.
I don't need the mouse pointer graphics information in the screen grab. I've tried both leaving in the 'mouse pointer' code and commenting it out, but it doesn't seem to make a difference.
I've run this on both my PC (running virtual desktop) and laptop (single desktop), and the behavior is similar (~1.8s no movement; ~158 ms movement).
I've also tried both CSDesktop and CSMonitor1, the behavior is the same.
Questions:
- Do you have any idea why the mouse might be holding up continuous acquisition?
- If I wanted to preprocess the screen-grab on the GPU card (e.g. with CUDA code) - is there a logical place to insert this? (I'm very new to Direct3D.)
I would like to have a very fast screen capture in a loop, extracting a portion of this data to send to a server. To start, I made some small additions to your (great) code, to try and benchmark the capturing of multiple desktops.
When I run this, it takes a long time, if I don't move the mouse. With no mouse movement, it typically takes 3.6 - 4.2s. If I move the mouse continuously, then run, it takes 137 ms.
I don't need the mouse pointer graphics information in the screen grab. I've tried both leaving in the 'mouse pointer' code and commenting it out, but it doesn't seem to make a difference.
I've run this on both my PC (running virtual desktop) and laptop (single desktop), and the behavior is similar (~1.8s no movement; ~158 ms movement).
I've also tried both
CSDesktopandCSMonitor1, the behavior is the same.Questions: