Direct3D 9 创建和释放线程?

发布于 2024-10-12 10:54:15 字数 383 浏览 6 评论 0原文

我有一个使用 Direct3D 渲染视口的应用程序,它是作为一个独立于主应用程序的 DLL 模块而在运行时链接到它的。主要应用程序是 C# 程序。

Direct3D设备及其资源的创建和初始化是在本机DLL端完成的。主 C# 程序仅从此 DLL 请求一个窗口。现在,由于主 GUI 循环位于 C# 可执行文件中,因此每当视口关闭/销毁时,它都必须调用 DLL 函数来请求释放相关的 Direct3D 设备/资源。

问题是,在尝试释放 Direct3D 设备时,程序会出现紧急情况。它表示有一个不同的线程(我猜是主 C# 程序,因为它将消息发送到 DLL),而不是创建设备并试图释放它。

有解决这个问题的方法吗?有什么想法吗?

我正在使用 Direct3D 9。

感谢帮助。

I have an application that uses Direct3D for rendering viewports and it's made as a separate DLL module from the main application which links to it at run-time. The main application is a C# program.

The creation and initialization of Direct3D device and its resources are done on the native DLL end. The main C# program only request a window from this DLL. Now since the main GUI loop is in the C# executable, whenever a viewport is closed/destroyed it has to call a DLL function to request release of related Direct3D device/resources.

The problem is that upon trying to release the Direct3D device, the program panics. It says that a different thread (the main C# program I guess since it's sending the message to the DLL) than that created the device trying to release it.

Is there a work around this problem? Any thoughts?

I'm using Direct3D 9.

Help appreciated.

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

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

发布评论

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

评论(1

冰火雁神 2024-10-19 10:54:15

D3D 设备调用都与创建它们的线程具有线程关联性。

您必须将回调编组回主 D3D 线程,或者使用 D3DCREATE_MULTITHREADED 初始化设备,以便允许从多个线程使用它。

D3D Device calls all have thread affinity with the thread on which they were created.

You have to either marshal the call back to the main D3D thread, or initialize the device with D3DCREATE_MULTITHREADED in order to allow it to be used from multiple threads.

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