How to apply ID2D1Effect into Direct3D render target RRS feed

  • Question

  • 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.

    Thursday, January 31, 2013 9:07 AM

All replies

  • Hello,
    I will involve more experts to investigate it.
    Best regards,

    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 4, 2013 10:08 AM
  • If you're using Direct3D 10.1 then you're writing a desktop app instead of a Windows Store app.  I'm going to move this post to the correct forum.

    EDIT:  I can't move this to the correct forum but you can re-post your question here:

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, February 8, 2013 3:31 PM