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!
I do call the TryGetNextFrame method.
My constructor looks as follows:
and than my callback looks like this:
Also yo make it clear the program runs without issues in directx11 environment. this only pops up in directx12...
The problem more related with dx12 environment, can you provide a mini repro sample for us, I will discuss with team to check if it is know issue.
Please find here a little project illustrating the issue with approach 1: https://github.com/Off-World-Live/d3d11on12CaptureTest
The project is a quick implementation on top of the directX12 HelloTexture project.
It doesn't actually render anything of interest, but the information is illustrated in the debug console which runs when we execute the build.
It shows that the
OnFrameArrivedis only being called the exact number of times that the NumBuffers specified in the WinRTCapture.h.
Most of the relevant code is inside the WinRTCapture class, but the other important parts are
Got it, I will discuss with team, If any updates I will share below.
Any updates on this?
Sign in to comment