Hello,have you found some solutions?Do you use mutil id3d11device and device contex?
Using D3DImage with DirectX 11 in WPF?
Hi,
I'm trying to replace WriteableBitmap-based image display with D3Dimage for my WPF with .Net framework 4.8 program.
The reason that I want to use D3Dimage is to display a quite large 16bit grayscale or float image and to support contrast/brightness adjustment.
Because I render the surface using DirectX 11, I did the followings,
- I created a texture of DirectX 9 for render target which is used for D3Dimage backbuffer.
- I call CreateRenderTargetView of DirectX 11 using the handle received from the above creation of DirectX 9 texture.
- I call ID3D11DeviceContext::Flush after a series of DirectX 11 rendering commands.
Here is my question.
Is it enough to call ID3D11DeviceContext::Flush to synchronize DirectX11 of DirectX 9 texture and DirectX 9 texture?
I read Flush is a asynchronous function according to this [https://video2.skills-academy.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-flush. So I'm worried.
I'm asking this question because sometimes(not that frequently) I see flickering.(between ClearRenderTargetView state and all rendered state, this is my guess based on my analysis so far).
I also tried the following but it doesn't solve my problem.
ID3D11Query* pQuery = nullptr;
D3D11_QUERY_DESC queryDesc;
queryDesc.Query = D3D11_QUERY_EVENT;
m_pD11Device->CreateQuery(&queryDesc, &pQuery);
m_pD11DeviceContext->End(pQuery);
m_pD11DeviceContext->Flush();
while (m_pD11DeviceContext->GetData(pQuery, NULL, 0, 0) == S_FALSE)
{ }
I also tried to solve the problem using [https://github.com/microsoft/WPFDXInterop but I experienced the same phenomenon.
When it is okay, it displays like this. I called ClearRenderTargetView with green color for the demonstration.
When it is not okay, it displays like this. I'm rendering overlays using WPF so it still displays. I only render image using D3DImage
Thank you for reading.