在DirectX 11中跨适配器传输纹理 [英] Transferring textures across adapters in DirectX 11

查看:195
本文介绍了在DirectX 11中跨适配器传输纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Desktop Duplication API从一个GPU捕获桌面,并且需要将纹理(位于GPU内存中)复制到另一个GPU。为此,我有一个捕获线程,该线程获取桌面映像,然后使用ID3D11DeviceContext :: CopyResource将其复制到暂存资源(在同一设备上创建)。然后,我将暂存资源与Read映射,将目标动态资源(在另一台设备上创建的)映射到WriteDiscard并复制数据。在渲染线程上,我将ID3D11DeviceContext :: CopyResource从动态纹理执行到最终的渲染目标上。

I'm capturing the desktop with the Desktop Duplication API from one GPU and need to copy the texture (which is in GPU memory) to another GPU. To do this I have a capture thread that acquires the desktop image then copies it to a staging resource (created on the same device) using ID3D11DeviceContext::CopyResource. I then map that staging resource with Read, map the destination dynamic resource (which was created on the other device) with WriteDiscard and copy the data. On the rendering thread, I do a ID3D11DeviceContext::CopyResource from the dynamic texture onto the final render target.

这可行,但我在nvwgf2umx.dll中会出现随机崩溃。 (异常代码:0xc0000005)过一会儿(通常在30秒内)。创建两个设备时都没有创建单线程标志。我做了一些研究,并使用动态纹理似乎是执行此操作的最佳方法。

This works but I will get a random crash in nvwgf2umx.dll (Exception code: 0xc0000005) after a while (usually within 30 seconds). Both devices are created without the SingleThreaded creation flag. I did a bit of research and using a dynamic texture seemed like the best way to do this.

关于导致崩溃的原因有何想法?

Any ideas on what's causing the crash? Could it be a bug specific to the Nvidia driver?

推荐答案

您必须使用QueryInterface与其他设备共享资源吗?使用。在C#中看起来像这样(我想您是在使用C ++中的给定代码片段的地方)

You have to QueryInterface for a shared resource with the other device you are using. This would look like this in C# (what I guess you are really using beside given snippets in C++)

var sharedResource = aquiredDesktopTexture11.QueryInterface<SharpDX.DXGI.Resource>();
var sharedSurfDesktop = device11.OpenSharedResource<SharpDX.Direct3D11.Texture2D>(sharedResource.SharedHandle);

.. aquiredDesktopTexture11是原始捕获中的复制资源,然后sharedSurfDesktop可以由其他设备。还要确保用法是互斥的。

..were aquiredDesktopTexture11 is the copyed resource from the original capture, and sharedSurfDesktop then can be used by the other device. Also make sure the usage is mutual exclusive.

这篇关于在DirectX 11中跨适配器传输纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆