Using Direct2D to draw on Direct3D11 surface
Asked Answered
C

4

5

I am trying to create a Media Foundation Transform that draws text on video using D2D and D3D11. I am trying to construct a D2D RenderTarget on top of D3D11 resources, but unfortunately, most means of D2D and D3D interop require D3D10, which is not available within this project.

The parameters I have to work with are as follows: ID3D11Device *pDevice, ID3D11Texture2D *pInput, UINT uiInIndex, ID3D11Texture2D *pOutput, and UINT uiOutIndex.

I attempted to follow the advice of this tutorial, but it turns out that it requires a ID3D10Texture2D object, which again is not an option for me.

Circumbendibus answered 2/8, 2012 at 4:55 Comment(0)
C
5

Essentially you copy the frame from the input texture to the output texture, then do the following to retrieve an IDXGI surface:

IDXGISurface *surface;
pOutput->QueryInterface(&surface);

Then, follow the steps in this tutorial to turn the surface into a Direct2D render target. Once you have the render target, you can draw on it in a similar manner to how the tutorial draws the gradient.

Circumbendibus answered 2/8, 2012 at 21:25 Comment(0)
B
5

I met the same problem before, it's depende on which system you are runing.

  1. On Windows 7, only Direct3D 10 support interoperate with Direct2D
  2. On Windows 8, Direct2D can interoperate with Direct3D 11
Bivalent answered 10/11, 2012 at 13:4 Comment(0)
A
1

Do you create a swap chain? You could creat one with IDXGIFactory2::CreateSwapChainForCoreWindow or CreateSwapChainForComposition if you use XAML UI. Then after you render your d3d stuff, you can creat d2d target and render on top just like in this d3d tutorial sample, look for "sampleOverlay.cpp"

http://code.msdn.microsoft.com/windowsapps/Direct3D-Tutorial-Sample-08667fb0/sourcecode?fileId=44730&pathId=1319002242

Aristaeus answered 2/8, 2012 at 5:21 Comment(1)
I ideally would like to map the d2d drawings onto the frames of the selected video, which the d3d context and device initially have access to. I thought swapchains were designed for windows -- can they be used in this scenario to apply drawings to the frames of a video stream?Circumbendibus
S
0

CreateBitmapFromDxgiSurface

The bitmap's underlying memory is the IDXGISurface. You can QI a ID3D11Texture2D to get a IDXGISurface.

Stuffed answered 23/8, 2023 at 22:40 Comment(1)
This is an 11 year old post.Isolating

© 2022 - 2024 — McMap. All rights reserved.