gpt4 book ai didi

c++ - IDXGISwapChain::Present 导致驱动程序崩溃和设备移除

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:12:28 25 4
gpt4 key购买 nike

我正在设计一个使用 DirectX 11 API 的游戏引擎,特别是使用延迟上下文。基本思想是让每个设备状态都有自己的延迟上下文,然后在渲染完所有几何图形后,通过遍历每个延迟上下文并在直接上下文中执行其命令列表来显示它。我通过简单地使用线框着色器在屏幕上绘制两个三角形来测试它,仅此而已。所有 DirectX 调用都不会返回错误,即使在 PIX 调试报告中查看时也是如此,但是一旦调用 IDXGISwapChain::Present(0,0),整个屏幕就会变黑然后返回。然后屏幕右下角会弹出一个错误框,提示显示驱动程序“已停止响应并已成功恢复”。查看 PIX 日志,我发现在 PIX 日志中调用的前 block 和后 block 之间有一行声明“D3D11: Removing Device”。 post block 中显示的返回值为 DXGI_ERROR_DEVICE_REMOVED。我不太确定该怎么做。 PIX日志如下:

Frame 000001 ........PRE: CreateDXGIFactory1(IID_IDXGIFactory1, 0x012E1E2C)
Frame 000001 ............PRE: AddObject(DXGI Factory, 0x0040FF98, 0x0065B810)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Factory, 0x0040FF98, 0x0065B810)
Frame 000001 ........POST: <S_OK> CreateDXGIFactory1(IID_IDXGIFactory1, 0x012E1E2C)
Frame 000001 ........PRE: D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 32, NULL, 0, 7, 0x0019F444, 0x012E1E5C, 0x012E1E54, 0x012E1E58, 0x012E1E60)
Frame 000001 ............PRE: AddObject(D3D11 Device, 0x03666B38, 0x009E9940)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Device, 0x03666B38, 0x009E9940)
Frame 000001 ............PRE: AddObject(DXGI Factory, 0x03666B98, 0x0065BAB0)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Factory, 0x03666B98, 0x0065BAB0)
Frame 000001 ............PRE: AddObject(DXGI Adapter, 0x03666BE8, 0x0065C940)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Adapter, 0x03666BE8, 0x0065C940)
Frame 000001 ............PRE: AddObject(DXGI Device, 0x03666C40, 0x009E9718)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Device, 0x03666C40, 0x009E9718)
Frame 000001 ............PRE: AddObject(DXGI Swap Chain, 0x03666CA0, 0x009EF940)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Swap Chain, 0x03666CA0, 0x009EF940)
Frame 000001 ............PRE: AddObject(DXGI Surface, 0x03666D38, 0x009EFB9C)
Frame 000001 ............POST: <TRUE> AddObject(DXGI Surface, 0x03666D38, 0x009EFB9C)
Frame 000001 ............PRE: AddObject(D3D11 Texture2D, 0x03666D98, 0x009EFBD4)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Texture2D, 0x03666D98, 0x009EFBD4)
Frame 000001 ............PRE: AddObject(D3D11 Device Context, 0x036C1E08, 0x009F1840)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Device Context, 0x036C1E08, 0x009F1840)
Frame 000001 ........POST: <S_OK> D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 32, NULL, 0, 7, 0x0019F444, 0x012E1E5C, 0x012E1E54, 0x012E1E58, 0x012E1E60)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CheckFeatureSupport(D3D11_FEATURE_THREADING, 0x0019F2C8, 8)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CheckFeatureSupport(D3D11_FEATURE_THREADING, 0x0019F2C8, 8)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, 0x0019F2BC, 4)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, 0x0019F2BC, 4)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CheckFormatSupport(DXGI_FORMAT_B8G8R8A8_UNORM, 0x0019F2B0)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CheckFormatSupport(DXGI_FORMAT_B8G8R8A8_UNORM, 0x0019F2B0)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::GetCreationFlags()
Frame 000001 ........POST: <32><this=0x03666b38> ID3D11Device::GetCreationFlags()
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateDeferredContext(0, 0x0FB34BA4)
Frame 000001 ............PRE: AddObject(D3D11 Device Context, 0x036C9C58, 0x009F7C38)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Device Context, 0x036C9C58, 0x009F7C38)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateDeferredContext(0, 0x0FB34BA4)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateRasterizerState(0x0019F3F8, 0x0FB34BA0)
Frame 000001 ............PRE: AddObject(D3D11 Rasterizer State, 0x03666E38, 0x009F0A98)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Rasterizer State, 0x03666E38, 0x009F0A98)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateRasterizerState(0x0019F3F8, 0x0FB34BA0)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateInputLayout(0x0FB50158, 2, 0x009F0368, 568, 0x0FB35B3C)
Frame 000001 ............PRE: AddObject(D3D11 Input Layout, 0x03666EB0, 0x009F0B18)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Input Layout, 0x03666EB0, 0x009F0B18)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateInputLayout(0x0FB50158, 2, 0x009F0368, 568, 0x0FB35B3C)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateSamplerState(0x0019F418, 0x0019F46C)
Frame 000001 ............PRE: AddObject(D3D11 Sampler State, 0x03666F10, 0x009EF8D8)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Sampler State, 0x03666F10, 0x009EF8D8)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateSamplerState(0x0019F418, 0x0019F46C)
Frame 000001 ........PRE: <this=0x03666f10>ID3D11SamplerState::AddRef()
Frame 000001 ........POST: <2><this=0x03666f10> ID3D11SamplerState::AddRef()
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::AddRef()
Frame 000001 ........POST: <8><this=0x03666b38> ID3D11Device::AddRef()
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateVertexShader(0x009F0368, 568, NULL, 0x0FB3046C)
Frame 000001 ............PRE: AddObject(D3D11 Vertex Shader, 0x03666F60, 0x009EFCB4)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Vertex Shader, 0x03666F60, 0x009EFCB4)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateVertexShader(0x009F0368, 568, NULL, 0x0FB3046C)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreatePixelShader(0x009F0958, 244, NULL, 0x0FB30470)
Frame 000001 ............PRE: AddObject(D3D11 Pixel Shader, 0x03666FB8, 0x009E2CF4)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Pixel Shader, 0x03666FB8, 0x009E2CF4)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreatePixelShader(0x009F0958, 244, NULL, 0x0FB30470)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::Release()
Frame 000001 ........POST: <9><this=0x03666b38> ID3D11Device::Release()
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB364A8)
Frame 000001 ............PRE: AddObject(D3D11 Buffer, 0x036656F0, 0x009E2E14)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Buffer, 0x036656F0, 0x009E2E14)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB364A8)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB3E1B0)
Frame 000001 ............PRE: AddObject(D3D11 Buffer, 0x03665778, 0x009F03D4)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Buffer, 0x03665778, 0x009F03D4)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB3E1B0)
Frame 000001 ........PRE: <this=0x03666b38>ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB46E58)
Frame 000001 ............PRE: AddObject(D3D11 Buffer, 0x03665800, 0x009E3994)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Buffer, 0x03665800, 0x009E3994)
Frame 000001 ........POST: <S_OK><this=0x03666b38> ID3D11Device::CreateBuffer(0x0019F914, NULL, 0x0FB46E58)
Frame 000001 ........PRE: <this=0x036c1e08>ID3D11DeviceContext::RSSetViewports(1, 0x012E1EBC)
Frame 000001 ........POST: <><this=0x036c1e08> ID3D11DeviceContext::RSSetViewports(1, 0x012E1EBC)
Frame 000001 ........PRE: <this=0x036c9c58>ID3D11DeviceContext::IASetInputLayout(0x03666EB0)
Frame 000001 ........POST: <><this=0x036c9c58> ID3D11DeviceContext::IASetInputLayout(0x03666EB0)
Frame 000001 ........PRE: <this=0x036c9c58>ID3D11DeviceContext::AddRef()
Frame 000001 ........POST: <2><this=0x036c9c58> ID3D11DeviceContext::AddRef()
Frame 000001 ........PRE: <this=0x036c9c58>ID3D11DeviceContext::DrawIndexed(6, 0, 0)
Frame 000001 ........POST: <><this=0x036c9c58> ID3D11DeviceContext::DrawIndexed(6, 0, 0)
Frame 000001 ........PRE: <this=0x036c9c58>ID3D11DeviceContext::Release()
Frame 000001 ........POST: <1><this=0x036c9c58> ID3D11DeviceContext::Release()
Frame 000001 ........PRE: <this=0x036c9c58>ID3D11DeviceContext::FinishCommandList(FALSE, 0x0019F928)
Frame 000001 ............PRE: AddObject(D3D11 Command List, 0x03665888, 0x009E3A94)
Frame 000001 ............POST: <TRUE> AddObject(D3D11 Command List, 0x03665888, 0x009E3A94)
Frame 000001 ........POST: <S_OK><this=0x036c9c58> ID3D11DeviceContext::FinishCommandList(FALSE, 0x0019F928)
Frame 000001 ........PRE: <this=0x036c1e08>ID3D11DeviceContext::ExecuteCommandList(0x03665888, FALSE)
Frame 000001 ........POST: <><this=0x036c1e08> ID3D11DeviceContext::ExecuteCommandList(0x03665888, FALSE)
Frame 000001 ........PRE: <this=0x03666ca0>IDXGISwapChain::Present(0, 1)
Frame 000001 ........POST: <S_OK><this=0x03666ca0> IDXGISwapChain::Present(0, 1)
Frame 000001 ........PRE: <this=0x03666ca0>IDXGISwapChain::Present(0, 0)
D3D11: Removing Device.
Frame 000001 ........POST: <DXGI_ERROR_DEVICE_REMOVED><this=0x03666ca0> IDXGISwapChain::Present(0, 0)
Frame 000001 ....POST: <> Frame(1)

如果还有其他需要,请告诉我。我没有发布代码,主要是因为它扩展了近 20 个独立的类,但我可以发布缓冲区内容、HLSL 和逻辑背后的解释。

更新:

我已经稍微解决了上面的问题,部分原因很可能是因为没有设置任何着色器,没有索引缓冲区,没有顶点缓冲区,也没有常量缓冲区。原来的问题还没有解决,但是在做这件事的时候,我有了一个新的想法。我从未调用过 ID3D11DeviceContext::Begin(0)。但是,在从设备状态类获取设备上下文并在该上下文上调用 Begin 后,我最终遇到访问冲突并且指向 ID3D11DeviceContext 对象的指针被设置为零。这只会在调用 Begin 时发生,删除调用会导致行为停止。查看 DirectX SDK 中的示例代码,我无法找到任何时候开始的显式调用。这个电话有必要吗?这似乎有点偏离主题,但如果命令列表因此而被破坏,这可能是 Present 正在删除设备的原因。

相关代码:

if(FAILED(devstate->BeginDraw(inlayout,&dc)))
{
return ACERROR_ALREADYDRAWING; //error handling block.
}
//dc->Begin(0); //access violation: error accessing location 0x00000024
for(UINT i=Shader_Vertex;i<Shader_Count;i++)
{
//set all relevant shaders to the device.
(dc->*(vtbls[i].ShaderSet))(shaders[i],0,0);
}

最佳答案

在过去 6 天审查了代码之后,我有了一个奇怪的发现:尽管我对 DirectX 9.0c 了如指掌,但在 DirectX 11 中编码是……不同的。在代码中发现几个愚蠢的错误后,我设法修复了硬件设备上的错误,但奇怪的是,不是在 ref 设备上。我目前正在研究 DirectX 11 管道更改,然后试图找出为什么我可以非常轻松地清除背景,但尝试使用延迟上下文绘制三角形根本不起作用。

感谢所有试图提供帮助的人的建议。

关于c++ - IDXGISwapChain::Present 导致驱动程序崩溃和设备移除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9843879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com