winrt::Windows::Graphics::Capture API on DirectX12

mzlt666 1 Reputation point
2022-08-17T17:09:58.553+00:00

I am trying to capture my monitor from a DirectX12 application using the Windows Runtime Capture API.
I tried doing this in two ways so far:

  • approach 1: use the D3D11On12CreateDevice function to create ID3D11Device and use that device to get the IDXGIDevice and CreateDirect3D11DeviceFromDXGIDevice from there.
  • Problem: in this situation the FrameArrived callback only gets called the exact amount of times as the number of declared buffers in the winrt::Windows::Graphics::Capture::Direct3D11CaptureFramePool::Create function. i.e. if the number of buffers is 2 it will only capture 2 frames.
  • approach 2: create new Device from the adapter using the use the D3D11CreateDevice function to create ID3D11Device and use that device to get the IDXGIDevice and CreateDirect3D11DeviceFromDXGIDevice from there. Also use the D3D11On12CreateDevice function to be able to copy the ID3D11Texture2D Texture into the Wrapped ID3D12Resource Resource.
  • Problem: in this situation the FrameArrived callback behaves as expected but the texture I copy into my wrapped resource is transparent. (I can correctly receive the Width, Height and PixelFormat of the texture but after the copy is performed into my wrapped resource the Render Target is still in it's clear colour).

Is there a better/ tested way of approaching this?

Any help would be great!

Universal Windows Platform (UWP)
{count} votes