1

I'm working on DXGI screenshot, there are lots of examples on google and they work fine (like https://github.com/pgurenko/DXGICaptureSample/blob/master/DXGICaptureSample/DXGIManager.cpp). Then i find Windows 10 built in Screen snip tool and have the interest to check if it is using DXGI or not. After loading it in windbg, i see it calls D3D11!D3D11CreateDevice and dxgi!CDXGIAdapter::EnumOutputs as expected, but it NEVER calls dxgi!CDXGIOutput::DuplicateOutput as all example codes that i can find do. So the question is how does it capture screen then?

herb
  • 139
  • 8

1 Answers1

1

To put it simply, The way DXGI captures the screen is by first receiving a pointer to the 2d texture of the screen known as the framebuffer in the GPU. Then that pointer(along with the textures height, width, etc. description) reads from the GPU and copies the data to the CPU memory. This is why people's framerate suffers when they start streaming because the bus(the connection between the CPU and GPU) is not very large. This image now exists in both the GPU and CPU ram until the next draw call when the framebuffer is overwritten.

Just doing some quick searching online (https://learn.microsoft.com/en-us/windows/win32/direct3darticles/dxgi-best-practices) using DXGI can be a "headaches for developers". My suggestion would be to check the formatting of the screen and see if it is interfering with DXGI. Changing anything in the framebuffer on the same frame your duplicating can cause problems.

capslpop
  • 73
  • 9
  • thank you for explanation, capslpop. But i want to know how Screen snip works in DXGI API level. Also i found that ScreenClippingHost.exe thhat i debugged was introduced since Win10 20H1, it should be a component inside explorer before. – herb Dec 11 '20 at 11:02