我有一个简单的 DirectX 程序,当我最小化然后取消最小化时会崩溃。
这些是我介绍的事件案例:
case WM_SIZING:
case WM_SIZE:
if(engine.isReady()) engine.resizeDevice();
if(engine.isReady()) engine.draw();
break;
调整大小大致为:
deviceContext->OMSetRenderTargets(0, NULL, NULL);
...
deviceInterface->CreateRenderTargetView( ... );
...
deviceContext->RSSetViewports(1, &vp);
...
deviceContext->OMSetRenderTargets(1, &renderTargetInterface, NULL);
当我取消最小化时,代码在尝试设置后台缓冲区时死亡。这是传递值的行:
hr=swapChain->ResizeBuffers(3, 640, 480, DXGI_FORMAT_UNKNOWN, 0);
ResizeBuffers() 返回错误 0x887a0005
后台缓冲区代码:
HRESULT _setBackBuffer(const SettingsVD &settings){
HRESULT hr;
hr=swapChain->ResizeBuffers(settings.bufferCount, settings.width, settings.height, DXGI_FORMAT_UNKNOWN, 0);
if(FAILED(hr)) return hr; // Dies here when UNminimizing
ID3D11Texture2D* backBuffer=NULL;
hr=swapChain->GetBuffer(0, __uuidof(backBuffer), (LPVOID*)&backBuffer);
if(FAILED(hr)) return hr;
hr=deviceInterface->CreateRenderTargetView(backBuffer, NULL, &renderTargetInterface);
if(FAILED(hr)) return hr;
release(backBuffer);
return hr;
}
任何人都知道为什么后台缓冲区呕吐?
- 可能与我的另一个线程有关,DirectX Crash When Resizing Tiny,但我还没有解决这个问题,所以....bump。