Hello,
I don't know if I am in the correct part of the forum but I hope so. I have to following problem: I have ID3D10RenderTargetView (it's Direct3D 10.1 but I think that it is same for Direct3D 11) and I want to apply Direct2D effect (ID2D1Effect) on its part
without excessive data copying.
Currently I follow this article http://msdn.microsoft.com/en-us/library/windows/desktop/dd370966(v=vs.85).aspx so I get IDXGISurface from ID3D10RenderTargetView's texture and then create Direct2D render target from it (using function d2dfactory->CreateDxgiSurfaceRenderTarget).
Then I create intermediate ID2D1Bitmap where I copy the requested rectangle from Direct2D render target (using bitmap->CopyFromRenderTarget). Now I can use this bitmap as the input to the ID2D1Effect (effect->SetInput(0, bitmap)) and draw this effect
back to render target (context->DrawImage(effect, destPoint, srcRect)). This works correctly, effect is applied but it is slow if I do it very often (I can cache the intermediate bitmap not to recreate it with every render but it does not help much).
(Now, I draw the effect into another ID3D10Texture2D which is rendered using direct3dDevice->Draw, because I want to apply effect only to region specified by direct3D vertex buffer (which is mostly the rectangle with the "hole" inside) and not
to whole rectangle (to exclude the "hole" inside. Can Direct2D be configured to draw effect into certain region only? - this is the another question which is not so important now)
I would like to ask whether there is some better (faster) method to apply Direct2D effect into Direct3D render target, because my solution seems to be slow. It always takes 0.3 ms regardless the size of the area where I want to apply the effect. How does
the Direct2D effects really work - does it apply the effect to whole input bitmap and then only draws requested rectangle in DrawImage, or does it apply effect only to the rectangle specified in DrawImage?
I have tried CreateBitmapFromDxgiSurface and CreateSharedBitmap to avoid copying render target's content into intermediate bitmap but this does not work at all. Direct2D's context->EndDraw fails with error.
Thanks in advance.