开发者

Can't create Direct2D DXGI Surface

I'm calling this method:

http://msdn.microsoft.com/en-us/library/dd371264(VS.85).aspx

The call fails with E_NOINTERFACE. The documentation is especially unhelpful as to why this may happen. I've enabled all of the DirectX 11 debug stuff and that's the best I got. I know that I have a valid IDXGISurface1* (also tried IDXGISurface) and the other parameters are set correctly. Any ideas as to why this call may fail?

Edit:

I also am having problems creating D3D11 devices. If I pass nullptr as the IDXGIAdapter* argument in D3D11CreateDeviceAndSwapChain, it works fine, but if I enumerate the adapters myself and pass in a pointer (the only one returned), it fails with invalid argument. Th开发者_JAVA百科e MSDN documentation explicitly says that if nullptr is passed, then the system uses the first return from EnumAdapters1. I am running a DX11 system.


Direct2D only works when you create a Direct3D 10.1 device, but it can share surfaces with Direct3D 11. All you need to do is create both devices and render all of your Direct2D content to a texture that you share between them. I use this technique in my own applications to use Direct2D with Direct3D 11. It incurs a slight cost, but it is small and constant per frame.

A basic outline of the process you will need to use is:

  1. Create your Direct3D 11 device like you do normally.
  2. Create a texture with the D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX option in order to allow access to the ID3D11KeyedMutex interface.
  3. Use the GetSharedHandle to get a handle to the texture that can be shared among devices.
  4. Create a Direct3D 10.1 device, ensuring that it is created on the same adapter.
  5. Use OpenSharedResource function on the Direct3D 10.1 device to get a version of the texture for Direct3D 10.1.
  6. Get access to the D3D10 KeyedMutex interface for the texture.
  7. Use the Direct3D 10.1 version of the texture to create the RenderTarget using Direct2D.
  8. When you want to render with D2D, use the keyed mutex to lock the texture for the D3D10 device. Then, acquire it in D3D11 and render the texture like you were probably already trying to do.

It's not trivial, but it works well, and it is the way that they intended you to interoperate between them. Windows 8 looks like it will introduce full D3D11 compatibility, so it will be just as simple as you expect.


Direct2D uses D3D10 devices not D3D11 devices. D3D11 device is probably that is reported as lacking interface by that E_NOINTERFACE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜