销毁directx设备和交换链 [英] destroy directx device and swap chain

查看:140
本文介绍了销毁directx设备和交换链的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的问题,我认为涉及 D3D11CreateDeviceAndSwapChain 我可以创建设备和交换链,但是当应用程序退出和 - > 在交换链,设备和设备上下文中调用,线程仍在运行。注释掉此行应用程序会按预期终止。

I am encountering a strange issue I think involves D3D11CreateDeviceAndSwapChain I can create the device and swap chain however when the application exits and ->destroy gets called on the swap chain, device, and device context a thread is still running. Commenting out this line the application terminates as expected.

featureLevel = D3D_FEATURE_LEVEL_11_0;
result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &m_swapChain, &m_device, NULL, &m_deviceContext);

if(FAILED(result))
{
#ifdef _DEBUG
    log(logDEBUG) << "Error at D3D11CreateDeviceAndSwapChain";
#endif
    return false;
}
return true;

和销毁:

if(m_swapChain)
{
    m_swapChain->SetFullscreenState(false, NULL);
}

if(m_device)
{
    m_device->Release();
}

if(m_deviceContext)
{
    m_deviceContext->Release();
}

if(m_swapChain)
{
    m_swapChain->Release();
}

我相信这个问题是来自这个, 100%肯定。通过代码,我看到每个版本被正确调用。 (如果第一个块被注释掉,应用程序将正常关闭。)

I am fairly confident that the issue is coming from this, but I am not 100% sure. stepping through the code i see that each Release gets called correctly. (the application will close properly if the first block is commented out.)

感谢您对此问题的任何见解。

Thanks for any insight regarding this issue.

推荐答案

我不完全确定我做了什么,但我设法使问题消失。我正在清理代码在不同的部分,突然一切都开始正常关闭。

I am not entirely sure what I did, but I managed to get the issue to go away. I was cleaning up code in a different portion and all of a sudden everything started closing properly.

我有一种感觉,我没有正确设置或关闭窗口。

I have a feeling I wasn't setting up or closing the window correctly.

这篇关于销毁directx设备和交换链的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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