无法创建 Direct2D DXGI 曲面

发布于 2024-10-08 17:14:46 字数 607 浏览 0 评论 0原文

我正在调用此方法:

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

调用失败,并显示 E_NOINTERFACE。该文档对于为什么会发生这种情况特别没有帮助。我已经启用了所有 DirectX 11 调试功能,这是我得到的最好的结果。我知道我有一个有效的 IDXGISurface1* (也尝试过 IDXGISurface)并且其他参数设置正确。关于为什么此调用可能失败的任何想法?

编辑:

我在创建 D3D11 设备时也遇到问题。如果我在 D3D11CreateDeviceAndSwapChain 中将 nullptr 作为 IDXGIAdapter* 参数传递,则它可以正常工作,但如果我自己枚举适配器并传入一个指针(唯一返回的指针),则它会因参数无效而失败。 MSDN 文档明确指出,如果传递 nullptr,则系统使用 EnumAdapters1 的第一个返回值。我正在运行 DX11 系统。

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. The MSDN documentation explicitly says that if nullptr is passed, then the system uses the first return from EnumAdapters1. I am running a DX11 system.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猥琐帝 2024-10-15 17:14:47

Direct2D 仅在您创建 Direct3D 10.1 设备时才起作用,但它可以与 Direct3D 11 共享表面。您所需要做的就是创建这两个设备并将所有 Direct2D 内容渲染到您之间共享的纹理他们。我在自己的应用程序中使用此技术,将 Direct2D 与 Direct3D 11 结合使用。它会产生少量成本,但每帧成本很小且恒定。

您需要使用的过程的基本概要是:

  1. 像平常一样创建 Direct3D 11 设备。
  2. 使用 D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX 选项创建纹理,以允许访问 ID3D11KeyedMutex 接口。
  3. 使用 GetSharedHandle获取可以在设备之间共享的纹理的句柄。
  4. 创建 Direct3D 10.1 设备,确保它是在同一适配器上创建的。
  5. 在 Direct3D 10.1 设备上使用 OpenSharedResource 函数来获取 Direct3D 10.1 的纹理版本。
  6. 访问纹理的 D3D10 KeyedMutex 接口。
  7. 使用 Direct3D 10.1 版本的纹理通过 Direct2D 创建 RenderTarget。
  8. 当您想要使用 D2D 渲染时,请使用键控互斥锁来锁定 D3D10 设备的纹理。然后,在 D3D11 中获取它并渲染纹理,就像您可能已经尝试做的那样。

这并不简单,但效果很好,而且这也是他们希望您在它们之间进行互操作的方式。 Windows 8 看起来将引入完整的 D3D11 兼容性,因此它会像您期望的那样简单。

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.

一指流沙 2024-10-15 17:14:47

Direct2D 使用 D3D10 设备而不是 D3D11 设备。 D3D11 设备可能被 E_NOINTERFACE 报告为缺少接口。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文